Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hwmon: (w83795): Remove use of i2c_match_id()

The function i2c_match_id() is used to fetch the matching ID from
the i2c_device_id table. This is often used to then retrieve the
matching driver_data. This can be done in one step with the helper
i2c_get_match_data().

This helper has a couple other benefits:
* It doesn't need the i2c_device_id passed in so we do not need
to have that forward declared, allowing us to remove those or
move the i2c_device_id table down to its more natural spot
with the other module info.
* It also checks for device match data, which allows for OF and
ACPI based probing. That means we do not have to manually check
those first and can remove those checks.

Signed-off-by: Andrew Davis <afd@ti.com>
Link: https://lore.kernel.org/r/20240403203633.914389-32-afd@ti.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Andrew Davis and committed by
Guenter Roeck
55076454 00dcf379

+1 -3
+1 -3
drivers/hwmon/w83795.c
··· 2134 2134 } 2135 2135 } 2136 2136 2137 - static const struct i2c_device_id w83795_id[]; 2138 - 2139 2137 static int w83795_probe(struct i2c_client *client) 2140 2138 { 2141 2139 int i; ··· 2147 2149 return -ENOMEM; 2148 2150 2149 2151 i2c_set_clientdata(client, data); 2150 - data->chip_type = i2c_match_id(w83795_id, client)->driver_data; 2152 + data->chip_type = (uintptr_t)i2c_get_match_data(client); 2151 2153 data->bank = i2c_smbus_read_byte_data(client, W83795_REG_BANKSEL); 2152 2154 mutex_init(&data->update_lock); 2153 2155