Drop generic i2c chip driver module parameters
Subsystems (3)
cover Drop generic i2c chip driver module parameters
Hi all,
Here comes the first part of a large patch series which aims at dropping the generic i2c chip driver module parameters that were inherited from the lm-sensors project: probe, ignore, force and force_<type>. The same functionality is much better handled in a centralized way than replicated across a hundred drivers, and the recent changes to the binding model make it possible. Actually, the replacement interface is already implemented: these are the sysfs new_device and delete_device entries which are now created in each i2c adapter directory. It might need some tweaking in the future, but the core functionality is there already.
The second part will require changes to individual drivers. For historical reasons, affected are mostly hwmon drivers: 44 out of the 49 i2c-based hwmon drivers are affected, and only a few other drivers are affected outside of the hwmon subsystem. Some statistics on these drivers:
* Removes 15 lines of source code per driver on average.
* Removes 1.4 kB of binary module per driver on average (-7.7%).
The third part will happen later, when all individual drivers are updated. These are interface cleanups which must be synchronized across all affected drivers, so it's quite a pain to handle. I'll keep them in my local tree for now, and push them upstream once all the rest is there already.
In the end, this is 140 lines removed from <linux/i2c.h> (-19%).
Full combined diffstat:
Documentation/i2c/old-module-parameters | 44 +++++ Documentation/i2c/writing-clients | 2 drivers/hwmon/adm1021.c | 87 +++-------- drivers/hwmon/adm1025.c | 85 +++-------- drivers/hwmon/adm1026.c | 58 +++---- drivers/hwmon/adm1029.c | 71 ++------- drivers/hwmon/adm1031.c | 35 +--- drivers/hwmon/adm9240.c | 70 +++------ drivers/hwmon/ads7828.c | 35 +--- drivers/hwmon/adt7462.c | 38 +---- drivers/hwmon/adt7470.c | 38 +---- drivers/hwmon/adt7473.c | 38 +---- drivers/hwmon/adt7475.c | 22 +- drivers/hwmon/asb100.c | 66 ++------ drivers/hwmon/atxp1.c | 11 - drivers/hwmon/dme1737.c | 42 +---- drivers/hwmon/ds1621.c | 31 +--- drivers/hwmon/f75375s.c | 40 +---- drivers/hwmon/fschmd.c | 60 +++---- drivers/hwmon/gl518sm.c | 40 +---- drivers/hwmon/gl520sm.c | 25 +-- drivers/hwmon/lm63.c | 69 +++------ drivers/hwmon/lm75.c | 65 +++----- drivers/hwmon/lm77.c | 90 +++++------ drivers/hwmon/lm78.c | 69 +++------ drivers/hwmon/lm80.c | 13 - drivers/hwmon/lm83.c | 93 +++--------- drivers/hwmon/lm85.c | 171 +++++++++------------- drivers/hwmon/lm87.c | 53 ++----- drivers/hwmon/lm90.c | 242 +++++++++++++------------------- drivers/hwmon/lm92.c | 40 +---- drivers/hwmon/lm93.c | 40 +---- drivers/hwmon/lm95241.c | 57 +------ drivers/hwmon/max1619.c | 76 +++------- drivers/hwmon/max6650.c | 30 --- drivers/hwmon/pcf8591.c | 5 drivers/hwmon/smsc47m192.c | 39 ++--- drivers/hwmon/thmc50.c | 40 +---- drivers/hwmon/tmp401.c | 64 +++----- drivers/hwmon/tmp421.c | 48 ++---- drivers/hwmon/w83781d.c | 141 +++++++----------- drivers/hwmon/w83791d.c | 69 ++------- drivers/hwmon/w83792d.c | 70 ++------- drivers/hwmon/w83793.c | 62 ++------ drivers/hwmon/w83l785ts.c | 82 +++------- drivers/hwmon/w83l786ng.c | 68 ++------ drivers/i2c/i2c-core.c | 102 ++----------- drivers/misc/eeprom/eeprom.c | 8 - drivers/misc/ics932s401.c | 46 ++---- include/linux/i2c.h | 146 ------------------- 50 files changed, 1082 insertions(+), 1954 deletions(-)
Signature · 1 line
Jean Delvare
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/3 i2c: Drop probe, ignore and force module parameters
The legacy probe and force module parameters are obsolete now, the same can be achieved using the new_device sysfs interface, which is both more flexible and cheaper (it is implemented by i2c-core rather than replicated in every driver module.)
The legacy ignore module parameters can be dropped as well. Ignoring can be done by instantiating a "dummy" device at the problematic address.
This is the first step of a huge cleanup to i2c-core's i2c_detect function, i2c.h's I2C_CLIENT_INSMOD* macros, and all drivers that made use of them.
--- Documentation/i2c/old-module-parameters | 44 ++++++++++++++ drivers/i2c/i2c-core.c | 65 ---------------------- include/linux/i2c.h | 91 ------------------------------- 3 files changed, 46 insertions(+), 154 deletions(-)
include/linux/i2c.h +1 -90
@@ -110,7 +110,7 @@ extern s32 i2c_smbus_write_i2c_block_dat* @driver: Device driver model driver * @id_table: List of I2C devices supported by this driver * @detect: Callback for device detection -* @address_data: The I2C addresses to probe, ignore or force (for detect) +* @address_data: The I2C addresses to probe (for detect) * @clients: List of detected clients we created (for i2c-core use only) * * The driver.owner field should be set to the module owner of this driver.
@@ -379,9 +379,6 @@ static inline void i2c_set_adapdata(stru*/ struct i2c_client_address_data {const unsigned short *normal_i2c; -const unsigned short *probe; -const unsigned short *ignore; -const unsigned short *const *forces; };/* Internal numbers to terminate lists */
@@ -595,134 +592,48 @@ union i2c_smbus_data { module_param_array(var, short, &var##_num, 0); \ MODULE_PARM_DESC(var, desc) -#define I2C_CLIENT_MODULE_PARM_FORCE (name) \ -I2C_CLIENT_MODULE_PARM(force_##name, \ - "List of adapter,address pairs which are " \ - "unquestionably assumed to contain a `" \ - # name "' chip") - -#define I2C_CLIENT_INSMOD_COMMON \ -I2C_CLIENT_MODULE_PARM(probe, "List of adapter,address pairs to scan " \ - "additionally"); \ -I2C_CLIENT_MODULE_PARM(ignore, "List of adapter,address pairs not to " \ - "scan"); \ static const struct i2c_client_address_data addr_data = { \ .normal_i2c = normal_i2c, \ - .probe = probe, \ - .ignore = ignore, \ - .forces = forces, \ } -#define I2C_CLIENT_FORCE_TEXT \ - "List of adapter,address pairs to boldly assume to be present" -/* These are the ones you want to use in your own drivers. Pick the one which matches the number of devices the driver differenciates between. */ #define I2C_CLIENT_INSMOD \ -I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ -static const unsigned short * const forces[] = { force, NULL }; \ I2C_CLIENT_INSMOD_COMMON#define I2C_CLIENT_INSMOD_1 (chip1) \ enum chips { any_chip, chip1 }; \ -I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ -static const unsigned short * const forces[] = { force, \ - force_##chip1, NULL }; \ I2C_CLIENT_INSMOD_COMMON#define I2C_CLIENT_INSMOD_2 (chip1, chip2) \ enum chips { any_chip, chip1, chip2 }; \ -I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ -static const unsigned short * const forces[] = { force, \ - force_##chip1, force_##chip2, NULL }; \ I2C_CLIENT_INSMOD_COMMON#define I2C_CLIENT_INSMOD_3 (chip1, chip2, chip3) \ enum chips { any_chip, chip1, chip2, chip3 }; \ -I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ -static const unsigned short * const forces[] = { force, \ - force_##chip1, force_##chip2, force_##chip3, NULL }; \ I2C_CLIENT_INSMOD_COMMON#define I2C_CLIENT_INSMOD_4 (chip1, chip2, chip3, chip4) \ enum chips { any_chip, chip1, chip2, chip3, chip4 }; \ -I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip4); \ -static const unsigned short * const forces[] = { force, \ - force_##chip1, force_##chip2, force_##chip3, \ - force_##chip4, NULL}; \ I2C_CLIENT_INSMOD_COMMON#define I2C_CLIENT_INSMOD_5 (chip1, chip2, chip3, chip4, chip5) \ enum chips { any_chip, chip1, chip2, chip3, chip4, chip5 }; \ -I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip4); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip5); \ -static const unsigned short * const forces[] = { force, \ - force_##chip1, force_##chip2, force_##chip3, \ - force_##chip4, force_##chip5, NULL }; \ I2C_CLIENT_INSMOD_COMMON#define I2C_CLIENT_INSMOD_6 (chip1, chip2, chip3, chip4, chip5, chip6) \ enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6 }; \ -I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip4); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip5); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip6); \ -static const unsigned short * const forces[] = { force, \ - force_##chip1, force_##chip2, force_##chip3, \ - force_##chip4, force_##chip5, force_##chip6, NULL }; \ I2C_CLIENT_INSMOD_COMMON#define I2C_CLIENT_INSMOD_7 (chip1, chip2, chip3, chip4, chip5, chip6, chip7) \ enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, \ chip7 }; \ -I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip4); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip5); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip6); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip7); \ -static const unsigned short * const forces[] = { force, \ - force_##chip1, force_##chip2, force_##chip3, \ - force_##chip4, force_##chip5, force_##chip6, \ - force_##chip7, NULL }; \ I2C_CLIENT_INSMOD_COMMON#define I2C_CLIENT_INSMOD_8 (chip1, chip2, chip3, chip4, chip5, chip6, chip7, chip8) \ enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, \ chip7, chip8 }; \ -I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip4); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip5); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip6); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip7); \ -I2C_CLIENT_MODULE_PARM_FORCE(chip8); \ -static const unsigned short * const forces[] = { force, \ - force_##chip1, force_##chip2, force_##chip3, \ - force_##chip4, force_##chip5, force_##chip6, \ - force_##chip7, force_##chip8, NULL }; \ I2C_CLIENT_INSMOD_COMMON#endif /* __KERNEL__ */ #endif /* _LINUX_I2C_H */
drivers/i2c/i2c-core.c +1 -64
84 lines not on this page · raw message
Documentation/i2c/old-module-parameters new file +44 -0
44 lines not on this page · raw message
Signature · 1 line
Jean Delvare
PATCH 2/3 i2c: Simplify i2c_detect_address
In reply to a message not in the archiveThe kind parameter of i2c_detect_address() always has value -1, so we can get rid of it.
Next step is to update all i2c detect callback functions to get rid of this now useless parameter.
--- drivers/i2c/i2c-core.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-)
drivers/i2c/i2c-core.c +10 -14
@@ -1169,7 +1169,7 @@ EXPORT_SYMBOL(i2c_master_recv);* ---------------------------------------------------- */ -static int i2c_detect_address (struct i2c_client *temp_client,int kind, +static int i2c_detect_address (struct i2c_client *temp_client,struct i2c_driver *driver) {struct i2c_board_info info;
@@ -1188,22 +1188,18 @@ static int i2c_detect_address(struct i2cif (i2c_check_addr (adapter, addr))return 0 ; -/* Make sure there is something at this address, unless forced */ -if (kind <0 ) { -if (i2c_smbus_xfer (adapter, addr,0 ,0 ,0 , -I2C_SMBUS_QUICK ,NULL ) <0 ) -return 0 ; - -/* prevent 24RF08 corruption */ -if ((addr & ~0x0f ) ==0x50 ) -i2c_smbus_xfer (adapter, addr,0 ,0 ,0 , -I2C_SMBUS_QUICK ,NULL ); - } +/* Make sure there is something at this address */ +if (i2c_smbus_xfer (adapter, addr,0 ,0 ,0 ,I2C_SMBUS_QUICK ,NULL ) <0 ) +return 0 ; + +/* Prevent 24RF08 corruption */ +if ((addr & ~0x0f ) ==0x50 ) +i2c_smbus_xfer (adapter, addr,0 ,0 ,0 ,I2C_SMBUS_QUICK ,NULL );/* Finally call the custom detection function */ memset (&info,0 ,sizeof (struct i2c_board_info )); info.addr = addr; - err = driver->detect (temp_client, kind, &info); + err = driver->detect (temp_client,-1 , &info);if (err) {/* -ENODEV is returned if the detection fails. We catch it here as this isn't an error. */
@@ -1268,7 +1264,7 @@ static int i2c_detect(struct i2c_adapter"addr 0x%02x\n" , adap_id, address_data->normal_i2c[i]); temp_client->addr = address_data->normal_i2c[i]; - err =i2c_detect_address (temp_client,-1 , driver); + err =i2c_detect_address (temp_client, driver);if (err) goto exit_free; }
Signature · 1 line
Jean Delvare
PATCH 3/3 ics932s401: Clean up detect function
In reply to a message not in the archiveAs kind is now hard-coded to -1, there is room for code clean-ups.
--- drivers/misc/ics932s401.c | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-)
drivers/misc/ics932s401.c +14 -21
@@ -417,32 +417,25 @@ static int ics932s401_detect(struct i2c_ struct i2c_board_info *info) {struct i2c_adapter *adapter = client->adapter; +int vendor, device, revision;if (!i2c_check_functionality (adapter,I2C_FUNC_SMBUS_BYTE_DATA ))return -ENODEV ; -if (kind <=0 ) { -int vendor, device, revision; + vendor =i2c_smbus_read_word_data (client,ICS932S401_REG_VENDOR_REV ); + vendor >>=8 ; + revision = vendor >>ICS932S401_REV_SHIFT ; + vendor &=ICS932S401_VENDOR_MASK ; +if (vendor !=ICS932S401_VENDOR ) +return -ENODEV ; + + device =i2c_smbus_read_word_data (client,ICS932S401_REG_DEVICE ); + device >>=8 ; +if (device !=ICS932S401_DEVICE ) +return -ENODEV ; - vendor =i2c_smbus_read_word_data (client, -ICS932S401_REG_VENDOR_REV ); - vendor >>=8 ; - revision = vendor >>ICS932S401_REV_SHIFT ; - vendor &=ICS932S401_VENDOR_MASK ; -if (vendor !=ICS932S401_VENDOR ) -return -ENODEV ; - - device =i2c_smbus_read_word_data (client, -ICS932S401_REG_DEVICE ); - device >>=8 ; -if (device !=ICS932S401_DEVICE ) -return -ENODEV ; - -if (revision !=ICS932S401_REV ) -dev_info (&adapter->dev,"Unknown revision %d\n" , - revision); - }else -dev_dbg (&adapter->dev,"detection forced\n" ); +if (revision !=ICS932S401_REV ) +dev_info (&adapter->dev,"Unknown revision %d\n" , revision);strlcpy (info->type,"ics932s401" ,I2C_NAME_SIZE );
Signature · 1 line
Jean Delvare
A message that is not in the archive (sent off-list or not yet received): [email protected]
Darrick J. Wong
Acked-byRe: [PATCH 3/3] ics932s401: Clean up detect function
Quoted 4 lines · Jean Delvare
As kind is now hard-coded to -1, there is room for code clean-ups.
Signed-off-by Jean Delvare <[email protected]>Cc "Darrick J. Wong" <djwong-r/[email protected]>
Based on some light testing, it looks like this is ok, so
--D