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

hwmon: (sht3x) 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-25-afd@ti.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Andrew Davis and committed by
Guenter Roeck
f147dbd7 77944b47

+10 -10
+10 -10
drivers/hwmon/sht3x.c
··· 882 882 .info = sht3x_channel_info, 883 883 }; 884 884 885 - /* device ID table */ 886 - static const struct i2c_device_id sht3x_ids[] = { 887 - {"sht3x", sht3x}, 888 - {"sts3x", sts3x}, 889 - {} 890 - }; 891 - 892 - MODULE_DEVICE_TABLE(i2c, sht3x_ids); 893 - 894 885 static int sht3x_probe(struct i2c_client *client) 895 886 { 896 887 int ret; ··· 911 920 data->mode = 0; 912 921 data->last_update = jiffies - msecs_to_jiffies(3000); 913 922 data->client = client; 914 - data->chip_id = i2c_match_id(sht3x_ids, client)->driver_data; 923 + data->chip_id = (uintptr_t)i2c_get_match_data(client); 915 924 crc8_populate_msb(sht3x_crc8_table, SHT3X_CRC8_POLYNOMIAL); 916 925 917 926 sht3x_select_command(data); ··· 953 962 954 963 return PTR_ERR_OR_ZERO(hwmon_dev); 955 964 } 965 + 966 + /* device ID table */ 967 + static const struct i2c_device_id sht3x_ids[] = { 968 + {"sht3x", sht3x}, 969 + {"sts3x", sts3x}, 970 + {} 971 + }; 972 + 973 + MODULE_DEVICE_TABLE(i2c, sht3x_ids); 956 974 957 975 static struct i2c_driver sht3x_i2c_driver = { 958 976 .driver.name = "sht3x",