Skip to content

Commit

Permalink
[PATCH] hwmon: hwmon vs i2c, second round (06/11)
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Jean Delvare authored and Greg Kroah-Hartman committed Sep 5, 2005
1 parent 96478ef commit f4b5026
Show file tree
Hide file tree
Showing 41 changed files with 188 additions and 342 deletions.
8 changes: 4 additions & 4 deletions Documentation/i2c/porting-clients
Original file line number Diff line number Diff line change
@@ -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>

Expand All @@ -17,20 +17,20 @@ yours for best results.

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
required for a given driver (e.g. "lm75.h").

* [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
Expand Down
68 changes: 15 additions & 53 deletions Documentation/i2c/writing-clients
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ NOTE: If you want to write a `sensors' driver, the interface is slightly



Probing classes (i2c)
---------------------
Probing classes
---------------

All parameters are given as lists of unsigned 16-bit integers. Lists are
terminated by I2C_CLIENT_END.
Expand All @@ -171,12 +171,18 @@ The following lists are used internally:
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:

Expand All @@ -186,61 +192,17 @@ parameter. The complete declaration could look like this:

/* 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
-----------------------

Expand Down
3 changes: 1 addition & 2 deletions drivers/hwmon/adm1021.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand All @@ -36,7 +35,7 @@ static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a,
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 */

Expand Down
3 changes: 1 addition & 2 deletions drivers/hwmon/adm1025.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -67,7 +66,7 @@ static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
* Insmod parameters
*/

SENSORS_INSMOD_2(adm1025, ne1619);
I2C_CLIENT_INSMOD_2(adm1025, ne1619);

/*
* The ADM1025 registers
Expand Down
3 changes: 1 addition & 2 deletions drivers/hwmon/adm1026.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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 };
Expand Down
3 changes: 1 addition & 2 deletions drivers/hwmon/adm1031.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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];

Expand Down
3 changes: 1 addition & 2 deletions drivers/hwmon/adm9240.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -55,7 +54,7 @@ static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f,
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
Expand Down
3 changes: 1 addition & 2 deletions drivers/hwmon/asb100.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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}");

Expand Down
3 changes: 1 addition & 2 deletions drivers/hwmon/atxp1.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -43,7 +42,7 @@ MODULE_AUTHOR("Sebastian Witt <se.witt@gmx.net>");

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);
Expand Down
3 changes: 1 addition & 2 deletions drivers/hwmon/ds1621.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -36,7 +35,7 @@ static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
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");
Expand Down
3 changes: 1 addition & 2 deletions drivers/hwmon/fscher.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand All @@ -45,7 +44,7 @@ static unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END };
* Insmod parameters
*/

SENSORS_INSMOD_1(fscher);
I2C_CLIENT_INSMOD_1(fscher);

/*
* The FSCHER registers
Expand Down
3 changes: 1 addition & 2 deletions drivers/hwmon/fscpos.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -47,7 +46,7 @@ static unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END };
/*
* Insmod parameters
*/
SENSORS_INSMOD_1(fscpos);
I2C_CLIENT_INSMOD_1(fscpos);

/*
* The FSCPOS registers
Expand Down
3 changes: 1 addition & 2 deletions drivers/hwmon/gl518sm.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,14 @@
#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>

/* Addresses to scan */
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 */

Expand Down
3 changes: 1 addition & 2 deletions drivers/hwmon/gl520sm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -40,7 +39,7 @@ MODULE_PARM_DESC(extra_sensor_type, "Type of extra sensor (0=autodetect, 1=tempe
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.
Expand Down
3 changes: 1 addition & 2 deletions drivers/hwmon/it87.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -51,7 +50,7 @@ static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d,
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 */
Expand Down
3 changes: 1 addition & 2 deletions drivers/hwmon/lm63.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -58,7 +57,7 @@ static unsigned short normal_i2c[] = { 0x4c, I2C_CLIENT_END };
* Insmod parameters
*/

SENSORS_INSMOD_1(lm63);
I2C_CLIENT_INSMOD_1(lm63);

/*
* The LM63 registers
Expand Down
3 changes: 1 addition & 2 deletions drivers/hwmon/lm75.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -34,7 +33,7 @@ static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
0x4d, 0x4e, 0x4f, I2C_CLIENT_END };

/* Insmod parameters */
SENSORS_INSMOD_1(lm75);
I2C_CLIENT_INSMOD_1(lm75);

/* Many LM75 constants specified below */

Expand Down
Loading

0 comments on commit f4b5026

Please sign in to comment.