Skip to content

Commit 249b4de

Browse files
groeckgregkh
authored andcommitted
eeprom: ee1004: Call i2c_new_scanned_device to instantiate thermal sensor
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. Fixes: 393bd10 ("eeprom: ee1004: add support for temperature sensor") Cc: Heiner Kallweit <[email protected]> Cc: Thomas Weißschuh <[email protected]> Signed-off-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 79d0df3 commit 249b4de

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/misc/eeprom/ee1004.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ static int ee1004_read(void *priv, unsigned int off, void *val, size_t count)
184184
static void ee1004_probe_temp_sensor(struct i2c_client *client)
185185
{
186186
struct i2c_board_info info = { .type = "jc42" };
187+
unsigned short addr = 0x18 | (client->addr & 7);
188+
unsigned short addr_list[] = { addr, I2C_CLIENT_END };
187189
u8 byte14;
188190
int ret;
189191

@@ -192,9 +194,7 @@ static void ee1004_probe_temp_sensor(struct i2c_client *client)
192194
if (ret != 1 || !(byte14 & BIT(7)))
193195
return;
194196

195-
info.addr = 0x18 | (client->addr & 7);
196-
197-
i2c_new_client_device(client->adapter, &info);
197+
i2c_new_scanned_device(client->adapter, &info, addr_list, NULL);
198198
}
199199

200200
static void ee1004_cleanup(int idx, struct ee1004_bus_data *bd)

0 commit comments

Comments
 (0)