public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2.6] (0/11) hwmon vs i2c, second round
@ 2005-07-31 18:59 Jean Delvare
  2005-07-31 19:20 ` [PATCH 2.6] (1/11) " Jean Delvare
                   ` (10 more replies)
  0 siblings, 11 replies; 15+ messages in thread
From: Jean Delvare @ 2005-07-31 18:59 UTC (permalink / raw)
  To: LKML, LM Sensors; +Cc: Greg KH

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     -2777

-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 2.6] (1/11) hwmon vs i2c, second round
  2005-07-31 18:59 [PATCH 2.6] (0/11) hwmon vs i2c, second round Jean Delvare
@ 2005-07-31 19:20 ` Jean Delvare
  2005-07-31 19:33 ` [PATCH 2.6] (2/11) " Jean Delvare
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Jean Delvare @ 2005-07-31 19:20 UTC (permalink / raw)
  To: LKML, LM Sensors; +Cc: Greg KH

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.)

Signed-off-by: Jean Delvare <khali@linux-fr.org>

 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(-)

--- linux-2.6.13-rc4.orig/drivers/media/video/adv7170.c	2005-07-31 16:03:01.000000000 +0200
+++ linux-2.6.13-rc4/drivers/media/video/adv7170.c	2005-07-31 20:56:05.000000000 +0200
@@ -391,7 +391,6 @@
 	.normal_i2c		= normal_i2c,
 	.probe			= &ignore,
 	.ignore			= &ignore,
-	.force			= &ignore,
 };
 
 static struct i2c_driver i2c_driver_adv7170;
--- linux-2.6.13-rc4.orig/drivers/media/video/adv7175.c	2005-07-31 16:03:01.000000000 +0200
+++ linux-2.6.13-rc4/drivers/media/video/adv7175.c	2005-07-31 20:56:05.000000000 +0200
@@ -441,7 +441,6 @@
 	.normal_i2c		= normal_i2c,
 	.probe			= &ignore,
 	.ignore			= &ignore,
-	.force			= &ignore,
 };
 
 static struct i2c_driver i2c_driver_adv7175;
--- linux-2.6.13-rc4.orig/drivers/media/video/bt819.c	2005-07-31 16:03:01.000000000 +0200
+++ linux-2.6.13-rc4/drivers/media/video/bt819.c	2005-07-31 20:56:05.000000000 +0200
@@ -507,7 +507,6 @@
 	.normal_i2c		= normal_i2c,
 	.probe			= &ignore,
 	.ignore			= &ignore,
-	.force			= &ignore,
 };
 
 static struct i2c_driver i2c_driver_bt819;
--- linux-2.6.13-rc4.orig/drivers/media/video/bt856.c	2005-07-31 16:03:01.000000000 +0200
+++ linux-2.6.13-rc4/drivers/media/video/bt856.c	2005-07-31 20:56:05.000000000 +0200
@@ -295,7 +295,6 @@
 	.normal_i2c		= normal_i2c,
 	.probe			= &ignore,
 	.ignore			= &ignore,
-	.force			= &ignore,
 };
 
 static struct i2c_driver i2c_driver_bt856;
--- linux-2.6.13-rc4.orig/drivers/media/video/saa7110.c	2005-07-31 16:03:01.000000000 +0200
+++ linux-2.6.13-rc4/drivers/media/video/saa7110.c	2005-07-31 20:56:05.000000000 +0200
@@ -470,7 +470,6 @@
 	.normal_i2c		= normal_i2c,
 	.probe			= &ignore,
 	.ignore			= &ignore,
-	.force			= &ignore,
 };
 
 static struct i2c_driver i2c_driver_saa7110;
--- linux-2.6.13-rc4.orig/drivers/media/video/saa7111.c	2005-07-31 16:03:01.000000000 +0200
+++ linux-2.6.13-rc4/drivers/media/video/saa7111.c	2005-07-31 20:56:05.000000000 +0200
@@ -489,7 +489,6 @@
 	.normal_i2c		= normal_i2c,
 	.probe			= &ignore,
 	.ignore			= &ignore,
-	.force			= &ignore,
 };
 
 static struct i2c_driver i2c_driver_saa7111;
--- linux-2.6.13-rc4.orig/drivers/media/video/saa7114.c	2005-07-31 16:03:01.000000000 +0200
+++ linux-2.6.13-rc4/drivers/media/video/saa7114.c	2005-07-31 20:56:05.000000000 +0200
@@ -827,7 +827,6 @@
 	.normal_i2c		= normal_i2c,
 	.probe			= &ignore,
 	.ignore			= &ignore,
-	.force			= &ignore,
 };
 
 static struct i2c_driver i2c_driver_saa7114;
--- linux-2.6.13-rc4.orig/drivers/media/video/saa7185.c	2005-07-31 16:03:01.000000000 +0200
+++ linux-2.6.13-rc4/drivers/media/video/saa7185.c	2005-07-31 20:56:05.000000000 +0200
@@ -387,7 +387,6 @@
 	.normal_i2c		= normal_i2c,
 	.probe			= &ignore,
 	.ignore			= &ignore,
-	.force			= &ignore,
 };
 
 static struct i2c_driver i2c_driver_saa7185;
--- linux-2.6.13-rc4.orig/drivers/media/video/tuner-3036.c	2005-07-31 16:03:01.000000000 +0200
+++ linux-2.6.13-rc4/drivers/media/video/tuner-3036.c	2005-07-31 20:56:05.000000000 +0200
@@ -41,7 +41,6 @@
 	.normal_i2c	= normal_i2c,
 	.probe		= &ignore,
 	.ignore		= &ignore,
-	.force		= &ignore,
 };
 
 /* ---------------------------------------------------------------------- */
--- linux-2.6.13-rc4.orig/drivers/media/video/vpx3220.c	2005-07-31 16:03:01.000000000 +0200
+++ linux-2.6.13-rc4/drivers/media/video/vpx3220.c	2005-07-31 20:56:05.000000000 +0200
@@ -576,7 +576,6 @@
 	.normal_i2c		= normal_i2c,
 	.probe			= &ignore,
 	.ignore			= &ignore,
-	.force			= &ignore,
 };
 
 static struct i2c_driver vpx3220_i2c_driver;
--- linux-2.6.13-rc4.orig/drivers/i2c/chips/ds1374.c	2005-07-31 16:03:01.000000000 +0200
+++ linux-2.6.13-rc4/drivers/i2c/chips/ds1374.c	2005-07-31 20:56:05.000000000 +0200
@@ -53,7 +53,6 @@
 	.normal_i2c = normal_addr,
 	.probe = ignore,
 	.ignore = ignore,
-	.force = ignore,
 };
 
 static ulong ds1374_read_rtc(void)
--- linux-2.6.13-rc4.orig/drivers/i2c/chips/m41t00.c	2005-07-31 16:03:01.000000000 +0200
+++ linux-2.6.13-rc4/drivers/i2c/chips/m41t00.c	2005-07-31 20:56:05.000000000 +0200
@@ -42,7 +42,6 @@
 	.normal_i2c		= normal_addr,
 	.probe			= ignore,
 	.ignore			= ignore,
-	.force			= ignore,
 };
 
 ulong
--- linux-2.6.13-rc4.orig/drivers/i2c/chips/rtc8564.c	2005-07-31 16:03:01.000000000 +0200
+++ linux-2.6.13-rc4/drivers/i2c/chips/rtc8564.c	2005-07-31 20:56:05.000000000 +0200
@@ -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);
--- linux-2.6.13-rc4.orig/drivers/i2c/i2c-core.c	2005-07-31 16:03:01.000000000 +0200
+++ linux-2.6.13-rc4/drivers/i2c/i2c-core.c	2005-07-31 20:56:05.000000000 +0200
@@ -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 */
--- linux-2.6.13-rc4.orig/include/linux/i2c.h	2005-07-31 16:03:01.000000000 +0200
+++ linux-2.6.13-rc4/include/linux/i2c.h	2005-07-31 20:56:05.000000000 +0200
@@ -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 */


-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 2.6] (2/11) hwmon vs i2c, second round
  2005-07-31 18:59 [PATCH 2.6] (0/11) hwmon vs i2c, second round Jean Delvare
  2005-07-31 19:20 ` [PATCH 2.6] (1/11) " Jean Delvare
@ 2005-07-31 19:33 ` Jean Delvare
  2005-07-31 19:36 ` [PATCH 2.6] (3/11) " Jean Delvare
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Jean Delvare @ 2005-07-31 19:33 UTC (permalink / raw)
  To: LKML, LM Sensors; +Cc: Greg KH

The 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.

Signed-off-by: Jean Delvare <khali@linux-fr.org>

 drivers/i2c/i2c-sensor-detect.c |   13 +--
 include/linux/i2c-sensor.h      |  133 ++++++++++++++++++----------------------
 2 files changed, 67 insertions(+), 79 deletions(-)

--- linux-2.6.13-rc4.orig/drivers/i2c/i2c-sensor-detect.c	2005-07-31 16:03:00.000000000 +0200
+++ linux-2.6.13-rc4/drivers/i2c/i2c-sensor-detect.c	2005-07-31 20:56:04.000000000 +0200
@@ -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;
 				}
--- linux-2.6.13-rc4.orig/include/linux/i2c-sensor.h	2005-07-31 16:03:00.000000000 +0200
+++ linux-2.6.13-rc4/include/linux/i2c-sensor.h	2005-07-31 20:56:04.000000000 +0200
@@ -22,22 +22,6 @@
 #ifndef _LINUX_I2C_SENSOR_H
 #define _LINUX_I2C_SENSOR_H
 
-/* A structure containing detect information.
-   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.
-   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.
-   kind: The kind of chip. 0 equals any chip.
-*/
-struct i2c_force_data {
-	unsigned short *force;
-	unsigned short kind;
-};
-
 /* 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.
@@ -50,14 +34,18 @@
      I2C bus), the second is the I2C address. These addresses are never
      probed. This parameter overrules 'normal' and  probe', but not the
     'force' lists.
-   force_data: insmod parameters. A list, ending with an element of which
-     the force field is NULL.
+   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;
-	struct i2c_force_data *forces;
+	unsigned short **forces;
 };
 
 #define SENSORS_MODULE_PARM_FORCE(name) \
@@ -88,7 +76,8 @@
   I2C_CLIENT_MODULE_PARM(force, \
                       "List of adapter,address pairs to boldly assume " \
                       "to be present"); \
-  static struct i2c_force_data forces[] = {{force,any_chip},{NULL}}; \
+  static unsigned short *forces[] = { force, \
+				      NULL }; \
   SENSORS_INSMOD
 
 #define SENSORS_INSMOD_1(chip1) \
@@ -97,9 +86,9 @@
                       "List of adapter,address pairs to boldly assume " \
                       "to be present"); \
   SENSORS_MODULE_PARM_FORCE(chip1); \
-  static struct i2c_force_data forces[] = {{force,any_chip},\
-                                                 {force_ ## chip1,chip1}, \
-                                                 {NULL}}; \
+  static unsigned short *forces[] = { force, \
+				      force_##chip1, \
+				      NULL }; \
   SENSORS_INSMOD
 
 #define SENSORS_INSMOD_2(chip1,chip2) \
@@ -109,10 +98,10 @@
                       "to be present"); \
   SENSORS_MODULE_PARM_FORCE(chip1); \
   SENSORS_MODULE_PARM_FORCE(chip2); \
-  static struct i2c_force_data forces[] = {{force,any_chip}, \
-                                                 {force_ ## chip1,chip1}, \
-                                                 {force_ ## chip2,chip2}, \
-                                                 {NULL}}; \
+  static unsigned short *forces[] = { force, \
+				      force_##chip1, \
+				      force_##chip2, \
+				      NULL }; \
   SENSORS_INSMOD
 
 #define SENSORS_INSMOD_3(chip1,chip2,chip3) \
@@ -123,11 +112,11 @@
   SENSORS_MODULE_PARM_FORCE(chip1); \
   SENSORS_MODULE_PARM_FORCE(chip2); \
   SENSORS_MODULE_PARM_FORCE(chip3); \
-  static struct i2c_force_data forces[] = {{force,any_chip}, \
-                                                 {force_ ## chip1,chip1}, \
-                                                 {force_ ## chip2,chip2}, \
-                                                 {force_ ## chip3,chip3}, \
-                                                 {NULL}}; \
+  static unsigned short *forces[] = { force, \
+				      force_##chip1, \
+				      force_##chip2, \
+				      force_##chip3, \
+				      NULL }; \
   SENSORS_INSMOD
 
 #define SENSORS_INSMOD_4(chip1,chip2,chip3,chip4) \
@@ -139,12 +128,12 @@
   SENSORS_MODULE_PARM_FORCE(chip2); \
   SENSORS_MODULE_PARM_FORCE(chip3); \
   SENSORS_MODULE_PARM_FORCE(chip4); \
-  static struct i2c_force_data forces[] = {{force,any_chip}, \
-                                                 {force_ ## chip1,chip1}, \
-                                                 {force_ ## chip2,chip2}, \
-                                                 {force_ ## chip3,chip3}, \
-                                                 {force_ ## chip4,chip4}, \
-                                                 {NULL}}; \
+  static unsigned short *forces[] = { force, \
+				      force_##chip1, \
+				      force_##chip2, \
+				      force_##chip3, \
+				      force_##chip4, \
+				      NULL}; \
   SENSORS_INSMOD
 
 #define SENSORS_INSMOD_5(chip1,chip2,chip3,chip4,chip5) \
@@ -157,13 +146,13 @@
   SENSORS_MODULE_PARM_FORCE(chip3); \
   SENSORS_MODULE_PARM_FORCE(chip4); \
   SENSORS_MODULE_PARM_FORCE(chip5); \
-  static struct i2c_force_data forces[] = {{force,any_chip}, \
-                                                 {force_ ## chip1,chip1}, \
-                                                 {force_ ## chip2,chip2}, \
-                                                 {force_ ## chip3,chip3}, \
-                                                 {force_ ## chip4,chip4}, \
-                                                 {force_ ## chip5,chip5}, \
-                                                 {NULL}}; \
+  static unsigned short *forces[] = { force, \
+				      force_##chip1, \
+				      force_##chip2, \
+				      force_##chip3, \
+				      force_##chip4, \
+				      force_##chip5, \
+				      NULL }; \
   SENSORS_INSMOD
 
 #define SENSORS_INSMOD_6(chip1,chip2,chip3,chip4,chip5,chip6) \
@@ -177,14 +166,14 @@
   SENSORS_MODULE_PARM_FORCE(chip4); \
   SENSORS_MODULE_PARM_FORCE(chip5); \
   SENSORS_MODULE_PARM_FORCE(chip6); \
-  static struct i2c_force_data forces[] = {{force,any_chip}, \
-                                                 {force_ ## chip1,chip1}, \
-                                                 {force_ ## chip2,chip2}, \
-                                                 {force_ ## chip3,chip3}, \
-                                                 {force_ ## chip4,chip4}, \
-                                                 {force_ ## chip5,chip5}, \
-                                                 {force_ ## chip6,chip6}, \
-                                                 {NULL}}; \
+  static unsigned short *forces[] = { force, \
+				      force_##chip1, \
+				      force_##chip2, \
+				      force_##chip3, \
+				      force_##chip4, \
+				      force_##chip5, \
+				      force_##chip6, \
+				      NULL }; \
   SENSORS_INSMOD
 
 #define SENSORS_INSMOD_7(chip1,chip2,chip3,chip4,chip5,chip6,chip7) \
@@ -199,15 +188,15 @@
   SENSORS_MODULE_PARM_FORCE(chip5); \
   SENSORS_MODULE_PARM_FORCE(chip6); \
   SENSORS_MODULE_PARM_FORCE(chip7); \
-  static struct i2c_force_data forces[] = {{force,any_chip}, \
-                                                 {force_ ## chip1,chip1}, \
-                                                 {force_ ## chip2,chip2}, \
-                                                 {force_ ## chip3,chip3}, \
-                                                 {force_ ## chip4,chip4}, \
-                                                 {force_ ## chip5,chip5}, \
-                                                 {force_ ## chip6,chip6}, \
-                                                 {force_ ## chip7,chip7}, \
-                                                 {NULL}}; \
+  static unsigned short *forces[] = { force, \
+				      force_##chip1, \
+				      force_##chip2, \
+				      force_##chip3, \
+				      force_##chip4, \
+				      force_##chip5, \
+				      force_##chip6, \
+				      force_##chip7, \
+				      NULL }; \
   SENSORS_INSMOD
 
 #define SENSORS_INSMOD_8(chip1,chip2,chip3,chip4,chip5,chip6,chip7,chip8) \
@@ -223,16 +212,16 @@
   SENSORS_MODULE_PARM_FORCE(chip6); \
   SENSORS_MODULE_PARM_FORCE(chip7); \
   SENSORS_MODULE_PARM_FORCE(chip8); \
-  static struct i2c_force_data forces[] = {{force,any_chip}, \
-                                                 {force_ ## chip1,chip1}, \
-                                                 {force_ ## chip2,chip2}, \
-                                                 {force_ ## chip3,chip3}, \
-                                                 {force_ ## chip4,chip4}, \
-                                                 {force_ ## chip5,chip5}, \
-                                                 {force_ ## chip6,chip6}, \
-                                                 {force_ ## chip7,chip7}, \
-                                                 {force_ ## chip8,chip8}, \
-                                                 {NULL}}; \
+  static unsigned short *forces[] = { force, \
+				      force_##chip1, \
+				      force_##chip2, \
+				      force_##chip3, \
+				      force_##chip4, \
+				      force_##chip5, \
+				      force_##chip6, \
+				      force_##chip7, \
+				      force_##chip8, \
+				      NULL }; \
   SENSORS_INSMOD
 
 /* Detect function. It iterates over all possible addresses itself. For


-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 2.6] (3/11) hwmon vs i2c, second round
  2005-07-31 18:59 [PATCH 2.6] (0/11) hwmon vs i2c, second round Jean Delvare
  2005-07-31 19:20 ` [PATCH 2.6] (1/11) " Jean Delvare
  2005-07-31 19:33 ` [PATCH 2.6] (2/11) " Jean Delvare
@ 2005-07-31 19:36 ` Jean Delvare
  2005-07-31 19:42 ` [PATCH 2.6] (4/11) " Jean Delvare
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Jean Delvare @ 2005-07-31 19:36 UTC (permalink / raw)
  To: LKML, LM Sensors; +Cc: Greg KH

We 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.)

Signed-off-by: Jean Delvare <khali@linux-fr.org>

 drivers/i2c/i2c-sensor-detect.c |    2 +-
 include/linux/i2c-sensor.h      |   30 +++---------------------------
 2 files changed, 4 insertions(+), 28 deletions(-)

--- linux-2.6.13-rc4.orig/drivers/i2c/i2c-sensor-detect.c	2005-07-31 16:07:56.000000000 +0200
+++ linux-2.6.13-rc4/drivers/i2c/i2c-sensor-detect.c	2005-07-31 20:56:02.000000000 +0200
@@ -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;
--- linux-2.6.13-rc4.orig/include/linux/i2c-sensor.h	2005-07-31 16:07:56.000000000 +0200
+++ linux-2.6.13-rc4/include/linux/i2c-sensor.h	2005-07-31 20:56:02.000000000 +0200
@@ -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 */


-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 2.6] (4/11) hwmon vs i2c, second round
  2005-07-31 18:59 [PATCH 2.6] (0/11) hwmon vs i2c, second round Jean Delvare
                   ` (2 preceding siblings ...)
  2005-07-31 19:36 ` [PATCH 2.6] (3/11) " Jean Delvare
@ 2005-07-31 19:42 ` Jean Delvare
  2005-07-31 19:45 ` [PATCH 2.6] (5/11) " Jean Delvare
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Jean Delvare @ 2005-07-31 19:42 UTC (permalink / raw)
  To: LKML, LM Sensors; +Cc: Greg KH

i2c_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.

Signed-off-by: Jean Delvare <khali@linux-fr.org>

 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(-)

--- linux-2.6.13-rc4.orig/Documentation/i2c/porting-clients	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/Documentation/i2c/porting-clients	2005-07-31 20:55:59.000000000 +0200
@@ -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
--- linux-2.6.13-rc4.orig/Documentation/i2c/writing-clients	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/Documentation/i2c/writing-clients	2005-07-31 20:55:59.000000000 +0200
@@ -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 */
--- linux-2.6.13-rc4.orig/drivers/hwmon/adm1021.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/adm1021.c	2005-07-31 20:55:59.000000000 +0200
@@ -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)
--- linux-2.6.13-rc4.orig/drivers/hwmon/adm1025.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/adm1025.c	2005-07-31 20:55:59.000000000 +0200
@@ -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);
 }
 
 /*
--- linux-2.6.13-rc4.orig/drivers/hwmon/adm1026.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/adm1026.c	2005-07-31 20:55:59.000000000 +0200
@@ -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)
--- linux-2.6.13-rc4.orig/drivers/hwmon/adm1031.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/adm1031.c	2005-07-31 20:55:59.000000000 +0200
@@ -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;
--- linux-2.6.13-rc4.orig/drivers/hwmon/adm9240.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/adm9240.c	2005-07-31 20:55:59.000000000 +0200
@@ -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)
--- linux-2.6.13-rc4.orig/drivers/hwmon/asb100.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/asb100.c	2005-07-31 20:55:59.000000000 +0200
@@ -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,
--- linux-2.6.13-rc4.orig/drivers/hwmon/atxp1.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/atxp1.c	2005-07-31 20:55:59.000000000 +0200
@@ -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)
--- linux-2.6.13-rc4.orig/drivers/hwmon/ds1621.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/ds1621.c	2005-07-31 20:55:59.000000000 +0200
@@ -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)
 {
--- linux-2.6.13-rc4.orig/drivers/hwmon/fscher.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/fscher.c	2005-07-31 20:55:59.000000000 +0200
@@ -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)
--- linux-2.6.13-rc4.orig/drivers/hwmon/fscpos.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/fscpos.c	2005-07-31 20:55:59.000000000 +0200
@@ -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)
--- linux-2.6.13-rc4.orig/drivers/hwmon/gl518sm.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/gl518sm.c	2005-07-31 20:55:59.000000000 +0200
@@ -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)
--- linux-2.6.13-rc4.orig/drivers/hwmon/gl520sm.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/gl520sm.c	2005-07-31 20:55:59.000000000 +0200
@@ -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)
--- linux-2.6.13-rc4.orig/drivers/hwmon/it87.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/it87.c	2005-07-31 20:55:59.000000000 +0200
@@ -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;
--- linux-2.6.13-rc4.orig/drivers/hwmon/lm63.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/lm63.c	2005-07-31 20:55:59.000000000 +0200
@@ -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);
 }
 
 /*
--- linux-2.6.13-rc4.orig/drivers/hwmon/lm75.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/lm75.c	2005-07-31 20:55:59.000000000 +0200
@@ -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;
--- linux-2.6.13-rc4.orig/drivers/hwmon/lm77.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/lm77.c	2005-07-31 20:55:59.000000000 +0200
@@ -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;
--- linux-2.6.13-rc4.orig/drivers/hwmon/lm78.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/lm78.c	2005-07-31 20:55:59.000000000 +0200
@@ -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;
--- linux-2.6.13-rc4.orig/drivers/hwmon/lm80.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/lm80.c	2005-07-31 20:55:59.000000000 +0200
@@ -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)
--- linux-2.6.13-rc4.orig/drivers/hwmon/lm83.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/lm83.c	2005-07-31 20:55:59.000000000 +0200
@@ -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);
 }
 
 /*
--- linux-2.6.13-rc4.orig/drivers/hwmon/lm85.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/lm85.c	2005-07-31 20:55:59.000000000 +0200
@@ -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,
--- linux-2.6.13-rc4.orig/drivers/hwmon/lm87.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/lm87.c	2005-07-31 20:55:59.000000000 +0200
@@ -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);
 }
 
 /*
--- linux-2.6.13-rc4.orig/drivers/hwmon/lm90.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/lm90.c	2005-07-31 20:55:59.000000000 +0200
@@ -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);
 }
 
 /*
--- linux-2.6.13-rc4.orig/drivers/hwmon/lm92.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/lm92.c	2005-07-31 20:55:59.000000000 +0200
@@ -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)
--- linux-2.6.13-rc4.orig/drivers/hwmon/max1619.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/max1619.c	2005-07-31 20:55:59.000000000 +0200
@@ -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);
 }
 
 /*
--- linux-2.6.13-rc4.orig/drivers/hwmon/w83781d.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/w83781d.c	2005-07-31 20:55:59.000000000 +0200
@@ -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
--- linux-2.6.13-rc4.orig/drivers/hwmon/w83792d.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/w83792d.c	2005-07-31 20:55:59.000000000 +0200
@@ -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);
 }
 
 
--- linux-2.6.13-rc4.orig/drivers/hwmon/w83l785ts.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/w83l785ts.c	2005-07-31 20:55:59.000000000 +0200
@@ -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);
 }
 
 /*
--- linux-2.6.13-rc4.orig/drivers/i2c/chips/ds1337.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/i2c/chips/ds1337.c	2005-07-31 20:55:59.000000000 +0200
@@ -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);
 }
 
 /*
--- linux-2.6.13-rc4.orig/drivers/i2c/chips/eeprom.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/i2c/chips/eeprom.c	2005-07-31 20:55:59.000000000 +0200
@@ -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;
--- linux-2.6.13-rc4.orig/drivers/i2c/chips/max6875.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/i2c/chips/max6875.c	2005-07-31 20:55:59.000000000 +0200
@@ -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;
--- linux-2.6.13-rc4.orig/drivers/i2c/chips/pca9539.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/i2c/chips/pca9539.c	2005-07-31 20:55:59.000000000 +0200
@@ -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;
--- linux-2.6.13-rc4.orig/drivers/i2c/chips/pcf8574.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/i2c/chips/pcf8574.c	2005-07-31 20:55:59.000000000 +0200
@@ -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;
--- linux-2.6.13-rc4.orig/drivers/i2c/chips/pcf8591.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/i2c/chips/pcf8591.c	2005-07-31 20:55:59.000000000 +0200
@@ -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;


-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 2.6] (5/11) hwmon vs i2c, second round
  2005-07-31 18:59 [PATCH 2.6] (0/11) hwmon vs i2c, second round Jean Delvare
                   ` (3 preceding siblings ...)
  2005-07-31 19:42 ` [PATCH 2.6] (4/11) " Jean Delvare
@ 2005-07-31 19:45 ` Jean Delvare
  2005-07-31 19:49 ` [PATCH 2.6] (6/11) " Jean Delvare
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Jean Delvare @ 2005-07-31 19:45 UTC (permalink / raw)
  To: LKML, LM Sensors; +Cc: Greg KH

The i2c_detect function has no more user, delete it.

Signed-off-by: Jean Delvare <khali@linux-fr.org>

 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(-)

--- linux-2.6.13-rc4.orig/drivers/i2c/Makefile	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/i2c/Makefile	2005-07-31 20:55:58.000000000 +0200
@@ -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)
--- linux-2.6.13-rc4.orig/drivers/i2c/i2c-sensor-detect.c	2005-07-31 16:09:08.000000000 +0200
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,125 +0,0 @@
-/*
-    i2c-sensor-detect.c - Part of lm_sensors, Linux kernel modules for hardware
-            		  monitoring
-    Copyright (c) 1998 - 2001 Frodo Looijaard <frodol@dds.nl> and
-    Mark D. Studebaker <mdsxyz123@yahoo.com>
-
-    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
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
-
-static unsigned short empty[] = {I2C_CLIENT_END};
-
-/* Won't work for 10-bit addresses! */
-int i2c_detect(struct i2c_adapter *adapter,
-	       struct i2c_client_address_data *address_data,
-	       int (*found_proc) (struct i2c_adapter *, int, int))
-{
-	int addr, i, found, j, err;
-	int adapter_id = i2c_adapter_id(adapter);
-	unsigned short *normal_i2c;
-	unsigned short *probe;
-	unsigned short *ignore;
-
-	/* Forget it if we can't probe using SMBUS_QUICK */
-	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK))
-		return -1;
-	
-	/* Use default "empty" list if the adapter doesn't specify any */
-	normal_i2c = probe = ignore = empty;
-	if (address_data->normal_i2c)
-		normal_i2c = address_data->normal_i2c;
-	if (address_data->probe)
-		probe = address_data->probe;
-	if (address_data->ignore)
-		ignore = address_data->ignore;
-
-	for (addr = 0x00; addr <= 0x7f; addr++) {
-		if (i2c_check_addr(adapter, addr))
-			continue;
-
-		/* If it is in one of the force entries, we don't do any
-		   detection at all */
-		found = 0;
-		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, i)))
-						return err;
-					found = 1;
-				}
-			}
-		}
-		if (found)
-			continue;
-
-		/* If this address is in one of the ignores, we can forget about it
-		   right now */
-		for (i = 0; !found && (ignore[i] != I2C_CLIENT_END); i += 2) {
-			if ( ((adapter_id == ignore[i]) ||
-			      (ignore[i] == ANY_I2C_BUS)) &&
-			      (addr == ignore[i + 1])) {
-				dev_dbg(&adapter->dev, "found ignore parameter for adapter %d, addr %04x\n", adapter_id, addr);
-				found = 1;
-			}
-		}
-		if (found)
-			continue;
-
-		/* Now, we will do a detection, but only if it is in the normal or 
-		   probe entries */
-		for (i = 0; !found && (normal_i2c[i] != I2C_CLIENT_END); i += 1) {
-			if (addr == normal_i2c[i]) {
-				found = 1;
-				dev_dbg(&adapter->dev, "found normal i2c entry for adapter %d, addr %02x\n", adapter_id, addr);
-			}
-		}
-
-		for (i = 0;
-		     !found && (probe[i] != I2C_CLIENT_END);
-		     i += 2) {
-			if (((adapter_id == probe[i]) ||
-			     (probe[i] == ANY_I2C_BUS))
-			    && (addr == probe[i + 1])) {
-				dev_dbg(&adapter->dev, "found probe parameter for adapter %d, addr %04x\n", adapter_id, addr);
-				found = 1;
-			}
-		}
-		if (!found)
-			continue;
-
-		/* OK, so we really should examine this address. First check
-		   whether there is some client here at all! */
-		if (i2c_smbus_xfer(adapter, addr, 0, 0, 0, I2C_SMBUS_QUICK, NULL) >= 0)
-			if ((err = found_proc(adapter, addr, -1)))
-				return err;
-	}
-	return 0;
-}
-
-EXPORT_SYMBOL(i2c_detect);
-
-MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>, "
-	      "Rudolf Marek <r.marek@sh.cvut.cz>");
-
-MODULE_DESCRIPTION("i2c-sensor driver");
-MODULE_LICENSE("GPL");
--- linux-2.6.13-rc4.orig/drivers/i2c/i2c-sensor-vid.c	2005-07-31 14:25:05.000000000 +0200
+++ linux-2.6.13-rc4/drivers/i2c/i2c-sensor-vid.c	2005-07-31 20:55:58.000000000 +0200
@@ -96,3 +96,8 @@
 #endif
 
 EXPORT_SYMBOL(i2c_which_vrm);
+
+MODULE_AUTHOR("Rudolf Marek <r.marek@sh.cvut.cz>");
+
+MODULE_DESCRIPTION("i2c-sensor driver");
+MODULE_LICENSE("GPL");
--- linux-2.6.13-rc4.orig/include/linux/i2c-sensor.h	2005-07-31 16:09:08.000000000 +0200
+++ linux-2.6.13-rc4/include/linux/i2c-sensor.h	2005-07-31 20:55:58.000000000 +0200
@@ -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 */


-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 2.6] (6/11) hwmon vs i2c, second round
  2005-07-31 18:59 [PATCH 2.6] (0/11) hwmon vs i2c, second round Jean Delvare
                   ` (4 preceding siblings ...)
  2005-07-31 19:45 ` [PATCH 2.6] (5/11) " Jean Delvare
@ 2005-07-31 19:49 ` Jean Delvare
  2005-07-31 19:52 ` [PATCH 2.6] (7/11) " Jean Delvare
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Jean Delvare @ 2005-07-31 19:49 UTC (permalink / raw)
  To: LKML, LM Sensors; +Cc: Greg KH

The 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.

Signed-off-by: Jean Delvare <khali@linux-fr>

 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(-)

--- linux-2.6.13-rc4.orig/Documentation/i2c/porting-clients	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/Documentation/i2c/porting-clients	2005-07-31 20:55:54.000000000 +0200
@@ -1,4 +1,4 @@
-Revision 4, 2004-03-30
+Revision 5, 2005-07-29
 Jean Delvare <khali@linux-fr.org>
 Greg KH <greg@kroah.com>
 
@@ -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
--- linux-2.6.13-rc4.orig/Documentation/i2c/writing-clients	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/Documentation/i2c/writing-clients	2005-07-31 20:55:54.000000000 +0200
@@ -155,8 +155,8 @@
 
 
 
-Probing classes (i2c)
----------------------
+Probing classes
+---------------
 
 All parameters are given as lists of unsigned 16-bit integers. Lists are
 terminated by I2C_CLIENT_END.
@@ -171,12 +171,18 @@
    ignore: insmod parameter.
      A list of pairs. The first value is a bus number (-1 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.
+     This parameter overrules the 'normal_i2c' list only.
    force: insmod parameter. 
      A list of pairs. The first value is a bus number (-1 for any I2C bus),
      the second is the I2C address. A device is blindly assumed to be on
      the given address, no probing is done. 
 
+Additionally, kind-specific force lists may optionally be defined if
+the driver supports several chip kinds. They are grouped in a
+NULL-terminated list of pointers named forces, those first element if the
+generic force list mentioned above. Each additional list correspond to an
+insmod parameter of the form force_<kind>.
+
 Fortunately, as a module writer, you just have to define the `normal_i2c' 
 parameter. The complete declaration could look like this:
 
@@ -186,61 +192,17 @@
 
   /* Magic definition of all other variables and things */
   I2C_CLIENT_INSMOD;
+  /* Or, if your driver supports, say, 2 kind of devices: */
+  I2C_CLIENT_INSMOD_2(foo, bar);
+
+If you use the multi-kind form, an enum will be defined for you:
+  enum chips { any_chip, foo, bar, ... }
+You can then (and certainly should) use it in the driver code.
 
 Note that you *have* to call the defined variable `normal_i2c',
 without any prefix!
 
 
-Probing classes (sensors)
--------------------------
-
-If you write a `sensors' driver, you use a slightly different interface.
-Also, we use a enum of chip types. Don't forget to include `sensors.h'.
-
-The following lists are used internally. They are all lists of integers.
-
-   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.
-
-Also used is a list of pointers to sensors_force_data structures:
-   force_data: insmod parameters. A list, ending with an element of which
-     the force field is NULL.
-     Each element contains the type of chip and a list of pairs.
-     The first value is a bus number (ANY_I2C_BUS for any I2C bus), the
-     second is the address.
-     These are automatically translated to insmod variables of the form
-     force_foo.
-
-So we have a generic insmod variabled `force', and chip-specific variables
-`force_CHIPNAME'.
-
-Fortunately, as a module writer, you just have to define the `normal_i2c' 
-parameter, and define what chip names are used. The complete declaration
-could look like this:
-  /* Scan i2c addresses 0x37, and 0x48 to 0x4f */
-  static unsigned short normal_i2c[] = { 0x37, 0x48, 0x49, 0x4a, 0x4b, 0x4c,
-                                         0x4d, 0x4e, 0x4f, I2C_CLIENT_END };
-
-  /* Define chips foo and bar, as well as all module parameters and things */
-  SENSORS_INSMOD_2(foo,bar);
-
-If you have one chip, you use macro SENSORS_INSMOD_1(chip), if you have 2
-you use macro SENSORS_INSMOD_2(chip1,chip2), etc. If you do not want to
-bother with chip types, you can use SENSORS_INSMOD_0.
-
-A enum is automatically defined as follows:
-  enum chips { any_chip, chip1, chip2, ... }
-
-
 Attaching to an adapter
 -----------------------
 
--- linux-2.6.13-rc4.orig/drivers/hwmon/adm1021.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/adm1021.c	2005-07-31 20:55:54.000000000 +0200
@@ -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 */
 
--- linux-2.6.13-rc4.orig/drivers/hwmon/adm1025.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/adm1025.c	2005-07-31 20:55:54.000000000 +0200
@@ -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
--- linux-2.6.13-rc4.orig/drivers/hwmon/adm1026.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/adm1026.c	2005-07-31 20:55:54.000000000 +0200
@@ -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 }; 
--- linux-2.6.13-rc4.orig/drivers/hwmon/adm1031.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/adm1031.c	2005-07-31 20:55:54.000000000 +0200
@@ -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];
 
--- linux-2.6.13-rc4.orig/drivers/hwmon/adm9240.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/adm9240.c	2005-07-31 20:55:54.000000000 +0200
@@ -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
--- linux-2.6.13-rc4.orig/drivers/hwmon/asb100.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/asb100.c	2005-07-31 20:55:54.000000000 +0200
@@ -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}");
 
--- linux-2.6.13-rc4.orig/drivers/hwmon/atxp1.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/atxp1.c	2005-07-31 20:55:54.000000000 +0200
@@ -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);
--- linux-2.6.13-rc4.orig/drivers/hwmon/ds1621.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/ds1621.c	2005-07-31 20:55:54.000000000 +0200
@@ -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");
--- linux-2.6.13-rc4.orig/drivers/hwmon/fscher.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/fscher.c	2005-07-31 20:55:54.000000000 +0200
@@ -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
--- linux-2.6.13-rc4.orig/drivers/hwmon/fscpos.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/fscpos.c	2005-07-31 20:55:54.000000000 +0200
@@ -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
--- linux-2.6.13-rc4.orig/drivers/hwmon/gl518sm.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/gl518sm.c	2005-07-31 20:55:54.000000000 +0200
@@ -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 */
 
--- linux-2.6.13-rc4.orig/drivers/hwmon/gl520sm.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/gl520sm.c	2005-07-31 20:55:54.000000000 +0200
@@ -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.
--- linux-2.6.13-rc4.orig/drivers/hwmon/it87.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/it87.c	2005-07-31 20:55:54.000000000 +0200
@@ -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 */
--- linux-2.6.13-rc4.orig/drivers/hwmon/lm63.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/lm63.c	2005-07-31 20:55:54.000000000 +0200
@@ -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
--- linux-2.6.13-rc4.orig/drivers/hwmon/lm75.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/lm75.c	2005-07-31 20:55:54.000000000 +0200
@@ -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 */
 
--- linux-2.6.13-rc4.orig/drivers/hwmon/lm77.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/lm77.c	2005-07-31 20:55:54.000000000 +0200
@@ -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
--- linux-2.6.13-rc4.orig/drivers/hwmon/lm78.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/lm78.c	2005-07-31 20:55:54.000000000 +0200
@@ -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 */
 
--- linux-2.6.13-rc4.orig/drivers/hwmon/lm80.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/lm80.c	2005-07-31 20:55:54.000000000 +0200
@@ -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 */
 
--- linux-2.6.13-rc4.orig/drivers/hwmon/lm83.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/lm83.c	2005-07-31 20:55:54.000000000 +0200
@@ -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
--- linux-2.6.13-rc4.orig/drivers/hwmon/lm85.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/lm85.c	2005-07-31 20:55:54.000000000 +0200
@@ -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 */
 
--- linux-2.6.13-rc4.orig/drivers/hwmon/lm87.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/lm87.c	2005-07-31 20:55:54.000000000 +0200
@@ -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
--- linux-2.6.13-rc4.orig/drivers/hwmon/lm90.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/lm90.c	2005-07-31 20:55:54.000000000 +0200
@@ -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
--- linux-2.6.13-rc4.orig/drivers/hwmon/lm92.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/lm92.c	2005-07-31 20:55:54.000000000 +0200
@@ -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 */
--- linux-2.6.13-rc4.orig/drivers/hwmon/max1619.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/max1619.c	2005-07-31 20:55:54.000000000 +0200
@@ -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
--- linux-2.6.13-rc4.orig/drivers/hwmon/sis5595.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/sis5595.c	2005-07-31 20:55:54.000000000 +0200
@@ -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>
--- linux-2.6.13-rc4.orig/drivers/hwmon/smsc47m1.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/smsc47m1.c	2005-07-31 20:55:54.000000000 +0200
@@ -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>
--- linux-2.6.13-rc4.orig/drivers/hwmon/via686a.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/via686a.c	2005-07-31 20:55:54.000000000 +0200
@@ -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>
--- linux-2.6.13-rc4.orig/drivers/hwmon/w83627hf.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/w83627hf.c	2005-07-31 20:55:54.000000000 +0200
@@ -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>
--- linux-2.6.13-rc4.orig/drivers/hwmon/w83781d.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/w83781d.c	2005-07-31 20:55:54.000000000 +0200
@@ -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}");
 
--- linux-2.6.13-rc4.orig/drivers/hwmon/w83792d.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/w83792d.c	2005-07-31 20:55:54.000000000 +0200
@@ -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}");
 
--- linux-2.6.13-rc4.orig/drivers/hwmon/w83l785ts.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/w83l785ts.c	2005-07-31 20:55:54.000000000 +0200
@@ -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
--- linux-2.6.13-rc4.orig/drivers/i2c/chips/ds1337.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/i2c/chips/ds1337.c	2005-07-31 20:55:54.000000000 +0200
@@ -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);
--- linux-2.6.13-rc4.orig/drivers/i2c/chips/eeprom.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/i2c/chips/eeprom.c	2005-07-31 20:55:54.000000000 +0200
@@ -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 */
--- linux-2.6.13-rc4.orig/drivers/i2c/chips/max6875.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/i2c/chips/max6875.c	2005-07-31 20:55:54.000000000 +0200
@@ -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
--- linux-2.6.13-rc4.orig/drivers/i2c/chips/pca9539.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/i2c/chips/pca9539.c	2005-07-31 20:55:54.000000000 +0200
@@ -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
 {
--- linux-2.6.13-rc4.orig/drivers/i2c/chips/pcf8574.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/i2c/chips/pcf8574.c	2005-07-31 20:55:54.000000000 +0200
@@ -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) */
--- linux-2.6.13-rc4.orig/drivers/i2c/chips/pcf8591.c	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/drivers/i2c/chips/pcf8591.c	2005-07-31 20:55:54.000000000 +0200
@@ -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);
--- linux-2.6.13-rc4.orig/include/linux/i2c-sensor.h	2005-07-31 16:50:47.000000000 +0200
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,203 +0,0 @@
-/*
-    i2c-sensor.h - Part of the i2c package
-    was originally sensors.h - Part of lm_sensors, Linux kernel modules
-                               for hardware monitoring
-    Copyright (c) 1998, 1999  Frodo Looijaard <frodol@dds.nl>
-
-    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
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifndef _LINUX_I2C_SENSOR_H
-#define _LINUX_I2C_SENSOR_H
-
-#include <linux/i2c.h>
-
-#define SENSORS_MODULE_PARM_FORCE(name) \
-  I2C_CLIENT_MODULE_PARM(force_ ## name, \
-                      "List of adapter,address pairs which are unquestionably" \
-                      " assumed to contain a `" # name "' chip")
-
-
-/* This defines several insmod variables, and the addr_data structure */
-#define SENSORS_INSMOD \
-  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 struct i2c_client_address_data addr_data = {		\
-			.normal_i2c =		normal_i2c,		\
-			.probe =		probe,			\
-			.ignore =		ignore,			\
-			.forces =		forces,			\
-		}
-
-/* The following functions create an enum with the chip names as elements. 
-   The first element of the enum is any_chip. These are the only macros
-   a module will want to use. */
-
-#define SENSORS_INSMOD_0 \
-  enum chips { any_chip }; \
-  I2C_CLIENT_MODULE_PARM(force, \
-                      "List of adapter,address pairs to boldly assume " \
-                      "to be present"); \
-  static unsigned short *forces[] = { force, \
-				      NULL }; \
-  SENSORS_INSMOD
-
-#define SENSORS_INSMOD_1(chip1) \
-  enum chips { any_chip, chip1 }; \
-  I2C_CLIENT_MODULE_PARM(force, \
-                      "List of adapter,address pairs to boldly assume " \
-                      "to be present"); \
-  SENSORS_MODULE_PARM_FORCE(chip1); \
-  static unsigned short *forces[] = { force, \
-				      force_##chip1, \
-				      NULL }; \
-  SENSORS_INSMOD
-
-#define SENSORS_INSMOD_2(chip1,chip2) \
-  enum chips { any_chip, chip1, chip2 }; \
-  I2C_CLIENT_MODULE_PARM(force, \
-                      "List of adapter,address pairs to boldly assume " \
-                      "to be present"); \
-  SENSORS_MODULE_PARM_FORCE(chip1); \
-  SENSORS_MODULE_PARM_FORCE(chip2); \
-  static unsigned short *forces[] = { force, \
-				      force_##chip1, \
-				      force_##chip2, \
-				      NULL }; \
-  SENSORS_INSMOD
-
-#define SENSORS_INSMOD_3(chip1,chip2,chip3) \
-  enum chips { any_chip, chip1, chip2, chip3 }; \
-  I2C_CLIENT_MODULE_PARM(force, \
-                      "List of adapter,address pairs to boldly assume " \
-                      "to be present"); \
-  SENSORS_MODULE_PARM_FORCE(chip1); \
-  SENSORS_MODULE_PARM_FORCE(chip2); \
-  SENSORS_MODULE_PARM_FORCE(chip3); \
-  static unsigned short *forces[] = { force, \
-				      force_##chip1, \
-				      force_##chip2, \
-				      force_##chip3, \
-				      NULL }; \
-  SENSORS_INSMOD
-
-#define SENSORS_INSMOD_4(chip1,chip2,chip3,chip4) \
-  enum chips { any_chip, chip1, chip2, chip3, chip4 }; \
-  I2C_CLIENT_MODULE_PARM(force, \
-                      "List of adapter,address pairs to boldly assume " \
-                      "to be present"); \
-  SENSORS_MODULE_PARM_FORCE(chip1); \
-  SENSORS_MODULE_PARM_FORCE(chip2); \
-  SENSORS_MODULE_PARM_FORCE(chip3); \
-  SENSORS_MODULE_PARM_FORCE(chip4); \
-  static unsigned short *forces[] = { force, \
-				      force_##chip1, \
-				      force_##chip2, \
-				      force_##chip3, \
-				      force_##chip4, \
-				      NULL}; \
-  SENSORS_INSMOD
-
-#define SENSORS_INSMOD_5(chip1,chip2,chip3,chip4,chip5) \
-  enum chips { any_chip, chip1, chip2, chip3, chip4, chip5 }; \
-  I2C_CLIENT_MODULE_PARM(force, \
-                      "List of adapter,address pairs to boldly assume " \
-                      "to be present"); \
-  SENSORS_MODULE_PARM_FORCE(chip1); \
-  SENSORS_MODULE_PARM_FORCE(chip2); \
-  SENSORS_MODULE_PARM_FORCE(chip3); \
-  SENSORS_MODULE_PARM_FORCE(chip4); \
-  SENSORS_MODULE_PARM_FORCE(chip5); \
-  static unsigned short *forces[] = { force, \
-				      force_##chip1, \
-				      force_##chip2, \
-				      force_##chip3, \
-				      force_##chip4, \
-				      force_##chip5, \
-				      NULL }; \
-  SENSORS_INSMOD
-
-#define SENSORS_INSMOD_6(chip1,chip2,chip3,chip4,chip5,chip6) \
-  enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6 }; \
-  I2C_CLIENT_MODULE_PARM(force, \
-                      "List of adapter,address pairs to boldly assume " \
-                      "to be present"); \
-  SENSORS_MODULE_PARM_FORCE(chip1); \
-  SENSORS_MODULE_PARM_FORCE(chip2); \
-  SENSORS_MODULE_PARM_FORCE(chip3); \
-  SENSORS_MODULE_PARM_FORCE(chip4); \
-  SENSORS_MODULE_PARM_FORCE(chip5); \
-  SENSORS_MODULE_PARM_FORCE(chip6); \
-  static unsigned short *forces[] = { force, \
-				      force_##chip1, \
-				      force_##chip2, \
-				      force_##chip3, \
-				      force_##chip4, \
-				      force_##chip5, \
-				      force_##chip6, \
-				      NULL }; \
-  SENSORS_INSMOD
-
-#define SENSORS_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, \
-                      "List of adapter,address pairs to boldly assume " \
-                      "to be present"); \
-  SENSORS_MODULE_PARM_FORCE(chip1); \
-  SENSORS_MODULE_PARM_FORCE(chip2); \
-  SENSORS_MODULE_PARM_FORCE(chip3); \
-  SENSORS_MODULE_PARM_FORCE(chip4); \
-  SENSORS_MODULE_PARM_FORCE(chip5); \
-  SENSORS_MODULE_PARM_FORCE(chip6); \
-  SENSORS_MODULE_PARM_FORCE(chip7); \
-  static unsigned short *forces[] = { force, \
-				      force_##chip1, \
-				      force_##chip2, \
-				      force_##chip3, \
-				      force_##chip4, \
-				      force_##chip5, \
-				      force_##chip6, \
-				      force_##chip7, \
-				      NULL }; \
-  SENSORS_INSMOD
-
-#define SENSORS_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, \
-                      "List of adapter,address pairs to boldly assume " \
-                      "to be present"); \
-  SENSORS_MODULE_PARM_FORCE(chip1); \
-  SENSORS_MODULE_PARM_FORCE(chip2); \
-  SENSORS_MODULE_PARM_FORCE(chip3); \
-  SENSORS_MODULE_PARM_FORCE(chip4); \
-  SENSORS_MODULE_PARM_FORCE(chip5); \
-  SENSORS_MODULE_PARM_FORCE(chip6); \
-  SENSORS_MODULE_PARM_FORCE(chip7); \
-  SENSORS_MODULE_PARM_FORCE(chip8); \
-  static unsigned short *forces[] = { force, \
-				      force_##chip1, \
-				      force_##chip2, \
-				      force_##chip3, \
-				      force_##chip4, \
-				      force_##chip5, \
-				      force_##chip6, \
-				      force_##chip7, \
-				      force_##chip8, \
-				      NULL }; \
-  SENSORS_INSMOD
-
-#endif				/* def _LINUX_I2C_SENSOR_H */
--- linux-2.6.13-rc4.orig/include/linux/i2c.h	2005-07-31 16:50:47.000000000 +0200
+++ linux-2.6.13-rc4/include/linux/i2c.h	2005-07-31 20:55:54.000000000 +0200
@@ -565,24 +565,148 @@
   module_param_array(var, short, &var##_num, 0); \
   MODULE_PARM_DESC(var,desc)
 
-/* This is the one you want to use in your own modules */
+#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 struct i2c_client_address_data addr_data = {			\
+	.normal_i2c	= normal_i2c,					\
+	.probe		= probe,					\
+	.ignore		= ignore,					\
+	.forces		= forces,					\
+}
+
+/* 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(probe, \
-                      "List of adapter,address pairs to scan additionally"); \
-  I2C_CLIENT_MODULE_PARM(ignore, \
-                      "List of adapter,address pairs not to scan"); \
   I2C_CLIENT_MODULE_PARM(force, \
                       "List of adapter,address pairs to boldly assume " \
                       "to be present"); \
-	static unsigned short *addr_forces[] = {			\
+	static unsigned short *forces[] = {				\
 			force,						\
 			NULL						\
 		};							\
-	static struct i2c_client_address_data addr_data = {		\
-			.normal_i2c = 		normal_i2c,		\
-			.probe =		probe,			\
-			.ignore =		ignore,			\
-			.forces =		addr_forces,		\
-		}
+I2C_CLIENT_INSMOD_COMMON
+
+#define I2C_CLIENT_INSMOD_1(chip1)					\
+enum chips { any_chip, chip1 };						\
+I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to "	\
+		       "boldly assume to be present");			\
+I2C_CLIENT_MODULE_PARM_FORCE(chip1);					\
+static unsigned short *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, "List of adapter,address pairs to "	\
+		       "boldly assume to be present");			\
+I2C_CLIENT_MODULE_PARM_FORCE(chip1);					\
+I2C_CLIENT_MODULE_PARM_FORCE(chip2);					\
+static unsigned short *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, "List of adapter,address pairs to "	\
+		       "boldly assume to be present");			\
+I2C_CLIENT_MODULE_PARM_FORCE(chip1);					\
+I2C_CLIENT_MODULE_PARM_FORCE(chip2);					\
+I2C_CLIENT_MODULE_PARM_FORCE(chip3);					\
+static unsigned short *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, "List of adapter,address pairs to "	\
+		       "boldly assume to be present");			\
+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 unsigned short *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, "List of adapter,address pairs to "	\
+		       "boldly assume to be present");			\
+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 unsigned short *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, "List of adapter,address pairs to "	\
+		       "boldly assume to be present");			\
+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 unsigned short *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, "List of adapter,address pairs to "	\
+		       "boldly assume to be present");			\
+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 unsigned short *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, "List of adapter,address pairs to "	\
+		       "boldly assume to be present");			\
+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 unsigned short *forces[] = { force, force_##chip1,		\
+				    force_##chip2, force_##chip3,	\
+				    force_##chip4, force_##chip5,	\
+				    force_##chip6, force_##chip7,	\
+				    force_##chip8, NULL };		\
+I2C_CLIENT_INSMOD_COMMON
 
 #endif /* _LINUX_I2C_H */


-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 2.6] (7/11) hwmon vs i2c, second round
  2005-07-31 18:59 [PATCH 2.6] (0/11) hwmon vs i2c, second round Jean Delvare
                   ` (5 preceding siblings ...)
  2005-07-31 19:49 ` [PATCH 2.6] (6/11) " Jean Delvare
@ 2005-07-31 19:52 ` Jean Delvare
  2005-07-31 19:54 ` [PATCH 2.6] (8/11) " Jean Delvare
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Jean Delvare @ 2005-07-31 19:52 UTC (permalink / raw)
  To: LKML, LM Sensors; +Cc: Greg KH

The 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.

Signed-off-by: Jean Delvare <khali@linux-fr.org>

 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(-)

--- linux-2.6.13-rc4.orig/Documentation/i2c/porting-clients	2005-07-31 16:59:10.000000000 +0200
+++ linux-2.6.13-rc4/Documentation/i2c/porting-clients	2005-07-31 20:55:51.000000000 +0200
@@ -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").
--- linux-2.6.13-rc4.orig/drivers/hwmon/Kconfig	2005-07-31 14:25:04.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/Kconfig	2005-07-31 20:55:51.000000000 +0200
@@ -19,10 +19,13 @@
 	  This support can also be built as a module.  If so, the module
 	  will be called hwmon.
 
+config HWMON_VID
+	tristate
+	default n
+
 config SENSORS_ADM1021
 	tristate "Analog Devices ADM1021 and compatibles"
 	depends on HWMON && I2C
-	select I2C_SENSOR
 	help
 	  If you say yes here you get support for Analog Devices ADM1021
 	  and ADM1023 sensor chips and clones: Maxim MAX1617 and MAX1617A,
@@ -35,7 +38,7 @@
 config SENSORS_ADM1025
 	tristate "Analog Devices ADM1025 and compatibles"
 	depends on HWMON && I2C && EXPERIMENTAL
-	select I2C_SENSOR
+	select HWMON_VID
 	help
 	  If you say yes here you get support for Analog Devices ADM1025
 	  and Philips NE1619 sensor chips.
@@ -46,7 +49,7 @@
 config SENSORS_ADM1026
 	tristate "Analog Devices ADM1026 and compatibles"
 	depends on HWMON && I2C && EXPERIMENTAL
-	select I2C_SENSOR
+	select HWMON_VID
 	help
 	  If you say yes here you get support for Analog Devices ADM1026
 	  sensor chip.
@@ -57,7 +60,6 @@
 config SENSORS_ADM1031
 	tristate "Analog Devices ADM1031 and compatibles"
 	depends on HWMON && I2C && EXPERIMENTAL
-	select I2C_SENSOR
 	help
 	  If you say yes here you get support for Analog Devices ADM1031
 	  and ADM1030 sensor chips.
@@ -68,7 +70,7 @@
 config SENSORS_ADM9240
 	tristate "Analog Devices ADM9240 and compatibles"
 	depends on HWMON && I2C && EXPERIMENTAL
-	select I2C_SENSOR
+	select HWMON_VID
 	help
 	  If you say yes here you get support for Analog Devices ADM9240,
 	  Dallas DS1780, National Semiconductor LM81 sensor chips.
@@ -79,7 +81,7 @@
 config SENSORS_ASB100
 	tristate "Asus ASB100 Bach"
 	depends on HWMON && I2C && EXPERIMENTAL
-	select I2C_SENSOR
+	select HWMON_VID
 	help
 	  If you say yes here you get support for the ASB100 Bach sensor
 	  chip found on some Asus mainboards.
@@ -90,7 +92,7 @@
 config SENSORS_ATXP1
 	tristate "Attansic ATXP1 VID controller"
 	depends on HWMON && I2C && EXPERIMENTAL
-	select I2C_SENSOR
+	select HWMON_VID
 	help
 	  If you say yes here you get support for the Attansic ATXP1 VID
 	  controller.
@@ -104,7 +106,6 @@
 config SENSORS_DS1621
 	tristate "Dallas Semiconductor DS1621 and DS1625"
 	depends on HWMON && I2C && EXPERIMENTAL
-	select I2C_SENSOR
 	help
 	  If you say yes here you get support for Dallas Semiconductor
 	  DS1621 and DS1625 sensor chips.
@@ -115,7 +116,6 @@
 config SENSORS_FSCHER
 	tristate "FSC Hermes"
 	depends on HWMON && I2C && EXPERIMENTAL
-	select I2C_SENSOR
 	help
 	  If you say yes here you get support for Fujitsu Siemens
 	  Computers Hermes sensor chips.
@@ -126,7 +126,6 @@
 config SENSORS_FSCPOS
 	tristate "FSC Poseidon"
 	depends on HWMON && I2C && EXPERIMENTAL
-	select I2C_SENSOR
 	help
 	  If you say yes here you get support for Fujitsu Siemens
 	  Computers Poseidon sensor chips.
@@ -137,7 +136,6 @@
 config SENSORS_GL518SM
 	tristate "Genesys Logic GL518SM"
 	depends on HWMON && I2C
-	select I2C_SENSOR
 	help
 	  If you say yes here you get support for Genesys Logic GL518SM
 	  sensor chips.
@@ -148,7 +146,7 @@
 config SENSORS_GL520SM
 	tristate "Genesys Logic GL520SM"
 	depends on HWMON && I2C && EXPERIMENTAL
-	select I2C_SENSOR
+	select HWMON_VID
 	help
 	  If you say yes here you get support for Genesys Logic GL520SM
 	  sensor chips.
@@ -159,8 +157,8 @@
 config SENSORS_IT87
 	tristate "ITE IT87xx and compatibles"
 	depends on HWMON && I2C
-	select I2C_SENSOR
 	select I2C_ISA
+	select HWMON_VID
 	help
 	  If you say yes here you get support for ITE IT87xx sensor chips
 	  and clones: SiS960.
@@ -171,7 +169,6 @@
 config SENSORS_LM63
 	tristate "National Semiconductor LM63"
 	depends on HWMON && I2C && EXPERIMENTAL
-	select I2C_SENSOR
 	help
 	  If you say yes here you get support for the National Semiconductor
 	  LM63 remote diode digital temperature sensor with integrated fan
@@ -184,7 +181,6 @@
 config SENSORS_LM75
 	tristate "National Semiconductor LM75 and compatibles"
 	depends on HWMON && I2C
-	select I2C_SENSOR
 	help
 	  If you say yes here you get support for National Semiconductor LM75
 	  sensor chips and clones: Dallas Semiconductor DS75 and DS1775 (in
@@ -200,7 +196,6 @@
 config SENSORS_LM77
 	tristate "National Semiconductor LM77"
 	depends on HWMON && I2C && EXPERIMENTAL
-	select I2C_SENSOR
 	help
 	  If you say yes here you get support for National Semiconductor LM77
 	  sensor chips.
@@ -211,7 +206,6 @@
 config SENSORS_LM78
 	tristate "National Semiconductor LM78 and compatibles"
 	depends on HWMON && I2C && EXPERIMENTAL
-	select I2C_SENSOR
 	select I2C_ISA
 	help
 	  If you say yes here you get support for National Semiconductor LM78,
@@ -223,7 +217,6 @@
 config SENSORS_LM80
 	tristate "National Semiconductor LM80"
 	depends on HWMON && I2C && EXPERIMENTAL
-	select I2C_SENSOR
 	help
 	  If you say yes here you get support for National Semiconductor
 	  LM80 sensor chips.
@@ -234,7 +227,6 @@
 config SENSORS_LM83
 	tristate "National Semiconductor LM83"
 	depends on HWMON && I2C
-	select I2C_SENSOR
 	help
 	  If you say yes here you get support for National Semiconductor
 	  LM83 sensor chips.
@@ -245,7 +237,7 @@
 config SENSORS_LM85
 	tristate "National Semiconductor LM85 and compatibles"
 	depends on HWMON && I2C && EXPERIMENTAL
-	select I2C_SENSOR
+	select HWMON_VID
 	help
 	  If you say yes here you get support for National Semiconductor LM85
 	  sensor chips and clones: ADT7463, EMC6D100, EMC6D102 and ADM1027.
@@ -256,7 +248,7 @@
 config SENSORS_LM87
 	tristate "National Semiconductor LM87"
 	depends on HWMON && I2C && EXPERIMENTAL
-	select I2C_SENSOR
+	select HWMON_VID
 	help
 	  If you say yes here you get support for National Semiconductor LM87
 	  sensor chips.
@@ -267,7 +259,6 @@
 config SENSORS_LM90
 	tristate "National Semiconductor LM90 and compatibles"
 	depends on HWMON && I2C
-	select I2C_SENSOR
 	help
 	  If you say yes here you get support for National Semiconductor LM90,
 	  LM86, LM89 and LM99, Analog Devices ADM1032 and Maxim MAX6657 and
@@ -282,7 +273,6 @@
 config SENSORS_LM92
 	tristate "National Semiconductor LM92 and compatibles"
 	depends on HWMON && I2C && EXPERIMENTAL
-	select I2C_SENSOR
 	help
 	  If you say yes here you get support for National Semiconductor LM92
 	  and Maxim MAX6635 sensor chips.
@@ -293,7 +283,6 @@
 config SENSORS_MAX1619
 	tristate "Maxim MAX1619 sensor chip"
 	depends on HWMON && I2C && EXPERIMENTAL
-	select I2C_SENSOR
 	help
 	  If you say yes here you get support for MAX1619 sensor chip.
 
@@ -303,8 +292,8 @@
 config SENSORS_PC87360
 	tristate "National Semiconductor PC87360 family"
 	depends on HWMON && I2C && EXPERIMENTAL
-	select I2C_SENSOR
 	select I2C_ISA
+	select HWMON_VID
 	help
 	  If you say yes here you get access to the hardware monitoring
 	  functions of the National Semiconductor PC8736x Super-I/O chips.
@@ -318,7 +307,6 @@
 config SENSORS_SIS5595
 	tristate "Silicon Integrated Systems Corp. SiS5595"
 	depends on HWMON && I2C && PCI && EXPERIMENTAL
-	select I2C_SENSOR
 	select I2C_ISA
 	help
 	  If you say yes here you get support for the integrated sensors in
@@ -330,7 +318,6 @@
 config SENSORS_SMSC47M1
 	tristate "SMSC LPC47M10x and compatibles"
 	depends on HWMON && I2C && EXPERIMENTAL
-	select I2C_SENSOR
 	select I2C_ISA
 	help
 	  If you say yes here you get support for the integrated fan
@@ -343,7 +330,6 @@
 config SENSORS_SMSC47B397
 	tristate "SMSC LPC47B397-NC"
 	depends on HWMON && I2C && EXPERIMENTAL
-	select I2C_SENSOR
 	select I2C_ISA
 	help
 	  If you say yes here you get support for the SMSC LPC47B397-NC
@@ -355,7 +341,6 @@
 config SENSORS_VIA686A
 	tristate "VIA686A"
 	depends on HWMON && I2C && PCI
-	select I2C_SENSOR
 	select I2C_ISA
 	help
 	  If you say yes here you get support for the integrated sensors in
@@ -367,8 +352,8 @@
 config SENSORS_W83781D
 	tristate "Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F"
 	depends on HWMON && I2C
-	select I2C_SENSOR
 	select I2C_ISA
+	select HWMON_VID
 	help
 	  If you say yes here you get support for the Winbond W8378x series
 	  of sensor chips: the W83781D, W83782D, W83783S and W83627HF,
@@ -380,7 +365,6 @@
 config SENSORS_W83792D
 	tristate "Winbond W83792D"
 	depends on HWMON && I2C && EXPERIMENTAL
-	select I2C_SENSOR
 	help
 	  If you say yes here you get support for the Winbond W83792D chip.
 	  
@@ -390,7 +374,6 @@
 config SENSORS_W83L785TS
 	tristate "Winbond W83L785TS-S"
 	depends on HWMON && I2C && EXPERIMENTAL
-	select I2C_SENSOR
 	help
 	  If you say yes here you get support for the Winbond W83L785TS-S
 	  sensor chip, which is used on the Asus A7N8X, among other
@@ -402,8 +385,8 @@
 config SENSORS_W83627HF
 	tristate "Winbond W83627HF, W83627THF, W83637HF, W83697HF"
 	depends on HWMON && I2C && EXPERIMENTAL
-	select I2C_SENSOR
 	select I2C_ISA
+	select HWMON_VID
 	help
 	  If you say yes here you get support for the Winbond W836X7 series
 	  of sensor chips: the W83627HF, W83627THF, W83637HF, and the W83697HF
@@ -414,7 +397,6 @@
 config SENSORS_W83627EHF
 	tristate "Winbond W83627EHF"
 	depends on HWMON && I2C && EXPERIMENTAL
-	select I2C_SENSOR
 	select I2C_ISA
 	help
 	  If you say yes here you get preliminary support for the hardware
--- linux-2.6.13-rc4.orig/drivers/hwmon/Makefile	2005-07-31 14:25:04.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/Makefile	2005-07-31 20:55:51.000000000 +0200
@@ -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
--- linux-2.6.13-rc4.orig/drivers/hwmon/adm1025.c	2005-07-31 16:59:10.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/adm1025.c	2005-07-31 20:55:51.000000000 +0200
@@ -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
--- linux-2.6.13-rc4.orig/drivers/hwmon/adm1026.c	2005-07-31 16:59:10.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/adm1026.c	2005-07-31 20:55:51.000000000 +0200
@@ -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);
--- linux-2.6.13-rc4.orig/drivers/hwmon/adm9240.c	2005-07-31 16:59:10.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/adm9240.c	2005-07-31 20:55:51.000000000 +0200
@@ -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);
--- linux-2.6.13-rc4.orig/drivers/hwmon/asb100.c	2005-07-31 16:59:10.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/asb100.c	2005-07-31 20:55:51.000000000 +0200
@@ -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 */
--- linux-2.6.13-rc4.orig/drivers/hwmon/atxp1.c	2005-07-31 16:59:10.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/atxp1.c	2005-07-31 20:55:51.000000000 +0200
@@ -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",
--- linux-2.6.13-rc4.orig/drivers/hwmon/gl520sm.c	2005-07-31 16:59:10.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/gl520sm.c	2005-07-31 20:55:51.000000000 +0200
@@ -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;
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.13-rc4/drivers/hwmon/hwmon-vid.c	2005-07-31 20:55:51.000000000 +0200
@@ -0,0 +1,103 @@
+/*
+    hwmon-vid.c - VID/VRM/VRD voltage conversions
+
+    Copyright (c) 2004 Rudolf Marek <r.marek@sh.cvut.cz>
+
+    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
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/hwmon-vid.h>
+
+struct vrm_model {
+	u8 vendor;
+	u8 eff_family;
+	u8 eff_model;
+	int vrm_type;
+};
+
+#define ANY 0xFF
+
+#ifdef CONFIG_X86
+
+static struct vrm_model vrm_models[] = {
+	{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, 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)
+{
+	int i = 0;
+
+	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)))
+				return vrm_models[i].vrm_type;
+		i++;
+	}
+
+	return 0;
+}
+
+int vid_which_vrm(void)
+{
+	struct cpuinfo_x86 *c = cpu_data;
+	u32 eax;
+	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 */
+	eax = cpuid_eax(1);
+	eff_family = ((eax & 0x00000F00)>>8);
+	eff_model  = ((eax & 0x000000F0)>>4);
+	if (eff_family == 0xF) {	/* use extended model & family */
+		eff_family += ((eax & 0x00F00000)>>20);
+		eff_model += ((eax & 0x000F0000)>>16)<<4;
+	}
+	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");
+	return vrm_ret;
+}
+
+/* and now for something completely different for Non-x86 world*/
+#else
+int vid_which_vrm(void)
+{
+	printk(KERN_INFO "hwmon-vid: Unknown VRM version of your CPU\n");
+	return 0;
+}
+#endif
+
+EXPORT_SYMBOL(vid_which_vrm);
+
+MODULE_AUTHOR("Rudolf Marek <r.marek@sh.cvut.cz>");
+
+MODULE_DESCRIPTION("hwmon-vid driver");
+MODULE_LICENSE("GPL");
--- linux-2.6.13-rc4.orig/drivers/hwmon/it87.c	2005-07-31 16:59:10.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/it87.c	2005-07-31 20:55:51.000000000 +0200
@@ -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);
 	}
--- linux-2.6.13-rc4.orig/drivers/hwmon/lm85.c	2005-07-31 16:59:10.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/lm85.c	2005-07-31 20:55:51.000000000 +0200
@@ -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);
--- linux-2.6.13-rc4.orig/drivers/hwmon/lm87.c	2005-07-31 16:59:10.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/lm87.c	2005-07-31 20:55:51.000000000 +0200
@@ -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)) {
--- linux-2.6.13-rc4.orig/drivers/hwmon/pc87360.c	2005-07-31 14:25:04.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/pc87360.c	2005-07-31 20:55:51.000000000 +0200
@@ -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>
 
--- linux-2.6.13-rc4.orig/drivers/hwmon/w83627hf.c	2005-07-31 16:59:10.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/w83627hf.c	2005-07-31 20:55:51.000000000 +0200
@@ -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);
--- linux-2.6.13-rc4.orig/drivers/hwmon/w83781d.c	2005-07-31 16:59:10.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/w83781d.c	2005-07-31 20:55:51.000000000 +0200
@@ -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);
--- linux-2.6.13-rc4.orig/drivers/hwmon/w83792d.c	2005-07-31 16:59:10.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/w83792d.c	2005-07-31 20:55:51.000000000 +0200
@@ -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>
--- linux-2.6.13-rc4.orig/drivers/i2c/Makefile	2005-07-31 16:10:11.000000000 +0200
+++ linux-2.6.13-rc4/drivers/i2c/Makefile	2005-07-31 20:55:51.000000000 +0200
@@ -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
--- linux-2.6.13-rc4.orig/drivers/i2c/chips/Kconfig	2005-07-31 14:25:04.000000000 +0200
+++ linux-2.6.13-rc4/drivers/i2c/chips/Kconfig	2005-07-31 20:55:51.000000000 +0200
@@ -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.
 
--- linux-2.6.13-rc4.orig/drivers/i2c/i2c-sensor-vid.c	2005-07-31 16:10:11.000000000 +0200
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,103 +0,0 @@
-/*
-    i2c-sensor-vid.c -  Part of lm_sensors, Linux kernel modules for hardware
-        		monitoring
-
-    Copyright (c) 2004 Rudolf Marek <r.marek@sh.cvut.cz>
-
-    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
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-
-struct vrm_model {
-	u8 vendor;
-	u8 eff_family;
-	u8 eff_model;
-	int vrm_type;
-};
-
-#define ANY 0xFF
-
-#ifdef CONFIG_X86
-
-static struct vrm_model vrm_models[] = {
-	{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, 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)
-{
-	int i = 0;
-
-	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)))
-				return vrm_models[i].vrm_type;
-		i++;
-	}
-
-	return 0;
-}
-
-int i2c_which_vrm(void)
-{
-	struct cpuinfo_x86 *c = cpu_data;
-	u32 eax;
-	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 */
-	eax = cpuid_eax(1);
-	eff_family = ((eax & 0x00000F00)>>8);
-	eff_model  = ((eax & 0x000000F0)>>4);
-	if (eff_family == 0xF) {	/* use extended model & family */
-		eff_family += ((eax & 0x00F00000)>>20);
-		eff_model += ((eax & 0x000F0000)>>16)<<4;
-	}
-	vrm_ret = find_vrm(eff_family,eff_model,c->x86_vendor);
-	if (vrm_ret == 0)
-		printk(KERN_INFO "i2c-sensor.o: Unknown VRM version of your"
-		" x86 CPU\n");
-	return vrm_ret;
-}
-
-/* and now for something completely different for Non-x86 world*/
-#else
-int i2c_which_vrm(void)
-{
-	printk(KERN_INFO "i2c-sensor.o: Unknown VRM version of your CPU\n");
-	return 0;
-}
-#endif
-
-EXPORT_SYMBOL(i2c_which_vrm);
-
-MODULE_AUTHOR("Rudolf Marek <r.marek@sh.cvut.cz>");
-
-MODULE_DESCRIPTION("i2c-sensor driver");
-MODULE_LICENSE("GPL");
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.13-rc4/include/linux/hwmon-vid.h	2005-07-31 20:55:51.000000000 +0200
@@ -0,0 +1,112 @@
+/*
+    hwmon-vid.h - VID/VRM/VRD voltage conversions
+
+    Originally part of lm_sensors
+    Copyright (c) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com>
+    With assistance from Trent Piepho <xyzzy@speakeasy.org>
+
+    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
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+/*
+    This file contains common code for decoding VID pins.
+    This file is #included in various chip drivers in this directory.
+    As the user is unlikely to load more than one driver which
+    includes this code we don't worry about the wasted space.
+    Reference: VRM x.y DC-DC Converter Design Guidelines,
+    available at http://developer.intel.com
+*/
+
+/*
+    AMD Opteron processors don't follow the Intel VRM spec.
+    I'm going to "make up" 2.4 as the VRM spec 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)
+ */
+
+/*
+    Legal val values 0x00 - 0x1f; except for VRD 10.0, 0x00 - 0x3f.
+    vrm is the Intel VRM document version.
+    Note: vrm version is scaled by 10 and the return value is scaled by 1000
+    to avoid floating point in the kernel.
+*/
+
+int vid_which_vrm(void);
+
+#define DEFAULT_VRM	82
+
+static inline 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);
+	}
+}
+
+static inline 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;
+	}
+}
--- linux-2.6.13-rc4.orig/include/linux/i2c-vid.h	2005-07-31 14:25:04.000000000 +0200
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,111 +0,0 @@
-/*
-    i2c-vid.h - Part of lm_sensors, Linux kernel modules for hardware
-                monitoring
-    Copyright (c) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com>
-    With assistance from Trent Piepho <xyzzy@speakeasy.org>
-
-    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
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-/*
-    This file contains common code for decoding VID pins.
-    This file is #included in various chip drivers in this directory.
-    As the user is unlikely to load more than one driver which
-    includes this code we don't worry about the wasted space.
-    Reference: VRM x.y DC-DC Converter Design Guidelines,
-    available at http://developer.intel.com
-*/
-
-/*
-    AMD Opteron processors don't follow the Intel VRM spec.
-    I'm going to "make up" 2.4 as the VRM spec 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)
- */
-
-/*
-    Legal val values 0x00 - 0x1f; except for VRD 10.0, 0x00 - 0x3f.
-    vrm is the Intel VRM document version.
-    Note: vrm version is scaled by 10 and the return value is scaled by 1000
-    to avoid floating point in the kernel.
-*/
-
-int i2c_which_vrm(void);
-
-#define DEFAULT_VRM	82
-
-static inline 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);
-	}
-}
-
-static inline 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;
-	}
-}


-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 2.6] (8/11) hwmon vs i2c, second round
  2005-07-31 18:59 [PATCH 2.6] (0/11) hwmon vs i2c, second round Jean Delvare
                   ` (6 preceding siblings ...)
  2005-07-31 19:52 ` [PATCH 2.6] (7/11) " Jean Delvare
@ 2005-07-31 19:54 ` Jean Delvare
  2005-07-31 19:57 ` [PATCH 2.6] (9/11) " Jean Delvare
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Jean Delvare @ 2005-07-31 19:54 UTC (permalink / raw)
  To: LKML, LM Sensors; +Cc: Greg KH

Cleanup hwmon-vid a bit, fixing typos, rewording some comments and
reindenting properly at places.

Signed-off-by: Jean Delvare <khali@linux-fr.org>

 drivers/hwmon/hwmon-vid.c |   21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 deletions(-)

--- linux-2.6.13-rc4.orig/drivers/hwmon/hwmon-vid.c	2005-07-31 16:59:30.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/hwmon-vid.c	2005-07-31 20:55:50.000000000 +0200
@@ -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)
 {


-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 2.6] (9/11) hwmon vs i2c, second round
  2005-07-31 18:59 [PATCH 2.6] (0/11) hwmon vs i2c, second round Jean Delvare
                   ` (7 preceding siblings ...)
  2005-07-31 19:54 ` [PATCH 2.6] (8/11) " Jean Delvare
@ 2005-07-31 19:57 ` Jean Delvare
  2005-07-31 20:02 ` [PATCH 2.6] (10/11) " Jean Delvare
  2005-07-31 20:12 ` [PATCH 2.6] (11/11) " Jean Delvare
  10 siblings, 0 replies; 15+ messages in thread
From: Jean Delvare @ 2005-07-31 19:57 UTC (permalink / raw)
  To: LKML, LM Sensors; +Cc: Greg KH

Delete DEFAULT_VRM from hwmon-vid.h, it has no more users.

Signed-off-by: Jean Delvare <khali@linux-fr.org>

 include/linux/hwmon-vid.h |    2 --
 1 files changed, 2 deletions(-)

--- linux-2.6.13-rc4.orig/include/linux/hwmon-vid.h	2005-07-31 16:59:30.000000000 +0200
+++ linux-2.6.13-rc4/include/linux/hwmon-vid.h	2005-07-31 20:55:49.000000000 +0200
@@ -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;


-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 2.6] (10/11) hwmon vs i2c, second round
  2005-07-31 18:59 [PATCH 2.6] (0/11) hwmon vs i2c, second round Jean Delvare
                   ` (8 preceding siblings ...)
  2005-07-31 19:57 ` [PATCH 2.6] (9/11) " Jean Delvare
@ 2005-07-31 20:02 ` Jean Delvare
  2005-07-31 20:56   ` Alexey Dobriyan
  2005-08-01 20:50   ` [PATCH 2.6] (10/11, revised) " Jean Delvare
  2005-07-31 20:12 ` [PATCH 2.6] (11/11) " Jean Delvare
  10 siblings, 2 replies; 15+ messages in thread
From: Jean Delvare @ 2005-07-31 20:02 UTC (permalink / raw)
  To: LKML, LM Sensors; +Cc: Greg KH

I 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.

Signed-off-by: Jean Delvare <khali@linux-fr.org>

 drivers/hwmon/hwmon-vid.c |   99 ++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/hwmon-vid.h |   90 ++---------------------------------------
 2 files changed, 104 insertions(+), 85 deletions(-)

--- linux-2.6.13-rc4.orig/drivers/hwmon/hwmon-vid.c	2005-07-31 17:00:12.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/hwmon-vid.c	2005-07-31 20:55:47.000000000 +0200
@@ -3,6 +3,10 @@
 
     Copyright (c) 2004 Rudolf Marek <r.marek@sh.cvut.cz>
 
+    Partly imported from i2c-vid.h of the lm_sensors project
+    Copyright (c) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com>
+    With assistance from Trent Piepho <xyzzy@speakeasy.org>
+
     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 <r.marek@sh.cvut.cz>");
--- linux-2.6.13-rc4.orig/include/linux/hwmon-vid.h	2005-07-31 17:00:35.000000000 +0200
+++ linux-2.6.13-rc4/include/linux/hwmon-vid.h	2005-07-31 20:55:47.000000000 +0200
@@ -20,91 +20,11 @@
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-/*
-    This file contains common code for decoding VID pins.
-    This file is #included in various chip drivers in this directory.
-    As the user is unlikely to load more than one driver which
-    includes this code we don't worry about the wasted space.
-    Reference: VRM x.y DC-DC Converter Design Guidelines,
-    available at http://developer.intel.com
-*/
-
-/*
-    AMD Opteron processors don't follow the Intel VRM spec.
-    I'm going to "make up" 2.4 as the VRM spec 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)
- */
-
-/*
-    Legal val values 0x00 - 0x1f; except for VRD 10.0, 0x00 - 0x3f.
-    vrm is the Intel VRM document version.
-    Note: vrm version is scaled by 10 and the return value is scaled by 1000
-    to avoid floating point in the kernel.
-*/
+#ifndef _LINUX_HWMON_VID_H
+#define _LINUX_HWMON_VID_H
 
+int vid_from_reg(int val, int vrm);
+int vid_to_reg(int val, int vrm);
 int vid_which_vrm(void);
 
-static inline 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);
-	}
-}
-
-static inline 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;
-	}
-}
+#endif /* _LINUX_HWMON_VID_H */


-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 2.6] (11/11) hwmon vs i2c, second round
  2005-07-31 18:59 [PATCH 2.6] (0/11) hwmon vs i2c, second round Jean Delvare
                   ` (9 preceding siblings ...)
  2005-07-31 20:02 ` [PATCH 2.6] (10/11) " Jean Delvare
@ 2005-07-31 20:12 ` Jean Delvare
  10 siblings, 0 replies; 15+ messages in thread
From: Jean Delvare @ 2005-07-31 20:12 UTC (permalink / raw)
  To: LKML, LM Sensors; +Cc: Greg KH

Use the common vid_from_reg function in lm78 rather than
reimplementing it.

Signed-off-by: Jean Delvare <khali@linux-fr.org>

 drivers/hwmon/Kconfig |    1 +
 drivers/hwmon/lm78.c  |   10 ++--------
 2 files changed, 3 insertions(+), 8 deletions(-)

--- linux-2.6.13-rc4.orig/drivers/hwmon/lm78.c	2005-07-31 16:59:10.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/lm78.c	2005-07-31 20:55:46.000000000 +0200
@@ -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);
 
--- linux-2.6.13-rc4.orig/drivers/hwmon/Kconfig	2005-07-31 16:59:30.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/Kconfig	2005-07-31 20:55:46.000000000 +0200
@@ -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.


-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2.6] (10/11) hwmon vs i2c, second round
  2005-07-31 20:02 ` [PATCH 2.6] (10/11) " Jean Delvare
@ 2005-07-31 20:56   ` Alexey Dobriyan
  2005-07-31 21:02     ` Jean Delvare
  2005-08-01 20:50   ` [PATCH 2.6] (10/11, revised) " Jean Delvare
  1 sibling, 1 reply; 15+ messages in thread
From: Alexey Dobriyan @ 2005-07-31 20:56 UTC (permalink / raw)
  To: Jean Delvare; +Cc: linux-kernel, lm-sensors, Greg KH

One nitpicking comment and two observations:

On Sun, Jul 31, 2005 at 10:02:24PM +0200, Jean Delvare wrote:
> I see very little reason why vid_from_reg and vid_to_reg are 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.]

> 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.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2.6] (10/11) hwmon vs i2c, second round
  2005-07-31 20:56   ` Alexey Dobriyan
@ 2005-07-31 21:02     ` Jean Delvare
  0 siblings, 0 replies; 15+ messages in thread
From: Jean Delvare @ 2005-07-31 21:02 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: LKML, LM Sensors, Greg KH

Hi Alexey,

> > I see very little reason why vid_from_reg and vid_to_reg are
> > 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.

> > 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.

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.

> 3) vid_to_reg is 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 :)
-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2.6] (10/11, revised) hwmon vs i2c, second round
  2005-07-31 20:02 ` [PATCH 2.6] (10/11) " Jean Delvare
  2005-07-31 20:56   ` Alexey Dobriyan
@ 2005-08-01 20:50   ` Jean Delvare
  1 sibling, 0 replies; 15+ messages in thread
From: Jean Delvare @ 2005-08-01 20:50 UTC (permalink / raw)
  To: LKML, LM Sensors; +Cc: Greg KH, Alexey Dobriyan

I 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.

Signed-off-by: Jean Delvare <khali@linux-fr.org>

 drivers/hwmon/hwmon-vid.c |   82 +++++++++++++++++++++++++++++++++++++++++++++
 include/linux/hwmon-vid.h |   83 ++++------------------------------------------
 2 files changed, 91 insertions(+), 74 deletions(-)

--- linux-2.6.13-rc4.orig/drivers/hwmon/hwmon-vid.c	2005-07-31 21:13:11.000000000 +0200
+++ linux-2.6.13-rc4/drivers/hwmon/hwmon-vid.c	2005-08-01 19:55:25.000000000 +0200
@@ -3,6 +3,10 @@
 
     Copyright (c) 2004 Rudolf Marek <r.marek@sh.cvut.cz>
 
+    Partly imported from i2c-vid.h of the lm_sensors project
+    Copyright (c) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com>
+    With assistance from Trent Piepho <xyzzy@speakeasy.org>
+
     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 <r.marek@sh.cvut.cz>");
--- linux-2.6.13-rc4.orig/include/linux/hwmon-vid.h	2005-07-31 21:13:23.000000000 +0200
+++ linux-2.6.13-rc4/include/linux/hwmon-vid.h	2005-08-01 19:56:08.000000000 +0200
@@ -20,83 +20,16 @@
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-/*
-    This file contains common code for decoding VID pins.
-    This file is #included in various chip drivers in this directory.
-    As the user is unlikely to load more than one driver which
-    includes this code we don't worry about the wasted space.
-    Reference: VRM x.y DC-DC Converter Design Guidelines,
-    available at http://developer.intel.com
-*/
-
-/*
-    AMD Opteron processors don't follow the Intel VRM spec.
-    I'm going to "make up" 2.4 as the VRM spec 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)
- */
-
-/*
-    Legal val values 0x00 - 0x1f; except for VRD 10.0, 0x00 - 0x3f.
-    vrm is the Intel VRM document version.
-    Note: vrm version is scaled by 10 and the return value is scaled by 1000
-    to avoid floating point in the kernel.
-*/
+#ifndef _LINUX_HWMON_VID_H
+#define _LINUX_HWMON_VID_H
 
+int vid_from_reg(int val, int vrm);
 int vid_which_vrm(void);
 
-static inline 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. */
 static inline int vid_to_reg(int val, int vrm)
 {
 	switch (vrm) {
@@ -108,3 +41,5 @@
 		return -1;
 	}
 }
+
+#endif /* _LINUX_HWMON_VID_H */


-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2005-08-01 20:51 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-31 18:59 [PATCH 2.6] (0/11) hwmon vs i2c, second round Jean Delvare
2005-07-31 19:20 ` [PATCH 2.6] (1/11) " Jean Delvare
2005-07-31 19:33 ` [PATCH 2.6] (2/11) " Jean Delvare
2005-07-31 19:36 ` [PATCH 2.6] (3/11) " Jean Delvare
2005-07-31 19:42 ` [PATCH 2.6] (4/11) " Jean Delvare
2005-07-31 19:45 ` [PATCH 2.6] (5/11) " Jean Delvare
2005-07-31 19:49 ` [PATCH 2.6] (6/11) " Jean Delvare
2005-07-31 19:52 ` [PATCH 2.6] (7/11) " Jean Delvare
2005-07-31 19:54 ` [PATCH 2.6] (8/11) " Jean Delvare
2005-07-31 19:57 ` [PATCH 2.6] (9/11) " Jean Delvare
2005-07-31 20:02 ` [PATCH 2.6] (10/11) " Jean Delvare
2005-07-31 20:56   ` Alexey Dobriyan
2005-07-31 21:02     ` Jean Delvare
2005-08-01 20:50   ` [PATCH 2.6] (10/11, revised) " Jean Delvare
2005-07-31 20:12 ` [PATCH 2.6] (11/11) " Jean Delvare

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox