(0/11) hwmon vs i2c, second round
Subsystems (9)
PATCH 1/1 (0/11) hwmon vs i2c, second round
Hi all,
Following my first hwmon vs. i2c series of patches, which was mostly aiming at moving non-i2c hardware monitoring drivers away from the i2c-core, here comes a second series which goes one step further in the direction of a clean separation of the hmwon-specific code from the i2c subsystem. It is made up of 11 cumulative patches, which I will now post.
This time, I am attempting to fix two different design errors that were made in the early days of the sensors drivers and never fixed since: i2c code being duplicated for the sensors drivers, and non i2c-related code used by sensors drivers being attached to the i2c subsystem.
This results in a significant code shrink, both at source (-333 lines) and binary (-2777 bytes) levels, and in large chunks of code being moved from drivers/i2c to drivers/hwmon (and include/linux/i2c-*.h to include/linux/hwmon-*.h.)
There are still a few cleanups I want to do on top of that, most notably a rewrite of i2c_probe and a better handling of address lists, but this series is certainly the most important (and intrusive) part of the cleanup process.
I've tried to keep the documentation up-to-date with each patch, but it seems that this documentation would still need a full review and update, as it contains pretty inaccurate information at places. I'll tackle that when I'm done with the code changes.
Thanks.
Documentation/i2c/porting-clients | 13 +- Documentation/i2c/writing-clients | 87 +++---------- drivers/hwmon/Kconfig | 51 ++----- drivers/hwmon/Makefile | 1 drivers/hwmon/adm1021.c | 5 drivers/hwmon/adm1025.c | 9 - drivers/hwmon/adm1026.c | 11 - drivers/hwmon/adm1031.c | 7 - drivers/hwmon/adm9240.c | 9 - drivers/hwmon/asb100.c | 9 - drivers/hwmon/atxp1.c | 9 - drivers/hwmon/ds1621.c | 7 - drivers/hwmon/fscher.c | 5 drivers/hwmon/fscpos.c | 5 drivers/hwmon/gl518sm.c | 5 drivers/hwmon/gl520sm.c | 9 - drivers/hwmon/hwmon-vid.c | 203 +++++++++++++++++++++++++++++++ drivers/hwmon/it87.c | 13 -- drivers/hwmon/lm63.c | 5 drivers/hwmon/lm75.c | 7 - drivers/hwmon/lm77.c | 7 - drivers/hwmon/lm78.c | 17 -- drivers/hwmon/lm80.c | 5 drivers/hwmon/lm83.c | 5 drivers/hwmon/lm85.c | 9 - drivers/hwmon/lm87.c | 9 - drivers/hwmon/lm90.c | 5 drivers/hwmon/lm92.c | 5 drivers/hwmon/max1619.c | 5 drivers/hwmon/pc87360.c | 2 drivers/hwmon/sis5595.c | 1 drivers/hwmon/smsc47m1.c | 1 drivers/hwmon/via686a.c | 1 drivers/hwmon/w83627hf.c | 5 drivers/hwmon/w83781d.c | 9 - drivers/hwmon/w83792d.c | 6 drivers/hwmon/w83l785ts.c | 5 drivers/i2c/Makefile | 4 drivers/i2c/chips/Kconfig | 10 - drivers/i2c/chips/ds1337.c | 5 drivers/i2c/chips/ds1374.c | 1 drivers/i2c/chips/eeprom.c | 7 - drivers/i2c/chips/m41t00.c | 1 drivers/i2c/chips/max6875.c | 7 - drivers/i2c/chips/pca9539.c | 7 - drivers/i2c/chips/pcf8574.c | 7 - drivers/i2c/chips/pcf8591.c | 7 - drivers/i2c/chips/rtc8564.c | 1 drivers/i2c/i2c-core.c | 38 ++++- drivers/i2c/i2c-sensor-detect.c | 126 ------------------- drivers/i2c/i2c-sensor-vid.c | 98 --------------- drivers/media/video/adv7170.c | 1 drivers/media/video/adv7175.c | 1 drivers/media/video/bt819.c | 1 drivers/media/video/bt856.c | 1 drivers/media/video/saa7110.c | 1 drivers/media/video/saa7111.c | 1 drivers/media/video/saa7114.c | 1 drivers/media/video/saa7185.c | 1 drivers/media/video/tuner-3036.c | 1 drivers/media/video/vpx3220.c | 1 include/linux/hwmon-vid.h | 30 ++++ include/linux/i2c-sensor.h | 245 -------------------------------------- include/linux/i2c-vid.h | 111 ----------------- include/linux/i2c.h | 153 +++++++++++++++++++++-- 65 files changed, 551 insertions(+), 884 deletions(-)
before after diff
drivers/hwmon/adm1021.ko 16408 16343 -65
drivers/hwmon/adm1025.ko 21005 20721 -284
drivers/hwmon/adm1026.ko 40572 40352 -220
drivers/hwmon/adm1031.ko 22799 22798 -1
drivers/hwmon/adm9240.ko 20842 20558 -284
drivers/hwmon/asb100.ko 26873 26725 -148
drivers/hwmon/atxp1.ko 10242 9993 -249
drivers/hwmon/ds1621.ko 9603 9602 -1
drivers/hwmon/fscher.ko 18725 18724 -1
drivers/hwmon/fscpos.ko 18896 18895 -1
drivers/hwmon/gl518sm.ko 20420 20355 -65
drivers/hwmon/gl520sm.ko 22904 22684 -220
drivers/hwmon/hwmon-vid.ko 0 3417 +3417
drivers/hwmon/it87.ko 26031 25747 -284
drivers/hwmon/lm63.ko 12077 12076 -1
drivers/hwmon/lm75.ko 9294 9293 -1
drivers/hwmon/lm77.ko 11498 11433 -65
drivers/hwmon/lm78.ko 21124 21096 -28
drivers/hwmon/lm80.ko 22096 22095 -1
drivers/hwmon/lm83.ko 9850 9849 -1
drivers/hwmon/lm85.ko 40438 40218 -220
drivers/hwmon/lm87.ko 25077 24857 -220
drivers/hwmon/lm90.ko 15213 15148 -65
drivers/hwmon/lm92.ko 11912 11847 -65
drivers/hwmon/max1619.ko 10643 10642 -1
drivers/hwmon/pc87360.ko 47225 47006 -219
drivers/hwmon/w83627hf.ko 30422 30203 -219
drivers/hwmon/w83781d.ko 39165 38945 -220
drivers/hwmon/w83792d.ko 32767 32766 -1
drivers/hwmon/w83l785ts.ko 8289 8288 -1
drivers/i2c/chips/ds1337.ko 8677 8612 -65
drivers/i2c/chips/ds1374.ko 6075 6067 -8
drivers/i2c/chips/eeprom.ko 8132 8131 -1
drivers/i2c/chips/max6875.ko 7822 7821 -1
drivers/i2c/chips/pca9539.ko 7763 7762 -1
drivers/i2c/chips/pcf8574.ko 8042 7977 -65
drivers/i2c/chips/pcf8591.ko 9630 9565 -65
drivers/i2c/chips/rtc8564.ko 6947 6939 -8
drivers/i2c/i2c-core.ko 21451 21579 +128
drivers/i2c/i2c-sensor.ko 3856 0 -3856
drivers/media/video/adv7170.ko 7333 7325 -8
drivers/media/video/adv7175.ko 7613 7605 -8
drivers/media/video/bt819.ko 9027 9019 -8
drivers/media/video/bt856.ko 7058 7050 -8
drivers/media/video/msp3400.ko 31404 31499 +95
drivers/media/video/saa5246a.ko 11254 11349 +95
drivers/media/video/saa5249.ko 13054 13149 +95
drivers/media/video/saa7110.ko 9512 9504 -8
drivers/media/video/saa7111.ko 7177 7169 -8
drivers/media/video/saa7114.ko 12048 12040 -8
drivers/media/video/saa7134/saa6752hs.ko 10489 10584 +95
drivers/media/video/saa7185.ko 6323 6315 -8
drivers/media/video/tda7432.ko 9373 9404 +31
drivers/media/video/tda9840.ko 8938 9033 +95
drivers/media/video/tda9875.ko 9234 9329 +95
drivers/media/video/tda9887.ko 16949 17044 +95
drivers/media/video/tea6415c.ko 7765 7860 +95
drivers/media/video/tea6420.ko 7635 7730 +95
drivers/media/video/tuner-3036.ko 5940 5932 -8
drivers/media/video/tuner.ko 45355 45386 +31
drivers/media/video/tvaudio.ko 25796 25827 +31
drivers/media/video/tveeprom.ko 15175 15206 +31
drivers/media/video/vpx3220.ko 10083 10075 -8
total -2777Signature · 1 line
Jean Delvare
PATCH 1/1 (1/11) hwmon vs i2c, second round
Add support for kind-forced addresses to i2c_probe, like i2c_detect has for (essentially) hardware monitoring drivers.
Note that this change will slightly increase the size of the drivers using I2C_CLIENT_INSMOD, with no immediate benefit. This is a requirement if we want to merge i2c_probe and i2c_detect though, and seems a reasonable price to pay in comparison with the previous cleanups which saved much more than that (such as the i2c-isa cleanup or the i2c address ranges removal.)
drivers/i2c/chips/ds1374.c | 1 - drivers/i2c/chips/m41t00.c | 1 - drivers/i2c/chips/rtc8564.c | 1 - drivers/i2c/i2c-core.c | 38 ++++++++++++++++++++++++++++---------- drivers/media/video/adv7170.c | 1 - drivers/media/video/adv7175.c | 1 - drivers/media/video/bt819.c | 1 - drivers/media/video/bt856.c | 1 - drivers/media/video/saa7110.c | 1 - drivers/media/video/saa7111.c | 1 - drivers/media/video/saa7114.c | 1 - drivers/media/video/saa7185.c | 1 - drivers/media/video/tuner-3036.c | 1 - drivers/media/video/vpx3220.c | 1 - include/linux/i2c.h | 9 ++++++--- 15 files changed, 34 insertions(+), 26 deletions(-)
drivers/media/video/adv7170.c +0 -1
@@ -391,7 +391,6 @@ .normal_i2c = normal_i2c, .probe = &ignore, .ignore = &ignore, - .force = &ignore, };static struct i2c_driver i2c_driver_adv7170;
drivers/media/video/adv7175.c +0 -1
@@ -441,7 +441,6 @@ .normal_i2c = normal_i2c, .probe = &ignore, .ignore = &ignore, - .force = &ignore, };static struct i2c_driver i2c_driver_adv7175;
drivers/media/video/bt819.c +0 -1
@@ -507,7 +507,6 @@ .normal_i2c = normal_i2c, .probe = &ignore, .ignore = &ignore, - .force = &ignore, };static struct i2c_driver i2c_driver_bt819;
drivers/media/video/bt856.c +0 -1
@@ -295,7 +295,6 @@ .normal_i2c = normal_i2c, .probe = &ignore, .ignore = &ignore, - .force = &ignore, };static struct i2c_driver i2c_driver_bt856;
drivers/media/video/saa7110.c +0 -1
@@ -470,7 +470,6 @@ .normal_i2c = normal_i2c, .probe = &ignore, .ignore = &ignore, - .force = &ignore, };static struct i2c_driver i2c_driver_saa7110;
drivers/media/video/saa7111.c +0 -1
@@ -489,7 +489,6 @@ .normal_i2c = normal_i2c, .probe = &ignore, .ignore = &ignore, - .force = &ignore, };static struct i2c_driver i2c_driver_saa7111;
drivers/media/video/saa7114.c +0 -1
@@ -827,7 +827,6 @@ .normal_i2c = normal_i2c, .probe = &ignore, .ignore = &ignore, - .force = &ignore, };static struct i2c_driver i2c_driver_saa7114;
drivers/media/video/saa7185.c +0 -1
@@ -387,7 +387,6 @@ .normal_i2c = normal_i2c, .probe = &ignore, .ignore = &ignore, - .force = &ignore, };static struct i2c_driver i2c_driver_saa7185;
drivers/media/video/tuner-3036.c +0 -1
@@ -41,7 +41,6 @@ .normal_i2c = normal_i2c, .probe = &ignore, .ignore = &ignore, - .force = &ignore, };/* ---------------------------------------------------------------------- */
drivers/media/video/vpx3220.c +0 -1
@@ -576,7 +576,6 @@ .normal_i2c = normal_i2c, .probe = &ignore, .ignore = &ignore, - .force = &ignore, };static struct i2c_driver vpx3220_i2c_driver;
drivers/i2c/chips/ds1374.c +0 -1
@@ -53,7 +53,6 @@ .normal_i2c = normal_addr, .probe = ignore, .ignore = ignore, - .force = ignore, };static ulong ds1374_read_rtc (void )
drivers/i2c/chips/m41t00.c +0 -1
@@ -42,7 +42,6 @@ .normal_i2c = normal_addr, .probe = ignore, .ignore = ignore, - .force = ignore, }; ulong
drivers/i2c/chips/rtc8564.c +0 -1
@@ -67,7 +67,6 @@ .normal_i2c = normal_addr, .probe = ignore, .ignore = ignore, - .force = ignore, };static int rtc8564_read_mem (struct i2c_client *client,struct mem *mem);
drivers/i2c/i2c-core.c +28 -10
@@ -662,6 +662,28 @@* Will not work for 10-bit addresses! * ---------------------------------------------------- */ +/* Return: kind (>= 0) if force found, -1 if not found */ +static inline int i2c_probe_forces (struct i2c_adapter *adapter,int addr, +unsigned short **forces) +{ +unsigned short kind; +int j, adap_id =i2c_adapter_id (adapter); + +for (kind =0 ; forces[kind]; kind++) { +for (j =0 ; forces[kind][j] !=I2C_CLIENT_END ; j +=2 ) { +if ((forces[kind][j] == adap_id || + forces[kind][j] ==ANY_I2C_BUS ) + && forces[kind][j +1 ] == addr) { +dev_dbg (&adapter->dev,"found force parameter, " +"addr 0x%02x, kind %u\n" , addr, kind); +return kind; + } + } + } + +return -1 ; +} +int i2c_probe (struct i2c_adapter *adapter,struct i2c_client_address_data *address_data,int (*found_proc) (struct i2c_adapter *,int ,int ))
@@ -683,19 +705,15 @@at all */ found =0 ; -for (i =0 ; !found && (address_data->force[i] !=I2C_CLIENT_END ); i +=2 ) { -if (((adap_id == address_data->force[i]) || - (address_data->force[i] ==ANY_I2C_BUS )) && - (addr == address_data->force[i+1 ])) { -dev_dbg (&adapter->dev,"found force parameter for adapter %d, addr %04x\n" , - adap_id, addr); -if ((err =found_proc (adapter,addr,0 ))) +if (address_data->forces) { +int kind =i2c_probe_forces (adapter, addr, + address_data->forces); +if (kind >=0 ) {/* force found */ +if ((err =found_proc (adapter, addr, kind)))return err; - found =1 ; +continue ; } } -if (found) -continue ;/* If this address is in one of the ignores, we can forget about it right now */
include/linux/i2c.h +6 -3
@@ -48,7 +48,6 @@struct i2c_adapter ;struct i2c_client ;struct i2c_driver ; -struct i2c_client_address_data ;union i2c_smbus_data ;/*
@@ -301,7 +300,7 @@unsigned short *normal_i2c;unsigned short *probe;unsigned short *ignore; -unsigned short *force; +unsigned short **forces; };/* Internal numbers to terminate lists */
@@ -575,11 +574,15 @@I2C_CLIENT_MODULE_PARM (force, \"List of adapter,address pairs to boldly assume " \"to be present" ); \ +static unsigned short *addr_forces[] = { \ + force, \ +NULL \ + }; \static struct i2c_client_address_data addr_data = { \ .normal_i2c = normal_i2c, \ .probe = probe, \ .ignore = ignore, \ - .force = force, \ + .forces = addr_forces, \ }#endif /* _LINUX_I2C_H */
Signature · 1 line
Jean Delvare
PATCH 1/1 (2/11) hwmon vs i2c, second round
In reply to Jean DelvareThe way i2c-sensor handles forced addresses could be optimized. It defines a structure (i2c_force_data) to associate a module parameter with a given kind value, but in fact this kind value is always the index of the structure in each array it is used in. So this additional value can be omitted, and still be deduced in the code handling these arrays.
drivers/i2c/i2c-sensor-detect.c | 13 +-- include/linux/i2c-sensor.h | 133 ++++++++++++++++++---------------------- 2 files changed, 67 insertions(+), 79 deletions(-)
drivers/i2c/i2c-sensor-detect.c +6 -7
@@ -32,7 +32,6 @@ int (*found_proc) (struct i2c_adapter *, int, int)) {int addr, i, found, j, err; -struct i2c_force_data *this_force;int adapter_id =i2c_adapter_id (adapter);unsigned short *normal_i2c;unsigned short *probe;
@@ -58,13 +57,13 @@/* If it is in one of the force entries, we don't do any detection at all */ found =0 ; -for (i =0 ; !found && (this_force = address_data->forces + i, this_force->force); i++) { -for (j =0 ; !found && (this_force->force[j] !=I2C_CLIENT_END ); j +=2 ) { -if ( ((adapter_id == this_force->force[j]) || - (this_force->force[j] ==ANY_I2C_BUS )) && - (addr == this_force->force[j +1 ]) ) { +for (i =0 ; address_data->forces[i]; i++) { +for (j =0 ; !found && (address_data->forces[i][j] !=I2C_CLIENT_END ); j +=2 ) { +if ( ((adapter_id == address_data->forces[i][j]) || + (address_data->forces[i][j] ==ANY_I2C_BUS )) && + (addr == address_data->forces[i][j +1 ]) ) {dev_dbg (&adapter->dev,"found force parameter for adapter %d, addr %04x\n" , adapter_id, addr); -if ((err =found_proc (adapter, addr, this_force->kind))) +if ((err =found_proc (adapter, addr, i)))return err; found =1 ; }
include/linux/i2c-sensor.h +61 -72
204 lines not on this page · raw message
Signature · 1 line
Jean Delvare
PATCH 1/1 (3/11) hwmon vs i2c, second round
In reply to Jean DelvareWe now have two identical structures, i2c_address_data in i2c-sensor.h and i2c_client_address_data in i2c.h. We can kill one of them, I choose to keep the one in i2c.h as it makes more sense (this structure is not specific to sensors.)
drivers/i2c/i2c-sensor-detect.c | 2 +- include/linux/i2c-sensor.h | 30 +++--------------------------- 2 files changed, 4 insertions(+), 28 deletions(-)
drivers/i2c/i2c-sensor-detect.c +1 -1
@@ -28,7 +28,7 @@/* Won't work for 10-bit addresses! */ int i2c_detect (struct i2c_adapter *adapter, -struct i2c_address_data *address_data, +struct i2c_client_address_data *address_data,int (*found_proc) (struct i2c_adapter *,int ,int )) {int addr, i, found, j, err;
include/linux/i2c-sensor.h +3 -27
@@ -22,31 +22,7 @@#ifndef _LINUX_I2C_SENSOR_H#define _LINUX_I2C_SENSOR_H -/* A structure containing the detect information. -normal_i2c: filled in by the module writer. Terminated by I2C_CLIENT_END. -A list of I2C addresses which should normally be examined. -probe: insmod parameter. Initialize this list with I2C_CLIENT_END values. -A list of pairs. The first value is a bus number (ANY_I2C_BUS for any -I2C bus), the second is the address. These addresses are also probed, -as if they were in the 'normal' list. -ignore: insmod parameter. Initialize this list with I2C_CLIENT_END values. -A list of pairs. The first value is a bus number (ANY_I2C_BUS for any -I2C bus), the second is the I2C address. These addresses are never -probed. This parameter overrules 'normal' and probe', but not the -'force' lists. -forces: insmod parameters. A list, ending with a NULL element. -Force variables overrule all other variables; they force a detection on -that place. If a specific chip is given, the module blindly assumes this -chip type is present; if a general force (kind == 0) is given, the module -will still try to figure out what type of chip is present. This is useful -if for some reasons the detect for SMBus address space filled fails. -*/ -struct i2c_address_data { -unsigned short *normal_i2c; -unsigned short *probe; -unsigned short *ignore; -unsigned short **forces; -}; +#include <linux/i2c.h> #define SENSORS_MODULE_PARM_FORCE (name) \ I2C_CLIENT_MODULE_PARM(force_ ## name, \
@@ -60,7 +36,7 @@ "List of adapter,address pairs to scan additionally"); \I2C_CLIENT_MODULE_PARM (ignore, \"List of adapter,address pairs not to scan" ); \ -static struct i2c_address_data addr_data = { \ +static struct i2c_client_address_data addr_data = { \ .normal_i2c = normal_i2c, \ .probe = probe, \ .ignore = ignore, \
@@ -228,7 +204,7 @@SMBus addresses, it will only call found_proc if some client is connected to the SMBus (unless a 'force' matched). */ extern int i2c_detect (struct i2c_adapter *adapter, -struct i2c_address_data *address_data, +struct i2c_client_address_data *address_data,int (*found_proc) (struct i2c_adapter *,int ,int ));#endif /* def _LINUX_I2C_SENSOR_H */
Signature · 1 line
Jean Delvare
PATCH 1/1 (4/11) hwmon vs i2c, second round
In reply to Jean Delvarei2c_probe and i2c_detect now do the exact same thing and operate on the same data structure, so we can have everyone call i2c_probe.
Documentation/i2c/porting-clients | 1 + Documentation/i2c/writing-clients | 19 +++++-------------- drivers/hwmon/adm1021.c | 2 +- drivers/hwmon/adm1025.c | 2 +- drivers/hwmon/adm1026.c | 2 +- drivers/hwmon/adm1031.c | 4 ++-- drivers/hwmon/adm9240.c | 2 +- drivers/hwmon/asb100.c | 2 +- drivers/hwmon/atxp1.c | 2 +- drivers/hwmon/ds1621.c | 4 ++-- drivers/hwmon/fscher.c | 2 +- drivers/hwmon/fscpos.c | 2 +- drivers/hwmon/gl518sm.c | 2 +- drivers/hwmon/gl520sm.c | 2 +- drivers/hwmon/it87.c | 4 ++-- drivers/hwmon/lm63.c | 2 +- drivers/hwmon/lm75.c | 4 ++-- drivers/hwmon/lm77.c | 4 ++-- drivers/hwmon/lm78.c | 4 ++-- drivers/hwmon/lm80.c | 2 +- drivers/hwmon/lm83.c | 2 +- drivers/hwmon/lm85.c | 2 +- drivers/hwmon/lm87.c | 2 +- drivers/hwmon/lm90.c | 2 +- drivers/hwmon/lm92.c | 2 +- drivers/hwmon/max1619.c | 2 +- drivers/hwmon/w83781d.c | 2 +- drivers/hwmon/w83792d.c | 2 +- drivers/hwmon/w83l785ts.c | 2 +- drivers/i2c/chips/ds1337.c | 2 +- drivers/i2c/chips/eeprom.c | 4 ++-- drivers/i2c/chips/max6875.c | 4 ++-- drivers/i2c/chips/pca9539.c | 4 ++-- drivers/i2c/chips/pcf8574.c | 4 ++-- drivers/i2c/chips/pcf8591.c | 4 ++-- 35 files changed, 50 insertions(+), 58 deletions(-)
Documentation/i2c/porting-clients +1 -0
@@ -66,6 +66,7 @@ if (!(adapter->class & I2C_CLASS_HWMON)) return 0; ISA-only drivers of course don't need this. + Call i2c_probe() instead of i2c_detect(). * [Detect] As mentioned earlier, the flags parameter is gone. The type_name and client_name strings are replaced by a single
Documentation/i2c/writing-clients +5 -14
@@ -148,7 +148,7 @@ detection algorithm. You do not have to use this parameter interface; but don't try to use -function i2c_probe() (or i2c_detect()) if you don't. +function i2c_probe() if you don't. NOTE: If you want to write a `sensors' driver, the interface is slightly different! See below.
@@ -259,17 +259,10 @@ return i2c_probe(adapter,&addr_data,&foo_detect_client); } -For `sensors' drivers, use the i2c_detect function instead: - - int foo_attach_adapter(struct i2c_adapter *adapter) - { - return i2c_detect(adapter,&addr_data,&foo_detect_client); - } - Remember, structure `addr_data' is defined by the macros explained above, so you do not have to define it yourself. -The i2c_probe or i2c_detect function will call the foo_detect_client +The i2c_probe function will call the foo_detect_client function only for those i2c addresses that actually have a device on them (unless a `force' parameter was used). In addition, addresses that are already in use (by some other registered client) are skipped.
@@ -278,11 +271,9 @@ The detect client function -------------------------- -The detect client function is called by i2c_probe or i2c_detect. -The `kind' parameter contains 0 if this call is due to a `force' -parameter, and -1 otherwise (for i2c_detect, it contains 0 if -this call is due to the generic `force' parameter, and the chip type -number if it is due to a specific `force' parameter). +The detect client function is called by i2c_probe. The `kind' parameter +contains -1 for a probed detection, 0 for a forced detection, or a positive +number for a forced detection with a chip type forced. Below, some things are only needed if this is a `sensors' driver. Those parts are between /* SENSORS ONLY START */ and /* SENSORS ONLY END */
drivers/hwmon/adm1021.c +1 -1
@@ -187,7 +187,7 @@ {if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ; -return i2c_detect (adapter, &addr_data, adm1021_detect); +return i2c_probe (adapter, &addr_data, adm1021_detect); }static int adm1021_detect (struct i2c_adapter *adapter,int address,int kind)
drivers/hwmon/adm1025.c +1 -1
@@ -314,7 +314,7 @@ {if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ; -return i2c_detect (adapter, &addr_data, adm1025_detect); +return i2c_probe (adapter, &addr_data, adm1025_detect); }/*
drivers/hwmon/adm1026.c +1 -1
@@ -321,7 +321,7 @@if (!(adapter->class &I2C_CLASS_HWMON )) {return 0 ; } -return i2c_detect (adapter, &addr_data, adm1026_detect); +return i2c_probe (adapter, &addr_data, adm1026_detect); }int adm1026_detach_client (struct i2c_client *client)
drivers/hwmon/adm1031.c +2 -2
@@ -727,10 +727,10 @@ {if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ; -return i2c_detect (adapter, &addr_data, adm1031_detect); +return i2c_probe (adapter, &addr_data, adm1031_detect); } -/* This function is called by i2c_detect */ +/* This function is called by i2c_probe */ static int adm1031_detect (struct i2c_adapter *adapter,int address,int kind) {struct i2c_client *new_client;
drivers/hwmon/adm9240.c +1 -1
@@ -635,7 +635,7 @@ {if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ; -return i2c_detect (adapter, &addr_data, adm9240_detect); +return i2c_probe (adapter, &addr_data, adm9240_detect); }static int adm9240_detach_client (struct i2c_client *client)
drivers/hwmon/asb100.c +1 -1
@@ -621,7 +621,7 @@ {if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ; -return i2c_detect (adapter, &addr_data, asb100_detect); +return i2c_probe (adapter, &addr_data, asb100_detect); } static int asb100_detect_subclients(struct i2c_adapter *adapter, int address,
drivers/hwmon/atxp1.c +1 -1
@@ -254,7 +254,7 @@static int atxp1_attach_adapter (struct i2c_adapter *adapter) { -return i2c_detect (adapter, &addr_data, &atxp1_detect); +return i2c_probe (adapter, &addr_data, &atxp1_detect); };static int atxp1_detect (struct i2c_adapter *adapter,int address,int kind)
drivers/hwmon/ds1621.c +2 -2
@@ -181,10 +181,10 @@static int ds1621_attach_adapter (struct i2c_adapter *adapter) { -return i2c_detect (adapter, &addr_data, ds1621_detect); +return i2c_probe (adapter, &addr_data, ds1621_detect); } -/* This function is called by i2c_detect */ +/* This function is called by i2c_probe */ int ds1621_detect (struct i2c_adapter *adapter,int address,int kind) {
drivers/hwmon/fscher.c +1 -1
@@ -289,7 +289,7 @@ {if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ; -return i2c_detect (adapter, &addr_data, fscher_detect); +return i2c_probe (adapter, &addr_data, fscher_detect); }static int fscher_detect (struct i2c_adapter *adapter,int address,int kind)
drivers/hwmon/fscpos.c +1 -1
@@ -436,7 +436,7 @@ {if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ; -return i2c_detect (adapter, &addr_data, fscpos_detect); +return i2c_probe (adapter, &addr_data, fscpos_detect); }int fscpos_detect (struct i2c_adapter *adapter,int address,int kind)
drivers/hwmon/gl518sm.c +1 -1
@@ -348,7 +348,7 @@ {if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ; -return i2c_detect (adapter, &addr_data, gl518_detect); +return i2c_probe (adapter, &addr_data, gl518_detect); }static int gl518_detect (struct i2c_adapter *adapter,int address,int kind)
drivers/hwmon/gl520sm.c +1 -1
@@ -520,7 +520,7 @@ {if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ; -return i2c_detect (adapter, &addr_data, gl520_detect); +return i2c_probe (adapter, &addr_data, gl520_detect); }static int gl520_detect (struct i2c_adapter *adapter,int address,int kind)
drivers/hwmon/it87.c +2 -2
@@ -698,7 +698,7 @@ {if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ; -return i2c_detect (adapter, &addr_data, it87_detect); +return i2c_probe (adapter, &addr_data, it87_detect); }static int it87_isa_attach_adapter (struct i2c_adapter *adapter)
@@ -738,7 +738,7 @@return err; } -/* This function is called by i2c_detect */ +/* This function is called by i2c_probe */ int it87_detect (struct i2c_adapter *adapter,int address,int kind) {int i;
drivers/hwmon/lm63.c +1 -1
@@ -360,7 +360,7 @@ {if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ; -return i2c_detect (adapter, &addr_data, lm63_detect); +return i2c_probe (adapter, &addr_data, lm63_detect); }/*
drivers/hwmon/lm75.c +2 -2
@@ -109,10 +109,10 @@ {if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ; -return i2c_detect (adapter, &addr_data, lm75_detect); +return i2c_probe (adapter, &addr_data, lm75_detect); } -/* This function is called by i2c_detect */ +/* This function is called by i2c_probe */ static int lm75_detect (struct i2c_adapter *adapter,int address,int kind) {int i;
drivers/hwmon/lm77.c +2 -2
@@ -209,10 +209,10 @@ {if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ; -return i2c_detect (adapter, &addr_data, lm77_detect); +return i2c_probe (adapter, &addr_data, lm77_detect); } -/* This function is called by i2c_detect */ +/* This function is called by i2c_probe */ static int lm77_detect (struct i2c_adapter *adapter,int address,int kind) {struct i2c_client *new_client;
drivers/hwmon/lm78.c +2 -2
@@ -478,7 +478,7 @@ {if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ; -return i2c_detect (adapter, &addr_data, lm78_detect); +return i2c_probe (adapter, &addr_data, lm78_detect); }static int lm78_isa_attach_adapter (struct i2c_adapter *adapter)
@@ -486,7 +486,7 @@return lm78_detect (adapter, isa_address,-1 ); } -/* This function is called by i2c_detect */ +/* This function is called by i2c_probe */ int lm78_detect (struct i2c_adapter *adapter,int address,int kind) {int i, err;
drivers/hwmon/lm80.c +1 -1
@@ -391,7 +391,7 @@ {if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ; -return i2c_detect (adapter, &addr_data, lm80_detect); +return i2c_probe (adapter, &addr_data, lm80_detect); }int lm80_detect (struct i2c_adapter *adapter,int address,int kind)
drivers/hwmon/lm83.c +1 -1
@@ -214,7 +214,7 @@ {if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ; -return i2c_detect (adapter, &addr_data, lm83_detect); +return i2c_probe (adapter, &addr_data, lm83_detect); }/*
drivers/hwmon/lm85.c +1 -1
@@ -1012,7 +1012,7 @@ {if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ; -return i2c_detect (adapter, &addr_data, lm85_detect); +return i2c_probe (adapter, &addr_data, lm85_detect); } int lm85_detect(struct i2c_adapter *adapter, int address,
drivers/hwmon/lm87.c +1 -1
@@ -539,7 +539,7 @@ {if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ; -return i2c_detect (adapter, &addr_data, lm87_detect); +return i2c_probe (adapter, &addr_data, lm87_detect); }/*
drivers/hwmon/lm90.c +1 -1
@@ -354,7 +354,7 @@ {if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ; -return i2c_detect (adapter, &addr_data, lm90_detect); +return i2c_probe (adapter, &addr_data, lm90_detect); }/*
drivers/hwmon/lm92.c +1 -1
@@ -389,7 +389,7 @@ {if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ; -return i2c_detect (adapter, &addr_data, lm92_detect); +return i2c_probe (adapter, &addr_data, lm92_detect); }static int lm92_detach_client (struct i2c_client *client)
drivers/hwmon/max1619.c +1 -1
@@ -180,7 +180,7 @@ {if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ; -return i2c_detect (adapter, &addr_data, max1619_detect); +return i2c_probe (adapter, &addr_data, max1619_detect); }/*
drivers/hwmon/w83781d.c +1 -1
@@ -869,7 +869,7 @@ {if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ; -return i2c_detect (adapter, &addr_data, w83781d_detect); +return i2c_probe (adapter, &addr_data, w83781d_detect); } static int
drivers/hwmon/w83792d.c +1 -1
@@ -1076,7 +1076,7 @@ {if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ; -return i2c_detect (adapter, &addr_data, w83792d_detect); +return i2c_probe (adapter, &addr_data, w83792d_detect); }
drivers/hwmon/w83l785ts.c +1 -1
@@ -142,7 +142,7 @@ {if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ; -return i2c_detect (adapter, &addr_data, w83l785ts_detect); +return i2c_probe (adapter, &addr_data, w83l785ts_detect); }/*
drivers/i2c/chips/ds1337.c +1 -1
@@ -226,7 +226,7 @@static int ds1337_attach_adapter (struct i2c_adapter *adapter) { -return i2c_detect (adapter, &addr_data, ds1337_detect); +return i2c_probe (adapter, &addr_data, ds1337_detect); }/*
drivers/i2c/chips/eeprom.c +2 -2
@@ -152,10 +152,10 @@static int eeprom_attach_adapter (struct i2c_adapter *adapter) { -return i2c_detect (adapter, &addr_data, eeprom_detect); +return i2c_probe (adapter, &addr_data, eeprom_detect); } -/* This function is called by i2c_detect */ +/* This function is called by i2c_probe */ int eeprom_detect (struct i2c_adapter *adapter,int address,int kind) {struct i2c_client *new_client;
drivers/i2c/chips/max6875.c +2 -2
@@ -161,10 +161,10 @@static int max6875_attach_adapter (struct i2c_adapter *adapter) { -return i2c_detect (adapter, &addr_data, max6875_detect); +return i2c_probe (adapter, &addr_data, max6875_detect); } -/* This function is called by i2c_detect */ +/* This function is called by i2c_probe */ static int max6875_detect (struct i2c_adapter *adapter,int address,int kind) {struct i2c_client *real_client;
drivers/i2c/chips/pca9539.c +2 -2
@@ -108,10 +108,10 @@static int pca9539_attach_adapter (struct i2c_adapter *adapter) { -return i2c_detect (adapter, &addr_data, pca9539_detect); +return i2c_probe (adapter, &addr_data, pca9539_detect); } -/* This function is called by i2c_detect */ +/* This function is called by i2c_probe */ static int pca9539_detect (struct i2c_adapter *adapter,int address,int kind) {struct i2c_client *new_client;
drivers/i2c/chips/pcf8574.c +2 -2
@@ -112,10 +112,10 @@static int pcf8574_attach_adapter (struct i2c_adapter *adapter) { -return i2c_detect (adapter, &addr_data, pcf8574_detect); +return i2c_probe (adapter, &addr_data, pcf8574_detect); } -/* This function is called by i2c_detect */ +/* This function is called by i2c_probe */ int pcf8574_detect (struct i2c_adapter *adapter,int address,int kind) {struct i2c_client *new_client;
drivers/i2c/chips/pcf8591.c +2 -2
@@ -163,10 +163,10 @@*/ static int pcf8591_attach_adapter (struct i2c_adapter *adapter) { -return i2c_detect (adapter, &addr_data, pcf8591_detect); +return i2c_probe (adapter, &addr_data, pcf8591_detect); } -/* This function is called by i2c_detect */ +/* This function is called by i2c_probe */ int pcf8591_detect (struct i2c_adapter *adapter,int address,int kind) {struct i2c_client *new_client;
Signature · 1 line
Jean Delvare
PATCH 1/1 (5/11) hwmon vs i2c, second round
In reply to Jean DelvareThe i2c_detect function has no more user, delete it.
drivers/i2c/Makefile | 2 drivers/i2c/i2c-sensor-detect.c | 125 ---------------------------------------- drivers/i2c/i2c-sensor-vid.c | 5 + include/linux/i2c-sensor.h | 7 -- 4 files changed, 6 insertions(+), 133 deletions(-)
drivers/i2c/Makefile +1 -1
@@ -7,7 +7,7 @@ obj-$(CONFIG_I2C_SENSOR) += i2c-sensor.o obj-y += busses/ chips/ algos/ -i2c-sensor-objs := i2c-sensor-detect.o i2c-sensor-vid.o +i2c-sensor-objs := i2c-sensor-vid.o ifeq ($(CONFIG_I2C_DEBUG_CORE),y)
drivers/i2c/i2c-sensor-detect.c deleted +0 -125
125 lines not on this page · raw message
drivers/i2c/i2c-sensor-vid.c +5 -0
@@ -96,3 +96,8 @@#endif EXPORT_SYMBOL (i2c_which_vrm); + +MODULE_AUTHOR ("Rudolf Marek <[email protected]>" ); + +MODULE_DESCRIPTION ("i2c-sensor driver" ); +MODULE_LICENSE ("GPL" );
include/linux/i2c-sensor.h +0 -7
@@ -200,11 +200,4 @@ NULL }; \ SENSORS_INSMOD -/* Detect function. It iterates over all possible addresses itself. For -SMBus addresses, it will only call found_proc if some client is connected -to the SMBus (unless a 'force' matched). */ -extern int i2c_detect(struct i2c_adapter *adapter, -struct i2c_client_address_data *address_data, -int (*found_proc) (struct i2c_adapter *,int ,int )); -#endif /* def _LINUX_I2C_SENSOR_H */
Signature · 1 line
Jean Delvare
PATCH 1/1 (6/11) hwmon vs i2c, second round
In reply to Jean DelvareThe only thing left in i2c-sensor.h are module parameter definition macros. It's only an extension of what i2c.h offers, and this extension is not sensors-specific. As a matter of fact, a few non-sensors drivers use them. So we better merge them in i2c.h, and get rid of i2c-sensor.h altogether.
Documentation/i2c/porting-clients | 8 - Documentation/i2c/writing-clients | 68 ++---------- drivers/hwmon/adm1021.c | 3 drivers/hwmon/adm1025.c | 3 drivers/hwmon/adm1026.c | 3 drivers/hwmon/adm1031.c | 3 drivers/hwmon/adm9240.c | 3 drivers/hwmon/asb100.c | 3 drivers/hwmon/atxp1.c | 3 drivers/hwmon/ds1621.c | 3 drivers/hwmon/fscher.c | 3 drivers/hwmon/fscpos.c | 3 drivers/hwmon/gl518sm.c | 3 drivers/hwmon/gl520sm.c | 3 drivers/hwmon/it87.c | 3 drivers/hwmon/lm63.c | 3 drivers/hwmon/lm75.c | 3 drivers/hwmon/lm77.c | 3 drivers/hwmon/lm78.c | 3 drivers/hwmon/lm80.c | 3 drivers/hwmon/lm83.c | 3 drivers/hwmon/lm85.c | 3 drivers/hwmon/lm87.c | 3 drivers/hwmon/lm90.c | 3 drivers/hwmon/lm92.c | 3 drivers/hwmon/max1619.c | 3 drivers/hwmon/sis5595.c | 1 drivers/hwmon/smsc47m1.c | 1 drivers/hwmon/via686a.c | 1 drivers/hwmon/w83627hf.c | 1 drivers/hwmon/w83781d.c | 3 drivers/hwmon/w83792d.c | 3 drivers/hwmon/w83l785ts.c | 3 drivers/i2c/chips/ds1337.c | 3 drivers/i2c/chips/eeprom.c | 3 drivers/i2c/chips/max6875.c | 3 drivers/i2c/chips/pca9539.c | 3 drivers/i2c/chips/pcf8574.c | 3 drivers/i2c/chips/pcf8591.c | 3 include/linux/i2c-sensor.h | 203 -------------------------------------- include/linux/i2c.h | 148 +++++++++++++++++++++++++-- 41 files changed, 188 insertions(+), 342 deletions(-)
Documentation/i2c/porting-clients +4 -4
@@ -1,4 +1,4 @@ -Revision 4, 2004-03-30 +Revision 5, 2005-07-29 Jean Delvare <[email protected]> Greg KH <[email protected]>
@@ -17,13 +17,12 @@ Technical changes: -* [Includes] Get rid of "version.h". Replace <linux/i2c-proc.h> with - <linux/i2c-sensor.h>. Includes typically look like that: +* [Includes] Get rid of "version.h" and <linux/i2c-proc.h>. + Includes typically look like that: #include <linux/module.h> #include <linux/init.h> #include <linux/slab.h> #include <linux/i2c.h> - #include <linux/i2c-sensor.h> #include <linux/i2c-vid.h> /* if you need VRM support */ #include <asm/io.h> /* if you have I/O operations */ Please respect this inclusion order. Some extra headers may be
@@ -31,6 +30,7 @@ * [Addresses] SENSORS_I2C_END becomes I2C_CLIENT_END, ISA addresses are no more handled by the i2c core. + SENSORS_INSMOD_<n> becomes I2C_CLIENT_INSMOD_<n>. * [Client data] Get rid of sysctl_id. Try using standard names for register values (for example, temp_os becomes temp_max). You're
Documentation/i2c/writing-clients +15 -53
96 lines not on this page · raw message
drivers/hwmon/adm1021.c +1 -2
@@ -24,7 +24,6 @@#include <linux/slab.h> #include <linux/jiffies.h> #include <linux/i2c.h> -#include <linux/i2c-sensor.h> #include <linux/hwmon.h> #include <linux/err.h>
@@ -36,7 +35,7 @@ I2C_CLIENT_END };/* Insmod parameters */ -SENSORS_INSMOD_8 (adm1021, adm1023, max1617, max1617a, thmc10, lm84, gl523sm, mc1066); +I2C_CLIENT_INSMOD_8 (adm1021, adm1023, max1617, max1617a, thmc10, lm84, gl523sm, mc1066);/* adm1021 constants specified below */
drivers/hwmon/adm1025.c +1 -2
@@ -50,7 +50,6 @@#include <linux/slab.h> #include <linux/jiffies.h> #include <linux/i2c.h> -#include <linux/i2c-sensor.h> #include <linux/i2c-vid.h> #include <linux/hwmon.h> #include <linux/err.h>
@@ -67,7 +66,7 @@* Insmod parameters */ -SENSORS_INSMOD_2 (adm1025, ne1619); +I2C_CLIENT_INSMOD_2 (adm1025, ne1619);/* * The ADM1025 registers
drivers/hwmon/adm1026.c +1 -2
@@ -28,7 +28,6 @@#include <linux/slab.h> #include <linux/jiffies.h> #include <linux/i2c.h> -#include <linux/i2c-sensor.h> #include <linux/i2c-vid.h> #include <linux/hwmon-sysfs.h> #include <linux/hwmon.h>
@@ -38,7 +37,7 @@static unsigned short normal_i2c[] = {0x2c ,0x2d ,0x2e ,I2C_CLIENT_END };/* Insmod parameters */ -SENSORS_INSMOD_1 (adm1026); +I2C_CLIENT_INSMOD_1 (adm1026);static int gpio_input[17 ] = {-1 ,-1 ,-1 ,-1 ,-1 ,-1 ,-1 ,-1 ,-1 ,-1 ,-1 ,-1 ,-1 ,-1 ,-1 ,-1 ,-1 };
drivers/hwmon/adm1031.c +1 -2
@@ -26,7 +26,6 @@#include <linux/slab.h> #include <linux/jiffies.h> #include <linux/i2c.h> -#include <linux/i2c-sensor.h> #include <linux/hwmon.h> #include <linux/err.h>
@@ -63,7 +62,7 @@static unsigned short normal_i2c[] = {0x2c ,0x2d ,0x2e ,I2C_CLIENT_END };/* Insmod parameters */ -SENSORS_INSMOD_2 (adm1030, adm1031); +I2C_CLIENT_INSMOD_2 (adm1030, adm1031);typedef u8 auto_chan_table_t [8 ][2 ];
drivers/hwmon/adm9240.c +1 -2
@@ -45,7 +45,6 @@#include <linux/module.h> #include <linux/slab.h> #include <linux/i2c.h> -#include <linux/i2c-sensor.h> #include <linux/i2c-vid.h> #include <linux/hwmon.h> #include <linux/err.h>
@@ -55,7 +54,7 @@ I2C_CLIENT_END };/* Insmod parameters */ -SENSORS_INSMOD_3 (adm9240, ds1780, lm81); +I2C_CLIENT_INSMOD_3 (adm9240, ds1780, lm81);/* ADM9240 registers */ #define ADM9240_REG_MAN_ID 0x3e
drivers/hwmon/asb100.c +1 -2
@@ -39,7 +39,6 @@#include <linux/module.h> #include <linux/slab.h> #include <linux/i2c.h> -#include <linux/i2c-sensor.h> #include <linux/i2c-vid.h> #include <linux/hwmon.h> #include <linux/err.h>
@@ -57,7 +56,7 @@static unsigned short normal_i2c[] = {0x2d ,I2C_CLIENT_END };/* Insmod parameters */ -SENSORS_INSMOD_1 (asb100); +I2C_CLIENT_INSMOD_1 (asb100);I2C_CLIENT_MODULE_PARM (force_subclients,"List of subclient addresses: " "{bus, clientaddr, subclientaddr1, subclientaddr2}" );
drivers/hwmon/atxp1.c +1 -2
@@ -23,7 +23,6 @@#include <linux/module.h> #include <linux/jiffies.h> #include <linux/i2c.h> -#include <linux/i2c-sensor.h> #include <linux/i2c-vid.h> #include <linux/hwmon.h> #include <linux/err.h>
@@ -43,7 +42,7 @@static unsigned short normal_i2c[] = {0x37 ,0x4e ,I2C_CLIENT_END }; -SENSORS_INSMOD_1 (atxp1); +I2C_CLIENT_INSMOD_1 (atxp1);static int atxp1_attach_adapter (struct i2c_adapter * adapter);static int atxp1_detach_client (struct i2c_client * client);
drivers/hwmon/ds1621.c +1 -2
@@ -26,7 +26,6 @@#include <linux/slab.h> #include <linux/jiffies.h> #include <linux/i2c.h> -#include <linux/i2c-sensor.h> #include <linux/hwmon.h> #include <linux/err.h> #include "lm75.h"
@@ -36,7 +35,7 @@ 0x4d, 0x4e, 0x4f, I2C_CLIENT_END };/* Insmod parameters */ -SENSORS_INSMOD_1 (ds1621); +I2C_CLIENT_INSMOD_1 (ds1621);static int polarity =-1 ;module_param (polarity, int,0 );MODULE_PARM_DESC (polarity,"Output's polarity: 0 = active high, 1 = active low" );
drivers/hwmon/fscher.c +1 -2
@@ -31,7 +31,6 @@#include <linux/slab.h> #include <linux/jiffies.h> #include <linux/i2c.h> -#include <linux/i2c-sensor.h> #include <linux/hwmon.h> #include <linux/err.h>
@@ -45,7 +44,7 @@* Insmod parameters */ -SENSORS_INSMOD_1 (fscher); +I2C_CLIENT_INSMOD_1 (fscher);/* * The FSCHER registers
drivers/hwmon/fscpos.c +1 -2
@@ -34,7 +34,6 @@#include <linux/slab.h> #include <linux/jiffies.h> #include <linux/i2c.h> -#include <linux/i2c-sensor.h> #include <linux/init.h> #include <linux/hwmon.h> #include <linux/err.h>
@@ -47,7 +46,7 @@/* * Insmod parameters */ -SENSORS_INSMOD_1 (fscpos); +I2C_CLIENT_INSMOD_1 (fscpos);/* * The FSCPOS registers
drivers/hwmon/gl518sm.c +1 -2
@@ -41,7 +41,6 @@#include <linux/slab.h> #include <linux/jiffies.h> #include <linux/i2c.h> -#include <linux/i2c-sensor.h> #include <linux/hwmon.h> #include <linux/err.h>
@@ -49,7 +48,7 @@static unsigned short normal_i2c[] = {0x2c ,0x2d ,I2C_CLIENT_END };/* Insmod parameters */ -SENSORS_INSMOD_2 (gl518sm_r00, gl518sm_r80); +I2C_CLIENT_INSMOD_2 (gl518sm_r00, gl518sm_r80);/* Many GL518 constants specified below */
drivers/hwmon/gl520sm.c +1 -2
@@ -26,7 +26,6 @@#include <linux/slab.h> #include <linux/jiffies.h> #include <linux/i2c.h> -#include <linux/i2c-sensor.h> #include <linux/i2c-vid.h> #include <linux/hwmon.h> #include <linux/err.h>
@@ -40,7 +39,7 @@static unsigned short normal_i2c[] = {0x2c ,0x2d ,I2C_CLIENT_END };/* Insmod parameters */ -SENSORS_INSMOD_1 (gl520sm); +I2C_CLIENT_INSMOD_1 (gl520sm);/* Many GL520 constants specified below One of the inputs can be configured as either temp or voltage.
drivers/hwmon/it87.c +1 -2
@@ -37,7 +37,6 @@#include <linux/jiffies.h> #include <linux/i2c.h> #include <linux/i2c-isa.h> -#include <linux/i2c-sensor.h> #include <linux/i2c-vid.h> #include <linux/hwmon-sysfs.h> #include <linux/hwmon.h>
@@ -51,7 +50,7 @@static unsigned short isa_address =0x290 ;/* Insmod parameters */ -SENSORS_INSMOD_2 (it87, it8712); +I2C_CLIENT_INSMOD_2 (it87, it8712);#define REG 0x2e/* The register to read/write */ #define DEV 0x07/* Register: Logical device select */
drivers/hwmon/lm63.c +1 -2
@@ -42,7 +42,6 @@#include <linux/slab.h> #include <linux/jiffies.h> #include <linux/i2c.h> -#include <linux/i2c-sensor.h> #include <linux/hwmon-sysfs.h> #include <linux/hwmon.h> #include <linux/err.h>
@@ -58,7 +57,7 @@* Insmod parameters */ -SENSORS_INSMOD_1 (lm63); +I2C_CLIENT_INSMOD_1 (lm63);/* * The LM63 registers
drivers/hwmon/lm75.c +1 -2
@@ -23,7 +23,6 @@#include <linux/slab.h> #include <linux/jiffies.h> #include <linux/i2c.h> -#include <linux/i2c-sensor.h> #include <linux/hwmon.h> #include <linux/err.h> #include "lm75.h"
@@ -34,7 +33,7 @@ 0x4d, 0x4e, 0x4f, I2C_CLIENT_END };/* Insmod parameters */ -SENSORS_INSMOD_1 (lm75); +I2C_CLIENT_INSMOD_1 (lm75);/* Many LM75 constants specified below */
drivers/hwmon/lm77.c +1 -2
@@ -30,7 +30,6 @@#include <linux/slab.h> #include <linux/jiffies.h> #include <linux/i2c.h> -#include <linux/i2c-sensor.h> #include <linux/hwmon.h> #include <linux/err.h>
@@ -38,7 +37,7 @@static unsigned short normal_i2c[] = {0x48 ,0x49 ,0x4a ,0x4b ,I2C_CLIENT_END };/* Insmod parameters */ -SENSORS_INSMOD_1 (lm77); +I2C_CLIENT_INSMOD_1 (lm77);/* The LM77 registers */ #define LM77_REG_TEMP 0x00
drivers/hwmon/lm78.c +1 -2
@@ -24,7 +24,6 @@#include <linux/jiffies.h> #include <linux/i2c.h> #include <linux/i2c-isa.h> -#include <linux/i2c-sensor.h> #include <linux/hwmon.h> #include <linux/err.h> #include <asm/io.h>
@@ -37,7 +36,7 @@static unsigned short isa_address =0x290 ;/* Insmod parameters */ -SENSORS_INSMOD_2 (lm78, lm79); +I2C_CLIENT_INSMOD_2 (lm78, lm79);/* Many LM78 constants specified below */
drivers/hwmon/lm80.c +1 -2
@@ -26,7 +26,6 @@#include <linux/slab.h> #include <linux/jiffies.h> #include <linux/i2c.h> -#include <linux/i2c-sensor.h> #include <linux/hwmon.h> #include <linux/err.h>
@@ -35,7 +34,7 @@ 0x2d, 0x2e, 0x2f, I2C_CLIENT_END };/* Insmod parameters */ -SENSORS_INSMOD_1 (lm80); +I2C_CLIENT_INSMOD_1 (lm80);/* Many LM80 constants specified below */
drivers/hwmon/lm83.c +1 -2
@@ -32,7 +32,6 @@#include <linux/slab.h> #include <linux/jiffies.h> #include <linux/i2c.h> -#include <linux/i2c-sensor.h> #include <linux/hwmon-sysfs.h> #include <linux/hwmon.h> #include <linux/err.h>
@@ -52,7 +51,7 @@* Insmod parameters */ -SENSORS_INSMOD_1 (lm83); +I2C_CLIENT_INSMOD_1 (lm83);/* * The LM83 registers
drivers/hwmon/lm85.c +1 -2
@@ -28,7 +28,6 @@#include <linux/slab.h> #include <linux/jiffies.h> #include <linux/i2c.h> -#include <linux/i2c-sensor.h> #include <linux/i2c-vid.h> #include <linux/hwmon.h> #include <linux/err.h>
@@ -37,7 +36,7 @@static unsigned short normal_i2c[] = {0x2c ,0x2d ,0x2e ,I2C_CLIENT_END };/* Insmod parameters */ -SENSORS_INSMOD_6 (lm85b, lm85c, adm1027, adt7463, emc6d100, emc6d102); +I2C_CLIENT_INSMOD_6 (lm85b, lm85c, adm1027, adt7463, emc6d100, emc6d102);/* The LM85 registers */
drivers/hwmon/lm87.c +1 -2
@@ -57,7 +57,6 @@#include <linux/slab.h> #include <linux/jiffies.h> #include <linux/i2c.h> -#include <linux/i2c-sensor.h> #include <linux/i2c-vid.h> #include <linux/hwmon.h> #include <linux/err.h>
@@ -73,7 +72,7 @@* Insmod parameters */ -SENSORS_INSMOD_1 (lm87); +I2C_CLIENT_INSMOD_1 (lm87);/* * The LM87 registers
drivers/hwmon/lm90.c +1 -2
@@ -75,7 +75,6 @@#include <linux/slab.h> #include <linux/jiffies.h> #include <linux/i2c.h> -#include <linux/i2c-sensor.h> #include <linux/hwmon-sysfs.h> #include <linux/hwmon.h> #include <linux/err.h>
@@ -96,7 +95,7 @@* Insmod parameters */ -SENSORS_INSMOD_6 (lm90, adm1032, lm99, lm86, max6657, adt7461); +I2C_CLIENT_INSMOD_6 (lm90, adm1032, lm99, lm86, max6657, adt7461);/* * The LM90 registers
drivers/hwmon/lm92.c +1 -2
@@ -44,7 +44,6 @@#include <linux/init.h> #include <linux/slab.h> #include <linux/i2c.h> -#include <linux/i2c-sensor.h> #include <linux/hwmon.h> #include <linux/err.h>
@@ -54,7 +53,7 @@ I2C_CLIENT_END };/* Insmod parameters */ -SENSORS_INSMOD_1 (lm92); +I2C_CLIENT_INSMOD_1 (lm92);/* The LM92 registers */ #define LM92_REG_CONFIG 0x01/* 8-bit, RW */
drivers/hwmon/max1619.c +1 -2
@@ -31,7 +31,6 @@#include <linux/slab.h> #include <linux/jiffies.h> #include <linux/i2c.h> -#include <linux/i2c-sensor.h> #include <linux/hwmon.h> #include <linux/err.h>
@@ -44,7 +43,7 @@* Insmod parameters */ -SENSORS_INSMOD_1 (max1619); +I2C_CLIENT_INSMOD_1 (max1619);/* * The MAX1619 registers
drivers/hwmon/sis5595.c +0 -1
@@ -56,7 +56,6 @@#include <linux/pci.h> #include <linux/i2c.h> #include <linux/i2c-isa.h> -#include <linux/i2c-sensor.h> #include <linux/hwmon.h> #include <linux/err.h> #include <linux/init.h>
drivers/hwmon/smsc47m1.c +0 -1
@@ -31,7 +31,6 @@#include <linux/jiffies.h> #include <linux/i2c.h> #include <linux/i2c-isa.h> -#include <linux/i2c-sensor.h> #include <linux/hwmon.h> #include <linux/err.h> #include <linux/init.h>
drivers/hwmon/via686a.c +0 -1
@@ -36,7 +36,6 @@#include <linux/jiffies.h> #include <linux/i2c.h> #include <linux/i2c-isa.h> -#include <linux/i2c-sensor.h> #include <linux/hwmon.h> #include <linux/err.h> #include <linux/init.h>
drivers/hwmon/w83627hf.c +0 -1
@@ -43,7 +43,6 @@#include <linux/jiffies.h> #include <linux/i2c.h> #include <linux/i2c-isa.h> -#include <linux/i2c-sensor.h> #include <linux/i2c-vid.h> #include <linux/hwmon.h> #include <linux/err.h>
drivers/hwmon/w83781d.c +1 -2
@@ -39,7 +39,6 @@#include <linux/jiffies.h> #include <linux/i2c.h> #include <linux/i2c-isa.h> -#include <linux/i2c-sensor.h> #include <linux/i2c-vid.h> #include <linux/hwmon.h> #include <linux/err.h>
@@ -53,7 +52,7 @@static unsigned short isa_address =0x290 ;/* Insmod parameters */ -SENSORS_INSMOD_5 (w83781d, w83782d, w83783s, w83627hf, as99127f); +I2C_CLIENT_INSMOD_5 (w83781d, w83782d, w83783s, w83627hf, as99127f);I2C_CLIENT_MODULE_PARM (force_subclients,"List of subclient addresses: " "{bus, clientaddr, subclientaddr1, subclientaddr2}" );
drivers/hwmon/w83792d.c +1 -2
@@ -40,7 +40,6 @@#include <linux/init.h> #include <linux/slab.h> #include <linux/i2c.h> -#include <linux/i2c-sensor.h> #include <linux/i2c-vid.h> #include <linux/hwmon.h> #include <linux/hwmon-sysfs.h>
@@ -50,7 +49,7 @@static unsigned short normal_i2c[] = {0x2c ,0x2d ,0x2e ,0x2f ,I2C_CLIENT_END };/* Insmod parameters */ -SENSORS_INSMOD_1 (w83792d); +I2C_CLIENT_INSMOD_1 (w83792d);I2C_CLIENT_MODULE_PARM (force_subclients,"List of subclient addresses: " "{bus, clientaddr, subclientaddr1, subclientaddr2}" );
drivers/hwmon/w83l785ts.c +1 -2
@@ -36,7 +36,6 @@#include <linux/slab.h> #include <linux/jiffies.h> #include <linux/i2c.h> -#include <linux/i2c-sensor.h> #include <linux/hwmon.h> #include <linux/err.h>
@@ -54,7 +53,7 @@* Insmod parameters */ -SENSORS_INSMOD_1 (w83l785ts); +I2C_CLIENT_INSMOD_1 (w83l785ts);/* * The W83L785TS-S registers
drivers/i2c/chips/ds1337.c +1 -2
@@ -17,7 +17,6 @@#include <linux/init.h> #include <linux/slab.h> #include <linux/i2c.h> -#include <linux/i2c-sensor.h> #include <linux/string.h> #include <linux/rtc.h> /* get the user-level API */ #include <linux/bcd.h>
@@ -40,7 +39,7 @@*/ static unsigned short normal_i2c[] = {0x68 ,I2C_CLIENT_END }; -SENSORS_INSMOD_1 (ds1337); +I2C_CLIENT_INSMOD_1 (ds1337);static int ds1337_attach_adapter (struct i2c_adapter *adapter);static int ds1337_detect (struct i2c_adapter *adapter,int address,int kind);
drivers/i2c/chips/eeprom.c +1 -2
@@ -33,14 +33,13 @@#include <linux/sched.h> #include <linux/jiffies.h> #include <linux/i2c.h> -#include <linux/i2c-sensor.h> /* Addresses to scan */ static unsigned short normal_i2c[] = {0x50 ,0x51 ,0x52 ,0x53 ,0x54 ,0x55 ,0x56 ,0x57 ,I2C_CLIENT_END };/* Insmod parameters */ -SENSORS_INSMOD_1 (eeprom); +I2C_CLIENT_INSMOD_1 (eeprom);/* Size of EEPROM in bytes */
drivers/i2c/chips/max6875.c +1 -2
@@ -31,14 +31,13 @@#include <linux/module.h> #include <linux/slab.h> #include <linux/i2c.h> -#include <linux/i2c-sensor.h> #include <asm/semaphore.h> /* Do not scan - the MAX6875 access method will write to some EEPROM chips */ static unsigned short normal_i2c[] = {I2C_CLIENT_END };/* Insmod parameters */ -SENSORS_INSMOD_1 (max6875); +I2C_CLIENT_INSMOD_1 (max6875);/* The MAX6875 can only read/write 16 bytes at a time */ #define SLICE_SIZE 16
drivers/i2c/chips/pca9539.c +1 -2
@@ -13,13 +13,12 @@#include <linux/slab.h> #include <linux/i2c.h> #include <linux/hwmon-sysfs.h> -#include <linux/i2c-sensor.h> /* Addresses to scan */ static unsigned short normal_i2c[] = {0x74 ,0x75 ,0x76 ,0x77 ,I2C_CLIENT_END };/* Insmod parameters */ -SENSORS_INSMOD_1 (pca9539); +I2C_CLIENT_INSMOD_1 (pca9539);enum pca9539_cmd {
drivers/i2c/chips/pcf8574.c +1 -2
@@ -39,7 +39,6 @@#include <linux/init.h> #include <linux/slab.h> #include <linux/i2c.h> -#include <linux/i2c-sensor.h> /* Addresses to scan */ static unsigned short normal_i2c[] = {0x20 ,0x21 ,0x22 ,0x23 ,0x24 ,0x25 ,0x26 ,0x27 ,
@@ -47,7 +46,7 @@ I2C_CLIENT_END };/* Insmod parameters */ -SENSORS_INSMOD_2 (pcf8574, pcf8574a); +I2C_CLIENT_INSMOD_2 (pcf8574, pcf8574a);/* Initial values */ #define PCF8574_INIT 255/* All outputs on (input mode) */
drivers/i2c/chips/pcf8591.c +1 -2
@@ -24,14 +24,13 @@#include <linux/init.h> #include <linux/slab.h> #include <linux/i2c.h> -#include <linux/i2c-sensor.h> /* Addresses to scan */ static unsigned short normal_i2c[] = {0x48 ,0x49 ,0x4a ,0x4b ,0x4c ,0x4d ,0x4e ,0x4f ,I2C_CLIENT_END };/* Insmod parameters */ -SENSORS_INSMOD_1 (pcf8591); +I2C_CLIENT_INSMOD_1 (pcf8591);static int input_mode;module_param (input_mode, int,0 );
include/linux/i2c-sensor.h deleted +0 -203
203 lines not on this page · raw message
include/linux/i2c.h +136 -12
160 lines not on this page · raw message
Signature · 1 line
Jean Delvare
PATCH 1/1 (7/11) hwmon vs i2c, second round
In reply to Jean DelvareThe only part left in i2c-sensor is the VRM/VRD/VID handling code. This is in no way related to i2c, so it doesn't belong there. Move the code to hwmon, where it belongs.
Note that not all hardware monitoring drivers do VRM/VRD/VID operations, so less drivers depend on hwmon-vid than there were depending on i2c-sensor.
Documentation/i2c/porting-clients | 4 + drivers/hwmon/Kconfig | 50 +++++----------- drivers/hwmon/Makefile | 1 drivers/hwmon/adm1025.c | 4 - drivers/hwmon/adm1026.c | 6 +- drivers/hwmon/adm9240.c | 4 - drivers/hwmon/asb100.c | 4 - drivers/hwmon/atxp1.c | 4 - drivers/hwmon/gl520sm.c | 4 - drivers/hwmon/hwmon-vid.c | 103 ++++++++++++++++++++++++++++++++++ drivers/hwmon/it87.c | 6 +- drivers/hwmon/lm85.c | 4 - drivers/hwmon/lm87.c | 4 - drivers/hwmon/pc87360.c | 2 drivers/hwmon/w83627hf.c | 4 - drivers/hwmon/w83781d.c | 4 - drivers/hwmon/w83792d.c | 1 drivers/i2c/Makefile | 4 - drivers/i2c/chips/Kconfig | 10 --- drivers/i2c/i2c-sensor-vid.c | 103 ---------------------------------- include/linux/hwmon-vid.h | 112 ++++++++++++++++++++++++++++++++++++++ include/linux/i2c-vid.h | 111 ------------------------------------- 22 files changed, 260 insertions(+), 289 deletions(-)
Documentation/i2c/porting-clients +3 -1
@@ -23,7 +23,9 @@ #include <linux/init.h> #include <linux/slab.h> #include <linux/i2c.h> - #include <linux/i2c-vid.h> /* if you need VRM support */ + #include <linux/hwmon.h> /* for hardware monitoring drivers */ + #include <linux/hwmon-sysfs.h> + #include <linux/hwmon-vid.h> /* if you need VRM support */ #include <asm/io.h> /* if you have I/O operations */ Please respect this inclusion order. Some extra headers may be required for a given driver (e.g. "lm75.h").
drivers/hwmon/Kconfig +16 -34
261 lines not on this page · raw message
drivers/hwmon/Makefile +1 -0
@@ -3,6 +3,7 @@ # obj-$(CONFIG_HWMON) += hwmon.o +obj-$(CONFIG_HWMON_VID) += hwmon-vid.o # asb100, then w83781d go first, as they can override other drivers' addresses. obj-$(CONFIG_SENSORS_ASB100) += asb100.o
drivers/hwmon/adm1025.c +2 -2
@@ -50,8 +50,8 @@#include <linux/slab.h> #include <linux/jiffies.h> #include <linux/i2c.h> -#include <linux/i2c-vid.h> #include <linux/hwmon.h> +#include <linux/hwmon-vid.h> #include <linux/err.h> /*
@@ -473,7 +473,7 @@struct adm1025_data *data =i2c_get_clientdata (client);int i; - data->vrm =i2c_which_vrm (); + data->vrm =vid_which_vrm ();/* * Set high limits
drivers/hwmon/adm1026.c +3 -3
@@ -28,9 +28,9 @@#include <linux/slab.h> #include <linux/jiffies.h> #include <linux/i2c.h> -#include <linux/i2c-vid.h> -#include <linux/hwmon-sysfs.h> #include <linux/hwmon.h> +#include <linux/hwmon-sysfs.h> +#include <linux/hwmon-vid.h> #include <linux/err.h> /* Addresses to scan */
@@ -1552,7 +1552,7 @@ goto exitfree;/* Set the VRM version */ - data->vrm =i2c_which_vrm (); + data->vrm =vid_which_vrm ();/* Initialize the ADM1026 chip */ adm1026_init_client (new_client);
drivers/hwmon/adm9240.c +2 -2
@@ -45,8 +45,8 @@#include <linux/module.h> #include <linux/slab.h> #include <linux/i2c.h> -#include <linux/i2c-vid.h> #include <linux/hwmon.h> +#include <linux/hwmon-vid.h> #include <linux/err.h> /* Addresses to scan */
@@ -657,7 +657,7 @@u8 conf =adm9240_read_value (client,ADM9240_REG_CONFIG );u8 mode =adm9240_read_value (client,ADM9240_REG_TEMP_CONF ) &3 ; - data->vrm =i2c_which_vrm ();/* need this to report vid as mV */ + data->vrm =vid_which_vrm ();/* need this to report vid as mV */ dev_info (&client->dev,"Using VRM: %d.%d\n" , data->vrm /10 , data->vrm %10 );
drivers/hwmon/asb100.c +2 -2
@@ -39,8 +39,8 @@#include <linux/module.h> #include <linux/slab.h> #include <linux/i2c.h> -#include <linux/i2c-vid.h> #include <linux/hwmon.h> +#include <linux/hwmon-vid.h> #include <linux/err.h> #include <linux/init.h> #include <linux/jiffies.h>
@@ -973,7 +973,7 @@ vid =asb100_read_value (client,ASB100_REG_VID_FANDIV ) &0x0f ; vid |= (asb100_read_value (client,ASB100_REG_CHIPID ) &0x01 ) <<4 ; - data->vrm =i2c_which_vrm (); + data->vrm =vid_which_vrm (); vid =vid_from_reg (vid, data->vrm);/* Start monitoring */
drivers/hwmon/atxp1.c +2 -2
@@ -23,8 +23,8 @@#include <linux/module.h> #include <linux/jiffies.h> #include <linux/i2c.h> -#include <linux/i2c-vid.h> #include <linux/hwmon.h> +#include <linux/hwmon-vid.h> #include <linux/err.h> MODULE_LICENSE ("GPL" );
@@ -296,7 +296,7 @@ }/* Get VRM */ - data->vrm =i2c_which_vrm (); + data->vrm =vid_which_vrm ();if ((data->vrm !=90 ) && (data->vrm !=91 )) { dev_err(&new_client->dev, "Not supporting VRM %d.%d\n",
drivers/hwmon/gl520sm.c +2 -2
@@ -26,8 +26,8 @@#include <linux/slab.h> #include <linux/jiffies.h> #include <linux/i2c.h> -#include <linux/i2c-vid.h> #include <linux/hwmon.h> +#include <linux/hwmon-vid.h> #include <linux/err.h> /* Type of the extra sensor */
@@ -617,7 +617,7 @@ conf = oldconf =gl520_read_value (client,GL520_REG_CONF ); data->alarm_mask =0xff ; - data->vrm =i2c_which_vrm (); + data->vrm =vid_which_vrm ();if (extra_sensor_type ==1 ) conf &= ~0x10 ;
drivers/hwmon/hwmon-vid.c new file +103 -0
103 lines not on this page · raw message
drivers/hwmon/it87.c +3 -3
@@ -37,9 +37,9 @@#include <linux/jiffies.h> #include <linux/i2c.h> #include <linux/i2c-isa.h> -#include <linux/i2c-vid.h> -#include <linux/hwmon-sysfs.h> #include <linux/hwmon.h> +#include <linux/hwmon-sysfs.h> +#include <linux/hwmon-vid.h> #include <linux/err.h> #include <asm/io.h>
@@ -919,7 +919,7 @@ }if (data->type == it8712) { - data->vrm =i2c_which_vrm (); + data->vrm =vid_which_vrm ();device_create_file_vrm (new_client);device_create_file_vid (new_client); }
drivers/hwmon/lm85.c +2 -2
@@ -28,8 +28,8 @@#include <linux/slab.h> #include <linux/jiffies.h> #include <linux/i2c.h> -#include <linux/i2c-vid.h> #include <linux/hwmon.h> +#include <linux/hwmon-vid.h> #include <linux/err.h> /* Addresses to scan */
@@ -1147,7 +1147,7 @@ goto ERROR1;/* Set the VRM version */ - data->vrm =i2c_which_vrm (); + data->vrm =vid_which_vrm ();/* Initialize the LM85 chip */ lm85_init_client (new_client);
drivers/hwmon/lm87.c +2 -2
@@ -57,8 +57,8 @@#include <linux/slab.h> #include <linux/jiffies.h> #include <linux/i2c.h> -#include <linux/i2c-vid.h> #include <linux/hwmon.h> +#include <linux/hwmon-vid.h> #include <linux/err.h> /*
@@ -694,7 +694,7 @@u8 config; data->channel =lm87_read_value (client,LM87_REG_CHANNEL_MODE ); - data->vrm =i2c_which_vrm (); + data->vrm =vid_which_vrm (); config =lm87_read_value (client,LM87_REG_CONFIG );if (!(config &0x01 )) {
drivers/hwmon/pc87360.c +1 -1
@@ -39,8 +39,8 @@#include <linux/jiffies.h> #include <linux/i2c.h> #include <linux/i2c-isa.h> -#include <linux/i2c-vid.h> #include <linux/hwmon.h> +#include <linux/hwmon-vid.h> #include <linux/err.h> #include <asm/io.h>
drivers/hwmon/w83627hf.c +2 -2
@@ -43,8 +43,8 @@#include <linux/jiffies.h> #include <linux/i2c.h> #include <linux/i2c-isa.h> -#include <linux/i2c-vid.h> #include <linux/hwmon.h> +#include <linux/hwmon-vid.h> #include <linux/err.h> #include <asm/io.h> #include "lm75.h"
@@ -1316,7 +1316,7 @@ data->vrm = (data->vrm_ovt &0x01 ) ?90 :82 ; }else {/* Convert VID to voltage based on default VRM */ - data->vrm =i2c_which_vrm (); + data->vrm =vid_which_vrm (); } tmp =w83627hf_read_value (client,W83781D_REG_SCFG1 );
drivers/hwmon/w83781d.c +2 -2
@@ -39,8 +39,8 @@#include <linux/jiffies.h> #include <linux/i2c.h> #include <linux/i2c-isa.h> -#include <linux/i2c-vid.h> #include <linux/hwmon.h> +#include <linux/hwmon-vid.h> #include <linux/err.h> #include <asm/io.h> #include "lm75.h"
@@ -1478,7 +1478,7 @@w83781d_write_value (client,W83781D_REG_BEEP_INTS2 ,0 ); } - data->vrm =i2c_which_vrm (); + data->vrm =vid_which_vrm ();if ((type != w83781d) && (type != as99127f)) { tmp =w83781d_read_value (client,W83781D_REG_SCFG1 );
drivers/hwmon/w83792d.c +0 -1
@@ -40,7 +40,6 @@#include <linux/init.h> #include <linux/slab.h> #include <linux/i2c.h> -#include <linux/i2c-vid.h> #include <linux/hwmon.h> #include <linux/hwmon-sysfs.h> #include <linux/err.h>
drivers/i2c/Makefile +0 -4
@@ -4,12 +4,8 @@ obj-$(CONFIG_I2C) += i2c-core.o obj-$(CONFIG_I2C_CHARDEV) += i2c-dev.o -obj-$(CONFIG_I2C_SENSOR) += i2c-sensor.o obj-y += busses/ chips/ algos/ -i2c-sensor-objs := i2c-sensor-vid.o - - ifeq ($(CONFIG_I2C_DEBUG_CORE),y) EXTRA_CFLAGS += -DDEBUG endif
drivers/i2c/chips/Kconfig +0 -10
@@ -2,17 +2,12 @@ # Miscellaneous I2C chip drivers configuration # -config I2C_SENSOR - tristate - default n - menu "Miscellaneous I2C Chip support" depends on I2C config SENSORS_DS1337 tristate "Dallas Semiconductor DS1337 and DS1339 Real Time Clock" depends on I2C && EXPERIMENTAL - select I2C_SENSOR help If you say yes here you get support for Dallas Semiconductor DS1337 and DS1339 real-time clock chips.
@@ -23,7 +18,6 @@ config SENSORS_DS1374 tristate "Maxim/Dallas Semiconductor DS1374 Real Time Clock" depends on I2C && EXPERIMENTAL - select I2C_SENSOR help If you say yes here you get support for Dallas Semiconductor DS1374 real-time clock chips.
@@ -34,7 +28,6 @@ config SENSORS_EEPROM tristate "EEPROM reader" depends on I2C && EXPERIMENTAL - select I2C_SENSOR help If you say yes here you get read-only access to the EEPROM data available on modern memory DIMMs and Sony Vaio laptops. Such
@@ -46,7 +39,6 @@ config SENSORS_PCF8574 tristate "Philips PCF8574 and PCF8574A" depends on I2C && EXPERIMENTAL - select I2C_SENSOR help If you say yes here you get support for Philips PCF8574 and PCF8574A chips.
@@ -67,7 +59,6 @@ config SENSORS_PCF8591 tristate "Philips PCF8591" depends on I2C && EXPERIMENTAL - select I2C_SENSOR help If you say yes here you get support for Philips PCF8591 chips.
@@ -77,7 +68,6 @@ config SENSORS_RTC8564 tristate "Epson 8564 RTC chip" depends on I2C && EXPERIMENTAL - select I2C_SENSOR help If you say yes here you get support for the Epson 8564 RTC chip.
drivers/i2c/i2c-sensor-vid.c deleted +0 -103
103 lines not on this page · raw message
include/linux/hwmon-vid.h new file +112 -0
112 lines not on this page · raw message
include/linux/i2c-vid.h deleted +0 -111
111 lines not on this page · raw message
Signature · 1 line
Jean Delvare
PATCH 1/1 (8/11) hwmon vs i2c, second round
In reply to Jean DelvareCleanup hwmon-vid a bit, fixing typos, rewording some comments and reindenting properly at places.
drivers/hwmon/hwmon-vid.c | 21 +++++++++++---------- 1 files changed, 11 insertions(+), 10 deletions(-)
drivers/hwmon/hwmon-vid.c +11 -10
@@ -38,14 +38,14 @@ {X86_VENDOR_AMD, 0x6, ANY, 90}, /* Athlon Duron etc */ {X86_VENDOR_AMD, 0xF, ANY, 24}, /* Athlon 64, Opteron */ {X86_VENDOR_INTEL, 0x6, 0x9, 85}, /* 0.13um too */ - {X86_VENDOR_INTEL, 0x6, 0xB, 85}, /* 0xB Tualatin */ + {X86_VENDOR_INTEL, 0x6, 0xB, 85}, /* Tualatin */ {X86_VENDOR_INTEL, 0x6, ANY, 82}, /* any P6 */ {X86_VENDOR_INTEL, 0x7, ANY, 0}, /* Itanium */ {X86_VENDOR_INTEL, 0xF, 0x3, 100}, /* P4 Prescott */ {X86_VENDOR_INTEL, 0xF, ANY, 90}, /* P4 before Prescott */ {X86_VENDOR_INTEL, 0x10,ANY, 0}, /* Itanium 2 */ {X86_VENDOR_UNKNOWN, ANY, ANY, 0} /* stop here */ - }; +};static int find_vrm (u8 eff_family,u8 eff_model,u8 vendor) {
@@ -53,9 +53,9 @@while (vrm_models[i].vendor!=X86_VENDOR_UNKNOWN ) {if (vrm_models[i].vendor==vendor) -if ((vrm_models[i].eff_family==eff_family)&& \ - ((vrm_models[i].eff_model==eff_model)|| \ - (vrm_models[i].eff_model==ANY ))) +if ((vrm_models[i].eff_family==eff_family) + && ((vrm_models[i].eff_model==eff_model) || + (vrm_models[i].eff_model==ANY )))return vrm_models[i].vrm_type; i++; }
@@ -70,8 +70,9 @@u8 eff_family, eff_model;int vrm_ret; -if (c->x86 <6 )return 0 ;/* any CPU with familly lower than 6 -dont have VID and/or CPUID */ +if (c->x86 <6 )/* Any CPU with family lower than 6 */ +return 0 ;/* doesn't have VID and/or CPUID */ + eax =cpuid_eax (1 ); eff_family = ((eax &0x00000F00 )>>8 ); eff_model = ((eax &0x000000F0 )>>4 );
@@ -81,12 +82,12 @@ } vrm_ret =find_vrm (eff_family,eff_model,c->x86_vendor);if (vrm_ret ==0 ) -printk (KERN_INFO "hwmon-vid: Unknown VRM version of your" -" x86 CPU\n" ); +printk (KERN_INFO "hwmon-vid: Unknown VRM version of your " +"x86 CPU\n" );return vrm_ret; } -/* and now for something completely different for Non-x86 world*/ +/* and now something completely different for the non-x86 world */ #else int vid_which_vrm (void ) {
Signature · 1 line
Jean Delvare
PATCH 1/1 (9/11) hwmon vs i2c, second round
In reply to Jean DelvareDelete DEFAULT_VRM from hwmon-vid.h, it has no more users.
include/linux/hwmon-vid.h | 2 -- 1 files changed, 2 deletions(-)
include/linux/hwmon-vid.h +0 -2
@@ -53,8 +53,6 @@int vid_which_vrm (void ); -#define DEFAULT_VRM 82 -static inline int vid_from_reg (int val,int vrm) {int vid;
Signature · 1 line
Jean Delvare
PATCH 1/1 (10/11) hwmon vs i2c, second round
In reply to Jean DelvareI see very little reason why vid_from_reg and vid_to_reg are inlined. The former is not exactly short, and they are never called in speed critical areas. Uninlining them should cause little performance loss if any, and saves a signficant space and compilation time as well.
drivers/hwmon/hwmon-vid.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++ include/linux/hwmon-vid.h | 90 ++--------------------------------------- 2 files changed, 104 insertions(+), 85 deletions(-)
drivers/hwmon/hwmon-vid.c +99 -0
@@ -3,6 +3,10 @@ Copyright (c) 2004 Rudolf Marek <[email protected]> + Partly imported from i2c-vid.h of the lm_sensors project + Copyright (c) 2002 Mark D. Studebaker <[email protected]> + With assistance from Trent Piepho <[email protected]> + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or
@@ -23,6 +27,99 @@#include <linux/kernel.h> #include <linux/hwmon-vid.h> +/* +Common code for decoding VID pins. + +References: + +For VRM 8.4 to 9.1, "VRM x.y DC-DC Converter Design Guidelines", +available at http://developer.intel.com/. + +For VRD 10.0 and up, "VRD x.y Design Guide", +available at http://developer.intel.com/. + +AMD Opteron processors don't follow the Intel specifications. +I'm going to "make up" 2.4 as the spec number for the Opterons. +No good reason just a mnemonic for the 24x Opteron processor +series. + +Opteron VID encoding is: +00000 = 1.550 V +00001 = 1.525 V +. . . . +11110 = 0.800 V +11111 = 0.000 V (off) +*/ + +/* vrm is the VRM/VRD document version multiplied by 10. +val is the 4-, 5- or 6-bit VID code. +Returned value is in mV to avoid floating point in the kernel. */ +int vid_from_reg (int val,int vrm) +{ +int vid; + +switch (vrm) { + +case 0 : +return 0 ; + +case 100 :/* VRD 10.0 */ +if ((val &0x1f ) ==0x1f ) +return 0 ; +if ((val &0x1f ) <=0x09 || val ==0x0a ) + vid =10875 - (val &0x1f ) *250 ; +else + vid =18625 - (val &0x1f ) *250 ; +if (val &0x20 ) + vid -=125 ; + vid /=10 ;/* only return 3 dec. places for now */ +return vid; + +case 24 :/* Opteron processor */ +return (val ==0x1f ?0 :1550 - val *25 ); + +case 91 :/* VRM 9.1 */ +case 90 :/* VRM 9.0 */ +return (val ==0x1f ?0 : +1850 - val *25 ); + +case 85 :/* VRM 8.5 */ +return ((val &0x10 ?25 :0 ) + + ((val &0x0f ) >0x04 ?2050 :1250 ) - + ((val &0x0f ) *50 )); + +case 84 :/* VRM 8.4 */ + val &=0x0f ; +/* fall through */ +default :/* VRM 8.2 */ +return (val ==0x1f ?0 : + val &0x10 ?5100 - (val) *100 : +2050 - (val) *50 ); + } +} + +/* vrm is the VRM/VRD document version multiplied by 10. +val is in mV to avoid floating point in the kernel. +Returned value is the 4-, 5- or 6-bit VID code. +Note that only VRM 9.x is supported for now. */ +int vid_to_reg (int val,int vrm) +{ +switch (vrm) { +case 91 :/* VRM 9.1 */ +case 90 :/* VRM 9.0 */ +return ((val >=1100 ) && (val <=1850 ) ? + ((18499 - val *10 ) /25 +5 ) /10 :-1 ); +default : +return -1 ; + } +} + + +/* +After this point is the code to automatically determine which +VRM/VRD specification should be used depending on the CPU. +*/ +struct vrm_model {u8 vendor;u8 eff_family;
@@ -96,6 +193,8 @@ }#endif +EXPORT_SYMBOL (vid_from_reg); +EXPORT_SYMBOL (vid_to_reg);EXPORT_SYMBOL (vid_which_vrm);MODULE_AUTHOR ("Rudolf Marek <[email protected]>" );
include/linux/hwmon-vid.h +5 -85
96 lines not on this page · raw message
Signature · 1 line
Jean Delvare
Re: [PATCH 2.6] (10/11) hwmon vs i2c, second round
One nitpicking comment and two observations:
Quoted 2 lines · Jean Delvare
I see very little reason why
vid_from_regandvid_to_regare inlined. The former is not exactly short,
1)
and their arguments aren't known at
compile time,
[Compiler can optimise them away _completely_ if both arguments are known at compile time or significantly of only one is known.]
Quoted 3 lines
and they are never called in speed critical areas. Uninlining them should cause little performance loss if any, and saves a signficant space and compilation time as well.
2) VID_FROM_REG is asking for removal from lm85.
3) vid_to_reg is used only by atxp1.
Re: [PATCH 2.6] (10/11) hwmon vs i2c, second round
Hi Alexey,
Quoted 9 lines
Quoted 2 lines
I see very little reason why
vid_from_regandvid_to_regare inlined. The former is not exactly short,1)
and their arguments aren't known at
compile time,[Compiler can optimise them away _completely_ if both arguments are known at compile time or significantly of only one is known.]
Good point, I'll try to remember that. It doesn't apply here though except for lm78 I think, and maybe lm93 when it gets ported. That's not the majority of users though, so I still believe uninlining is the correct decision.
Quoted 5 lines
Quoted 3 lines
and they are never called in speed critical areas. Uninlining them should cause little performance loss if any, and saves a signficant space and compilation time as well.
2)
VID_FROM_REGis asking for removal from lm85.
True, I wrote a patch doing this already:
http://lists.lm-sensors.org/pipermail/lm-sensors/2005-July/013148.html
Just wait for Greg to pick it and it'll show in -mm.
Quoted 1 line
3)
vid_to_regis used only by atxp1.
That's right. Do you suggest that it should be kept inlined then? Similar drivers may be written in the future, causing vid_to_reg to gain users and possibly grow larger (to support more VRM/VRD standards), then we'll certainly want to uninline it anyway - but I agree that this ain't the case at the moment.
I'll change that patch to only uninline vid_from_reg and not vid_to_reg if a majority prefers me to do so.
Thanks for your comments :)
Signature · 1 line
Jean Delvare
Re: [PATCH 2.6] (10/11, revised) hwmon vs i2c, second round
In reply to Jean DelvareI see very little reason why vid_from_reg is inlined. It is not exactly short, its parameters are seldom known in advance, and it is never called in speed critical areas. Uninlining it should cause little performance loss if any, and saves a signficant space as well as compilation time.
As suggested by Alexey Dobriyan, I am leaving vid_to_reg inline for now, as it is short and has a single user so far.
drivers/hwmon/hwmon-vid.c | 82 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/hwmon-vid.h | 83 ++++------------------------------------------ 2 files changed, 91 insertions(+), 74 deletions(-)
drivers/hwmon/hwmon-vid.c +82 -0
@@ -3,6 +3,10 @@ Copyright (c) 2004 Rudolf Marek <[email protected]> + Partly imported from i2c-vid.h of the lm_sensors project + Copyright (c) 2002 Mark D. Studebaker <[email protected]> + With assistance from Trent Piepho <[email protected]> + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or
@@ -23,6 +27,83 @@#include <linux/kernel.h> #include <linux/hwmon-vid.h> +/* +Common code for decoding VID pins. + +References: + +For VRM 8.4 to 9.1, "VRM x.y DC-DC Converter Design Guidelines", +available at http://developer.intel.com/. + +For VRD 10.0 and up, "VRD x.y Design Guide", +available at http://developer.intel.com/. + +AMD Opteron processors don't follow the Intel specifications. +I'm going to "make up" 2.4 as the spec number for the Opterons. +No good reason just a mnemonic for the 24x Opteron processor +series. + +Opteron VID encoding is: +00000 = 1.550 V +00001 = 1.525 V +. . . . +11110 = 0.800 V +11111 = 0.000 V (off) +*/ + +/* vrm is the VRM/VRD document version multiplied by 10. +val is the 4-, 5- or 6-bit VID code. +Returned value is in mV to avoid floating point in the kernel. */ +int vid_from_reg (int val,int vrm) +{ +int vid; + +switch (vrm) { + +case 0 : +return 0 ; + +case 100 :/* VRD 10.0 */ +if ((val &0x1f ) ==0x1f ) +return 0 ; +if ((val &0x1f ) <=0x09 || val ==0x0a ) + vid =10875 - (val &0x1f ) *250 ; +else + vid =18625 - (val &0x1f ) *250 ; +if (val &0x20 ) + vid -=125 ; + vid /=10 ;/* only return 3 dec. places for now */ +return vid; + +case 24 :/* Opteron processor */ +return (val ==0x1f ?0 :1550 - val *25 ); + +case 91 :/* VRM 9.1 */ +case 90 :/* VRM 9.0 */ +return (val ==0x1f ?0 : +1850 - val *25 ); + +case 85 :/* VRM 8.5 */ +return ((val &0x10 ?25 :0 ) + + ((val &0x0f ) >0x04 ?2050 :1250 ) - + ((val &0x0f ) *50 )); + +case 84 :/* VRM 8.4 */ + val &=0x0f ; +/* fall through */ +default :/* VRM 8.2 */ +return (val ==0x1f ?0 : + val &0x10 ?5100 - (val) *100 : +2050 - (val) *50 ); + } +} + + +/* +After this point is the code to automatically determine which +VRM/VRD specification should be used depending on the CPU. +*/ +struct vrm_model {u8 vendor;u8 eff_family;
@@ -96,6 +177,7 @@ }#endif +EXPORT_SYMBOL (vid_from_reg);EXPORT_SYMBOL (vid_which_vrm);MODULE_AUTHOR ("Rudolf Marek <[email protected]>" );
include/linux/hwmon-vid.h +9 -74
95 lines not on this page · raw message
Signature · 1 line
Jean Delvare
PATCH 1/1 (11/11) hwmon vs i2c, second round
In reply to Jean DelvareUse the common vid_from_reg function in lm78 rather than reimplementing it.
drivers/hwmon/Kconfig | 1 + drivers/hwmon/lm78.c | 10 ++-------- 2 files changed, 3 insertions(+), 8 deletions(-)
drivers/hwmon/lm78.c +2 -8
@@ -25,6 +25,7 @@#include <linux/i2c.h> #include <linux/i2c-isa.h> #include <linux/hwmon.h> +#include <linux/hwmon-vid.h> #include <linux/err.h> #include <asm/io.h>
@@ -106,13 +107,6 @@return val *1000 ; } -/* VID: mV -REG: (see doc/vid) */ -static inline int VID_FROM_REG (u8 val) -{ -return val==0x1f ?0 : val>=0x10 ?5100 -val*100 :2050 -val*50 ; -} -#define DIV_FROM_REG (val) (1 << (val))/* There are some complications in a module like this. First off, LM78 chips
@@ -457,7 +451,7 @@static ssize_t show_vid (struct device *dev,struct device_attribute *attr,char *buf) {struct lm78_data *data =lm78_update_device (dev); -return sprintf (buf,"%d\n" ,VID_FROM_REG (data->vid)); +return sprintf (buf,"%d\n" ,vid_from_reg (82 , data->vid)); } static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL);
drivers/hwmon/Kconfig +1 -0
@@ -207,6 +207,7 @@ tristate "National Semiconductor LM78 and compatibles" depends on HWMON && I2C && EXPERIMENTAL select I2C_ISA + select HWMON_VID help If you say yes here you get support for National Semiconductor LM78, LM78-J and LM79.
Signature · 1 line
Jean Delvare