lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <c9b234e2-983f-4d24-a379-5d61ae9408cc@linux.ibm.com>
Date: Wed, 17 Apr 2024 08:50:15 -0500
From: Eddie James <eajames@...ux.ibm.com>
To: Guenter Roeck <linux@...ck-us.net>
Cc: Andi Shyti <andi.shyti@...nel.org>, devicetree@...r.kernel.org,
        conor+dt@...nel.org, alistair@...ple.id.au,
        linux-kernel@...r.kernel.org, lakshmiy@...ibmcom,
        linux-i2c@...r.kernel.org, krzysztof.kozlowski+dt@...aro.org,
        linux-fsi@...ts.ozlabs.org, robh@...nel.org
Subject: Re: [PATCH v2 25/31] i2c: fsi: Calculate clock divider from local bus
 frequency


On 4/16/24 16:20, Guenter Roeck wrote:
> On Tue, Apr 16, 2024 at 01:09:04PM -0500, Eddie James wrote:
>> On 4/15/24 17:11, Andi Shyti wrote:
>>> Hi Eddie,
>>>
>>>> @@ -689,6 +692,20 @@ static int fsi_i2c_probe(struct device *dev)
>>>>    	mutex_init(&i2c->lock);
>>>>    	i2c->fsi = to_fsi_dev(dev);
>>>>    	INIT_LIST_HEAD(&i2c->ports);
>>>> +	i2c->clock_div = I2C_DEFAULT_CLK_DIV;
>>>> +
>>>> +	lbus = fsi_device_local_bus_frequency(i2c->fsi);
>>>> +	if (lbus) {
>>>> +		u32 clock = I2C_DEFAULT_CLK_RATE;
>>> I don't see the need for initialization.
>>
>> Does device_property_read_u32 set clock if the property isn't found? If not,
>> it needs to be initialized here. Or I can set it in an else statement from
>> device_property_read_u32.
>>
>>
>>>> +
>>>> +		if (!device_property_read_u32(dev, "clock-frequency", &clock)) {
>>>> +			if (!clock)
>>>> +				clock = I2C_DEFAULT_CLK_RATE;
>>>> +		}
> 		if (device_property_read_u32(dev, "clock-frequency", &clock) || !clock)
> 			clock = I2C_DEFAULT_CLK_RATE;


Nice one, thanks.


>
>>>> +
>>>> +		// i2c clock rate = local bus clock / (4 * (i2c clock div + 1))
>>> You forgot to remove this.
>>
>> I actually meant to leave that comment to explain how the clock rate is
>> calculated, as the reverse calculation in the code is a little more
>> confusing.
>>
> Partially that is because you implemented DIV_ROUND_UP() manually.


Thanks Guenter, good point.


Eddie


>>> Andi
>>>
>>>> +		i2c->clock_div = (((lbus + (clock - 1)) / clock) / 4) - 1;
> 				= DIV_ROUND_UP(lbus, clock) / 4 - 1
>
> Guenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ