lkml.org 
[lkml]   [2014]   [Oct]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v4] i2c: rk3x: adjust the LOW divison based on characteristics of SCL
From
Max,

On Sun, Oct 12, 2014 at 5:10 AM, Max Schwarz <max.schwarz@online.de> wrote:
>> + /* Adjust to avoid overflow */
>> + i2c_rate_khz = DIV_ROUND_UP(i2c_rate, 1000);
>> + scl_rate_khz = DIV_ROUND_UP(scl_rate, 1000);
>
> I'm not really comfortable with using DIV_ROUND_UP on the last line, since
> this may violate the user's set SCL rate. Rounding up 1.1kHz SCL rate to 2kHz
> is not good.

Ah, good point. So we round up for i2c_rate and down for scl_rate:

i2c_rate_khz = DIV_ROUND_UP(i2c_rate, 1000);
scl_rate_khz = scl_rate / 1000;


> I suggest using scl_rate / 1000 and placing a
>
> if(WARN_ON(scl_rate < 1000))
> scl_rate = 1000;
>
> somewhere to prevent scl_rate_khz from becoming 0.

Ah, makes sense. Yeah, that should be at the top.


\
 
 \ /
  Last update: 2014-10-13 00:01    [W:0.071 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site