Re: [PATCH 1/2] eeprom: ee1004: Call i2c_new_scanned_device to instantiate thermal sensor

From: Guenter Roeck
Date: Sat Jun 29 2024 - 18:27:01 EST


On 6/29/24 15:00, Heiner Kallweit wrote:
On 29.06.2024 19:37, Guenter Roeck wrote:
Instantiating a device by calling i2c_new_client_device() assumes that the
device is not already instantiated. If that is not the case, it will return
an error and generate a misleading kernel log message.

i2c i2c-0: Failed to register i2c client jc42 at 0x18 (-16)

This can be reproduced by unloading the ee1004 driver and loading it again.

Avoid this by calling i2c_new_scanned_device() instead, which returns
silently if a device is already instantiated or does not exist.

However i2c_new_scanned_device() runs i2c_default_probe() on the device,
whilst i2c_new_client_device() doesn't access the i2c bus.
If possible I'd like to avoid this overhead.


I am not as much concerned with that overhead since there are already several
other i2c accesses in both this driver and in the jc42 driver, so it seemed to
me that another quick operation does not make much of a difference. Also, I
wanted to suggest a solution which does not require changing the i2c core.
However, I am not "married" to this solution. Please feel free to suggest
something different, or to drop this patch (and the next one) entirely.

Thanks,
Guenter