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

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

authored by

Andrew Davis and committed by
Guenter Roeck
72fdab6b 698d692c

+20 -26
+20 -26
drivers/hwmon/f75375s.c
··· 111 111 s8 temp_max_hyst[2]; 112 112 }; 113 113 114 - static int f75375_detect(struct i2c_client *client, 115 - struct i2c_board_info *info); 116 - static int f75375_probe(struct i2c_client *client); 117 - static void f75375_remove(struct i2c_client *client); 118 - 119 - static const struct i2c_device_id f75375_id[] = { 120 - { "f75373", f75373 }, 121 - { "f75375", f75375 }, 122 - { "f75387", f75387 }, 123 - { } 124 - }; 125 - MODULE_DEVICE_TABLE(i2c, f75375_id); 126 - 127 - static struct i2c_driver f75375_driver = { 128 - .class = I2C_CLASS_HWMON, 129 - .driver = { 130 - .name = "f75375", 131 - }, 132 - .probe = f75375_probe, 133 - .remove = f75375_remove, 134 - .id_table = f75375_id, 135 - .detect = f75375_detect, 136 - .address_list = normal_i2c, 137 - }; 138 - 139 114 static inline int f75375_read8(struct i2c_client *client, u8 reg) 140 115 { 141 116 return i2c_smbus_read_byte_data(client, reg); ··· 805 830 806 831 i2c_set_clientdata(client, data); 807 832 mutex_init(&data->update_lock); 808 - data->kind = i2c_match_id(f75375_id, client)->driver_data; 833 + data->kind = (uintptr_t)i2c_get_match_data(client); 809 834 810 835 err = sysfs_create_group(&client->dev.kobj, &f75375_group); 811 836 if (err) ··· 876 901 return 0; 877 902 } 878 903 904 + static const struct i2c_device_id f75375_id[] = { 905 + { "f75373", f75373 }, 906 + { "f75375", f75375 }, 907 + { "f75387", f75387 }, 908 + { } 909 + }; 910 + MODULE_DEVICE_TABLE(i2c, f75375_id); 911 + 912 + static struct i2c_driver f75375_driver = { 913 + .class = I2C_CLASS_HWMON, 914 + .driver = { 915 + .name = "f75375", 916 + }, 917 + .probe = f75375_probe, 918 + .remove = f75375_remove, 919 + .id_table = f75375_id, 920 + .detect = f75375_detect, 921 + .address_list = normal_i2c, 922 + }; 879 923 module_i2c_driver(f75375_driver); 880 924 881 925 MODULE_AUTHOR("Riku Voipio");