diff options
| author | Christoph Hellwig <hch@sgi.com> | 2003-02-19 01:07:11 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@home.transmeta.com> | 2003-02-19 01:07:11 -0800 |
| commit | 204e654ecfcae553f8a509f603cb6e045b385496 (patch) | |
| tree | ee7cf304eb1c708d86056e7065e4fedb99420896 | |
| parent | b76a852bfb51ffe25505bab3dfd87ddbc821c2aa (diff) | |
[PATCH] i2c sanity
small updates to bring us nearer the lm_Sensors CVS (docs, comments,
missing statics, named initializers). I still need to review their
actual code changes before submitting those..
| -rw-r--r-- | Documentation/i2c/i2c-protocol | 16 | ||||
| -rw-r--r-- | Documentation/i2c/smbus-protocol | 2 | ||||
| -rw-r--r-- | Documentation/i2c/summary | 14 | ||||
| -rw-r--r-- | Documentation/i2c/writing-clients | 4 | ||||
| -rw-r--r-- | drivers/i2c/chips/adm1021.c | 52 | ||||
| -rw-r--r-- | drivers/i2c/chips/lm75.c | 36 | ||||
| -rw-r--r-- | drivers/i2c/i2c-algo-bit.c | 8 | ||||
| -rw-r--r-- | drivers/i2c/i2c-algo-pcf.c | 5 | ||||
| -rw-r--r-- | drivers/i2c/i2c-dev.c | 17 | ||||
| -rw-r--r-- | drivers/i2c/i2c-elv.c | 19 | ||||
| -rw-r--r-- | drivers/i2c/i2c-frodo.c | 10 | ||||
| -rw-r--r-- | drivers/i2c/i2c-philips-par.c | 31 | ||||
| -rw-r--r-- | drivers/i2c/i2c-proc.c | 17 | ||||
| -rw-r--r-- | drivers/i2c/i2c-rpx.c | 5 | ||||
| -rw-r--r-- | drivers/i2c/i2c-velleman.c | 20 | ||||
| -rw-r--r-- | include/linux/i2c-algo-bit.h | 10 | ||||
| -rw-r--r-- | include/linux/i2c-algo-pcf.h | 11 | ||||
| -rw-r--r-- | include/linux/i2c-dev.h | 3 | ||||
| -rw-r--r-- | include/linux/i2c-id.h | 14 | ||||
| -rw-r--r-- | include/linux/i2c-proc.h | 15 | ||||
| -rw-r--r-- | include/linux/i2c.h | 11 |
21 files changed, 142 insertions, 178 deletions
diff --git a/Documentation/i2c/i2c-protocol b/Documentation/i2c/i2c-protocol index 40c686d6585d..b4022c914210 100644 --- a/Documentation/i2c/i2c-protocol +++ b/Documentation/i2c/i2c-protocol @@ -52,10 +52,10 @@ Modified transactions We have found some I2C devices that needs the following modifications: Flag I2C_M_NOSTART: - In a combined transaction, no 'S Addr' is generated at some point. - For example, setting I2C_M_NOSTART on the second partial message + In a combined transaction, no 'S Addr Wr/Rd [A]' is generated at some + point. For example, setting I2C_M_NOSTART on the second partial message generates something like: - S Addr Rd [A] [Data] NA Wr [A] Data [A] P + S Addr Rd [A] [Data] NA Data [A] P If you set the I2C_M_NOSTART variable for the first partial message, we do not generate Addr, but we do generate the startbit S. This will probably confuse all other clients on your bus, so don't try this. @@ -65,4 +65,12 @@ We have found some I2C devices that needs the following modifications: need to emit an Rd instead of a Wr, or vice versa, you set this flag. For example: S Addr Rd [A] Data [A] Data [A] ... [A] Data [A] P - + + Flags I2C_M_IGNORE_NAK + Normally message is interrupted immediately if there is [NA] from the + client. Setting this flag treats any [NA] as [A], and all of + message is sent. + These messages may still fail to SCL lo->hi timeout. + + Flags I2C_M_NO_RD_ACK + In a read message, master A/NA bit is skipped. diff --git a/Documentation/i2c/smbus-protocol b/Documentation/i2c/smbus-protocol index 2e15a0483844..09f5e5ca4927 100644 --- a/Documentation/i2c/smbus-protocol +++ b/Documentation/i2c/smbus-protocol @@ -61,7 +61,7 @@ SMBus Write Byte This is the reverse of Read Byte: it sends a single byte to a device. See Read Byte for more information. -S Addr Wr [A] Data NA P +S Addr Wr [A] Data [A] P SMBus Read Byte Data diff --git a/Documentation/i2c/summary b/Documentation/i2c/summary index 6755f2d94c94..c0288bb8dc40 100644 --- a/Documentation/i2c/summary +++ b/Documentation/i2c/summary @@ -4,7 +4,7 @@ I2C and SMBus ============= I2C (pronounce: I squared C) is a protocol developed by Philips. It is a -slow two-wire protocol (10-100 kHz), but it suffices for many types of +slow two-wire protocol (10-400 kHz), but it suffices for many types of devices. SMBus (System Management Bus) is a subset of the I2C protocol. Many @@ -43,15 +43,15 @@ for device drivers. Included Bus Drivers ==================== -Note that not only stable drivers are patched into the kernel by 'mkpatch'. +Note that only stable drivers are patched into the kernel by 'mkpatch'. Base modules ------------ -i2c-core: The basic I2C code, including the /proc interface -i2c-dev: The /dev interface -i2c-proc: The /proc interface for device (client) drivers +i2c-core: The basic I2C code, including the /proc/bus/i2c* interface +i2c-dev: The /dev/i2c-* interface +i2c-proc: The /proc/sys/dev/sensors interface for device (client) drivers Algorithm drivers ----------------- @@ -59,7 +59,7 @@ Algorithm drivers i2c-algo-8xx: An algorithm for CPM's I2C device in Motorola 8xx processors (NOT BUILT BY DEFAULT) i2c-algo-bit: A bit-banging algorithm i2c-algo-pcf: A PCF 8584 style algorithm -i2c-algo-ibmocp: An algorithm for the I2C device in IBM 4xx processors (NOT BUILT BY DEFAULT) +i2c-algo-ibm_ocp: An algorithm for the I2C device in IBM 4xx processors (NOT BUILT BY DEFAULT) Adapter drivers --------------- @@ -68,7 +68,7 @@ i2c-elektor: Elektor ISA card (uses i2c-algo-pcf) i2c-elv: ELV parallel port adapter (uses i2c-algo-bit) i2c-pcf-epp: PCF8584 on a EPP parallel port (uses i2c-algo-pcf) (NOT mkpatched) i2c-philips-par: Philips style parallel port adapter (uses i2c-algo-bit) -i2c-adap_ibmocp: IBM 4xx processor I2C device (uses i2c-algo-ibmocp) (NOT BUILT BY DEFAULT) +i2c-adap-ibm_ocp: IBM 4xx processor I2C device (uses i2c-algo-ibm_ocp) (NOT BUILT BY DEFAULT) i2c-pport: Primitive parallel port adapter (uses i2c-algo-bit) i2c-rpx: RPX board Motorola 8xx I2C device (uses i2c-algo-8xx) (NOT BUILT BY DEFAULT) i2c-velleman: Velleman K9000 parallel port adapter (uses i2c-algo-bit) diff --git a/Documentation/i2c/writing-clients b/Documentation/i2c/writing-clients index 1a1ed14b5235..8b310eae51ee 100644 --- a/Documentation/i2c/writing-clients +++ b/Documentation/i2c/writing-clients @@ -448,9 +448,9 @@ For now, you can ignore the `flags' parameter. It is there for future use. /* Note that we reserve some space for foo_data too. If you don't need it, remove it. We do it here to help to lessen memory fragmentation. */ - if (! (new_client = kmalloc(sizeof(struct i2c_client)) + + if (! (new_client = kmalloc(sizeof(struct i2c_client) + sizeof(struct foo_data), - GFP_KERNEL)) { + GFP_KERNEL))) { err = -ENOMEM; goto ERROR0; } diff --git a/drivers/i2c/chips/adm1021.c b/drivers/i2c/chips/adm1021.c index 19c4fed60425..44bd127e5efe 100644 --- a/drivers/i2c/chips/adm1021.c +++ b/drivers/i2c/chips/adm1021.c @@ -19,12 +19,12 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <linux/version.h> #include <linux/module.h> +#include <linux/init.h> #include <linux/slab.h> #include <linux/i2c.h> #include <linux/i2c-proc.h> -#include <linux/init.h> + /* Registers */ #define ADM1021_SYSCTL_TEMP 1200 @@ -123,8 +123,6 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, unsigned short flags, int kind); static void adm1021_init_client(struct i2c_client *client); static int adm1021_detach_client(struct i2c_client *client); -static int adm1021_command(struct i2c_client *client, unsigned int cmd, - void *arg); static int adm1021_read_value(struct i2c_client *client, u8 reg); static int adm1021_write_value(struct i2c_client *client, u8 reg, u16 value); @@ -151,7 +149,6 @@ static struct i2c_driver adm1021_driver = { .flags = I2C_DF_NOTIFY, .attach_adapter = adm1021_attach_adapter, .detach_client = adm1021_detach_client, - .command = adm1021_command, }; /* These files are created for each detected adm1021. This is just a template; @@ -186,7 +183,7 @@ static ctl_table adm1021_max_dir_table_template[] = { take more memory than the datastructure takes now. */ static int adm1021_id = 0; -int adm1021_attach_adapter(struct i2c_adapter *adapter) +static int adm1021_attach_adapter(struct i2c_adapter *adapter) { return i2c_detect(adapter, &addr_data, adm1021_detect); } @@ -339,7 +336,7 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, return err; } -void adm1021_init_client(struct i2c_client *client) +static void adm1021_init_client(struct i2c_client *client) { /* Initialize the adm1021 chip */ adm1021_write_value(client, ADM1021_REG_TOS_W, @@ -356,7 +353,7 @@ void adm1021_init_client(struct i2c_client *client) adm1021_write_value(client, ADM1021_REG_CONV_RATE_W, 0x04); } -int adm1021_detach_client(struct i2c_client *client) +static int adm1021_detach_client(struct i2c_client *client) { int err; @@ -376,28 +373,20 @@ int adm1021_detach_client(struct i2c_client *client) } - -/* No commands defined yet */ -int adm1021_command(struct i2c_client *client, unsigned int cmd, void *arg) -{ - return 0; -} - /* All registers are byte-sized */ -int adm1021_read_value(struct i2c_client *client, u8 reg) +static int adm1021_read_value(struct i2c_client *client, u8 reg) { return i2c_smbus_read_byte_data(client, reg); } -int adm1021_write_value(struct i2c_client *client, u8 reg, u16 value) +static int adm1021_write_value(struct i2c_client *client, u8 reg, u16 value) { - if (read_only > 0) - return 0; - - return i2c_smbus_write_byte_data(client, reg, value); + if (!read_only) + return i2c_smbus_write_byte_data(client, reg, value); + return 0; } -void adm1021_update_client(struct i2c_client *client) +static void adm1021_update_client(struct i2c_client *client) { struct adm1021_data *data = client->data; @@ -447,10 +436,11 @@ void adm1021_update_client(struct i2c_client *client) } -void adm1021_temp(struct i2c_client *client, int operation, int ctl_name, - int *nrels_mag, long *results) +static void adm1021_temp(struct i2c_client *client, int operation, + int ctl_name, int *nrels_mag, long *results) { struct adm1021_data *data = client->data; + if (operation == SENSORS_PROC_REAL_INFO) *nrels_mag = 0; else if (operation == SENSORS_PROC_REAL_READ) { @@ -473,8 +463,8 @@ void adm1021_temp(struct i2c_client *client, int operation, int ctl_name, } } -void adm1021_remote_temp(struct i2c_client *client, int operation, - int ctl_name, int *nrels_mag, long *results) +static void adm1021_remote_temp(struct i2c_client *client, int operation, + int ctl_name, int *nrels_mag, long *results) { struct adm1021_data *data = client->data; int prec = 0; @@ -546,10 +536,11 @@ void adm1021_remote_temp(struct i2c_client *client, int operation, } } -void adm1021_die_code(struct i2c_client *client, int operation, - int ctl_name, int *nrels_mag, long *results) +static void adm1021_die_code(struct i2c_client *client, int operation, + int ctl_name, int *nrels_mag, long *results) { struct adm1021_data *data = client->data; + if (operation == SENSORS_PROC_REAL_INFO) *nrels_mag = 0; else if (operation == SENSORS_PROC_REAL_READ) { @@ -561,8 +552,8 @@ void adm1021_die_code(struct i2c_client *client, int operation, } } -void adm1021_alarms(struct i2c_client *client, int operation, int ctl_name, - int *nrels_mag, long *results) +static void adm1021_alarms(struct i2c_client *client, int operation, + int ctl_name, int *nrels_mag, long *results) { struct adm1021_data *data = client->data; if (operation == SENSORS_PROC_REAL_INFO) @@ -578,7 +569,6 @@ void adm1021_alarms(struct i2c_client *client, int operation, int ctl_name, static int __init sensors_adm1021_init(void) { - return i2c_add_driver(&adm1021_driver); } diff --git a/drivers/i2c/chips/lm75.c b/drivers/i2c/chips/lm75.c index e628f4418420..0ab250105a5a 100644 --- a/drivers/i2c/chips/lm75.c +++ b/drivers/i2c/chips/lm75.c @@ -18,12 +18,11 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <linux/version.h> #include <linux/module.h> +#include <linux/init.h> #include <linux/slab.h> #include <linux/i2c.h> #include <linux/i2c-proc.h> -#include <linux/init.h> #define LM75_SYSCTL_TEMP 1200 /* Degrees Celcius * 10 */ @@ -72,8 +71,6 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, unsigned short flags, int kind); static void lm75_init_client(struct i2c_client *client); static int lm75_detach_client(struct i2c_client *client); -static int lm75_command(struct i2c_client *client, unsigned int cmd, - void *arg); static u16 swap_bytes(u16 val); static int lm75_read_value(struct i2c_client *client, u8 reg); static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value); @@ -84,12 +81,12 @@ static void lm75_update_client(struct i2c_client *client); /* This is the driver that will be inserted */ static struct i2c_driver lm75_driver = { + .owner = THIS_MODULE, .name = "LM75 sensor chip driver", .id = I2C_DRIVERID_LM75, .flags = I2C_DF_NOTIFY, .attach_adapter = lm75_attach_adapter, .detach_client = lm75_detach_client, - .command = lm75_command, }; /* These files are created for each detected LM75. This is just a template; @@ -105,14 +102,14 @@ static ctl_table lm75_dir_table_template[] = { static int lm75_id = 0; -int lm75_attach_adapter(struct i2c_adapter *adapter) +static int lm75_attach_adapter(struct i2c_adapter *adapter) { return i2c_detect(adapter, &addr_data, lm75_detect); } /* This function is called by i2c_detect */ -int lm75_detect(struct i2c_adapter *adapter, int address, - unsigned short flags, int kind) +static int lm75_detect(struct i2c_adapter *adapter, int address, + unsigned short flags, int kind) { int i, cur, conf, hyst, os; struct i2c_client *new_client; @@ -217,7 +214,7 @@ int lm75_detect(struct i2c_adapter *adapter, int address, return err; } -int lm75_detach_client(struct i2c_client *client) +static int lm75_detach_client(struct i2c_client *client) { struct lm75_data *data = client->data; @@ -227,12 +224,7 @@ int lm75_detach_client(struct i2c_client *client) return 0; } -int lm75_command(struct i2c_client *client, unsigned int cmd, void *arg) -{ - return 0; -} - -u16 swap_bytes(u16 val) +static u16 swap_bytes(u16 val) { return (val >> 8) | (val << 8); } @@ -240,7 +232,7 @@ u16 swap_bytes(u16 val) /* All registers are word-sized, except for the configuration register. LM75 uses a high-byte first convention, which is exactly opposite to the usual practice. */ -int lm75_read_value(struct i2c_client *client, u8 reg) +static int lm75_read_value(struct i2c_client *client, u8 reg) { if (reg == LM75_REG_CONF) return i2c_smbus_read_byte_data(client, reg); @@ -251,7 +243,7 @@ int lm75_read_value(struct i2c_client *client, u8 reg) /* All registers are word-sized, except for the configuration register. LM75 uses a high-byte first convention, which is exactly opposite to the usual practice. */ -int lm75_write_value(struct i2c_client *client, u8 reg, u16 value) +static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value) { if (reg == LM75_REG_CONF) return i2c_smbus_write_byte_data(client, reg, value); @@ -260,7 +252,7 @@ int lm75_write_value(struct i2c_client *client, u8 reg, u16 value) swap_bytes(value)); } -void lm75_init_client(struct i2c_client *client) +static void lm75_init_client(struct i2c_client *client) { /* Initialize the LM75 chip */ lm75_write_value(client, LM75_REG_TEMP_OS, @@ -270,7 +262,7 @@ void lm75_init_client(struct i2c_client *client) lm75_write_value(client, LM75_REG_CONF, 0); } -void lm75_update_client(struct i2c_client *client) +static void lm75_update_client(struct i2c_client *client) { struct lm75_data *data = client->data; @@ -292,8 +284,8 @@ void lm75_update_client(struct i2c_client *client) } -void lm75_temp(struct i2c_client *client, int operation, int ctl_name, - int *nrels_mag, long *results) +static void lm75_temp(struct i2c_client *client, int operation, int ctl_name, + int *nrels_mag, long *results) { struct lm75_data *data = client->data; if (operation == SENSORS_PROC_REAL_INFO) @@ -318,7 +310,7 @@ void lm75_temp(struct i2c_client *client, int operation, int ctl_name, } } -int __init sensors_lm75_init(void) +static int __init sensors_lm75_init(void) { return i2c_add_driver(&lm75_driver); } diff --git a/drivers/i2c/i2c-algo-bit.c b/drivers/i2c/i2c-algo-bit.c index 73b9f304493c..6be618f5a141 100644 --- a/drivers/i2c/i2c-algo-bit.c +++ b/drivers/i2c/i2c-algo-bit.c @@ -21,21 +21,19 @@ /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even Frodo Looijaard <frodol@dds.nl> */ -/* $Id: i2c-algo-bit.c,v 1.37 2002/07/08 00:41:49 mds Exp $ */ +/* $Id: i2c-algo-bit.c,v 1.44 2003/01/21 08:08:16 kmalkki Exp $ */ #include <linux/kernel.h> #include <linux/module.h> #include <linux/delay.h> #include <linux/slab.h> -#include <linux/version.h> #include <linux/init.h> -#include <asm/uaccess.h> -#include <linux/ioport.h> #include <linux/errno.h> - +#include <linux/sched.h> #include <linux/i2c.h> #include <linux/i2c-algo-bit.h> + /* ----- global defines ----------------------------------------------- */ #define DEB(x) if (i2c_debug>=1) x; #define DEB2(x) if (i2c_debug>=2) x; diff --git a/drivers/i2c/i2c-algo-pcf.c b/drivers/i2c/i2c-algo-pcf.c index ffa237cfa2f4..429dad07a523 100644 --- a/drivers/i2c/i2c-algo-pcf.c +++ b/drivers/i2c/i2c-algo-pcf.c @@ -31,16 +31,13 @@ #include <linux/module.h> #include <linux/delay.h> #include <linux/slab.h> -#include <linux/version.h> #include <linux/init.h> -#include <asm/uaccess.h> -#include <linux/ioport.h> #include <linux/errno.h> - #include <linux/i2c.h> #include <linux/i2c-algo-pcf.h> #include "i2c-pcf8584.h" + /* ----- global defines ----------------------------------------------- */ #define DEB(x) if (i2c_debug>=1) x #define DEB2(x) if (i2c_debug>=2) x diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index 14d0081b98fe..da7934d2f978 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c @@ -28,25 +28,22 @@ /* The devfs code is contributed by Philipp Matthias Hahn <pmhahn@titan.lahn.de> */ -/* $Id: i2c-dev.c,v 1.48 2002/10/01 14:10:04 ac9410 Exp $ */ +/* $Id: i2c-dev.c,v 1.53 2003/01/21 08:08:16 kmalkki Exp $ */ -#include <linux/config.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/fs.h> #include <linux/slab.h> -#include <linux/version.h> #include <linux/smp_lock.h> #include <linux/devfs_fs_kernel.h> - +#include <linux/init.h> +#include <linux/i2c.h> +#include <linux/i2c-dev.h> +#include <asm/uaccess.h> /* If you want debugging uncomment: */ /* #define DEBUG */ -#include <linux/init.h> -#include <asm/uaccess.h> -#include <linux/i2c.h> -#include <linux/i2c-dev.h> /* struct file_operations changed too often in the 2.1 series for nice code */ @@ -107,9 +104,9 @@ static ssize_t i2cdev_read (struct file *file, char *buf, size_t count, struct i2c_client *client = (struct i2c_client *)file->private_data; - if(count > 8192) + if (count > 8192) count = 8192; - + /* copy user space data to kernel space. */ tmp = kmalloc(count,GFP_KERNEL); if (tmp==NULL) diff --git a/drivers/i2c/i2c-elv.c b/drivers/i2c/i2c-elv.c index b4c74e564813..54626a0e57fd 100644 --- a/drivers/i2c/i2c-elv.c +++ b/drivers/i2c/i2c-elv.c @@ -21,20 +21,18 @@ /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even Frodo Looijaard <frodol@dds.nl> */ -/* $Id: i2c-elv.c,v 1.21 2001/11/19 18:45:02 mds Exp $ */ +/* $Id: i2c-elv.c,v 1.27 2003/01/21 08:08:16 kmalkki Exp $ */ #include <linux/kernel.h> #include <linux/module.h> #include <linux/delay.h> #include <linux/slab.h> -#include <linux/version.h> #include <linux/init.h> -#include <asm/uaccess.h> #include <linux/ioport.h> -#include <asm/io.h> #include <linux/errno.h> #include <linux/i2c.h> #include <linux/i2c-algo-bit.h> +#include <asm/io.h> #define DEFAULT_BASE 0x378 static int base=0; @@ -120,12 +118,13 @@ fail: * This is only done when more than one hardware adapter is supported. */ static struct i2c_algo_bit_data bit_elv_data = { - NULL, - bit_elv_setsda, - bit_elv_setscl, - bit_elv_getsda, - bit_elv_getscl, - 80, 80, 100, /* waits, timeout */ + .setsda = bit_elv_setsda, + .setscl = bit_elv_setscl, + .getsda = bit_elv_getsda, + .getscl = bit_elv_getscl, + .udelay = 80, + .mdelay = 80, + .timeout = HZ }; static struct i2c_adapter bit_elv_ops = { diff --git a/drivers/i2c/i2c-frodo.c b/drivers/i2c/i2c-frodo.c index 80f6cffcc13f..fa4f3bec85b1 100644 --- a/drivers/i2c/i2c-frodo.c +++ b/drivers/i2c/i2c-frodo.c @@ -12,18 +12,14 @@ * version 2 as published by the Free Software Foundation. */ -#include <linux/config.h> -#include <linux/version.h> #include <linux/module.h> - #include <linux/kernel.h> #include <linux/init.h> #include <linux/delay.h> - -#include <asm/hardware.h> - #include <linux/i2c.h> #include <linux/i2c-algo-bit.h> +#include <asm/hardware.h> + static void frodo_setsda (void *data,int state) { @@ -58,7 +54,7 @@ static struct i2c_algo_bit_data bit_frodo_data = { .getscl = frodo_getscl, .udelay = 80, .mdelay = 80, - .timeout = 100 + .timeout = HZ }; static struct i2c_adapter frodo_ops = { diff --git a/drivers/i2c/i2c-philips-par.c b/drivers/i2c/i2c-philips-par.c index b489b5f37114..e4965c320271 100644 --- a/drivers/i2c/i2c-philips-par.c +++ b/drivers/i2c/i2c-philips-par.c @@ -21,7 +21,7 @@ /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even Frodo Looijaard <frodol@dds.nl> */ -/* $Id: i2c-philips-par.c,v 1.23 2002/02/06 08:50:58 simon Exp $ */ +/* $Id: i2c-philips-par.c,v 1.29 2003/01/21 08:08:16 kmalkki Exp $ */ #include <linux/kernel.h> #include <linux/ioport.h> @@ -32,10 +32,6 @@ #include <linux/i2c.h> #include <linux/i2c-algo-bit.h> -#ifndef __exit -#define __exit __init -#endif - static int type; struct i2c_par @@ -135,21 +131,22 @@ static int bit_lp_getsda2(void *data) */ static struct i2c_algo_bit_data bit_lp_data = { - NULL, - bit_lp_setsda, - bit_lp_setscl, - bit_lp_getsda, - bit_lp_getscl, - 80, 80, 100, /* waits, timeout */ + .setsda = bit_lp_setsda, + .setscl = bit_lp_setscl, + .getsda = bit_lp_getsda, + .getscl = bit_lp_getscl, + .udelay = 80, + .mdelay = 80, + .timeout = HZ }; static struct i2c_algo_bit_data bit_lp_data2 = { - NULL, - bit_lp_setsda2, - bit_lp_setscl2, - bit_lp_getsda2, - NULL, - 80, 80, 100, /* waits, timeout */ + .setsda = bit_lp_setsda2, + .setscl = bit_lp_setscl2, + .getsda = bit_lp_getsda2, + .udelay = 80, + .mdelay = 80, + .timeout = HZ }; static struct i2c_adapter bit_lp_ops = { diff --git a/drivers/i2c/i2c-proc.c b/drivers/i2c/i2c-proc.c index ab462d034e22..a109bf62fdcd 100644 --- a/drivers/i2c/i2c-proc.c +++ b/drivers/i2c/i2c-proc.c @@ -29,10 +29,10 @@ #include <linux/ctype.h> #include <linux/sysctl.h> #include <linux/proc_fs.h> +#include <linux/init.h> #include <linux/ioport.h> #include <linux/i2c.h> #include <linux/i2c-proc.h> -#include <linux/init.h> #include <asm/uaccess.h> static int i2c_create_name(char **name, const char *prefix, @@ -87,7 +87,7 @@ static struct ctl_table_header *i2c_proc_header; (for a LM78 chip on the ISA bus at port 0x310), or lm75-i2c-3-4e (for a LM75 chip on the third i2c bus at address 0x4e). name is allocated first. */ -int i2c_create_name(char **name, const char *prefix, +static int i2c_create_name(char **name, const char *prefix, struct i2c_adapter *adapter, int addr) { char name_buffer[50]; @@ -200,7 +200,8 @@ void i2c_deregister_entry(int id) { ctl_table *table; char *temp; - id -= 256; + + id -= 256; if (i2c_entries[id]) { table = i2c_entries[id]->ctl_table; unregister_sysctl_table(i2c_entries[id]); @@ -213,7 +214,7 @@ void i2c_deregister_entry(int id) } } -int i2c_proc_chips(ctl_table * ctl, int write, struct file *filp, +static int i2c_proc_chips(ctl_table * ctl, int write, struct file *filp, void *buffer, size_t * lenp) { char BUF[SENSORS_PREFIX_MAX + 30]; @@ -251,7 +252,7 @@ int i2c_proc_chips(ctl_table * ctl, int write, struct file *filp, return 0; } -int i2c_sysctl_chips(ctl_table * table, int *name, int nlen, +static int i2c_sysctl_chips(ctl_table * table, int *name, int nlen, void *oldval, size_t * oldlenp, void *newval, size_t newlen, void **context) { @@ -413,7 +414,7 @@ int i2c_sysctl_real(ctl_table * table, int *name, int nlen, WARNING! This is tricky code. I have tested it, but there may still be hidden bugs in it, even leading to crashes and things! */ -int i2c_parse_reals(int *nrels, void *buffer, int bufsize, +static int i2c_parse_reals(int *nrels, void *buffer, int bufsize, long *results, int magnitude) { int maxels, min, mag; @@ -822,11 +823,11 @@ static void __exit i2c_proc_exit(void) unregister_sysctl_table(i2c_proc_header); } +EXPORT_SYMBOL(i2c_register_entry); EXPORT_SYMBOL(i2c_deregister_entry); -EXPORT_SYMBOL(i2c_detect); EXPORT_SYMBOL(i2c_proc_real); -EXPORT_SYMBOL(i2c_register_entry); EXPORT_SYMBOL(i2c_sysctl_real); +EXPORT_SYMBOL(i2c_detect); MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>"); MODULE_DESCRIPTION("i2c-proc driver"); diff --git a/drivers/i2c/i2c-rpx.c b/drivers/i2c/i2c-rpx.c index 389b738641c8..8db56630b86a 100644 --- a/drivers/i2c/i2c-rpx.c +++ b/drivers/i2c/i2c-rpx.c @@ -17,12 +17,11 @@ #include <linux/init.h> #include <linux/stddef.h> #include <linux/parport.h> - +#include <linux/i2c.h> +#include <linux/i2c-algo-8xx.h> #include <asm/mpc8xx.h> #include <asm/commproc.h> -#include <linux/i2c.h> -#include <linux/i2c-algo-8xx.h> static void rpx_iic_init(struct i2c_algo_8xx_data *data) diff --git a/drivers/i2c/i2c-velleman.c b/drivers/i2c/i2c-velleman.c index b158fc59a656..807c190412c8 100644 --- a/drivers/i2c/i2c-velleman.c +++ b/drivers/i2c/i2c-velleman.c @@ -18,17 +18,16 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* ------------------------------------------------------------------------- */ -/* $Id: i2c-velleman.c,v 1.23 2001/11/19 18:45:02 mds Exp $ */ +/* $Id: i2c-velleman.c,v 1.29 2003/01/21 08:08:16 kmalkki Exp $ */ #include <linux/kernel.h> #include <linux/ioport.h> #include <linux/module.h> #include <linux/init.h> -#include <linux/string.h> /* for 2.0 kernels to get NULL */ -#include <asm/errno.h> /* for 2.0 kernels to get ENODEV */ -#include <asm/io.h> +#include <linux/delay.h> #include <linux/i2c.h> #include <linux/i2c-algo-bit.h> +#include <asm/io.h> /* ----- global defines ----------------------------------------------- */ #define DEB(x) /* should be reasonable open, close &c. */ @@ -104,12 +103,13 @@ static int bit_velle_init(void) */ static struct i2c_algo_bit_data bit_velle_data = { - NULL, - bit_velle_setsda, - bit_velle_setscl, - bit_velle_getsda, - bit_velle_getscl, - 10, 10, 100, /* waits, timeout */ + .setsda = bit_velle_setsda, + .setscl = bit_velle_setscl, + .getsda = bit_velle_getsda, + .getscl = bit_velle_getscl, + .udelay = 10, + .mdelay = 10, + .timeout = HZ }; static struct i2c_adapter bit_velle_ops = { diff --git a/include/linux/i2c-algo-bit.h b/include/linux/i2c-algo-bit.h index fea550f163d9..110904481238 100644 --- a/include/linux/i2c-algo-bit.h +++ b/include/linux/i2c-algo-bit.h @@ -21,12 +21,10 @@ /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even Frodo Looijaard <frodol@dds.nl> */ -/* $Id: i2c-algo-bit.h,v 1.7 1999/12/21 23:45:58 frodo Exp $ */ +/* $Id: i2c-algo-bit.h,v 1.10 2003/01/21 08:08:16 kmalkki Exp $ */ -#ifndef I2C_ALGO_BIT_H -#define I2C_ALGO_BIT_H 1 - -#include <linux/i2c.h> +#ifndef _LINUX_I2C_ALGO_BIT_H +#define _LINUX_I2C_ALGO_BIT_H /* --- Defines for bit-adapters --------------------------------------- */ /* @@ -53,4 +51,4 @@ struct i2c_algo_bit_data { int i2c_bit_add_bus(struct i2c_adapter *); int i2c_bit_del_bus(struct i2c_adapter *); -#endif /* I2C_ALGO_BIT_H */ +#endif /* _LINUX_I2C_ALGO_BIT_H */ diff --git a/include/linux/i2c-algo-pcf.h b/include/linux/i2c-algo-pcf.h index 892d737ca96c..2a508562255f 100644 --- a/include/linux/i2c-algo-pcf.h +++ b/include/linux/i2c-algo-pcf.h @@ -22,13 +22,10 @@ /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even Frodo Looijaard <frodol@dds.nl> */ -/* $Id: i2c-algo-pcf.h,v 1.7 2000/02/27 23:02:45 frodo Exp $ */ +/* $Id: i2c-algo-pcf.h,v 1.8 2003/01/21 08:08:16 kmalkki Exp $ */ -#ifndef I2C_ALGO_PCF_H -#define I2C_ALGO_PCF_H 1 - -/* --- Defines for pcf-adapters --------------------------------------- */ -#include <linux/i2c.h> +#ifndef _LINUX_I2C_ALGO_PCF_H +#define _LINUX_I2C_ALGO_PCF_H struct i2c_algo_pcf_data { void *data; /* private data for lolevel routines */ @@ -49,4 +46,4 @@ struct i2c_algo_pcf_data { int i2c_pcf_add_bus(struct i2c_adapter *); int i2c_pcf_del_bus(struct i2c_adapter *); -#endif /* I2C_ALGO_PCF_H */ +#endif /* _LINUX_I2C_ALGO_PCF_H */ diff --git a/include/linux/i2c-dev.h b/include/linux/i2c-dev.h index 84bede1ed6ac..3803c36293a8 100644 --- a/include/linux/i2c-dev.h +++ b/include/linux/i2c-dev.h @@ -19,13 +19,12 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: i2c-dev.h,v 1.11 2002/07/07 15:42:47 mds Exp $ */ +/* $Id: i2c-dev.h,v 1.13 2003/01/21 08:08:16 kmalkki Exp $ */ #ifndef _LINUX_I2C_DEV_H #define _LINUX_I2C_DEV_H #include <linux/types.h> -#include <linux/i2c.h> /* Some IOCTL commands are defined in <linux/i2c.h> */ /* Note: 10-bit addresses are NOT supported! */ diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h index 0061776f0402..fbdb019dcc2b 100644 --- a/include/linux/i2c-id.h +++ b/include/linux/i2c-id.h @@ -20,10 +20,11 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* ------------------------------------------------------------------------- */ -/* $Id: i2c-id.h,v 1.56 2002/10/13 15:50:02 mds Exp $ */ +/* $Id: i2c-id.h,v 1.63 2003/01/21 08:08:16 kmalkki Exp $ */ + +#ifndef LINUX_I2C_ID_H +#define LINUX_I2C_ID_H -#ifndef I2C_ID_H -#define I2C_ID_H /* * This file is part of the i2c-bus package and contains the identifier * values for drivers, adapters and other folk populating these serial @@ -95,7 +96,8 @@ #define I2C_DRIVERID_ADV717x 48 /* ADV 7175/7176 video encoder */ #define I2C_DRIVERID_ZR36067 49 /* Zoran 36067 video encoder */ #define I2C_DRIVERID_ZR36120 50 /* Zoran 36120 video encoder */ -#define I2C_DRIVERID_24LC32A 51 /* Microchip 24LC32A 32k EEPROM */ +#define I2C_DRIVERID_24LC32A 51 /* Microchip 24LC32A 32k EEPROM */ +#define I2C_DRIVERID_STM41T00 52 /* real time clock */ @@ -147,6 +149,7 @@ #define I2C_DRIVERID_SMARTBATT 1035 #define I2C_DRIVERID_BMCSENSORS 1036 #define I2C_DRIVERID_FS451 1037 +#define I2C_DRIVERID_W83627HF 1038 /* * ---- Adapter types ---------------------------------------------------- @@ -172,6 +175,7 @@ #define I2C_ALGO_MPC8XX 0x110000 /* MPC8xx PowerPC I2C algorithm */ #define I2C_ALGO_OCP 0x120000 /* IBM or otherwise On-chip I2C algorithm */ +#define I2C_ALGO_BITHS 0x130000 /* enhanced bit style adapters */ #define I2C_ALGO_EXP 0x800000 /* experimental */ @@ -250,4 +254,4 @@ /* --- IPMB adapter */ #define I2C_HW_IPMB 0x00 -#endif /* I2C_ID_H */ +#endif /* LINUX_I2C_ID_H */ diff --git a/include/linux/i2c-proc.h b/include/linux/i2c-proc.h index ccdd2a95b1d1..c1433e5f916b 100644 --- a/include/linux/i2c-proc.h +++ b/include/linux/i2c-proc.h @@ -19,14 +19,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifndef SENSORS_SENSORS_H -#define SENSORS_SENSORS_H +#ifndef _LINUX_I2C_PROC_H +#define _LINUX_I2C_PROC_H -#ifdef __KERNEL__ - -/* Next two must be included before sysctl.h can be included, in 2.0 kernels */ -#include <linux/types.h> -#include <linux/fs.h> #include <linux/sysctl.h> /* The type of callback functions used in sensors_{proc,sysctl}_real */ @@ -388,7 +383,7 @@ extern int i2c_detect(struct i2c_adapter *adapter, /* This macro is used to scale user-input to sensible values in almost all chip drivers. */ -extern inline int SENSORS_LIMIT(long value, long low, long high) +static inline int SENSORS_LIMIT(long value, long low, long high) { if (value < low) return low; @@ -398,8 +393,6 @@ extern inline int SENSORS_LIMIT(long value, long low, long high) return value; } -#endif /* def __KERNEL__ */ - /* The maximum length of the prefix */ #define SENSORS_PREFIX_MAX 20 @@ -418,5 +411,5 @@ struct i2c_chips_data { char name[SENSORS_PREFIX_MAX + 13]; }; -#endif /* def SENSORS_SENSORS_H */ +#endif /* def _LINUX_I2C_PROC_H */ diff --git a/include/linux/i2c.h b/include/linux/i2c.h index de3dc122f059..083081de5020 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -23,20 +23,19 @@ /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and Frodo Looijaard <frodol@dds.nl> */ -/* $Id: i2c.h,v 1.59 2002/07/19 20:53:45 phil Exp $ */ +/* $Id: i2c.h,v 1.68 2003/01/21 08:08:16 kmalkki Exp $ */ #ifndef _LINUX_I2C_H #define _LINUX_I2C_H -#define I2C_DATE "20020719" -#define I2C_VERSION "2.6.4" +#define I2C_DATE "20021208" +#define I2C_VERSION "2.7.0" -#include <linux/i2c-id.h> /* id values of adapters et. al. */ +#include <linux/module.h> #include <linux/types.h> -#include <linux/config.h> +#include <linux/i2c-id.h> #include <asm/semaphore.h> - /* --- General options ------------------------------------------------ */ #define I2C_ALGO_MAX 4 /* control memory consumption */ |
