From bc769ff8f5f6e3d249bfde082653e5bf1c2b5698 Mon Sep 17 00:00:00 2001 From: "bgardner@wabtec.com" Date: Tue, 12 Jul 2005 13:21:11 -0500 Subject: [PATCH] I2C: simplify max6875 driver This is an update to the max6875 driver. It no longer does any detection, so the address must be forced on module load. It only makes available the user EEPROM (read-only). This patch is based off 2.6.13-rc2-mm2. Signed-off-by: Ben Gardner Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/chips/max6875.c | 445 ++++++++++++-------------------------------- 1 file changed, 123 insertions(+), 322 deletions(-) diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c index 0230375f72e5..4d4ace4b805f 100644 --- a/drivers/i2c/chips/max6875.c +++ b/drivers/i2c/chips/max6875.c @@ -5,97 +5,62 @@ Based on i2c/chips/eeprom.c - The MAX6875 has two EEPROM sections: config and user. - At reset, the config EEPROM is read into the registers. + The MAX6875 has a bank of registers and two banks of EEPROM. + Address ranges are defined as follows: + * 0x0000 - 0x0046 = configuration registers + * 0x8000 - 0x8046 = configuration EEPROM + * 0x8100 - 0x82FF = user EEPROM - This driver make 3 binary files available in sysfs: - reg_config - direct access to the registers - eeprom_config - acesses configuration eeprom space - eeprom_user - free for application use + This driver makes the user EEPROM available for read. - In our application, we put device serial & model numbers in user eeprom. + The registers & config EEPROM should be accessed via i2c-dev. - Notes: - 1) The datasheet says that register 0x44 / EEPROM 0x8044 should NOT - be overwritten, so the driver explicitly prevents that. - 2) It's a good idea to keep the config (0x45) locked in config EEPROM. - You can temporarily enable config writes by changing register 0x45. + The MAX6875 ignores the lowest address bit, so each chip responds to + two addresses - 0x50/0x51 and 0x52/0x53. + + Note that the MAX6875 uses i2c_smbus_write_byte_data() to set the read + address, so this driver is destructive if loaded for the wrong EEPROM chip. 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; version 2 of the License. */ -#include #include #include #include #include -#include -#include #include #include +#include -/* Addresses to scan */ -/* No address scanned by default, as this could corrupt standard EEPROMS. */ +/* Do not scan - the MAX6875 access method will write to some EEPROM chips */ static unsigned short normal_i2c[] = {I2C_CLIENT_END}; static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END}; /* Insmod parameters */ SENSORS_INSMOD_1(max6875); -/* this param will prevent 'accidental' writes to the eeprom */ -static int allow_write = 0; -module_param(allow_write, int, 0); -MODULE_PARM_DESC(allow_write, - "Enable write access:\n" - "*0: Read only\n" - " 1: Read/Write access"); - /* The MAX6875 can only read/write 16 bytes at a time */ #define SLICE_SIZE 16 #define SLICE_BITS 4 -/* CONFIG EEPROM is at addresses 0x8000 - 0x8045, registers are at 0 - 0x45 */ -#define CONFIG_EEPROM_BASE 0x8000 -#define CONFIG_EEPROM_SIZE 0x0046 -#define CONFIG_EEPROM_SLICES 5 - /* USER EEPROM is at addresses 0x8100 - 0x82FF */ #define USER_EEPROM_BASE 0x8100 #define USER_EEPROM_SIZE 0x0200 #define USER_EEPROM_SLICES 32 /* MAX6875 commands */ -#define MAX6875_CMD_BLOCK_WRITE 0x83 -#define MAX6875_CMD_BLOCK_READ 0x84 -#define MAX6875_CMD_REBOOT 0x88 - -enum max6875_area_type { - max6875_register_config=0, - max6875_eeprom_config, - max6875_eeprom_user, - max6857_max -}; - -struct eeprom_block { - enum max6875_area_type type; - u8 slices; - u32 size; - u32 valid; - u32 base; - unsigned long *updated; - u8 *data; -}; +#define MAX6875_CMD_BLK_READ 0x84 /* Each client has this additional data */ struct max6875_data { struct i2c_client client; struct semaphore update_lock; - struct eeprom_block blocks[max6857_max]; - /* the above structs point into the arrays below */ - u8 data[USER_EEPROM_SIZE + (CONFIG_EEPROM_SIZE*2)]; - unsigned long last_updated[USER_EEPROM_SLICES + (CONFIG_EEPROM_SLICES*2)]; + + u32 valid; + u8 data[USER_EEPROM_SIZE]; + unsigned long last_updated[USER_EEPROM_SLICES]; }; static int max6875_attach_adapter(struct i2c_adapter *adapter); @@ -111,224 +76,98 @@ static struct i2c_driver max6875_driver = { .detach_client = max6875_detach_client, }; -static int max6875_update_slice(struct i2c_client *client, - struct eeprom_block *blk, - int slice) +static void max6875_update_slice(struct i2c_client *client, int slice) { struct max6875_data *data = i2c_get_clientdata(client); - int i, j, addr, count; - u8 rdbuf[SLICE_SIZE]; + int i, j, addr; + u8 *buf; int retval = 0; - if (slice >= blk->slices) - return -1; + if (slice >= USER_EEPROM_SLICES) + return; down(&data->update_lock); - if (!(blk->valid & (1 << slice)) || - (jiffies - blk->updated[slice] > 300 * HZ) || - (jiffies < blk->updated[slice])) { - dev_dbg(&client->dev, "Starting eeprom update, slice %u, base %u\n", + buf = &data->data[slice << SLICE_BITS]; + + if (!(data->valid & (1 << slice)) || + time_after(jiffies, data->last_updated[slice])) { + + dev_dbg(&client->dev, "Starting update of slice %u\n", slice, blk->base); - addr = blk->base + (slice << SLICE_BITS); - count = blk->size - (slice << SLICE_BITS); - if (count > SLICE_SIZE) { - count = SLICE_SIZE; - } + data->valid &= ~(1 << slice); - /* Preset the read address */ - if (addr < 0x100) { - /* select the register */ - if (i2c_smbus_write_byte(client, addr & 0xFF)) { - dev_dbg(&client->dev, "max6875 register select has failed!\n"); - retval = -1; - goto exit; - } - } else { - /* select the eeprom */ - if (i2c_smbus_write_byte_data(client, addr >> 8, addr & 0xFF)) { - dev_dbg(&client->dev, "max6875 address set has failed!\n"); - retval = -1; - goto exit; - } + addr = USER_EEPROM_BASE + (slice << SLICE_BITS); + + /* select the eeprom address */ + if (i2c_smbus_write_byte_data(client, addr >> 8, addr & 0xFF)) { + dev_err(&client->dev, "address set failed\n"); + retval = -1; + goto exit_up; } - if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { - if (i2c_smbus_read_i2c_block_data(client, MAX6875_CMD_BLOCK_READ, - rdbuf) != SLICE_SIZE) - { + if (i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { + if (i2c_smbus_read_i2c_block_data(client, + MAX6875_CMD_BLK_READ, + buf) != SLICE_SIZE) { retval = -1; - goto exit; + goto exit_up; } - - memcpy(&blk->data[slice << SLICE_BITS], rdbuf, count); } else { - for (i = 0; i < count; i++) { + for (i = 0; i < SLICE_SIZE; i++) { j = i2c_smbus_read_byte(client); - if (j < 0) - { + if (j < 0) { retval = -1; - goto exit; + goto exit_up; } - blk->data[(slice << SLICE_BITS) + i] = (u8) j; + buf[i] = j; } } - blk->updated[slice] = jiffies; - blk->valid |= (1 << slice); + data->last_updated[slice] = jiffies; + data->valid |= (1 << slice); } - exit: +exit_up: up(&data->update_lock); - return retval; -} - -static ssize_t max6875_read(struct kobject *kobj, char *buf, loff_t off, size_t count, - enum max6875_area_type area_type) -{ - struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj)); - struct max6875_data *data = i2c_get_clientdata(client); - struct eeprom_block *blk; - int slice; - - blk = &data->blocks[area_type]; - - if (off > blk->size) - return 0; - if (off + count > blk->size) - count = blk->size - off; - - /* Only refresh slices which contain requested bytes */ - for (slice = (off >> SLICE_BITS); slice <= ((off + count - 1) >> SLICE_BITS); slice++) - max6875_update_slice(client, blk, slice); - - memcpy(buf, &blk->data[off], count); - - return count; -} - -static ssize_t max6875_user_read(struct kobject *kobj, char *buf, loff_t off, size_t count) -{ - return max6875_read(kobj, buf, off, count, max6875_eeprom_user); } -static ssize_t max6875_config_read(struct kobject *kobj, char *buf, loff_t off, size_t count) +static inline struct i2c_client *kobj_to_i2c_client(struct kobject *kobj) { - return max6875_read(kobj, buf, off, count, max6875_eeprom_config); + return to_i2c_client(container_of(kobj, struct device, kobj)); } -static ssize_t max6875_cfgreg_read(struct kobject *kobj, char *buf, loff_t off, size_t count) +static ssize_t max6875_read(struct kobject *kobj, char *buf, loff_t off, + size_t count) { - return max6875_read(kobj, buf, off, count, max6875_register_config); -} - - -static ssize_t max6875_write(struct kobject *kobj, char *buf, loff_t off, size_t count, - enum max6875_area_type area_type) -{ - struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj)); + struct i2c_client *client = kobj_to_i2c_client(kobj); struct max6875_data *data = i2c_get_clientdata(client); - struct eeprom_block *blk; - int slice, addr, retval; - ssize_t sent = 0; - - blk = &data->blocks[area_type]; + int slice, max_slice; - if (off > blk->size) + if (off > USER_EEPROM_SIZE) return 0; - if ((off + count) > blk->size) - count = blk->size - off; - if (down_interruptible(&data->update_lock)) - return -EAGAIN; + if (off + count > USER_EEPROM_SIZE) + count = USER_EEPROM_SIZE - off; - /* writing to a register is done with i2c_smbus_write_byte_data() */ - if (blk->type == max6875_register_config) { - for (sent = 0; sent < count; sent++) { - addr = off + sent; - if (addr == 0x44) - continue; + /* refresh slices which contain requested bytes */ + max_slice = (off + count - 1) >> SLICE_BITS; + for (slice = (off >> SLICE_BITS); slice <= max_slice; slice++) + max6875_update_slice(client, slice); - retval = i2c_smbus_write_byte_data(client, addr, buf[sent]); - } - } else { - int cmd, val; - - /* We are writing to EEPROM */ - for (sent = 0; sent < count; sent++) { - addr = blk->base + off + sent; - cmd = addr >> 8; - val = (addr & 0xff) | (buf[sent] << 8); // reversed - - if (addr == 0x8044) - continue; - - retval = i2c_smbus_write_word_data(client, cmd, val); - - if (retval) { - goto error_exit; - } + memcpy(buf, &data->data[off], count); - /* A write takes up to 11 ms */ - msleep(11); - } - } - - /* Invalidate the scratch buffer */ - for (slice = (off >> SLICE_BITS); slice <= ((off + count - 1) >> SLICE_BITS); slice++) - blk->valid &= ~(1 << slice); - - error_exit: - up(&data->update_lock); - - return sent; -} - -static ssize_t max6875_user_write(struct kobject *kobj, char *buf, loff_t off, size_t count) -{ - return max6875_write(kobj, buf, off, count, max6875_eeprom_user); -} - -static ssize_t max6875_config_write(struct kobject *kobj, char *buf, loff_t off, size_t count) -{ - return max6875_write(kobj, buf, off, count, max6875_eeprom_config); -} - -static ssize_t max6875_cfgreg_write(struct kobject *kobj, char *buf, loff_t off, size_t count) -{ - return max6875_write(kobj, buf, off, count, max6875_register_config); + return count; } static struct bin_attribute user_eeprom_attr = { .attr = { - .name = "eeprom_user", - .mode = S_IRUGO | S_IWUSR | S_IWGRP, + .name = "eeprom", + .mode = S_IRUGO, .owner = THIS_MODULE, }, - .size = USER_EEPROM_SIZE, - .read = max6875_user_read, - .write = max6875_user_write, -}; - -static struct bin_attribute config_eeprom_attr = { - .attr = { - .name = "eeprom_config", - .mode = S_IRUGO | S_IWUSR, - .owner = THIS_MODULE, - }, - .size = CONFIG_EEPROM_SIZE, - .read = max6875_config_read, - .write = max6875_config_write, -}; - -static struct bin_attribute config_register_attr = { - .attr = { - .name = "reg_config", - .mode = S_IRUGO | S_IWUSR, - .owner = THIS_MODULE, - }, - .size = CONFIG_EEPROM_SIZE, - .read = max6875_cfgreg_read, - .write = max6875_cfgreg_write, + .size = USER_EEPROM_SIZE, + .read = max6875_read, }; static int max6875_attach_adapter(struct i2c_adapter *adapter) @@ -339,109 +178,73 @@ static int max6875_attach_adapter(struct i2c_adapter *adapter) /* This function is called by i2c_detect */ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind) { - struct i2c_client *new_client; + struct i2c_client *real_client; + struct i2c_client *fake_client; struct max6875_data *data; int err = 0; - /* Prevent 24RF08 corruption (in case of user error) */ + /* Prevent 24rf08 corruption (in case of user error) */ if (kind < 0) i2c_smbus_xfer(adapter, address, 0, 0, 0, I2C_SMBUS_QUICK, NULL); - /* There are three ways we can read the EEPROM data: - (1) I2C block reads (faster, but unsupported by most adapters) - (2) Consecutive byte reads (100% overhead) - (3) Regular byte data reads (200% overhead) - The third method is not implemented by this driver because all - known adapters support at least the second. */ - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE_DATA | - I2C_FUNC_SMBUS_BYTE | - I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) - goto exit; - - /* OK. For now, we presume we have a valid client. We now create the - client structure, even though we cannot fill it completely yet. - But it allows us to access eeprom_{read,write}_value. */ - if (!(data = kmalloc(sizeof(struct max6875_data), GFP_KERNEL))) { - err = -ENOMEM; - goto exit; - } + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA + | I2C_FUNC_SMBUS_READ_BYTE)) + return 0; + + /* Only check even addresses */ + if (address & 1) + return 0; + + if (!(data = kmalloc(sizeof(struct max6875_data), GFP_KERNEL))) + return -ENOMEM; memset(data, 0, sizeof(struct max6875_data)); - new_client = &data->client; - i2c_set_clientdata(new_client, data); - new_client->addr = address; - new_client->adapter = adapter; - new_client->driver = &max6875_driver; - new_client->flags = 0; - - /* Setup the user section */ - data->blocks[max6875_eeprom_user].type = max6875_eeprom_user; - data->blocks[max6875_eeprom_user].slices = USER_EEPROM_SLICES; - data->blocks[max6875_eeprom_user].size = USER_EEPROM_SIZE; - data->blocks[max6875_eeprom_user].base = USER_EEPROM_BASE; - data->blocks[max6875_eeprom_user].data = data->data; - data->blocks[max6875_eeprom_user].updated = data->last_updated; - - /* Setup the config section */ - data->blocks[max6875_eeprom_config].type = max6875_eeprom_config; - data->blocks[max6875_eeprom_config].slices = CONFIG_EEPROM_SLICES; - data->blocks[max6875_eeprom_config].size = CONFIG_EEPROM_SIZE; - data->blocks[max6875_eeprom_config].base = CONFIG_EEPROM_BASE; - data->blocks[max6875_eeprom_config].data = &data->data[USER_EEPROM_SIZE]; - data->blocks[max6875_eeprom_config].updated = &data->last_updated[USER_EEPROM_SLICES]; - - /* Setup the register section */ - data->blocks[max6875_register_config].type = max6875_register_config; - data->blocks[max6875_register_config].slices = CONFIG_EEPROM_SLICES; - data->blocks[max6875_register_config].size = CONFIG_EEPROM_SIZE; - data->blocks[max6875_register_config].base = 0; - data->blocks[max6875_register_config].data = &data->data[USER_EEPROM_SIZE+CONFIG_EEPROM_SIZE]; - data->blocks[max6875_register_config].updated = &data->last_updated[USER_EEPROM_SLICES+CONFIG_EEPROM_SLICES]; - - /* Init the data */ - memset(data->data, 0xff, sizeof(data->data)); - - /* Fill in the remaining client fields */ - strlcpy(new_client->name, "max6875", I2C_NAME_SIZE); + /* A fake client is created on the odd address */ + if (!(fake_client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL))) { + err = -ENOMEM; + goto exit_kfree1; + } + memset(fake_client, 0, sizeof(struct i2c_client)); + + /* Init real i2c_client */ + real_client = &data->client; + i2c_set_clientdata(real_client, data); + real_client->addr = address; + real_client->adapter = adapter; + real_client->driver = &max6875_driver; + real_client->flags = 0; + strlcpy(real_client->name, "max6875", I2C_NAME_SIZE); init_MUTEX(&data->update_lock); - /* Verify that the chip is really what we think it is */ - if ((max6875_update_slice(new_client, &data->blocks[max6875_eeprom_config], 4) < 0) || - (max6875_update_slice(new_client, &data->blocks[max6875_register_config], 4) < 0)) - goto exit_kfree; - - /* 0x41,0x42 must be zero and 0x40 must match in eeprom and registers */ - if ((data->blocks[max6875_eeprom_config].data[0x41] != 0) || - (data->blocks[max6875_eeprom_config].data[0x42] != 0) || - (data->blocks[max6875_register_config].data[0x41] != 0) || - (data->blocks[max6875_register_config].data[0x42] != 0) || - (data->blocks[max6875_eeprom_config].data[0x40] != - data->blocks[max6875_register_config].data[0x40])) - goto exit_kfree; - - /* Tell the I2C layer a new client has arrived */ - if ((err = i2c_attach_client(new_client))) - goto exit_kfree; - - /* create the sysfs eeprom files with the correct permissions */ - if (allow_write == 0) { - user_eeprom_attr.attr.mode &= ~S_IWUGO; - user_eeprom_attr.write = NULL; - config_eeprom_attr.attr.mode &= ~S_IWUGO; - config_eeprom_attr.write = NULL; - config_register_attr.attr.mode &= ~S_IWUGO; - config_register_attr.write = NULL; - } - sysfs_create_bin_file(&new_client->dev.kobj, &user_eeprom_attr); - sysfs_create_bin_file(&new_client->dev.kobj, &config_eeprom_attr); - sysfs_create_bin_file(&new_client->dev.kobj, &config_register_attr); + /* Init fake client data */ + /* set the client data to the i2c_client so that it will get freed */ + i2c_set_clientdata(fake_client, fake_client); + fake_client->addr = address | 1; + fake_client->adapter = adapter; + fake_client->driver = &max6875_driver; + fake_client->flags = 0; + strlcpy(fake_client->name, "max6875-dummy", I2C_NAME_SIZE); + + /* Prevent 24RF08 corruption (in case of user error) */ + i2c_smbus_write_quick(real_client, 0); + + if ((err = i2c_attach_client(real_client)) != 0) + goto exit_kfree2; + + if ((err = i2c_attach_client(fake_client)) != 0) + goto exit_detach; + + sysfs_create_bin_file(&real_client->dev.kobj, &user_eeprom_attr); return 0; -exit_kfree: +exit_detach: + i2c_detach_client(real_client); +exit_kfree2: + kfree(fake_client); +exit_kfree1: kfree(data); -exit: return err; } @@ -451,12 +254,10 @@ static int max6875_detach_client(struct i2c_client *client) err = i2c_detach_client(client); if (err) { - dev_err(&client->dev, "Client deregistration failed, client not detached.\n"); + dev_err(&client->dev, "i2c_detach_client() failed\n"); return err; } - kfree(i2c_get_clientdata(client)); - return 0; } -- cgit v1.2.2 From 93ffa435147abd47ebd7d7d24176b3c653aef940 Mon Sep 17 00:00:00 2001 From: "bgardner@wabtec.com" Date: Tue, 12 Jul 2005 13:21:50 -0500 Subject: [PATCH] I2C: update max6875 documentation Updates to the max6875 driver documentation. This brings the documentation in sync with the code, which was recently simplified. This patch is based off 2.6.13-rc2-mm2. Signed-off-by: Ben Gardner Signed-off-by: Greg Kroah-Hartman --- Documentation/i2c/chips/max6875 | 94 +++++++++++++++++++++++++++++------------ 1 file changed, 68 insertions(+), 26 deletions(-) diff --git a/Documentation/i2c/chips/max6875 b/Documentation/i2c/chips/max6875 index b02002898a09..46b8dc34c971 100644 --- a/Documentation/i2c/chips/max6875 +++ b/Documentation/i2c/chips/max6875 @@ -4,22 +4,13 @@ Kernel driver max6875 Supported chips: * Maxim MAX6874, MAX6875 Prefix: 'max6875' - Addresses scanned: 0x50, 0x52 + Addresses scanned: None (see below) Datasheet: http://pdfserv.maxim-ic.com/en/ds/MAX6874-MAX6875.pdf Author: Ben Gardner -Module Parameters ------------------ - -* allow_write int - Set to non-zero to enable write permission: - *0: Read only - 1: Read and write - - Description ----------- @@ -33,34 +24,85 @@ registers. The Maxim MAX6874 is a similar, mostly compatible device, with more intputs and outputs: - vin gpi vout MAX6874 6 4 8 MAX6875 4 3 5 -MAX6874 chips can have four different addresses (as opposed to only two for -the MAX6875). The additional addresses (0x54 and 0x56) are not probed by -this driver by default, but the probe module parameter can be used if -needed. - -See the datasheet for details on how to program the EEPROM. +See the datasheet for more information. Sysfs entries ------------- -eeprom_user - 512 bytes of user-defined EEPROM space. Only writable if - allow_write was set and register 0x43 is 0. - -eeprom_config - 70 bytes of config EEPROM. Note that changes will not get - loaded into register space until a power cycle or device reset. - -reg_config - 70 bytes of register space. Any changes take affect immediately. +eeprom - 512 bytes of user-defined EEPROM space. General Remarks --------------- -A typical application will require that the EEPROMs be programmed once and -never altered afterwards. +Valid addresses for the MAX6875 are 0x50 and 0x52. +Valid addresses for the MAX6874 are 0x50, 0x52, 0x54 and 0x56. +The driver does not probe any address, so you must force the address. + +Example: +$ modprobe max6875 force=0,0x50 + +The MAX6874/MAX6875 ignores address bit 0, so this driver attaches to multiple +addresses. For example, for address 0x50, it also reserves 0x51. +The even-address instance is called 'max6875', the odd one is 'max6875-dummy'. + + +Programming the chip using i2c-dev +---------------------------------- + +Use the i2c-dev interface to access and program the chips. +Reads and write are performed differently depending on the address range. + +The configuration registers are at addresses 0x00 - 0x45. +Use i2c_smbus_write_byte_data() to write a register and +i2c_smbus_read_byte_data() to read a register. +The command is the register number. + +Examples: +To write a 1 to register 0x45: + i2c_smbus_write_byte_data(fd, 0x45, 1); + +To read register 0x45: + value = i2c_smbus_read_byte_data(fd, 0x45); + + +The configuration EEPROM is at addresses 0x8000 - 0x8045. +The user EEPROM is at addresses 0x8100 - 0x82ff. + +Use i2c_smbus_write_word_data() to write a byte to EEPROM. + +The command is the upper byte of the address: 0x80, 0x81, or 0x82. +The data word is the lower part of the address or'd with data << 8. + cmd = address >> 8; + val = (address & 0xff) | (data << 8); + +Example: +To write 0x5a to address 0x8003: + i2c_smbus_write_word_data(fd, 0x80, 0x5a03); + + +Reading data from the EEPROM is a little more complicated. +Use i2c_smbus_write_byte_data() to set the read address and then +i2c_smbus_read_byte() or i2c_smbus_read_i2c_block_data() to read the data. + +Example: +To read data starting at offset 0x8100, first set the address: + i2c_smbus_write_byte_data(fd, 0x81, 0x00); + +And then read the data + value = i2c_smbus_read_byte(fd); + + or + + count = i2c_smbus_read_i2c_block_data(fd, 0x84, buffer); + +The block read should read 16 bytes. +0x84 is the block read command. + +See the datasheet for more details. -- cgit v1.2.2 From a8decc658a8800e61f13b9240125f2a34d7fd3f5 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 27 Jul 2005 12:43:03 -0500 Subject: [PATCH] I2C: fix max6875 build error Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/chips/max6875.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c index 4d4ace4b805f..1a7993e63541 100644 --- a/drivers/i2c/chips/max6875.c +++ b/drivers/i2c/chips/max6875.c @@ -93,8 +93,7 @@ static void max6875_update_slice(struct i2c_client *client, int slice) if (!(data->valid & (1 << slice)) || time_after(jiffies, data->last_updated[slice])) { - dev_dbg(&client->dev, "Starting update of slice %u\n", - slice, blk->base); + dev_dbg(&client->dev, "Starting update of slice %u\n", slice); data->valid &= ~(1 << slice); -- cgit v1.2.2 From 5033017c2678df9dc75be0139f19701ff224a498 Mon Sep 17 00:00:00 2001 From: Hans-Frieder Vogt Date: Sat, 23 Jul 2005 15:33:39 +0200 Subject: [PATCH] I2C: cleanup of i2c-nforce2 attached is a small patch that removes unused code from i2c-nforce2 and adds a single debug message. The patch is against 2.6.13-rc3-mm1. I have tested the patch with 2.6.13-rc3: compiles cleanly and works as without the patch (as expected). Signed-off-by: Hans-Frieder Vogt Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/busses/i2c-nforce2.c | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c index 74eb89aa9350..1df601bb7f4f 100644 --- a/drivers/i2c/busses/i2c-nforce2.c +++ b/drivers/i2c/busses/i2c-nforce2.c @@ -131,7 +131,6 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr, struct nforce2_smbus *smbus = adap->algo_data; unsigned char protocol, pec, temp; unsigned char len = 0; /* to keep the compiler quiet */ - int timeout = 0; int i; protocol = (read_write == I2C_SMBUS_READ) ? NVIDIA_SMB_PRTCL_READ : @@ -191,29 +190,10 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr, case I2C_SMBUS_PROC_CALL: dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n"); return -1; - /* - outb_p(command, NVIDIA_SMB_CMD); - outb_p(data->word, NVIDIA_SMB_DATA); - outb_p(data->word >> 8, NVIDIA_SMB_DATA + 1); - protocol = NVIDIA_SMB_PRTCL_PROC_CALL | pec; - read_write = I2C_SMBUS_READ; - break; - */ case I2C_SMBUS_BLOCK_PROC_CALL: dev_err(&adap->dev, "I2C_SMBUS_BLOCK_PROC_CALL not supported!\n"); return -1; - /* - protocol |= pec; - len = min_t(u8, data->block[0], 31); - outb_p(command, NVIDIA_SMB_CMD); - outb_p(len, NVIDIA_SMB_BCNT); - for (i = 0; i < len; i++) - outb_p(data->block[i + 1], NVIDIA_SMB_DATA + i); - protocol = NVIDIA_SMB_PRTCL_BLOCK_PROC_CALL | pec; - read_write = I2C_SMBUS_READ; - break; - */ case I2C_SMBUS_WORD_DATA_PEC: case I2C_SMBUS_BLOCK_DATA_PEC: @@ -232,12 +212,6 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr, temp = inb_p(NVIDIA_SMB_STS); -#if 0 - do { - i2c_do_pause(1); - temp = inb_p(NVIDIA_SMB_STS); - } while (((temp & NVIDIA_SMB_STS_DONE) == 0) && (timeout++ < MAX_TIMEOUT)); -#endif if (~temp & NVIDIA_SMB_STS_DONE) { udelay(500); temp = inb_p(NVIDIA_SMB_STS); @@ -247,9 +221,10 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr, temp = inb_p(NVIDIA_SMB_STS); } - if ((timeout >= MAX_TIMEOUT) || (~temp & NVIDIA_SMB_STS_DONE) - || (temp & NVIDIA_SMB_STS_STATUS)) + if ((~temp & NVIDIA_SMB_STS_DONE) || (temp & NVIDIA_SMB_STS_STATUS)) { + dev_dbg(&adap->dev, "SMBus Timeout! (0x%02x)\n", temp); return -1; + } if (read_write == I2C_SMBUS_WRITE) return 0; -- cgit v1.2.2 From a61fc683ae1b7871d8d81ac5025af1a923731547 Mon Sep 17 00:00:00 2001 From: "bgardner@wabtec.com" Date: Wed, 27 Jul 2005 12:43:03 -0500 Subject: [PATCH] I2C: add kobj_to_i2c_client Move the inline function kobj_to_i2c_client() from max6875.c to i2c.h. Signed-off-by: Ben Gardner Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/chips/max6875.c | 5 ----- include/linux/i2c.h | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c index 1a7993e63541..35a8e9215294 100644 --- a/drivers/i2c/chips/max6875.c +++ b/drivers/i2c/chips/max6875.c @@ -131,11 +131,6 @@ exit_up: up(&data->update_lock); } -static inline struct i2c_client *kobj_to_i2c_client(struct kobject *kobj) -{ - return to_i2c_client(container_of(kobj, struct device, kobj)); -} - static ssize_t max6875_read(struct kobject *kobj, char *buf, loff_t off, size_t count) { diff --git a/include/linux/i2c.h b/include/linux/i2c.h index be837b13f297..017445943816 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -160,6 +160,11 @@ struct i2c_client { }; #define to_i2c_client(d) container_of(d, struct i2c_client, dev) +static inline struct i2c_client *kobj_to_i2c_client(struct kobject *kobj) +{ + return to_i2c_client(container_of(kobj, struct device, kobj)); +} + static inline void *i2c_get_clientdata (struct i2c_client *dev) { return dev_get_drvdata (&dev->dev); -- cgit v1.2.2 From 0283fe6c3bdbe9ca9aefa28b24883ec1dee3ccbd Mon Sep 17 00:00:00 2001 From: "bgardner@wabtec.com" Date: Wed, 27 Jul 2005 12:43:21 -0500 Subject: [PATCH] I2C: max6875 documentation cleanup Fix a spelling error and change a sysfs name. Signed-off-by: Ben Gardner Signed-off-by: Greg Kroah-Hartman --- Documentation/i2c/chips/max6875 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/i2c/chips/max6875 b/Documentation/i2c/chips/max6875 index 46b8dc34c971..96fec562a8e9 100644 --- a/Documentation/i2c/chips/max6875 +++ b/Documentation/i2c/chips/max6875 @@ -49,14 +49,14 @@ $ modprobe max6875 force=0,0x50 The MAX6874/MAX6875 ignores address bit 0, so this driver attaches to multiple addresses. For example, for address 0x50, it also reserves 0x51. -The even-address instance is called 'max6875', the odd one is 'max6875-dummy'. +The even-address instance is called 'max6875', the odd one is 'max6875 subclient'. Programming the chip using i2c-dev ---------------------------------- Use the i2c-dev interface to access and program the chips. -Reads and write are performed differently depending on the address range. +Reads and writes are performed differently depending on the address range. The configuration registers are at addresses 0x00 - 0x45. Use i2c_smbus_write_byte_data() to write a register and -- cgit v1.2.2 From 17f990c87a1e5addc49b99a53b3d2a2fac9680e9 Mon Sep 17 00:00:00 2001 From: "bgardner@wabtec.com" Date: Wed, 27 Jul 2005 12:43:14 -0500 Subject: [PATCH] I2C: max6875 code cleanup Remove an unused local variable and change the subclient name. Signed-off-by: Ben Gardner Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/chips/max6875.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c index 35a8e9215294..f0e306237739 100644 --- a/drivers/i2c/chips/max6875.c +++ b/drivers/i2c/chips/max6875.c @@ -81,7 +81,6 @@ static void max6875_update_slice(struct i2c_client *client, int slice) struct max6875_data *data = i2c_get_clientdata(client); int i, j, addr; u8 *buf; - int retval = 0; if (slice >= USER_EEPROM_SLICES) return; @@ -102,7 +101,6 @@ static void max6875_update_slice(struct i2c_client *client, int slice) /* select the eeprom address */ if (i2c_smbus_write_byte_data(client, addr >> 8, addr & 0xFF)) { dev_err(&client->dev, "address set failed\n"); - retval = -1; goto exit_up; } @@ -111,14 +109,12 @@ static void max6875_update_slice(struct i2c_client *client, int slice) if (i2c_smbus_read_i2c_block_data(client, MAX6875_CMD_BLK_READ, buf) != SLICE_SIZE) { - retval = -1; goto exit_up; } } else { for (i = 0; i < SLICE_SIZE; i++) { j = i2c_smbus_read_byte(client); if (j < 0) { - retval = -1; goto exit_up; } buf[i] = j; @@ -182,7 +178,7 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind) i2c_smbus_xfer(adapter, address, 0, 0, 0, I2C_SMBUS_QUICK, NULL); - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_BYTE_DATA | I2C_FUNC_SMBUS_READ_BYTE)) return 0; @@ -218,7 +214,7 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind) fake_client->adapter = adapter; fake_client->driver = &max6875_driver; fake_client->flags = 0; - strlcpy(fake_client->name, "max6875-dummy", I2C_NAME_SIZE); + strlcpy(fake_client->name, "max6875 subclient", I2C_NAME_SIZE); /* Prevent 24RF08 corruption (in case of user error) */ i2c_smbus_write_quick(real_client, 0); -- cgit v1.2.2 From e647ecf15e365679f0528d7815ab4db0d4802918 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 27 Jul 2005 21:28:28 +0200 Subject: [PATCH] hwmon: soften lm75 initialization The LM75 initialization is a bit agressive, it arbitrarily reconfigures the chip. Make it only change the bit it needs. This is a port from the 2.4 kernel version of the driver (lm_sensors). Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/lm75.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index 5be164ed278e..79d7ebc9b14a 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c @@ -251,8 +251,12 @@ static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value) static void lm75_init_client(struct i2c_client *client) { - /* Initialize the LM75 chip */ - lm75_write_value(client, LM75_REG_CONF, 0); + int reg; + + /* Enable if in shutdown mode */ + reg = lm75_read_value(client, LM75_REG_CONF); + if (reg >= 0 && (reg & 0x01)) + lm75_write_value(client, LM75_REG_CONF, reg & 0xfe); } static struct lm75_data *lm75_update_device(struct device *dev) -- cgit v1.2.2 From 27fe048eb3787d29bf9cf9d6d12077bb8af869a6 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 27 Jul 2005 21:30:16 +0200 Subject: [PATCH] hwmon: kill client name lm78-j Drop the separate client name for the LM78-J chip. This is really only a later revision of the LM78, with almost no difference and no difference the driver handles in any case. This was the only client name that had a dash in it, and special care had to be taken in libsensors because of it. As we plan to write a new library soon, I'd like to get rid of this exception before we do. As a nice side effect, it saves 876 bytes in lm78.ko. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- Documentation/hwmon/lm78 | 7 +------ drivers/hwmon/lm78.c | 11 ++++------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/Documentation/hwmon/lm78 b/Documentation/hwmon/lm78 index 357086ed7f64..fd5dc7a19f0e 100644 --- a/Documentation/hwmon/lm78 +++ b/Documentation/hwmon/lm78 @@ -2,16 +2,11 @@ Kernel driver lm78 ================== Supported chips: - * National Semiconductor LM78 + * National Semiconductor LM78 / LM78-J Prefix: 'lm78' Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports) Datasheet: Publicly available at the National Semiconductor website http://www.national.com/ - * National Semiconductor LM78-J - Prefix: 'lm78-j' - Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports) - Datasheet: Publicly available at the National Semiconductor website - http://www.national.com/ * National Semiconductor LM79 Prefix: 'lm79' Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports) diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c index 29241469dcba..cf7a2a7f54b5 100644 --- a/drivers/hwmon/lm78.c +++ b/drivers/hwmon/lm78.c @@ -34,7 +34,7 @@ static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24, static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END }; /* Insmod parameters */ -SENSORS_INSMOD_3(lm78, lm78j, lm79); +SENSORS_INSMOD_2(lm78, lm79); /* Many LM78 constants specified below */ @@ -559,10 +559,9 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind) /* Determine the chip type. */ if (kind <= 0) { i = lm78_read_value(new_client, LM78_REG_CHIPID); - if (i == 0x00 || i == 0x20) + if (i == 0x00 || i == 0x20 /* LM78 */ + || i == 0x40) /* LM78-J */ kind = lm78; - else if (i == 0x40) - kind = lm78j; else if ((i & 0xfe) == 0xc0) kind = lm79; else { @@ -578,8 +577,6 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind) if (kind == lm78) { client_name = "lm78"; - } else if (kind == lm78j) { - client_name = "lm78-j"; } else if (kind == lm79) { client_name = "lm79"; } @@ -788,7 +785,7 @@ static void __exit sm_lm78_exit(void) MODULE_AUTHOR("Frodo Looijaard "); -MODULE_DESCRIPTION("LM78, LM78-J and LM79 driver"); +MODULE_DESCRIPTION("LM78/LM79 driver"); MODULE_LICENSE("GPL"); module_init(sm_lm78_init); -- cgit v1.2.2 From 8dd2d2ca7fafdedaebd1862e954fccaef212f1e1 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 27 Jul 2005 21:33:15 +0200 Subject: [PATCH] hwmon: Document on the W83627EHG chip Document the fact that the W83627EHG is compatible with the W83627EHF. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/Kconfig | 3 +++ drivers/hwmon/w83627ehf.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 140d5f851a5b..f9aa3faa6b88 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -404,6 +404,9 @@ config SENSORS_W83627EHF Only fan and temperature inputs are supported at the moment, while the chip does much more than that. + This driver also supports the W83627EHG, which is the lead-free + version of the W83627EHF. + This driver can also be built as a module. If so, the module will be called w83627ehf. diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c index 8a40b6976e1a..250f6b059a54 100644 --- a/drivers/hwmon/w83627ehf.c +++ b/drivers/hwmon/w83627ehf.c @@ -9,6 +9,9 @@ Thanks to Leon Moonen, Steve Cliffe and Grant Coady for their help in testing and debugging this driver. + This driver also supports the W83627EHG, which is the lead-free + version of the W83627EHF. + 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 -- cgit v1.2.2 From 1236441f38b6a98caf4c7983e7efdecc2d1527b5 Mon Sep 17 00:00:00 2001 From: "Mark M. Hoffman" Date: Fri, 15 Jul 2005 21:38:08 -0400 Subject: [PATCH] I2C hwmon: hwmon sysfs class This patch adds the sysfs class "hwmon" for use by hardware monitoring (sensors) chip drivers. It also fixes up the related Kconfig/Makefile bits. Signed-off-by: Mark M. Hoffman Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/Kconfig | 7 +++- drivers/hwmon/Makefile | 2 ++ drivers/hwmon/hwmon.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/hwmon.h | 24 +++++++++++++ 4 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 drivers/hwmon/hwmon.c create mode 100644 include/linux/hwmon.h diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index f9aa3faa6b88..8c3911313700 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -12,7 +12,12 @@ config HWMON of a system. Most modern motherboards include such a device. It can include temperature sensors, voltage sensors, fan speed sensors and various additional features such as the ability to - control the speed of the fans. + control the speed of the fans. If you want this support you + should say Y here and also to the specific driver(s) for your + sensors chip(s) below. + + This support can also be built as a module. If so, the module + will be called hwmon. config SENSORS_ADM1021 tristate "Analog Devices ADM1021 and compatibles" diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 2781403a0236..bd1bd59eb149 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -2,6 +2,8 @@ # Makefile for sensor chip drivers. # +obj-$(CONFIG_HWMON) += hwmon.o + # asb100, then w83781d go first, as they can override other drivers' addresses. obj-$(CONFIG_SENSORS_ASB100) += asb100.o obj-$(CONFIG_SENSORS_W83627HF) += w83627hf.o diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c new file mode 100644 index 000000000000..9b41c9bd805f --- /dev/null +++ b/drivers/hwmon/hwmon.c @@ -0,0 +1,98 @@ +/* + hwmon.c - part of lm_sensors, Linux kernel modules for hardware monitoring + + This file defines the sysfs class "hwmon", for use by sensors drivers. + + Copyright (C) 2005 Mark M. Hoffman + + 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; version 2 of the License. +*/ + +#include +#include +#include +#include +#include +#include + +#define HWMON_ID_PREFIX "hwmon" +#define HWMON_ID_FORMAT HWMON_ID_PREFIX "%d" + +static struct class *hwmon_class; + +static DEFINE_IDR(hwmon_idr); + +/** + * hwmon_device_register - register w/ hwmon sysfs class + * @dev: the device to register + * + * hwmon_device_unregister() must be called when the class device is no + * longer needed. + * + * Returns the pointer to the new struct class device. + */ +struct class_device *hwmon_device_register(struct device *dev) +{ + struct class_device *cdev; + int id; + + if (idr_pre_get(&hwmon_idr, GFP_KERNEL) == 0) + return ERR_PTR(-ENOMEM); + + if (idr_get_new(&hwmon_idr, NULL, &id) < 0) + return ERR_PTR(-ENOMEM); + + id = id & MAX_ID_MASK; + cdev = class_device_create(hwmon_class, MKDEV(0,0), dev, + HWMON_ID_FORMAT, id); + + if (IS_ERR(cdev)) + idr_remove(&hwmon_idr, id); + + return cdev; +} + +/** + * hwmon_device_unregister - removes the previously registered class device + * + * @cdev: the class device to destroy + */ +void hwmon_device_unregister(struct class_device *cdev) +{ + int id; + + if (sscanf(cdev->class_id, HWMON_ID_FORMAT, &id) == 1) { + class_device_unregister(cdev); + idr_remove(&hwmon_idr, id); + } else + dev_dbg(cdev->dev, + "hwmon_device_unregister() failed: bad class ID!\n"); +} + +static int __init hwmon_init(void) +{ + hwmon_class = class_create(THIS_MODULE, "hwmon"); + if (IS_ERR(hwmon_class)) { + printk(KERN_ERR "hwmon.c: couldn't create sysfs class\n"); + return PTR_ERR(hwmon_class); + } + return 0; +} + +static void __exit hwmon_exit(void) +{ + class_destroy(hwmon_class); +} + +module_init(hwmon_init); +module_exit(hwmon_exit); + +EXPORT_SYMBOL_GPL(hwmon_device_register); +EXPORT_SYMBOL_GPL(hwmon_device_unregister); + +MODULE_AUTHOR("Mark M. Hoffman "); +MODULE_DESCRIPTION("hardware monitoring sysfs/class support"); +MODULE_LICENSE("GPL"); + diff --git a/include/linux/hwmon.h b/include/linux/hwmon.h new file mode 100644 index 000000000000..bf90e6001e3b --- /dev/null +++ b/include/linux/hwmon.h @@ -0,0 +1,24 @@ +/* + hwmon.h - part of lm_sensors, Linux kernel modules for hardware monitoring + + This file declares helper functions for the sysfs class "hwmon", + for use by sensors drivers. + + Copyright (C) 2005 Mark M. Hoffman + + 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; version 2 of the License. +*/ + +#ifndef _HWMON_H_ +#define _HWMON_H_ + +#include + +struct class_device *hwmon_device_register(struct device *dev); + +void hwmon_device_unregister(struct class_device *cdev); + +#endif + -- cgit v1.2.2 From 943b0830cebe4711354945ed3cb44e84152aaca0 Mon Sep 17 00:00:00 2001 From: "Mark M. Hoffman" Date: Fri, 15 Jul 2005 21:39:18 -0400 Subject: [PATCH] I2C hwmon: add hwmon sysfs class to drivers This patch modifies sensors chip drivers to make use of the new sysfs class "hwmon". Signed-off-by: Mark M. Hoffman Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/adm1021.c | 16 +++++++++++++++- drivers/hwmon/adm1025.c | 16 +++++++++++++++- drivers/hwmon/adm1026.c | 15 ++++++++++++++- drivers/hwmon/adm1031.c | 16 +++++++++++++++- drivers/hwmon/adm9240.c | 17 ++++++++++++++++- drivers/hwmon/asb100.c | 31 +++++++++++++++++++++++++------ drivers/hwmon/atxp1.c | 16 +++++++++++++++- drivers/hwmon/ds1621.c | 16 +++++++++++++++- drivers/hwmon/fscher.c | 16 +++++++++++++++- drivers/hwmon/fscpos.c | 16 +++++++++++++++- drivers/hwmon/gl518sm.c | 17 +++++++++++++++-- drivers/hwmon/gl520sm.c | 16 +++++++++++++++- drivers/hwmon/it87.c | 16 +++++++++++++++- drivers/hwmon/lm63.c | 16 +++++++++++++++- drivers/hwmon/lm75.c | 15 ++++++++++++++- drivers/hwmon/lm77.c | 16 ++++++++++++++-- drivers/hwmon/lm78.c | 16 +++++++++++++++- drivers/hwmon/lm80.c | 16 +++++++++++++++- drivers/hwmon/lm83.c | 16 +++++++++++++++- drivers/hwmon/lm85.c | 15 ++++++++++++++- drivers/hwmon/lm87.c | 16 +++++++++++++++- drivers/hwmon/lm90.c | 16 +++++++++++++++- drivers/hwmon/lm92.c | 17 +++++++++++++++-- drivers/hwmon/max1619.c | 17 +++++++++++++++-- drivers/hwmon/pc87360.c | 13 +++++++++++++ drivers/hwmon/sis5595.c | 18 ++++++++++++++++-- drivers/hwmon/smsc47b397.c | 16 +++++++++++++++- drivers/hwmon/smsc47m1.c | 17 ++++++++++++++++- drivers/hwmon/via686a.c | 24 +++++++++++++++++++----- drivers/hwmon/w83627ehf.c | 16 +++++++++++++++- drivers/hwmon/w83627hf.c | 16 +++++++++++++++- drivers/hwmon/w83781d.c | 39 +++++++++++++++++++++++++++++++-------- drivers/hwmon/w83l785ts.c | 16 +++++++++++++++- 33 files changed, 522 insertions(+), 53 deletions(-) diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c index d2c774c32f45..a483d96e4cef 100644 --- a/drivers/hwmon/adm1021.c +++ b/drivers/hwmon/adm1021.c @@ -25,6 +25,8 @@ #include #include #include +#include +#include /* Addresses to scan */ @@ -89,6 +91,7 @@ clearing it. Weird, ey? --Phil */ /* Each client has this additional data */ struct adm1021_data { struct i2c_client client; + struct class_device *class_dev; enum chips type; struct semaphore update_lock; @@ -295,6 +298,12 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind) adm1021_init_client(new_client); /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto error2; + } + device_create_file(&new_client->dev, &dev_attr_temp1_max); device_create_file(&new_client->dev, &dev_attr_temp1_min); device_create_file(&new_client->dev, &dev_attr_temp1_input); @@ -305,6 +314,8 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +error2: + i2c_detach_client(new_client); error1: kfree(data); error0: @@ -322,14 +333,17 @@ static void adm1021_init_client(struct i2c_client *client) static int adm1021_detach_client(struct i2c_client *client) { + struct adm1021_data *data = i2c_get_clientdata(client); int err; + hwmon_device_unregister(data->class_dev); + if ((err = i2c_detach_client(client))) { dev_err(&client->dev, "Client deregistration failed, client not detached.\n"); return err; } - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c index e452d0daf906..b68b292c00d4 100644 --- a/drivers/hwmon/adm1025.c +++ b/drivers/hwmon/adm1025.c @@ -52,6 +52,8 @@ #include #include #include +#include +#include /* * Addresses to scan @@ -132,6 +134,7 @@ static struct i2c_driver adm1025_driver = { struct adm1025_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore update_lock; char valid; /* zero until following fields are valid */ unsigned long last_updated; /* in jiffies */ @@ -416,6 +419,12 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind) adm1025_init_client(new_client); /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto exit_detach; + } + device_create_file(&new_client->dev, &dev_attr_in0_input); device_create_file(&new_client->dev, &dev_attr_in1_input); device_create_file(&new_client->dev, &dev_attr_in2_input); @@ -452,6 +461,8 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +exit_detach: + i2c_detach_client(new_client); exit_free: kfree(data); exit: @@ -502,15 +513,18 @@ static void adm1025_init_client(struct i2c_client *client) static int adm1025_detach_client(struct i2c_client *client) { + struct adm1025_data *data = i2c_get_clientdata(client); int err; + hwmon_device_unregister(data->class_dev); + if ((err = i2c_detach_client(client))) { dev_err(&client->dev, "Client deregistration failed, " "client not detached.\n"); return err; } - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c index c8a7f47911f9..eb55133a13ee 100644 --- a/drivers/hwmon/adm1026.c +++ b/drivers/hwmon/adm1026.c @@ -31,6 +31,8 @@ #include #include #include +#include +#include /* Addresses to scan */ static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; @@ -259,6 +261,7 @@ struct pwm_data { struct adm1026_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore lock; enum chips type; @@ -324,8 +327,10 @@ int adm1026_attach_adapter(struct i2c_adapter *adapter) int adm1026_detach_client(struct i2c_client *client) { + struct adm1026_data *data = i2c_get_clientdata(client); + hwmon_device_unregister(data->class_dev); i2c_detach_client(client); - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } @@ -1555,6 +1560,12 @@ int adm1026_detect(struct i2c_adapter *adapter, int address, adm1026_init_client(new_client); /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto exitdetach; + } + device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr); device_create_file(&new_client->dev, &sensor_dev_attr_in0_max.dev_attr); device_create_file(&new_client->dev, &sensor_dev_attr_in0_min.dev_attr); @@ -1690,6 +1701,8 @@ int adm1026_detect(struct i2c_adapter *adapter, int address, return 0; /* Error out and cleanup code */ +exitdetach: + i2c_detach_client(new_client); exitfree: kfree(data); exit: diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c index 936250957270..ac3b1542556e 100644 --- a/drivers/hwmon/adm1031.c +++ b/drivers/hwmon/adm1031.c @@ -27,6 +27,8 @@ #include #include #include +#include +#include /* Following macros takes channel parameter starting from 0 to 2 */ #define ADM1031_REG_FAN_SPEED(nr) (0x08 + (nr)) @@ -69,6 +71,7 @@ typedef u8 auto_chan_table_t[8][2]; /* Each client has this additional data */ struct adm1031_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore update_lock; int chip_type; char valid; /* !=0 if following fields are valid */ @@ -788,6 +791,12 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind) adm1031_init_client(new_client); /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto exit_detach; + } + device_create_file(&new_client->dev, &dev_attr_fan1_input); device_create_file(&new_client->dev, &dev_attr_fan1_div); device_create_file(&new_client->dev, &dev_attr_fan1_min); @@ -833,6 +842,8 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +exit_detach: + i2c_detach_client(new_client); exit_free: kfree(data); exit: @@ -841,11 +852,14 @@ exit: static int adm1031_detach_client(struct i2c_client *client) { + struct adm1031_data *data = i2c_get_clientdata(client); int ret; + + hwmon_device_unregister(data->class_dev); if ((ret = i2c_detach_client(client)) != 0) { return ret; } - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c index ce2a6eb93f6e..7ef61206ba10 100644 --- a/drivers/hwmon/adm9240.c +++ b/drivers/hwmon/adm9240.c @@ -47,6 +47,8 @@ #include #include #include +#include +#include /* Addresses to scan */ static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, @@ -150,6 +152,7 @@ static struct i2c_driver adm9240_driver = { struct adm9240_data { enum chips type; struct i2c_client client; + struct class_device *class_dev; struct semaphore update_lock; char valid; unsigned long last_updated_measure; @@ -582,6 +585,12 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) adm9240_init_client(new_client); /* populate sysfs filesystem */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto exit_detach; + } + device_create_file(&new_client->dev, &dev_attr_in0_input); device_create_file(&new_client->dev, &dev_attr_in0_min); device_create_file(&new_client->dev, &dev_attr_in0_max); @@ -615,6 +624,9 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) device_create_file(&new_client->dev, &dev_attr_cpu0_vid); return 0; + +exit_detach: + i2c_detach_client(new_client); exit_free: kfree(data); exit: @@ -630,15 +642,18 @@ static int adm9240_attach_adapter(struct i2c_adapter *adapter) static int adm9240_detach_client(struct i2c_client *client) { + struct adm9240_data *data = i2c_get_clientdata(client); int err; + hwmon_device_unregister(data->class_dev); + if ((err = i2c_detach_client(client))) { dev_err(&client->dev, "Client deregistration failed, " "client not detached.\n"); return err; } - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c index 70d996d6fe0a..3ab7a2ddafba 100644 --- a/drivers/hwmon/asb100.c +++ b/drivers/hwmon/asb100.c @@ -41,6 +41,8 @@ #include #include #include +#include +#include #include #include #include "lm75.h" @@ -183,6 +185,7 @@ static u8 DIV_TO_REG(long val) dynamically allocated, at the same time the client itself is allocated. */ struct asb100_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore lock; enum chips type; @@ -821,6 +824,12 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind) data->fan_min[2] = asb100_read_value(new_client, ASB100_REG_FAN_MIN(2)); /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto ERROR3; + } + device_create_file_in(new_client, 0); device_create_file_in(new_client, 1); device_create_file_in(new_client, 2); @@ -847,6 +856,11 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +ERROR3: + i2c_detach_client(data->lm75[1]); + i2c_detach_client(data->lm75[0]); + kfree(data->lm75[1]); + kfree(data->lm75[0]); ERROR2: i2c_detach_client(new_client); ERROR1: @@ -857,21 +871,26 @@ ERROR0: static int asb100_detach_client(struct i2c_client *client) { + struct asb100_data *data = i2c_get_clientdata(client); int err; + /* main client */ + if (data) + hwmon_device_unregister(data->class_dev); + if ((err = i2c_detach_client(client))) { dev_err(&client->dev, "client deregistration failed; " "client not detached.\n"); return err; } - if (i2c_get_clientdata(client)==NULL) { - /* subclients */ + /* main client */ + if (data) + kfree(data); + + /* subclient */ + else kfree(client); - } else { - /* main client */ - kfree(i2c_get_clientdata(client)); - } return 0; } diff --git a/drivers/hwmon/atxp1.c b/drivers/hwmon/atxp1.c index fca3fc1cef72..5f79f07a4ab8 100644 --- a/drivers/hwmon/atxp1.c +++ b/drivers/hwmon/atxp1.c @@ -25,6 +25,8 @@ #include #include #include +#include +#include MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("System voltages control via Attansic ATXP1"); @@ -59,6 +61,7 @@ static struct i2c_driver atxp1_driver = { struct atxp1_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore update_lock; unsigned long last_updated; u8 valid; @@ -317,6 +320,12 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind) goto exit_free; } + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto exit_detach; + } + device_create_file(&new_client->dev, &dev_attr_gpio1); device_create_file(&new_client->dev, &dev_attr_gpio2); device_create_file(&new_client->dev, &dev_attr_cpu0_vid); @@ -326,6 +335,8 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +exit_detach: + i2c_detach_client(new_client); exit_free: kfree(data); exit: @@ -334,14 +345,17 @@ exit: static int atxp1_detach_client(struct i2c_client * client) { + struct atxp1_data * data = i2c_get_clientdata(client); int err; + hwmon_device_unregister(data->class_dev); + err = i2c_detach_client(client); if (err) dev_err(&client->dev, "Failed to detach client.\n"); else - kfree(i2c_get_clientdata(client)); + kfree(data); return err; }; diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c index 5360d58804f6..9ed21ac46e97 100644 --- a/drivers/hwmon/ds1621.c +++ b/drivers/hwmon/ds1621.c @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include "lm75.h" /* Addresses to scan */ @@ -71,6 +73,7 @@ MODULE_PARM_DESC(polarity, "Output's polarity: 0 = active high, 1 = active low") /* Each client has this additional data */ struct ds1621_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore update_lock; char valid; /* !=0 if following fields are valid */ unsigned long last_updated; /* In jiffies */ @@ -250,6 +253,12 @@ int ds1621_detect(struct i2c_adapter *adapter, int address, ds1621_init_client(new_client); /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto exit_detach; + } + device_create_file(&new_client->dev, &dev_attr_alarms); device_create_file(&new_client->dev, &dev_attr_temp1_input); device_create_file(&new_client->dev, &dev_attr_temp1_min); @@ -259,6 +268,8 @@ int ds1621_detect(struct i2c_adapter *adapter, int address, /* OK, this is not exactly good programming practice, usually. But it is very code-efficient in this case. */ + exit_detach: + i2c_detach_client(new_client); exit_free: kfree(data); exit: @@ -267,15 +278,18 @@ int ds1621_detect(struct i2c_adapter *adapter, int address, static int ds1621_detach_client(struct i2c_client *client) { + struct ds1621_data *data = i2c_get_clientdata(client); int err; + hwmon_device_unregister(data->class_dev); + if ((err = i2c_detach_client(client))) { dev_err(&client->dev, "Client deregistration failed, " "client not detached.\n"); return err; } - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } diff --git a/drivers/hwmon/fscher.c b/drivers/hwmon/fscher.c index da411741c2c5..b794580a0726 100644 --- a/drivers/hwmon/fscher.c +++ b/drivers/hwmon/fscher.c @@ -32,6 +32,8 @@ #include #include #include +#include +#include /* * Addresses to scan @@ -132,6 +134,7 @@ static struct i2c_driver fscher_driver = { struct fscher_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore update_lock; char valid; /* zero until following fields are valid */ unsigned long last_updated; /* in jiffies */ @@ -341,6 +344,12 @@ static int fscher_detect(struct i2c_adapter *adapter, int address, int kind) fscher_init_client(new_client); /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto exit_detach; + } + device_create_file_revision(new_client); device_create_file_alarms(new_client); device_create_file_control(new_client); @@ -360,6 +369,8 @@ static int fscher_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +exit_detach: + i2c_detach_client(new_client); exit_free: kfree(data); exit: @@ -368,15 +379,18 @@ exit: static int fscher_detach_client(struct i2c_client *client) { + struct fscher_data *data = i2c_get_clientdata(client); int err; + hwmon_device_unregister(data->class_dev); + if ((err = i2c_detach_client(client))) { dev_err(&client->dev, "Client deregistration failed, " "client not detached.\n"); return err; } - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } diff --git a/drivers/hwmon/fscpos.c b/drivers/hwmon/fscpos.c index 301ae98bd0ad..4cb33b231124 100644 --- a/drivers/hwmon/fscpos.c +++ b/drivers/hwmon/fscpos.c @@ -36,6 +36,8 @@ #include #include #include +#include +#include /* * Addresses to scan @@ -113,6 +115,7 @@ static struct i2c_driver fscpos_driver = { */ struct fscpos_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore update_lock; char valid; /* 0 until following fields are valid */ unsigned long last_updated; /* In jiffies */ @@ -496,6 +499,12 @@ int fscpos_detect(struct i2c_adapter *adapter, int address, int kind) dev_info(&new_client->dev, "Found fscpos chip, rev %u\n", data->revision); /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto exit_detach; + } + device_create_file(&new_client->dev, &dev_attr_event); device_create_file(&new_client->dev, &dev_attr_in0_input); device_create_file(&new_client->dev, &dev_attr_in1_input); @@ -526,6 +535,8 @@ int fscpos_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +exit_detach: + i2c_detach_client(new_client); exit_free: kfree(data); exit: @@ -534,14 +545,17 @@ exit: static int fscpos_detach_client(struct i2c_client *client) { + struct fscpos_data *data = i2c_get_clientdata(client); int err; + hwmon_device_unregister(data->class_dev); + if ((err = i2c_detach_client(client))) { dev_err(&client->dev, "Client deregistration failed, client" " not detached.\n"); return err; } - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c index 6bedf729dcf5..49972929a69b 100644 --- a/drivers/hwmon/gl518sm.c +++ b/drivers/hwmon/gl518sm.c @@ -42,6 +42,8 @@ #include #include #include +#include +#include /* Addresses to scan */ static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; @@ -117,6 +119,7 @@ static inline u8 FAN_TO_REG(long rpm, int div) /* Each client has this additional data */ struct gl518_data { struct i2c_client client; + struct class_device *class_dev; enum chips type; struct semaphore update_lock; @@ -419,6 +422,12 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind) gl518_init_client((struct i2c_client *) new_client); /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto exit_detach; + } + device_create_file(&new_client->dev, &dev_attr_in0_input); device_create_file(&new_client->dev, &dev_attr_in1_input); device_create_file(&new_client->dev, &dev_attr_in2_input); @@ -450,6 +459,8 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind) /* OK, this is not exactly good programming practice, usually. But it is very code-efficient in this case. */ +exit_detach: + i2c_detach_client(new_client); exit_free: kfree(data); exit: @@ -477,16 +488,18 @@ static void gl518_init_client(struct i2c_client *client) static int gl518_detach_client(struct i2c_client *client) { + struct gl518_data *data = i2c_get_clientdata(client); int err; + hwmon_device_unregister(data->class_dev); + if ((err = i2c_detach_client(client))) { dev_err(&client->dev, "Client deregistration failed, " "client not detached.\n"); return err; } - kfree(i2c_get_clientdata(client)); - + kfree(data); return 0; } diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c index 80ae8d30c2af..ce482e17e03c 100644 --- a/drivers/hwmon/gl520sm.c +++ b/drivers/hwmon/gl520sm.c @@ -28,6 +28,8 @@ #include #include #include +#include +#include /* Type of the extra sensor */ static unsigned short extra_sensor_type; @@ -120,6 +122,7 @@ static struct i2c_driver gl520_driver = { /* Client data */ struct gl520_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore update_lock; char valid; /* zero until the following fields are valid */ unsigned long last_updated; /* in jiffies */ @@ -571,6 +574,12 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind) gl520_init_client(new_client); /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto exit_detach; + } + device_create_file_vid(new_client, 0); device_create_file_in(new_client, 0); @@ -592,6 +601,8 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +exit_detach: + i2c_detach_client(new_client); exit_free: kfree(data); exit: @@ -639,15 +650,18 @@ static void gl520_init_client(struct i2c_client *client) static int gl520_detach_client(struct i2c_client *client) { + struct gl520_data *data = i2c_get_clientdata(client); int err; + hwmon_device_unregister(data->class_dev); + if ((err = i2c_detach_client(client))) { dev_err(&client->dev, "Client deregistration failed, " "client not detached.\n"); return err; } - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index db20c9e47393..92c5b2420f9b 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -39,6 +39,8 @@ #include #include #include +#include +#include #include @@ -192,6 +194,7 @@ static int DIV_TO_REG(int val) allocated. */ struct it87_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore lock; enum chips type; @@ -840,6 +843,12 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind) it87_init_client(new_client, data); /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto ERROR3; + } + device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr); device_create_file(&new_client->dev, &sensor_dev_attr_in1_input.dev_attr); device_create_file(&new_client->dev, &sensor_dev_attr_in2_input.dev_attr); @@ -904,6 +913,8 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +ERROR3: + i2c_detach_client(new_client); ERROR2: kfree(data); ERROR1: @@ -915,8 +926,11 @@ ERROR0: static int it87_detach_client(struct i2c_client *client) { + struct it87_data *data = i2c_get_clientdata(client); int err; + hwmon_device_unregister(data->class_dev); + if ((err = i2c_detach_client(client))) { dev_err(&client->dev, "Client deregistration failed, client not detached.\n"); @@ -925,7 +939,7 @@ static int it87_detach_client(struct i2c_client *client) if(i2c_is_isa_client(client)) release_region(client->addr, IT87_EXTENT); - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c index 7c6f9ea5a254..cba0a40ad667 100644 --- a/drivers/hwmon/lm63.c +++ b/drivers/hwmon/lm63.c @@ -44,6 +44,8 @@ #include #include #include +#include +#include /* * Addresses to scan @@ -152,6 +154,7 @@ static struct i2c_driver lm63_driver = { struct lm63_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore update_lock; char valid; /* zero until following fields are valid */ unsigned long last_updated; /* in jiffies */ @@ -437,6 +440,12 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind) lm63_init_client(new_client); /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto exit_detach; + } + if (data->config & 0x04) { /* tachometer enabled */ device_create_file(&new_client->dev, &sensor_dev_attr_fan1_input.dev_attr); @@ -462,6 +471,8 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +exit_detach: + i2c_detach_client(new_client); exit_free: kfree(data); exit: @@ -505,15 +516,18 @@ static void lm63_init_client(struct i2c_client *client) static int lm63_detach_client(struct i2c_client *client) { + struct lm63_data *data = i2c_get_clientdata(client); int err; + hwmon_device_unregister(data->class_dev); + if ((err = i2c_detach_client(client))) { dev_err(&client->dev, "Client deregistration failed, " "client not detached\n"); return err; } - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index 79d7ebc9b14a..129c8f213331 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include "lm75.h" @@ -46,6 +48,7 @@ SENSORS_INSMOD_1(lm75); /* Each client has this additional data */ struct lm75_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore update_lock; char valid; /* !=0 if following fields are valid */ unsigned long last_updated; /* In jiffies */ @@ -208,12 +211,20 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, int kind) lm75_init_client(new_client); /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto exit_detach; + } + device_create_file(&new_client->dev, &dev_attr_temp1_max); device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst); device_create_file(&new_client->dev, &dev_attr_temp1_input); return 0; +exit_detach: + i2c_detach_client(new_client); exit_free: kfree(data); exit: @@ -222,8 +233,10 @@ exit: static int lm75_detach_client(struct i2c_client *client) { + struct lm75_data *data = i2c_get_clientdata(client); + hwmon_device_unregister(data->class_dev); i2c_detach_client(client); - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c index b98f44952997..15f30fdc75c6 100644 --- a/drivers/hwmon/lm77.c +++ b/drivers/hwmon/lm77.c @@ -31,7 +31,8 @@ #include #include #include - +#include +#include /* Addresses to scan */ static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, I2C_CLIENT_END }; @@ -51,6 +52,7 @@ SENSORS_INSMOD_1(lm77); /* Each client has this additional data */ struct lm77_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore update_lock; char valid; unsigned long last_updated; /* In jiffies */ @@ -317,6 +319,12 @@ static int lm77_detect(struct i2c_adapter *adapter, int address, int kind) lm77_init_client(new_client); /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto exit_detach; + } + device_create_file(&new_client->dev, &dev_attr_temp1_input); device_create_file(&new_client->dev, &dev_attr_temp1_crit); device_create_file(&new_client->dev, &dev_attr_temp1_min); @@ -327,6 +335,8 @@ static int lm77_detect(struct i2c_adapter *adapter, int address, int kind) device_create_file(&new_client->dev, &dev_attr_alarms); return 0; +exit_detach: + i2c_detach_client(new_client); exit_free: kfree(data); exit: @@ -335,8 +345,10 @@ exit: static int lm77_detach_client(struct i2c_client *client) { + struct lm77_data *data = i2c_get_clientdata(client); + hwmon_device_unregister(data->class_dev); i2c_detach_client(client); - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c index cf7a2a7f54b5..570098e15366 100644 --- a/drivers/hwmon/lm78.c +++ b/drivers/hwmon/lm78.c @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include /* Addresses to scan */ @@ -134,6 +136,7 @@ static inline int VID_FROM_REG(u8 val) allocated. */ struct lm78_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore lock; enum chips type; @@ -602,6 +605,12 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind) } /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto ERROR3; + } + device_create_file(&new_client->dev, &dev_attr_in0_input); device_create_file(&new_client->dev, &dev_attr_in0_min); device_create_file(&new_client->dev, &dev_attr_in0_max); @@ -640,6 +649,8 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +ERROR3: + i2c_detach_client(new_client); ERROR2: kfree(data); ERROR1: @@ -651,8 +662,11 @@ ERROR0: static int lm78_detach_client(struct i2c_client *client) { + struct lm78_data *data = i2c_get_clientdata(client); int err; + hwmon_device_unregister(data->class_dev); + if ((err = i2c_detach_client(client))) { dev_err(&client->dev, "Client deregistration failed, client not detached.\n"); @@ -662,7 +676,7 @@ static int lm78_detach_client(struct i2c_client *client) if(i2c_is_isa_client(client)) release_region(client->addr, LM78_EXTENT); - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c index 8100595feb44..dbf8df386250 100644 --- a/drivers/hwmon/lm80.c +++ b/drivers/hwmon/lm80.c @@ -27,6 +27,8 @@ #include #include #include +#include +#include /* Addresses to scan */ static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, @@ -107,6 +109,7 @@ static inline long TEMP_FROM_REG(u16 temp) struct lm80_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore update_lock; char valid; /* !=0 if following fields are valid */ unsigned long last_updated; /* In jiffies */ @@ -451,6 +454,12 @@ int lm80_detect(struct i2c_adapter *adapter, int address, int kind) data->fan_min[1] = lm80_read_value(new_client, LM80_REG_FAN_MIN(2)); /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto error_detach; + } + device_create_file(&new_client->dev, &dev_attr_in0_min); device_create_file(&new_client->dev, &dev_attr_in1_min); device_create_file(&new_client->dev, &dev_attr_in2_min); @@ -487,6 +496,8 @@ int lm80_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +error_detach: + i2c_detach_client(new_client); error_free: kfree(data); exit: @@ -495,15 +506,18 @@ exit: static int lm80_detach_client(struct i2c_client *client) { + struct lm80_data *data = i2c_get_clientdata(client); int err; + hwmon_device_unregister(data->class_dev); + if ((err = i2c_detach_client(client))) { dev_err(&client->dev, "Client deregistration failed, " "client not detached.\n"); return err; } - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c index a49008b444c8..f3f3901c7294 100644 --- a/drivers/hwmon/lm83.c +++ b/drivers/hwmon/lm83.c @@ -34,6 +34,8 @@ #include #include #include +#include +#include /* * Addresses to scan @@ -138,6 +140,7 @@ static struct i2c_driver lm83_driver = { struct lm83_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore update_lock; char valid; /* zero until following fields are valid */ unsigned long last_updated; /* in jiffies */ @@ -312,6 +315,12 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind) */ /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto exit_detach; + } + device_create_file(&new_client->dev, &sensor_dev_attr_temp1_input.dev_attr); device_create_file(&new_client->dev, @@ -340,6 +349,8 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +exit_detach: + i2c_detach_client(new_client); exit_free: kfree(data); exit: @@ -348,15 +359,18 @@ exit: static int lm83_detach_client(struct i2c_client *client) { + struct lm83_data *data = i2c_get_clientdata(client); int err; + hwmon_device_unregister(data->class_dev); + if ((err = i2c_detach_client(client))) { dev_err(&client->dev, "Client deregistration failed, client not detached.\n"); return err; } - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index b4d7fd418264..4203f904bbe2 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c @@ -30,6 +30,8 @@ #include #include #include +#include +#include /* Addresses to scan */ static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; @@ -339,6 +341,7 @@ struct lm85_autofan { struct lm85_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore lock; enum chips type; @@ -1166,6 +1169,12 @@ int lm85_detect(struct i2c_adapter *adapter, int address, lm85_init_client(new_client); /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto ERROR2; + } + device_create_file(&new_client->dev, &dev_attr_fan1_input); device_create_file(&new_client->dev, &dev_attr_fan2_input); device_create_file(&new_client->dev, &dev_attr_fan3_input); @@ -1235,6 +1244,8 @@ int lm85_detect(struct i2c_adapter *adapter, int address, return 0; /* Error out and cleanup code */ + ERROR2: + i2c_detach_client(new_client); ERROR1: kfree(data); ERROR0: @@ -1243,8 +1254,10 @@ int lm85_detect(struct i2c_adapter *adapter, int address, int lm85_detach_client(struct i2c_client *client) { + struct lm85_data *data = i2c_get_clientdata(client); + hwmon_device_unregister(data->class_dev); i2c_detach_client(client); - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index 1921ed1af182..7e14858c257b 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c @@ -59,6 +59,8 @@ #include #include #include +#include +#include /* * Addresses to scan @@ -175,6 +177,7 @@ static struct i2c_driver lm87_driver = { struct lm87_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore update_lock; char valid; /* zero until following fields are valid */ unsigned long last_updated; /* In jiffies */ @@ -608,6 +611,12 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind) data->in_scale[7] = 1875; /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto exit_detach; + } + device_create_file(&new_client->dev, &dev_attr_in1_input); device_create_file(&new_client->dev, &dev_attr_in1_min); device_create_file(&new_client->dev, &dev_attr_in1_max); @@ -673,6 +682,8 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +exit_detach: + i2c_detach_client(new_client); exit_free: kfree(data); exit: @@ -719,15 +730,18 @@ static void lm87_init_client(struct i2c_client *client) static int lm87_detach_client(struct i2c_client *client) { + struct lm87_data *data = i2c_get_clientdata(client); int err; + hwmon_device_unregister(data->class_dev); + if ((err = i2c_detach_client(client))) { dev_err(&client->dev, "Client deregistration failed, " "client not detached.\n"); return err; } - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index a67dcadf7cb0..c1e8d0e965f7 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c @@ -77,6 +77,8 @@ #include #include #include +#include +#include /* * Addresses to scan @@ -200,6 +202,7 @@ static struct i2c_driver lm90_driver = { struct lm90_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore update_lock; char valid; /* zero until following fields are valid */ unsigned long last_updated; /* in jiffies */ @@ -500,6 +503,12 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) lm90_init_client(new_client); /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto exit_detach; + } + device_create_file(&new_client->dev, &sensor_dev_attr_temp1_input.dev_attr); device_create_file(&new_client->dev, @@ -524,6 +533,8 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +exit_detach: + i2c_detach_client(new_client); exit_free: kfree(data); exit: @@ -547,15 +558,18 @@ static void lm90_init_client(struct i2c_client *client) static int lm90_detach_client(struct i2c_client *client) { + struct lm90_data *data = i2c_get_clientdata(client); int err; + hwmon_device_unregister(data->class_dev); + if ((err = i2c_detach_client(client))) { dev_err(&client->dev, "Client deregistration failed, " "client not detached.\n"); return err; } - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c index 215c8e40ffdd..0fb601c07519 100644 --- a/drivers/hwmon/lm92.c +++ b/drivers/hwmon/lm92.c @@ -45,7 +45,8 @@ #include #include #include - +#include +#include /* The LM92 and MAX6635 have 2 two-state pins for address selection, resulting in 4 possible addresses. */ @@ -96,6 +97,7 @@ static struct i2c_driver lm92_driver; /* Client data (each client gets its own) */ struct lm92_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore update_lock; char valid; /* zero until following fields are valid */ unsigned long last_updated; /* in jiffies */ @@ -359,6 +361,12 @@ static int lm92_detect(struct i2c_adapter *adapter, int address, int kind) lm92_init_client(new_client); /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto exit_detach; + } + device_create_file(&new_client->dev, &dev_attr_temp1_input); device_create_file(&new_client->dev, &dev_attr_temp1_crit); device_create_file(&new_client->dev, &dev_attr_temp1_crit_hyst); @@ -370,6 +378,8 @@ static int lm92_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +exit_detach: + i2c_detach_client(new_client); exit_free: kfree(data); exit: @@ -385,15 +395,18 @@ static int lm92_attach_adapter(struct i2c_adapter *adapter) static int lm92_detach_client(struct i2c_client *client) { + struct lm92_data *data = i2c_get_clientdata(client); int err; + hwmon_device_unregister(data->class_dev); + if ((err = i2c_detach_client(client))) { dev_err(&client->dev, "Client deregistration failed, " "client not detached.\n"); return err; } - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c index 3c159f1d49ee..56c34c2d3619 100644 --- a/drivers/hwmon/max1619.c +++ b/drivers/hwmon/max1619.c @@ -32,7 +32,8 @@ #include #include #include - +#include +#include static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, @@ -104,6 +105,7 @@ static struct i2c_driver max1619_driver = { struct max1619_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore update_lock; char valid; /* zero until following fields are valid */ unsigned long last_updated; /* in jiffies */ @@ -275,6 +277,12 @@ static int max1619_detect(struct i2c_adapter *adapter, int address, int kind) max1619_init_client(new_client); /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto exit_detach; + } + device_create_file(&new_client->dev, &dev_attr_temp1_input); device_create_file(&new_client->dev, &dev_attr_temp2_input); device_create_file(&new_client->dev, &dev_attr_temp2_min); @@ -285,6 +293,8 @@ static int max1619_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +exit_detach: + i2c_detach_client(new_client); exit_free: kfree(data); exit: @@ -308,15 +318,18 @@ static void max1619_init_client(struct i2c_client *client) static int max1619_detach_client(struct i2c_client *client) { + struct max1619_data *data = i2c_get_clientdata(client); int err; + hwmon_device_unregister(data->class_dev); + if ((err = i2c_detach_client(client))) { dev_err(&client->dev, "Client deregistration failed, " "client not detached.\n"); return err; } - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c index fa4032d53b79..496549bf96b9 100644 --- a/drivers/hwmon/pc87360.c +++ b/drivers/hwmon/pc87360.c @@ -40,6 +40,8 @@ #include #include #include +#include +#include #include static unsigned short normal_i2c[] = { I2C_CLIENT_END }; @@ -186,6 +188,7 @@ static inline u8 PWM_TO_REG(int val, int inv) struct pc87360_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore lock; struct semaphore update_lock; char valid; /* !=0 if following fields are valid */ @@ -838,6 +841,12 @@ int pc87360_detect(struct i2c_adapter *adapter, int address, int kind) } /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto ERROR3; + } + if (data->innr) { device_create_file(&new_client->dev, &dev_attr_in0_input); device_create_file(&new_client->dev, &dev_attr_in1_input); @@ -974,6 +983,8 @@ int pc87360_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +ERROR3: + i2c_detach_client(new_client); ERROR2: for (i = 0; i < 3; i++) { if (data->address[i]) { @@ -990,6 +1001,8 @@ static int pc87360_detach_client(struct i2c_client *client) struct pc87360_data *data = i2c_get_clientdata(client); int i; + hwmon_device_unregister(data->class_dev); + if ((i = i2c_detach_client(client))) { dev_err(&client->dev, "Client deregistration failed, " "client not detached.\n"); diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c index 6bbfc8fb4f13..ea5934f89f05 100644 --- a/drivers/hwmon/sis5595.c +++ b/drivers/hwmon/sis5595.c @@ -56,6 +56,8 @@ #include #include #include +#include +#include #include #include #include @@ -168,6 +170,7 @@ static inline u8 DIV_TO_REG(int val) allocated. */ struct sis5595_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore lock; struct semaphore update_lock; @@ -578,6 +581,12 @@ int sis5595_detect(struct i2c_adapter *adapter, int address, int kind) } /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto exit_detach; + } + device_create_file(&new_client->dev, &dev_attr_in0_input); device_create_file(&new_client->dev, &dev_attr_in0_min); device_create_file(&new_client->dev, &dev_attr_in0_max); @@ -608,7 +617,9 @@ int sis5595_detect(struct i2c_adapter *adapter, int address, int kind) device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst); } return 0; - + +exit_detach: + i2c_detach_client(new_client); exit_free: kfree(data); exit_release: @@ -619,8 +630,11 @@ exit: static int sis5595_detach_client(struct i2c_client *client) { + struct sis5595_data *data = i2c_get_clientdata(client); int err; + hwmon_device_unregister(data->class_dev); + if ((err = i2c_detach_client(client))) { dev_err(&client->dev, "Client deregistration failed, client not detached.\n"); @@ -630,7 +644,7 @@ static int sis5595_detach_client(struct i2c_client *client) if (i2c_is_isa_client(client)) release_region(client->addr, SIS5595_EXTENT); - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c index fdeeb3ab6f2f..96b9eb40f425 100644 --- a/drivers/hwmon/smsc47b397.c +++ b/drivers/hwmon/smsc47b397.c @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include #include @@ -100,6 +102,7 @@ static u8 smsc47b397_reg_temp[] = {0x25, 0x26, 0x27, 0x80}; struct smsc47b397_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore lock; struct semaphore update_lock; @@ -226,8 +229,11 @@ static int smsc47b397_attach_adapter(struct i2c_adapter *adapter) static int smsc47b397_detach_client(struct i2c_client *client) { + struct smsc47b397_data *data = i2c_get_clientdata(client); int err; + hwmon_device_unregister(data->class_dev); + if ((err = i2c_detach_client(client))) { dev_err(&client->dev, "Client deregistration failed, " "client not detached.\n"); @@ -235,7 +241,7 @@ static int smsc47b397_detach_client(struct i2c_client *client) } release_region(client->addr, SMSC_EXTENT); - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } @@ -285,6 +291,12 @@ static int smsc47b397_detect(struct i2c_adapter *adapter, int addr, int kind) if ((err = i2c_attach_client(new_client))) goto error_free; + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto error_detach; + } + device_create_file_temp(new_client, 1); device_create_file_temp(new_client, 2); device_create_file_temp(new_client, 3); @@ -297,6 +309,8 @@ static int smsc47b397_detect(struct i2c_adapter *adapter, int addr, int kind) return 0; +error_detach: + i2c_detach_client(new_client); error_free: kfree(data); error_release: diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c index 7166ad0b2fda..de7c7f804d66 100644 --- a/drivers/hwmon/smsc47m1.c +++ b/drivers/hwmon/smsc47m1.c @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include #include @@ -108,6 +110,7 @@ superio_exit(void) struct smsc47m1_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore lock; struct semaphore update_lock; @@ -461,6 +464,13 @@ static int smsc47m1_detect(struct i2c_adapter *adapter, int address, int kind) function. */ smsc47m1_update_device(&new_client->dev, 1); + /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto error_detach; + } + if (fan1) { device_create_file(&new_client->dev, &dev_attr_fan1_input); device_create_file(&new_client->dev, &dev_attr_fan1_min); @@ -494,6 +504,8 @@ static int smsc47m1_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +error_detach: + i2c_detach_client(new_client); error_free: kfree(data); error_release: @@ -503,8 +515,11 @@ error_release: static int smsc47m1_detach_client(struct i2c_client *client) { + struct smsc47m1_data *data = i2c_get_clientdata(client); int err; + hwmon_device_unregister(data->class_dev); + if ((err = i2c_detach_client(client))) { dev_err(&client->dev, "Client deregistration failed, " "client not detached.\n"); @@ -512,7 +527,7 @@ static int smsc47m1_detach_client(struct i2c_client *client) } release_region(client->addr, SMSC_EXTENT); - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c index 164d47948390..8eb9d084149d 100644 --- a/drivers/hwmon/via686a.c +++ b/drivers/hwmon/via686a.c @@ -36,6 +36,8 @@ #include #include #include +#include +#include #include #include @@ -297,6 +299,7 @@ static inline long TEMP_FROM_REG10(u16 val) via686a client is allocated. */ struct via686a_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore update_lock; char valid; /* !=0 if following fields are valid */ unsigned long last_updated; /* In jiffies */ @@ -637,7 +640,7 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind) if (!(data = kmalloc(sizeof(struct via686a_data), GFP_KERNEL))) { err = -ENOMEM; - goto ERROR0; + goto exit_release; } memset(data, 0, sizeof(struct via686a_data)); @@ -655,12 +658,18 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind) init_MUTEX(&data->update_lock); /* Tell the I2C layer a new client has arrived */ if ((err = i2c_attach_client(new_client))) - goto ERROR3; + goto exit_free; /* Initialize the VIA686A chip */ via686a_init_client(new_client); /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto exit_detach; + } + device_create_file(&new_client->dev, &dev_attr_in0_input); device_create_file(&new_client->dev, &dev_attr_in1_input); device_create_file(&new_client->dev, &dev_attr_in2_input); @@ -695,17 +704,22 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind) return 0; -ERROR3: +exit_detach: + i2c_detach_client(new_client); +exit_free: kfree(data); -ERROR0: +exit_release: release_region(address, VIA686A_EXTENT); return err; } static int via686a_detach_client(struct i2c_client *client) { + struct via686a_data *data = i2c_get_clientdata(client); int err; + hwmon_device_unregister(data->class_dev); + if ((err = i2c_detach_client(client))) { dev_err(&client->dev, "Client deregistration failed, client not detached.\n"); @@ -713,7 +727,7 @@ static int via686a_detach_client(struct i2c_client *client) } release_region(client->addr, VIA686A_EXTENT); - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c index 250f6b059a54..956e7f830aa6 100644 --- a/drivers/hwmon/w83627ehf.c +++ b/drivers/hwmon/w83627ehf.c @@ -41,6 +41,8 @@ #include #include #include +#include +#include #include #include "lm75.h" @@ -177,6 +179,7 @@ temp1_to_reg(int temp) struct w83627ehf_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore lock; struct semaphore update_lock; @@ -723,6 +726,12 @@ static int w83627ehf_detect(struct i2c_adapter *adapter, int address, int kind) data->has_fan |= (1 << 4); /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto exit_detach; + } + device_create_file(&client->dev, &dev_attr_fan1_input); device_create_file(&client->dev, &dev_attr_fan1_min); device_create_file(&client->dev, &dev_attr_fan1_div); @@ -756,6 +765,8 @@ static int w83627ehf_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +exit_detach: + i2c_detach_client(client); exit_free: kfree(data); exit_release: @@ -773,15 +784,18 @@ static int w83627ehf_attach_adapter(struct i2c_adapter *adapter) static int w83627ehf_detach_client(struct i2c_client *client) { + struct w83627ehf_data *data = i2c_get_clientdata(client); int err; + hwmon_device_unregister(data->class_dev); + if ((err = i2c_detach_client(client))) { dev_err(&client->dev, "Client deregistration failed, " "client not detached.\n"); return err; } release_region(client->addr, REGION_LENGTH); - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c index bd87a42e068a..da2f4992ee21 100644 --- a/drivers/hwmon/w83627hf.c +++ b/drivers/hwmon/w83627hf.c @@ -44,6 +44,8 @@ #include #include #include +#include +#include #include #include "lm75.h" @@ -277,6 +279,7 @@ static inline u8 DIV_TO_REG(long val) dynamically allocated, at the same time when a new client is allocated. */ struct w83627hf_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore lock; enum chips type; @@ -1102,6 +1105,12 @@ int w83627hf_detect(struct i2c_adapter *adapter, int address, data->fan_min[2] = w83627hf_read_value(new_client, W83781D_REG_FAN_MIN(3)); /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto ERROR3; + } + device_create_file_in(new_client, 0); if (kind != w83697hf) device_create_file_in(new_client, 1); @@ -1152,6 +1161,8 @@ int w83627hf_detect(struct i2c_adapter *adapter, int address, return 0; + ERROR3: + i2c_detach_client(new_client); ERROR2: kfree(data); ERROR1: @@ -1162,8 +1173,11 @@ int w83627hf_detect(struct i2c_adapter *adapter, int address, static int w83627hf_detach_client(struct i2c_client *client) { + struct w83627hf_data *data = i2c_get_clientdata(client); int err; + hwmon_device_unregister(data->class_dev); + if ((err = i2c_detach_client(client))) { dev_err(&client->dev, "Client deregistration failed, client not detached.\n"); @@ -1171,7 +1185,7 @@ static int w83627hf_detach_client(struct i2c_client *client) } release_region(client->addr, WINB_EXTENT); - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c index 0bb131ce09eb..c83ae769e362 100644 --- a/drivers/hwmon/w83781d.c +++ b/drivers/hwmon/w83781d.c @@ -40,6 +40,8 @@ #include #include #include +#include +#include #include #include "lm75.h" @@ -218,6 +220,7 @@ DIV_TO_REG(long val, enum chips type) allocated. */ struct w83781d_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore lock; enum chips type; @@ -961,10 +964,10 @@ w83781d_detect_subclients(struct i2c_adapter *adapter, int address, int kind, ERROR_SC_3: i2c_detach_client(data->lm75[0]); ERROR_SC_2: - if (NULL != data->lm75[1]) + if (data->lm75[1]) kfree(data->lm75[1]); ERROR_SC_1: - if (NULL != data->lm75[0]) + if (data->lm75[0]) kfree(data->lm75[0]); ERROR_SC_0: return err; @@ -1189,6 +1192,12 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) data->pwmenable[i] = 1; /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto ERROR4; + } + device_create_file_in(new_client, 0); if (kind != w83783s) device_create_file_in(new_client, 1); @@ -1241,6 +1250,15 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +ERROR4: + if (data->lm75[1]) { + i2c_detach_client(data->lm75[1]); + kfree(data->lm75[1]); + } + if (data->lm75[0]) { + i2c_detach_client(data->lm75[0]); + kfree(data->lm75[0]); + } ERROR3: i2c_detach_client(new_client); ERROR2: @@ -1255,8 +1273,13 @@ ERROR0: static int w83781d_detach_client(struct i2c_client *client) { + struct w83781d_data *data = i2c_get_clientdata(client); int err; + /* main client */ + if (data) + hwmon_device_unregister(data->class_dev); + if (i2c_is_isa_client(client)) release_region(client->addr, W83781D_EXTENT); @@ -1266,13 +1289,13 @@ w83781d_detach_client(struct i2c_client *client) return err; } - if (i2c_get_clientdata(client)==NULL) { - /* subclients */ + /* main client */ + if (data) + kfree(data); + + /* subclient */ + else kfree(client); - } else { - /* main client */ - kfree(i2c_get_clientdata(client)); - } return 0; } diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c index 4469d52aba4c..1f763499dac4 100644 --- a/drivers/hwmon/w83l785ts.c +++ b/drivers/hwmon/w83l785ts.c @@ -37,6 +37,8 @@ #include #include #include +#include +#include /* How many retries on register read error */ #define MAX_RETRIES 5 @@ -105,6 +107,7 @@ static struct i2c_driver w83l785ts_driver = { struct w83l785ts_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore update_lock; char valid; /* zero until following fields are valid */ unsigned long last_updated; /* in jiffies */ @@ -239,11 +242,19 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind) */ /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto exit_detach; + } + device_create_file(&new_client->dev, &dev_attr_temp1_input); device_create_file(&new_client->dev, &dev_attr_temp1_max); return 0; +exit_detach: + i2c_detach_client(new_client); exit_free: kfree(data); exit: @@ -252,15 +263,18 @@ exit: static int w83l785ts_detach_client(struct i2c_client *client) { + struct w83l785ts_data *data = i2c_get_clientdata(client); int err; + hwmon_device_unregister(data->class_dev); + if ((err = i2c_detach_client(client))) { dev_err(&client->dev, "Client deregistration failed, " "client not detached.\n"); return err; } - kfree(i2c_get_clientdata(client)); + kfree(data); return 0; } -- cgit v1.2.2 From efde723fdac02111872bff606ef362074fc1efa8 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 20 Jul 2005 23:03:50 +0200 Subject: [PATCH] I2C: Separate non-i2c hwmon drivers from i2c-core (1/9) Temporarily export a few structures and functions from i2c-core, because we will soon need them in i2c-isa. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/i2c-core.c | 14 ++++++++++---- include/linux/i2c.h | 7 +++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 4a9ead277596..7a7837ae3114 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -61,7 +61,7 @@ static int i2c_bus_resume(struct device * dev) return rc; } -static struct bus_type i2c_bus_type = { +struct bus_type i2c_bus_type = { .name = "i2c", .match = i2c_device_match, .suspend = i2c_bus_suspend, @@ -78,13 +78,13 @@ static int i2c_device_remove(struct device *dev) return 0; } -static void i2c_adapter_dev_release(struct device *dev) +void i2c_adapter_dev_release(struct device *dev) { struct i2c_adapter *adap = dev_to_i2c_adapter(dev); complete(&adap->dev_released); } -static struct device_driver i2c_adapter_driver = { +struct device_driver i2c_adapter_driver = { .name = "i2c_adapter", .bus = &i2c_bus_type, .probe = i2c_device_probe, @@ -97,7 +97,7 @@ static void i2c_adapter_class_dev_release(struct class_device *dev) complete(&adap->class_dev_released); } -static struct class i2c_adapter_class = { +struct class i2c_adapter_class = { .name = "i2c-adapter", .release = &i2c_adapter_class_dev_release, }; @@ -1171,6 +1171,12 @@ s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags, } +/* Next four are needed by i2c-isa */ +EXPORT_SYMBOL_GPL(i2c_adapter_dev_release); +EXPORT_SYMBOL_GPL(i2c_adapter_driver); +EXPORT_SYMBOL_GPL(i2c_adapter_class); +EXPORT_SYMBOL_GPL(i2c_bus_type); + EXPORT_SYMBOL(i2c_add_adapter); EXPORT_SYMBOL(i2c_del_adapter); EXPORT_SYMBOL(i2c_add_driver); diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 017445943816..3be06105034c 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -34,6 +34,13 @@ #include /* for struct device */ #include +/* --- For i2c-isa ---------------------------------------------------- */ + +extern void i2c_adapter_dev_release(struct device *dev); +extern struct device_driver i2c_adapter_driver; +extern struct class i2c_adapter_class; +extern struct bus_type i2c_bus_type; + /* --- General options ------------------------------------------------ */ struct i2c_msg; -- cgit v1.2.2 From 400c455eaa0d0819d18cd42a74070e0e238a73dc Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Tue, 19 Jul 2005 23:48:43 +0200 Subject: [PATCH] I2C: Separate non-i2c hwmon drivers from i2c-core (2/9) Convert i2c-isa from a dumb i2c_adapter into a pseudo i2c-core for ISA hardware monitoring drivers. The isa i2c_adapter is no more registered with i2c-core, drivers have to explicitely connect to it using the new i2c_isa_{add,del}_driver interface. At this point, all ISA chip drivers are useless, because they still register with i2c-core in the hope i2c-isa is registered there as well, but it isn't anymore. The fake bus will be named i2c-9191 in sysfs. This is the number it already had internally in various places, so it's not exactly new, except that now the number is seen in userspace as well. This shouldn't be a problem until someone really has 9192 I2C busses in a given system ;) The fake bus will no more show in "i2cdetect -l", as it won't be seen by i2c-dev anymore (not being registered with i2c-core), which is a good thing, as i2cdetect/i2cdump/i2cset cannot operate on this fake bus anyway. Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/busses/i2c-isa.c | 158 ++++++++++++++++++++++++++++++++++++++++--- include/linux/i2c-isa.h | 29 ++++++++ 2 files changed, 177 insertions(+), 10 deletions(-) create mode 100644 include/linux/i2c-isa.h diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c index 00e7f7157b75..a60f4801757e 100644 --- a/drivers/i2c/busses/i2c-isa.c +++ b/drivers/i2c/busses/i2c-isa.c @@ -1,6 +1,8 @@ /* - i2c-isa.c - Part of lm_sensors, Linux kernel modules for hardware - monitoring + i2c-isa.c - an i2c-core-like thing for ISA hardware monitoring chips + Copyright (C) 2005 Jean Delvare + + Based on the i2c-isa pseudo-adapter from the lm_sensors project Copyright (c) 1998, 1999 Frodo Looijaard This program is free software; you can redistribute it and/or modify @@ -18,17 +20,24 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* This implements an i2c algorithm/adapter for ISA bus. Not that this is - on first sight very useful; almost no functionality is preserved. - Except that it makes writing drivers for chips which can be on both - the SMBus and the ISA bus very much easier. See lm78.c for an example - of this. */ +/* This implements an i2c-core-like thing for ISA hardware monitoring + chips. Such chips are linked to the i2c subsystem for historical + reasons (because the early ISA hardware monitoring chips such as the + LM78 had both an I2C and an ISA interface). They used to be + registered with the main i2c-core, but as a first step in the + direction of a clean separation between I2C and ISA chip drivers, + we now have this separate core for ISA ones. It is significantly + more simple than the real one, of course, because we don't have to + handle multiple busses: there is only one (fake) ISA adapter. + It is worth noting that we still rely on i2c-core for some things + at the moment - but hopefully this won't last. */ #include #include #include #include #include +#include static u32 isa_func(struct i2c_adapter *adapter); @@ -53,17 +62,146 @@ static u32 isa_func(struct i2c_adapter *adapter) return 0; } + +/* Copied from i2c-core */ +static ssize_t show_adapter_name(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct i2c_adapter *adap = dev_to_i2c_adapter(dev); + return sprintf(buf, "%s\n", adap->name); +} +static DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL); + +static int i2c_isa_device_probe(struct device *dev) +{ + return -ENODEV; +} + +static int i2c_isa_device_remove(struct device *dev) +{ + return 0; +} + + +/* We implement an interface which resembles i2c_{add,del}_driver, + but for i2c-isa drivers. We don't have to remember and handle lists + of drivers and adapters so this is much more simple, of course. */ + +int i2c_isa_add_driver(struct i2c_driver *driver) +{ + int res; + + /* Add the driver to the list of i2c drivers in the driver core */ + driver->driver.name = driver->name; + driver->driver.bus = &i2c_bus_type; + driver->driver.probe = i2c_isa_device_probe; + driver->driver.remove = i2c_isa_device_remove; + res = driver_register(&driver->driver); + if (res) + return res; + dev_dbg(&isa_adapter.dev, "Driver %s registered\n", driver->name); + + /* Now look for clients */ + driver->attach_adapter(&isa_adapter); + + return 0; +} + +int i2c_isa_del_driver(struct i2c_driver *driver) +{ + struct list_head *item, *_n; + struct i2c_client *client; + int res; + + /* Detach all clients belonging to this one driver */ + list_for_each_safe(item, _n, &isa_adapter.clients) { + client = list_entry(item, struct i2c_client, list); + if (client->driver != driver) + continue; + dev_dbg(&isa_adapter.dev, "Detaching client %s at 0x%x\n", + client->name, client->addr); + if ((res = driver->detach_client(client))) { + dev_err(&isa_adapter.dev, "Failed, driver " + "%s not unregistered!\n", + driver->name); + return res; + } + } + + /* Get the driver off the core list */ + driver_unregister(&driver->driver); + dev_dbg(&isa_adapter.dev, "Driver %s unregistered\n", driver->name); + + return 0; +} + + static int __init i2c_isa_init(void) { - return i2c_add_adapter(&isa_adapter); + init_MUTEX(&isa_adapter.clist_lock); + INIT_LIST_HEAD(&isa_adapter.clients); + + isa_adapter.nr = ANY_I2C_ISA_BUS; + isa_adapter.dev.parent = &platform_bus; + sprintf(isa_adapter.dev.bus_id, "i2c-%d", isa_adapter.nr); + isa_adapter.dev.driver = &i2c_adapter_driver; + isa_adapter.dev.release = &i2c_adapter_dev_release; + device_register(&isa_adapter.dev); + device_create_file(&isa_adapter.dev, &dev_attr_name); + + /* Add this adapter to the i2c_adapter class */ + memset(&isa_adapter.class_dev, 0x00, sizeof(struct class_device)); + isa_adapter.class_dev.dev = &isa_adapter.dev; + isa_adapter.class_dev.class = &i2c_adapter_class; + strlcpy(isa_adapter.class_dev.class_id, isa_adapter.dev.bus_id, + BUS_ID_SIZE); + class_device_register(&isa_adapter.class_dev); + + dev_dbg(&isa_adapter.dev, "%s registered\n", isa_adapter.name); + + return 0; } static void __exit i2c_isa_exit(void) { - i2c_del_adapter(&isa_adapter); +#ifdef DEBUG + struct list_head *item, *_n; + struct i2c_client *client = NULL; +#endif + + /* There should be no more active client */ +#ifdef DEBUG + dev_dbg(&isa_adapter.dev, "Looking for clients\n"); + list_for_each_safe(item, _n, &isa_adapter.clients) { + client = list_entry(item, struct i2c_client, list); + dev_err(&isa_adapter.dev, "Driver %s still has an active " + "ISA client at 0x%x\n", client->driver->name, + client->addr); + } + if (client != NULL) + return; +#endif + + /* Clean up the sysfs representation */ + dev_dbg(&isa_adapter.dev, "Unregistering from sysfs\n"); + init_completion(&isa_adapter.dev_released); + init_completion(&isa_adapter.class_dev_released); + class_device_unregister(&isa_adapter.class_dev); + device_remove_file(&isa_adapter.dev, &dev_attr_name); + device_unregister(&isa_adapter.dev); + + /* Wait for sysfs to drop all references */ + dev_dbg(&isa_adapter.dev, "Waiting for sysfs completion\n"); + wait_for_completion(&isa_adapter.dev_released); + wait_for_completion(&isa_adapter.class_dev_released); + + dev_dbg(&isa_adapter.dev, "%s unregistered\n", isa_adapter.name); } -MODULE_AUTHOR("Frodo Looijaard "); +EXPORT_SYMBOL(i2c_isa_add_driver); +EXPORT_SYMBOL(i2c_isa_del_driver); + +MODULE_AUTHOR("Jean Delvare "); MODULE_DESCRIPTION("ISA bus access through i2c"); MODULE_LICENSE("GPL"); diff --git a/include/linux/i2c-isa.h b/include/linux/i2c-isa.h new file mode 100644 index 000000000000..b5727d7702e1 --- /dev/null +++ b/include/linux/i2c-isa.h @@ -0,0 +1,29 @@ +/* + * i2c-isa.h - definitions for the i2c-isa pseudo-i2c-adapter interface + * + * Copyright (C) 2005 Jean Delvare + * + * 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_ISA_H +#define _LINUX_I2C_ISA_H + +#include + +extern int i2c_isa_add_driver(struct i2c_driver *driver); +extern int i2c_isa_del_driver(struct i2c_driver *driver); + +#endif /* _LINUX_I2C_ISA_H */ -- cgit v1.2.2 From fde0950903ce8cc38a91dd095280decceda2ff82 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Tue, 19 Jul 2005 23:51:07 +0200 Subject: [PATCH] I2C: Separate non-i2c hwmon drivers from i2c-core (3/9) Convert the 10 ISA hardware monitoring drivers (it87, lm78, pc87360, sis5595, smsc47b397, smsc47m1, via686a, w83627hf, w83627ehf, w83781d) to explicitely register with i2c-isa. For hybrid drivers (it87, lm78, w83781d), we now have two separate instances of i2c_driver, one for the I2C interface of the chip, and one for ISA interface. In the long run, the one for ISA will be replaced with a different driver type. At this point, all drivers are working again, except for missing dependencies in Kconfig. Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/it87.c | 29 +++++++++++++++++++++++++---- drivers/hwmon/lm78.c | 29 ++++++++++++++++++++++++++--- drivers/hwmon/pc87360.c | 5 +++-- drivers/hwmon/sis5595.c | 5 +++-- drivers/hwmon/smsc47b397.c | 5 +++-- drivers/hwmon/smsc47m1.c | 5 +++-- drivers/hwmon/via686a.c | 5 +++-- drivers/hwmon/w83627ehf.c | 5 +++-- drivers/hwmon/w83627hf.c | 5 +++-- drivers/hwmon/w83781d.c | 28 +++++++++++++++++++++++++--- 10 files changed, 97 insertions(+), 24 deletions(-) diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index 92c5b2420f9b..a438adb4b09f 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -242,6 +243,14 @@ static struct i2c_driver it87_driver = { .detach_client = it87_detach_client, }; +static struct i2c_driver it87_isa_driver = { + .owner = THIS_MODULE, + .name = "it87-isa", + .attach_adapter = it87_attach_adapter, + .detach_client = it87_detach_client, +}; + + static ssize_t show_in(struct device *dev, struct device_attribute *attr, char *buf) { @@ -741,7 +750,7 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind) /* Reserve the ISA region */ if (is_isa) - if (!request_region(address, IT87_EXTENT, it87_driver.name)) + if (!request_region(address, IT87_EXTENT, it87_isa_driver.name)) goto ERROR0; /* Probe whether there is anything available on this address. Already @@ -787,7 +796,7 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind) i2c_set_clientdata(new_client, data); new_client->addr = address; new_client->adapter = adapter; - new_client->driver = &it87_driver; + new_client->driver = is_isa ? &it87_isa_driver : &it87_driver; new_client->flags = 0; /* Now, we do the remaining detection. */ @@ -1172,16 +1181,28 @@ static struct it87_data *it87_update_device(struct device *dev) static int __init sm_it87_init(void) { - int addr; + int addr, res; if (!it87_find(&addr)) { normal_isa[0] = addr; } - return i2c_add_driver(&it87_driver); + + res = i2c_add_driver(&it87_driver); + if (res) + return res; + + res = i2c_isa_add_driver(&it87_isa_driver); + if (res) { + i2c_del_driver(&it87_driver); + return res; + } + + return 0; } static void __exit sm_it87_exit(void) { + i2c_isa_del_driver(&it87_isa_driver); i2c_del_driver(&it87_driver); } diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c index 570098e15366..a69e7d4670ad 100644 --- a/drivers/hwmon/lm78.c +++ b/drivers/hwmon/lm78.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -177,6 +178,14 @@ static struct i2c_driver lm78_driver = { .detach_client = lm78_detach_client, }; +static struct i2c_driver lm78_isa_driver = { + .owner = THIS_MODULE, + .name = "lm78-isa", + .attach_adapter = lm78_attach_adapter, + .detach_client = lm78_detach_client, +}; + + /* 7 Voltages */ static ssize_t show_in(struct device *dev, char *buf, int nr) { @@ -488,7 +497,8 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind) /* Reserve the ISA region */ if (is_isa) - if (!request_region(address, LM78_EXTENT, lm78_driver.name)) { + if (!request_region(address, LM78_EXTENT, + lm78_isa_driver.name)) { err = -EBUSY; goto ERROR0; } @@ -543,7 +553,7 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind) i2c_set_clientdata(new_client, data); new_client->addr = address; new_client->adapter = adapter; - new_client->driver = &lm78_driver; + new_client->driver = is_isa ? &lm78_isa_driver : &lm78_driver; new_client->flags = 0; /* Now, we do the remaining detection. */ @@ -788,11 +798,24 @@ static struct lm78_data *lm78_update_device(struct device *dev) static int __init sm_lm78_init(void) { - return i2c_add_driver(&lm78_driver); + int res; + + res = i2c_add_driver(&lm78_driver); + if (res) + return res; + + res = i2c_isa_add_driver(&lm78_isa_driver); + if (res) { + i2c_del_driver(&lm78_driver); + return res; + } + + return 0; } static void __exit sm_lm78_exit(void) { + i2c_isa_del_driver(&lm78_isa_driver); i2c_del_driver(&lm78_driver); } diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c index 496549bf96b9..97ffe5b5cf83 100644 --- a/drivers/hwmon/pc87360.c +++ b/drivers/hwmon/pc87360.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -1344,12 +1345,12 @@ static int __init pc87360_init(void) return -ENODEV; } - return i2c_add_driver(&pc87360_driver); + return i2c_isa_add_driver(&pc87360_driver); } static void __exit pc87360_exit(void) { - i2c_del_driver(&pc87360_driver); + i2c_isa_del_driver(&pc87360_driver); } diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c index ea5934f89f05..e5db835d63f0 100644 --- a/drivers/hwmon/sis5595.c +++ b/drivers/hwmon/sis5595.c @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -790,7 +791,7 @@ static int __devinit sis5595_pci_probe(struct pci_dev *dev, normal_isa[0] = addr; s_bridge = pci_dev_get(dev); - if (i2c_add_driver(&sis5595_driver)) { + if (i2c_isa_add_driver(&sis5595_driver)) { pci_dev_put(s_bridge); s_bridge = NULL; } @@ -817,7 +818,7 @@ static void __exit sm_sis5595_exit(void) { pci_unregister_driver(&sis5595_pci_driver); if (s_bridge != NULL) { - i2c_del_driver(&sis5595_driver); + i2c_isa_del_driver(&sis5595_driver); pci_dev_put(s_bridge); s_bridge = NULL; } diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c index 96b9eb40f425..0f965921b8ed 100644 --- a/drivers/hwmon/smsc47b397.c +++ b/drivers/hwmon/smsc47b397.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -350,12 +351,12 @@ static int __init smsc47b397_init(void) if ((ret = smsc47b397_find(normal_isa))) return ret; - return i2c_add_driver(&smsc47b397_driver); + return i2c_isa_add_driver(&smsc47b397_driver); } static void __exit smsc47b397_exit(void) { - i2c_del_driver(&smsc47b397_driver); + i2c_isa_del_driver(&smsc47b397_driver); } MODULE_AUTHOR("Mark M. Hoffman "); diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c index de7c7f804d66..b07d01ecd2e3 100644 --- a/drivers/hwmon/smsc47m1.c +++ b/drivers/hwmon/smsc47m1.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -592,12 +593,12 @@ static int __init sm_smsc47m1_init(void) return -ENODEV; } - return i2c_add_driver(&smsc47m1_driver); + return i2c_isa_add_driver(&smsc47m1_driver); } static void __exit sm_smsc47m1_exit(void) { - i2c_del_driver(&smsc47m1_driver); + i2c_isa_del_driver(&smsc47m1_driver); } MODULE_AUTHOR("Mark D. Studebaker "); diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c index 8eb9d084149d..e6fc43a8ba47 100644 --- a/drivers/hwmon/via686a.c +++ b/drivers/hwmon/via686a.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -846,7 +847,7 @@ static int __devinit via686a_pci_probe(struct pci_dev *dev, normal_isa[0] = addr; s_bridge = pci_dev_get(dev); - if (i2c_add_driver(&via686a_driver)) { + if (i2c_isa_add_driver(&via686a_driver)) { pci_dev_put(s_bridge); s_bridge = NULL; } @@ -873,7 +874,7 @@ static void __exit sm_via686a_exit(void) { pci_unregister_driver(&via686a_pci_driver); if (s_bridge != NULL) { - i2c_del_driver(&via686a_driver); + i2c_isa_del_driver(&via686a_driver); pci_dev_put(s_bridge); s_bridge = NULL; } diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c index 956e7f830aa6..a3c642ef5c42 100644 --- a/drivers/hwmon/w83627ehf.c +++ b/drivers/hwmon/w83627ehf.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -847,12 +848,12 @@ static int __init sensors_w83627ehf_init(void) && w83627ehf_find(0x4e, &normal_isa[0])) return -ENODEV; - return i2c_add_driver(&w83627ehf_driver); + return i2c_isa_add_driver(&w83627ehf_driver); } static void __exit sensors_w83627ehf_exit(void) { - i2c_del_driver(&w83627ehf_driver); + i2c_isa_del_driver(&w83627ehf_driver); } MODULE_AUTHOR("Jean Delvare "); diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c index da2f4992ee21..a2c7cea502cb 100644 --- a/drivers/hwmon/w83627hf.c +++ b/drivers/hwmon/w83627hf.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -1507,12 +1508,12 @@ static int __init sensors_w83627hf_init(void) } normal_isa[0] = addr; - return i2c_add_driver(&w83627hf_driver); + return i2c_isa_add_driver(&w83627hf_driver); } static void __exit sensors_w83627hf_exit(void) { - i2c_del_driver(&w83627hf_driver); + i2c_isa_del_driver(&w83627hf_driver); } MODULE_AUTHOR("Frodo Looijaard , " diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c index c83ae769e362..69b061e2dc00 100644 --- a/drivers/hwmon/w83781d.c +++ b/drivers/hwmon/w83781d.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -276,6 +277,14 @@ static struct i2c_driver w83781d_driver = { .detach_client = w83781d_detach_client, }; +static struct i2c_driver w83781d_isa_driver = { + .owner = THIS_MODULE, + .name = "w83781d-isa", + .attach_adapter = w83781d_attach_adapter, + .detach_client = w83781d_detach_client, +}; + + /* following are the sysfs callback functions */ #define show_in_reg(reg) \ static ssize_t show_##reg (struct device *dev, char *buf, int nr) \ @@ -1002,7 +1011,7 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) if (is_isa) if (!request_region(address, W83781D_EXTENT, - w83781d_driver.name)) { + w83781d_isa_driver.name)) { dev_dbg(&adapter->dev, "Request of region " "0x%x-0x%x for w83781d failed\n", address, address + W83781D_EXTENT - 1); @@ -1060,7 +1069,7 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) new_client->addr = address; init_MUTEX(&data->lock); new_client->adapter = adapter; - new_client->driver = &w83781d_driver; + new_client->driver = is_isa ? &w83781d_isa_driver : &w83781d_driver; new_client->flags = 0; /* Now, we do the remaining detection. */ @@ -1636,12 +1645,25 @@ static struct w83781d_data *w83781d_update_device(struct device *dev) static int __init sensors_w83781d_init(void) { - return i2c_add_driver(&w83781d_driver); + int res; + + res = i2c_add_driver(&w83781d_driver); + if (res) + return res; + + res = i2c_isa_add_driver(&w83781d_isa_driver); + if (res) { + i2c_del_driver(&w83781d_driver); + return res; + } + + return 0; } static void __exit sensors_w83781d_exit(void) { + i2c_isa_del_driver(&w83781d_isa_driver); i2c_del_driver(&w83781d_driver); } -- cgit v1.2.2 From 5042c7d752fe72c6924037058367f63902e68c5c Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Tue, 19 Jul 2005 23:53:07 +0200 Subject: [PATCH] I2C: Separate non-i2c hwmon drivers from i2c-core (4/9) All ISA hardware monitoring drivers (including hybrid drivers) now have a hard dependency on i2c-isa, so they must select I2C_ISA. As a result, CONFIG_I2C_ISA doesn't need to be left visible to the user. The good thing here is that users will stop complaining that some driver doesn't work just because they forgot to compile or load i2c-isa. At this point, all drivers are working again and the cleanup phase can begin. Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/Kconfig | 3 +++ drivers/i2c/busses/Kconfig | 8 +------- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 8c3911313700..29583e1f7a20 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -160,6 +160,7 @@ config SENSORS_IT87 tristate "ITE IT87xx and compatibles" depends on HWMON && I2C select I2C_SENSOR + select I2C_ISA help If you say yes here you get support for ITE IT87xx sensor chips and clones: SiS960. @@ -211,6 +212,7 @@ 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, LM78-J and LM79. @@ -366,6 +368,7 @@ config SENSORS_W83781D tristate "Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F" depends on HWMON && I2C select I2C_SENSOR + select I2C_ISA help If you say yes here you get support for the Winbond W8378x series of sensor chips: the W83781D, W83782D, W83783S and W83627HF, diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 916ba5e40a96..6e9da1372225 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -182,14 +182,8 @@ config I2C_IOP3XX will be called i2c-iop3xx. config I2C_ISA - tristate "ISA Bus support" + tristate depends on I2C - help - If you say yes to this option, support will be included for i2c - interfaces that are on the ISA bus. - - This driver can also be built as a module. If so, the module - will be called i2c-isa. config I2C_ITE tristate "ITE I2C Adapter" -- cgit v1.2.2 From 2d8672c5a6ba0d3f1d8d3ad61ef67868941364f0 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Tue, 19 Jul 2005 23:56:35 +0200 Subject: [PATCH] I2C: Separate non-i2c hwmon drivers from i2c-core (5/9) Call the ISA chip drivers detection function directly instead of relying on i2c_detect. The net effect is that address lists won't be handled anymore, but they were mostly useless in the ISA case anyway (pc87360, smsc47m1, smsc47b397 had already dropped them). We don't need to handle multiple devices, all we may need is a way to force a given address instead of the original one (some drivers already do: sis5595, via686a, w83627hf), and, for drivers supporting multiple chips, a way to force one given kind. All this may be added later on demand, but I actually don't think there will be much demand. Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/it87.c | 16 ++++++++++----- drivers/hwmon/lm78.c | 11 +++++++++-- drivers/hwmon/pc87360.c | 38 +++++++++-------------------------- drivers/hwmon/sis5595.c | 41 +++++++++----------------------------- drivers/hwmon/smsc47b397.c | 48 ++++++++++++--------------------------------- drivers/hwmon/smsc47m1.c | 42 +++++++++------------------------------ drivers/hwmon/via686a.c | 41 ++++++++------------------------------ drivers/hwmon/w83627ehf.c | 35 +++++++++------------------------ drivers/hwmon/w83627hf.c | 49 ++++++++++++---------------------------------- drivers/hwmon/w83781d.c | 12 ++++++++++-- 10 files changed, 98 insertions(+), 235 deletions(-) diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index a438adb4b09f..722ef0cd5c00 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -48,7 +48,8 @@ /* Addresses to scan */ static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END }; +static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; +static unsigned short isa_address = 0x290; /* Insmod parameters */ SENSORS_INSMOD_2(it87, it8712); @@ -222,7 +223,7 @@ struct it87_data { static int it87_attach_adapter(struct i2c_adapter *adapter); -static int it87_find(int *address); +static int it87_isa_attach_adapter(struct i2c_adapter *adapter); static int it87_detect(struct i2c_adapter *adapter, int address, int kind); static int it87_detach_client(struct i2c_client *client); @@ -246,7 +247,7 @@ static struct i2c_driver it87_driver = { static struct i2c_driver it87_isa_driver = { .owner = THIS_MODULE, .name = "it87-isa", - .attach_adapter = it87_attach_adapter, + .attach_adapter = it87_isa_attach_adapter, .detach_client = it87_detach_client, }; @@ -701,7 +702,12 @@ static int it87_attach_adapter(struct i2c_adapter *adapter) return i2c_detect(adapter, &addr_data, it87_detect); } -/* SuperIO detection - will change normal_isa[0] if a chip is found */ +static int it87_isa_attach_adapter(struct i2c_adapter *adapter) +{ + return it87_detect(adapter, isa_address, -1); +} + +/* SuperIO detection - will change isa_address if a chip is found */ static int it87_find(int *address) { int err = -ENODEV; @@ -1184,7 +1190,7 @@ static int __init sm_it87_init(void) int addr, res; if (!it87_find(&addr)) { - normal_isa[0] = addr; + isa_address = addr; } res = i2c_add_driver(&it87_driver); diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c index a69e7d4670ad..c3712f8d9964 100644 --- a/drivers/hwmon/lm78.c +++ b/drivers/hwmon/lm78.c @@ -34,7 +34,8 @@ static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END }; +static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; +static unsigned short isa_address = 0x290; /* Insmod parameters */ SENSORS_INSMOD_2(lm78, lm79); @@ -160,6 +161,7 @@ struct lm78_data { static int lm78_attach_adapter(struct i2c_adapter *adapter); +static int lm78_isa_attach_adapter(struct i2c_adapter *adapter); static int lm78_detect(struct i2c_adapter *adapter, int address, int kind); static int lm78_detach_client(struct i2c_client *client); @@ -181,7 +183,7 @@ static struct i2c_driver lm78_driver = { static struct i2c_driver lm78_isa_driver = { .owner = THIS_MODULE, .name = "lm78-isa", - .attach_adapter = lm78_attach_adapter, + .attach_adapter = lm78_isa_attach_adapter, .detach_client = lm78_detach_client, }; @@ -480,6 +482,11 @@ static int lm78_attach_adapter(struct i2c_adapter *adapter) return i2c_detect(adapter, &addr_data, lm78_detect); } +static int lm78_isa_attach_adapter(struct i2c_adapter *adapter) +{ + return lm78_detect(adapter, isa_address, -1); +} + /* This function is called by i2c_detect */ int lm78_detect(struct i2c_adapter *adapter, int address, int kind) { diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c index 97ffe5b5cf83..4041488de6f1 100644 --- a/drivers/hwmon/pc87360.c +++ b/drivers/hwmon/pc87360.c @@ -39,25 +39,17 @@ #include #include #include -#include #include #include #include #include -static unsigned short normal_i2c[] = { I2C_CLIENT_END }; -static unsigned int normal_isa[] = { 0, I2C_CLIENT_ISA_END }; -static struct i2c_force_data forces[] = {{ NULL }}; static u8 devid; -static unsigned int extra_isa[3]; +static unsigned short address; +static unsigned short extra_isa[3]; static u8 confreg[4]; enum chips { any_chip, pc87360, pc87363, pc87364, pc87365, pc87366 }; -static struct i2c_address_data addr_data = { - .normal_i2c = normal_i2c, - .normal_isa = normal_isa, - .forces = forces, -}; static int init = 1; module_param(init, int, 0); @@ -228,8 +220,7 @@ struct pc87360_data { * Functions declaration */ -static int pc87360_attach_adapter(struct i2c_adapter *adapter); -static int pc87360_detect(struct i2c_adapter *adapter, int address, int kind); +static int pc87360_detect(struct i2c_adapter *adapter); static int pc87360_detach_client(struct i2c_client *client); static int pc87360_read_value(struct pc87360_data *data, u8 ldi, u8 bank, @@ -246,8 +237,7 @@ static struct pc87360_data *pc87360_update_device(struct device *dev); static struct i2c_driver pc87360_driver = { .owner = THIS_MODULE, .name = "pc87360", - .flags = I2C_DF_NOTIFY, - .attach_adapter = pc87360_attach_adapter, + .attach_adapter = pc87360_detect, .detach_client = pc87360_detach_client, }; @@ -636,12 +626,7 @@ static DEVICE_ATTR(alarms_temp, S_IRUGO, show_temp_alarms, NULL); * Device detection, registration and update */ -static int pc87360_attach_adapter(struct i2c_adapter *adapter) -{ - return i2c_detect(adapter, &addr_data, pc87360_detect); -} - -static int pc87360_find(int sioaddr, u8 *devid, int *address) +static int pc87360_find(int sioaddr, u8 *devid, unsigned short *addresses) { u16 val; int i; @@ -687,7 +672,7 @@ static int pc87360_find(int sioaddr, u8 *devid, int *address) continue; } - address[i] = val; + addresses[i] = val; if (i==0) { /* Fans */ confreg[0] = superio_inb(sioaddr, 0xF0); @@ -731,9 +716,7 @@ static int pc87360_find(int sioaddr, u8 *devid, int *address) return 0; } -/* We don't really care about the address. - Read from extra_isa instead. */ -int pc87360_detect(struct i2c_adapter *adapter, int address, int kind) +static int pc87360_detect(struct i2c_adapter *adapter) { int i; struct i2c_client *new_client; @@ -742,9 +725,6 @@ int pc87360_detect(struct i2c_adapter *adapter, int address, int kind) const char *name = "pc87360"; int use_thermistors = 0; - if (!i2c_is_isa_adapter(adapter)) - return -ENODEV; - if (!(data = kmalloc(sizeof(struct pc87360_data), GFP_KERNEL))) return -ENOMEM; memset(data, 0x00, sizeof(struct pc87360_data)); @@ -1334,12 +1314,12 @@ static int __init pc87360_init(void) /* Arbitrarily pick one of the addresses */ for (i = 0; i < 3; i++) { if (extra_isa[i] != 0x0000) { - normal_isa[0] = extra_isa[i]; + address = extra_isa[i]; break; } } - if (normal_isa[0] == 0x0000) { + if (address == 0x0000) { printk(KERN_WARNING "pc87360: No active logical device, " "module not inserted.\n"); return -ENODEV; diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c index e5db835d63f0..67246299a308 100644 --- a/drivers/hwmon/sis5595.c +++ b/drivers/hwmon/sis5595.c @@ -71,14 +71,10 @@ module_param(force_addr, ushort, 0); MODULE_PARM_DESC(force_addr, "Initialize the base address of the sensors"); -/* Addresses to scan. +/* Device address Note that we can't determine the ISA address until we have initialized our module */ -static unsigned short normal_i2c[] = { I2C_CLIENT_END }; -static unsigned int normal_isa[] = { 0x0000, I2C_CLIENT_ISA_END }; - -/* Insmod parameters */ -SENSORS_INSMOD_1(sis5595); +static unsigned short address; /* Many SIS5595 constants specified below */ @@ -194,8 +190,7 @@ struct sis5595_data { static struct pci_dev *s_bridge; /* pointer to the (only) sis5595 */ -static int sis5595_attach_adapter(struct i2c_adapter *adapter); -static int sis5595_detect(struct i2c_adapter *adapter, int address, int kind); +static int sis5595_detect(struct i2c_adapter *adapter); static int sis5595_detach_client(struct i2c_client *client); static int sis5595_read_value(struct i2c_client *client, u8 register); @@ -206,9 +201,7 @@ static void sis5595_init_client(struct i2c_client *client); static struct i2c_driver sis5595_driver = { .owner = THIS_MODULE, .name = "sis5595", - .id = I2C_DRIVERID_SIS5595, - .flags = I2C_DF_NOTIFY, - .attach_adapter = sis5595_attach_adapter, + .attach_adapter = sis5595_detect, .detach_client = sis5595_detach_client, }; @@ -480,14 +473,7 @@ static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, ch static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); /* This is called when the module is loaded */ -static int sis5595_attach_adapter(struct i2c_adapter *adapter) -{ - if (!(adapter->class & I2C_CLASS_HWMON)) - return 0; - return i2c_detect(adapter, &addr_data, sis5595_detect); -} - -int sis5595_detect(struct i2c_adapter *adapter, int address, int kind) +static int sis5595_detect(struct i2c_adapter *adapter) { int err = 0; int i; @@ -496,10 +482,6 @@ int sis5595_detect(struct i2c_adapter *adapter, int address, int kind) char val; u16 a; - /* Make sure we are probing the ISA bus!! */ - if (!i2c_is_isa_adapter(adapter)) - goto exit; - if (force_addr) address = force_addr & ~(SIS5595_EXTENT - 1); /* Reserve the ISA region */ @@ -642,8 +624,7 @@ static int sis5595_detach_client(struct i2c_client *client) return err; } - if (i2c_is_isa_client(client)) - release_region(client->addr, SIS5595_EXTENT); + release_region(client->addr, SIS5595_EXTENT); kfree(data); @@ -760,7 +741,6 @@ static int __devinit sis5595_pci_probe(struct pci_dev *dev, { u16 val; int *i; - int addr = 0; for (i = blacklist; *i != 0; i++) { struct pci_dev *dev; @@ -776,19 +756,16 @@ static int __devinit sis5595_pci_probe(struct pci_dev *dev, pci_read_config_word(dev, SIS5595_BASE_REG, &val)) return -ENODEV; - addr = val & ~(SIS5595_EXTENT - 1); - if (addr == 0 && force_addr == 0) { + address = val & ~(SIS5595_EXTENT - 1); + if (address == 0 && force_addr == 0) { dev_err(&dev->dev, "Base address not set - upgrade BIOS or use force_addr=0xaddr\n"); return -ENODEV; } - if (force_addr) - addr = force_addr; /* so detect will get called */ - if (!addr) { + if (!address) { dev_err(&dev->dev,"No SiS 5595 sensors found.\n"); return -ENODEV; } - normal_isa[0] = addr; s_bridge = pci_dev_get(dev); if (i2c_isa_add_driver(&sis5595_driver)) { diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c index 0f965921b8ed..dddc94a7649b 100644 --- a/drivers/hwmon/smsc47b397.c +++ b/drivers/hwmon/smsc47b397.c @@ -32,25 +32,13 @@ #include #include #include -#include #include #include #include #include -static unsigned short normal_i2c[] = { I2C_CLIENT_END }; /* Address is autodetected, there is no default value */ -static unsigned int normal_isa[] = { 0x0000, I2C_CLIENT_ISA_END }; -static struct i2c_force_data forces[] = {{NULL}}; - -enum chips { any_chip, smsc47b397 }; -static struct i2c_address_data addr_data = { - .normal_i2c = normal_i2c, - .normal_isa = normal_isa, - .probe = normal_i2c, /* cheat */ - .ignore = normal_i2c, /* cheat */ - .forces = forces, -}; +static unsigned short address; /* Super-I/0 registers and commands */ @@ -219,15 +207,6 @@ sysfs_fan(4); #define device_create_file_fan(client, num) \ device_create_file(&client->dev, &dev_attr_fan##num##_input) -static int smsc47b397_detect(struct i2c_adapter *adapter, int addr, int kind); - -static int smsc47b397_attach_adapter(struct i2c_adapter *adapter) -{ - if (!(adapter->class & I2C_CLASS_HWMON)) - return 0; - return i2c_detect(adapter, &addr_data, smsc47b397_detect); -} - static int smsc47b397_detach_client(struct i2c_client *client) { struct smsc47b397_data *data = i2c_get_clientdata(client); @@ -247,27 +226,24 @@ static int smsc47b397_detach_client(struct i2c_client *client) return 0; } +static int smsc47b397_detect(struct i2c_adapter *adapter); + static struct i2c_driver smsc47b397_driver = { .owner = THIS_MODULE, .name = "smsc47b397", - .id = I2C_DRIVERID_SMSC47B397, - .flags = I2C_DF_NOTIFY, - .attach_adapter = smsc47b397_attach_adapter, + .attach_adapter = smsc47b397_detect, .detach_client = smsc47b397_detach_client, }; -static int smsc47b397_detect(struct i2c_adapter *adapter, int addr, int kind) +static int smsc47b397_detect(struct i2c_adapter *adapter) { struct i2c_client *new_client; struct smsc47b397_data *data; int err = 0; - if (!i2c_is_isa_adapter(adapter)) { - return 0; - } - - if (!request_region(addr, SMSC_EXTENT, smsc47b397_driver.name)) { - dev_err(&adapter->dev, "Region 0x%x already in use!\n", addr); + if (!request_region(address, SMSC_EXTENT, smsc47b397_driver.name)) { + dev_err(&adapter->dev, "Region 0x%x already in use!\n", + address); return -EBUSY; } @@ -279,7 +255,7 @@ static int smsc47b397_detect(struct i2c_adapter *adapter, int addr, int kind) new_client = &data->client; i2c_set_clientdata(new_client, data); - new_client->addr = addr; + new_client->addr = address; init_MUTEX(&data->lock); new_client->adapter = adapter; new_client->driver = &smsc47b397_driver; @@ -315,11 +291,11 @@ error_detach: error_free: kfree(data); error_release: - release_region(addr, SMSC_EXTENT); + release_region(address, SMSC_EXTENT); return err; } -static int __init smsc47b397_find(unsigned int *addr) +static int __init smsc47b397_find(unsigned short *addr) { u8 id, rev; @@ -348,7 +324,7 @@ static int __init smsc47b397_init(void) { int ret; - if ((ret = smsc47b397_find(normal_isa))) + if ((ret = smsc47b397_find(&address))) return ret; return i2c_isa_add_driver(&smsc47b397_driver); diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c index b07d01ecd2e3..8126fdd7cbee 100644 --- a/drivers/hwmon/smsc47m1.c +++ b/drivers/hwmon/smsc47m1.c @@ -37,17 +37,8 @@ #include #include -static unsigned short normal_i2c[] = { I2C_CLIENT_END }; /* Address is autodetected, there is no default value */ -static unsigned int normal_isa[] = { 0x0000, I2C_CLIENT_ISA_END }; -static struct i2c_force_data forces[] = {{NULL}}; - -enum chips { any_chip, smsc47m1 }; -static struct i2c_address_data addr_data = { - .normal_i2c = normal_i2c, - .normal_isa = normal_isa, - .forces = forces, -}; +static unsigned short address; /* Super-I/0 registers and commands */ @@ -125,9 +116,7 @@ struct smsc47m1_data { }; -static int smsc47m1_attach_adapter(struct i2c_adapter *adapter); -static int smsc47m1_find(int *address); -static int smsc47m1_detect(struct i2c_adapter *adapter, int address, int kind); +static int smsc47m1_detect(struct i2c_adapter *adapter); static int smsc47m1_detach_client(struct i2c_client *client); static int smsc47m1_read_value(struct i2c_client *client, u8 reg); @@ -140,9 +129,7 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev, static struct i2c_driver smsc47m1_driver = { .owner = THIS_MODULE, .name = "smsc47m1", - .id = I2C_DRIVERID_SMSC47M1, - .flags = I2C_DF_NOTIFY, - .attach_adapter = smsc47m1_attach_adapter, + .attach_adapter = smsc47m1_detect, .detach_client = smsc47m1_detach_client, }; @@ -358,14 +345,7 @@ fan_present(2); static DEVICE_ATTR(alarms, S_IRUGO, get_alarms, NULL); -static int smsc47m1_attach_adapter(struct i2c_adapter *adapter) -{ - if (!(adapter->class & I2C_CLASS_HWMON)) - return 0; - return i2c_detect(adapter, &addr_data, smsc47m1_detect); -} - -static int smsc47m1_find(int *address) +static int smsc47m1_find(unsigned short *addr) { u8 val; @@ -392,10 +372,10 @@ static int smsc47m1_find(int *address) } superio_select(); - *address = (superio_inb(SUPERIO_REG_BASE) << 8) - | superio_inb(SUPERIO_REG_BASE + 1); + *addr = (superio_inb(SUPERIO_REG_BASE) << 8) + | superio_inb(SUPERIO_REG_BASE + 1); val = superio_inb(SUPERIO_REG_ACT); - if (*address == 0 || (val & 0x01) == 0) { + if (*addr == 0 || (val & 0x01) == 0) { printk(KERN_INFO "smsc47m1: Device is disabled, will not use\n"); superio_exit(); return -ENODEV; @@ -405,17 +385,13 @@ static int smsc47m1_find(int *address) return 0; } -static int smsc47m1_detect(struct i2c_adapter *adapter, int address, int kind) +static int smsc47m1_detect(struct i2c_adapter *adapter) { struct i2c_client *new_client; struct smsc47m1_data *data; int err = 0; int fan1, fan2, pwm1, pwm2; - if (!i2c_is_isa_adapter(adapter)) { - return 0; - } - if (!request_region(address, SMSC_EXTENT, smsc47m1_driver.name)) { dev_err(&adapter->dev, "Region 0x%x already in use!\n", address); return -EBUSY; @@ -589,7 +565,7 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev, static int __init sm_smsc47m1_init(void) { - if (smsc47m1_find(normal_isa)) { + if (smsc47m1_find(&address)) { return -ENODEV; } diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c index e6fc43a8ba47..cd3732c36671 100644 --- a/drivers/hwmon/via686a.c +++ b/drivers/hwmon/via686a.c @@ -50,14 +50,10 @@ module_param(force_addr, ushort, 0); MODULE_PARM_DESC(force_addr, "Initialize the base address of the sensors"); -/* Addresses to scan. +/* Device address Note that we can't determine the ISA address until we have initialized our module */ -static unsigned short normal_i2c[] = { I2C_CLIENT_END }; -static unsigned int normal_isa[] = { 0x0000, I2C_CLIENT_ISA_END }; - -/* Insmod parameters */ -SENSORS_INSMOD_1(via686a); +static unsigned short address; /* The Via 686a southbridge has a LM78-like chip integrated on the same IC. @@ -319,8 +315,7 @@ struct via686a_data { static struct pci_dev *s_bridge; /* pointer to the (only) via686a */ -static int via686a_attach_adapter(struct i2c_adapter *adapter); -static int via686a_detect(struct i2c_adapter *adapter, int address, int kind); +static int via686a_detect(struct i2c_adapter *adapter); static int via686a_detach_client(struct i2c_client *client); static inline int via686a_read_value(struct i2c_client *client, u8 reg) @@ -580,22 +575,13 @@ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); static struct i2c_driver via686a_driver = { .owner = THIS_MODULE, .name = "via686a", - .id = I2C_DRIVERID_VIA686A, - .flags = I2C_DF_NOTIFY, - .attach_adapter = via686a_attach_adapter, + .attach_adapter = via686a_detect, .detach_client = via686a_detach_client, }; /* This is called when the module is loaded */ -static int via686a_attach_adapter(struct i2c_adapter *adapter) -{ - if (!(adapter->class & I2C_CLASS_HWMON)) - return 0; - return i2c_detect(adapter, &addr_data, via686a_detect); -} - -static int via686a_detect(struct i2c_adapter *adapter, int address, int kind) +static int via686a_detect(struct i2c_adapter *adapter) { struct i2c_client *new_client; struct via686a_data *data; @@ -603,13 +589,6 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind) const char client_name[] = "via686a"; u16 val; - /* Make sure we are probing the ISA bus!! */ - if (!i2c_is_isa_adapter(adapter)) { - dev_err(&adapter->dev, - "via686a_detect called for an I2C bus adapter?!?\n"); - return 0; - } - /* 8231 requires multiple of 256, we enforce that on 686 as well */ if (force_addr) address = force_addr & 0xFF00; @@ -825,26 +804,22 @@ static int __devinit via686a_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) { u16 val; - int addr = 0; if (PCIBIOS_SUCCESSFUL != pci_read_config_word(dev, VIA686A_BASE_REG, &val)) return -ENODEV; - addr = val & ~(VIA686A_EXTENT - 1); - if (addr == 0 && force_addr == 0) { + address = val & ~(VIA686A_EXTENT - 1); + if (address == 0 && force_addr == 0) { dev_err(&dev->dev, "base address not set - upgrade BIOS " "or use force_addr=0xaddr\n"); return -ENODEV; } - if (force_addr) - addr = force_addr; /* so detect will get called */ - if (!addr) { + if (!address) { dev_err(&dev->dev, "No Via 686A sensors found.\n"); return -ENODEV; } - normal_isa[0] = addr; s_bridge = pci_dev_get(dev); if (i2c_isa_add_driver(&via686a_driver)) { diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c index a3c642ef5c42..b14801cd615d 100644 --- a/drivers/hwmon/w83627ehf.c +++ b/drivers/hwmon/w83627ehf.c @@ -41,19 +41,13 @@ #include #include #include -#include #include #include #include #include "lm75.h" -/* Addresses to scan - The actual ISA address is read from Super-I/O configuration space */ -static unsigned short normal_i2c[] = { I2C_CLIENT_END }; -static unsigned int normal_isa[] = { 0, I2C_CLIENT_ISA_END }; - -/* Insmod parameters */ -SENSORS_INSMOD_1(w83627ehf); +/* The actual ISA address is read from Super-I/O configuration space */ +static unsigned short address; /* * Super-I/O constants and functions @@ -673,15 +667,12 @@ static void w83627ehf_init_client(struct i2c_client *client) } } -static int w83627ehf_detect(struct i2c_adapter *adapter, int address, int kind) +static int w83627ehf_detect(struct i2c_adapter *adapter) { struct i2c_client *client; struct w83627ehf_data *data; int i, err = 0; - if (!i2c_is_isa_adapter(adapter)) - return 0; - if (!request_region(address, REGION_LENGTH, w83627ehf_driver.name)) { err = -EBUSY; goto exit; @@ -776,13 +767,6 @@ exit: return err; } -static int w83627ehf_attach_adapter(struct i2c_adapter *adapter) -{ - if (!(adapter->class & I2C_CLASS_HWMON)) - return 0; - return i2c_detect(adapter, &addr_data, w83627ehf_detect); -} - static int w83627ehf_detach_client(struct i2c_client *client) { struct w83627ehf_data *data = i2c_get_clientdata(client); @@ -804,12 +788,11 @@ static int w83627ehf_detach_client(struct i2c_client *client) static struct i2c_driver w83627ehf_driver = { .owner = THIS_MODULE, .name = "w83627ehf", - .flags = I2C_DF_NOTIFY, - .attach_adapter = w83627ehf_attach_adapter, + .attach_adapter = w83627ehf_detect, .detach_client = w83627ehf_detach_client, }; -static int __init w83627ehf_find(int sioaddr, int *address) +static int __init w83627ehf_find(int sioaddr, unsigned short *addr) { u16 val; @@ -827,8 +810,8 @@ static int __init w83627ehf_find(int sioaddr, int *address) superio_select(W83627EHF_LD_HWM); val = (superio_inb(SIO_REG_ADDR) << 8) | superio_inb(SIO_REG_ADDR + 1); - *address = val & ~(REGION_LENGTH - 1); - if (*address == 0) { + *addr = val & ~(REGION_LENGTH - 1); + if (*addr == 0) { superio_exit(); return -ENODEV; } @@ -844,8 +827,8 @@ static int __init w83627ehf_find(int sioaddr, int *address) static int __init sensors_w83627ehf_init(void) { - if (w83627ehf_find(0x2e, &normal_isa[0]) - && w83627ehf_find(0x4e, &normal_isa[0])) + if (w83627ehf_find(0x2e, &address) + && w83627ehf_find(0x4e, &address)) return -ENODEV; return i2c_isa_add_driver(&w83627ehf_driver); diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c index a2c7cea502cb..9e31f5559ccc 100644 --- a/drivers/hwmon/w83627hf.c +++ b/drivers/hwmon/w83627hf.c @@ -59,12 +59,11 @@ module_param(force_i2c, byte, 0); MODULE_PARM_DESC(force_i2c, "Initialize the i2c address of the sensors"); -/* Addresses to scan */ -static unsigned short normal_i2c[] = { I2C_CLIENT_END }; -static unsigned int normal_isa[] = { 0, I2C_CLIENT_ISA_END }; +/* The actual ISA address is read from Super-I/O configuration space */ +static unsigned short address; /* Insmod parameters */ -SENSORS_INSMOD_4(w83627hf, w83627thf, w83697hf, w83637hf); +enum chips { any_chip, w83627hf, w83627thf, w83697hf, w83637hf }; static int init = 1; module_param(init, bool, 0); @@ -318,9 +317,7 @@ struct w83627hf_data { }; -static int w83627hf_attach_adapter(struct i2c_adapter *adapter); -static int w83627hf_detect(struct i2c_adapter *adapter, int address, - int kind); +static int w83627hf_detect(struct i2c_adapter *adapter); static int w83627hf_detach_client(struct i2c_client *client); static int w83627hf_read_value(struct i2c_client *client, u16 register); @@ -332,9 +329,7 @@ static void w83627hf_init_client(struct i2c_client *client); static struct i2c_driver w83627hf_driver = { .owner = THIS_MODULE, .name = "w83627hf", - .id = I2C_DRIVERID_W83627HF, - .flags = I2C_DF_NOTIFY, - .attach_adapter = w83627hf_attach_adapter, + .attach_adapter = w83627hf_detect, .detach_client = w83627hf_detach_client, }; @@ -963,16 +958,7 @@ device_create_file(&client->dev, &dev_attr_temp##offset##_type); \ } while (0) -/* This function is called when: - * w83627hf_driver is inserted (when this module is loaded), for each - available adapter - * when a new adapter is inserted (and w83627hf_driver is still present) */ -static int w83627hf_attach_adapter(struct i2c_adapter *adapter) -{ - return i2c_detect(adapter, &addr_data, w83627hf_detect); -} - -static int w83627hf_find(int sioaddr, int *address) +static int w83627hf_find(int sioaddr, unsigned short *addr) { u16 val; @@ -992,32 +978,24 @@ static int w83627hf_find(int sioaddr, int *address) superio_select(W83627HF_LD_HWM); val = (superio_inb(WINB_BASE_REG) << 8) | superio_inb(WINB_BASE_REG + 1); - *address = val & ~(WINB_EXTENT - 1); - if (*address == 0 && force_addr == 0) { + *addr = val & ~(WINB_EXTENT - 1); + if (*addr == 0 && force_addr == 0) { superio_exit(); return -ENODEV; } - if (force_addr) - *address = force_addr; /* so detect will get called */ superio_exit(); return 0; } -int w83627hf_detect(struct i2c_adapter *adapter, int address, - int kind) +static int w83627hf_detect(struct i2c_adapter *adapter) { - int val; + int val, kind; struct i2c_client *new_client; struct w83627hf_data *data; int err = 0; const char *client_name = ""; - if (!i2c_is_isa_adapter(adapter)) { - err = -ENODEV; - goto ERROR0; - } - if(force_addr) address = force_addr & ~(WINB_EXTENT - 1); @@ -1500,13 +1478,10 @@ static struct w83627hf_data *w83627hf_update_device(struct device *dev) static int __init sensors_w83627hf_init(void) { - int addr; - - if (w83627hf_find(0x2e, &addr) - && w83627hf_find(0x4e, &addr)) { + if (w83627hf_find(0x2e, &address) + && w83627hf_find(0x4e, &address)) { return -ENODEV; } - normal_isa[0] = addr; return i2c_isa_add_driver(&w83627hf_driver); } diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c index 69b061e2dc00..a4ab819ac360 100644 --- a/drivers/hwmon/w83781d.c +++ b/drivers/hwmon/w83781d.c @@ -50,7 +50,8 @@ static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END }; +static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; +static unsigned short isa_address = 0x290; /* Insmod parameters */ SENSORS_INSMOD_5(w83781d, w83782d, w83783s, w83627hf, as99127f); @@ -259,6 +260,7 @@ struct w83781d_data { }; static int w83781d_attach_adapter(struct i2c_adapter *adapter); +static int w83781d_isa_attach_adapter(struct i2c_adapter *adapter); static int w83781d_detect(struct i2c_adapter *adapter, int address, int kind); static int w83781d_detach_client(struct i2c_client *client); @@ -280,7 +282,7 @@ static struct i2c_driver w83781d_driver = { static struct i2c_driver w83781d_isa_driver = { .owner = THIS_MODULE, .name = "w83781d-isa", - .attach_adapter = w83781d_attach_adapter, + .attach_adapter = w83781d_isa_attach_adapter, .detach_client = w83781d_detach_client, }; @@ -871,6 +873,12 @@ w83781d_attach_adapter(struct i2c_adapter *adapter) return i2c_detect(adapter, &addr_data, w83781d_detect); } +static int +w83781d_isa_attach_adapter(struct i2c_adapter *adapter) +{ + return w83781d_detect(adapter, isa_address, -1); +} + /* Assumes that adapter is of I2C, not ISA variety. * OTHERWISE DON'T CALL THIS */ -- cgit v1.2.2 From 4926c0d4de77c5396a274ee7941ed7fc02afed26 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Tue, 19 Jul 2005 23:57:54 +0200 Subject: [PATCH] I2C: Separate non-i2c hwmon drivers from i2c-core (6/9) Kill all isa-related stuff from i2c_detect, it's not used anymore. This is one major step in the directiom of merging i2c_probe and i2c_detect. The last obstacle I can think of is the different way forced addresses work between sensors and non-sensors i2c drivers. I'll deal with that in a later patchset. Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/i2c-sensor-detect.c | 45 ++++++++++++----------------------------- 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/drivers/i2c/i2c-sensor-detect.c b/drivers/i2c/i2c-sensor-detect.c index f99a8161a9f1..5aede3ca9cb0 100644 --- a/drivers/i2c/i2c-sensor-detect.c +++ b/drivers/i2c/i2c-sensor-detect.c @@ -25,42 +25,34 @@ #include static unsigned short empty[] = {I2C_CLIENT_END}; -static unsigned int empty_isa[] = {I2C_CLIENT_ISA_END}; -/* Very inefficient for ISA detects, and won't work for 10-bit addresses! */ +/* Won't work for 10-bit addresses! */ int i2c_detect(struct i2c_adapter *adapter, struct i2c_address_data *address_data, int (*found_proc) (struct i2c_adapter *, int, int)) { int addr, i, found, j, err; struct i2c_force_data *this_force; - int is_isa = i2c_is_isa_adapter(adapter); - int adapter_id = - is_isa ? ANY_I2C_ISA_BUS : i2c_adapter_id(adapter); + int adapter_id = i2c_adapter_id(adapter); unsigned short *normal_i2c; - unsigned int *normal_isa; unsigned short *probe; unsigned short *ignore; /* Forget it if we can't probe using SMBUS_QUICK */ - if ((!is_isa) && - !i2c_check_functionality(adapter, I2C_FUNC_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; - normal_isa = empty_isa; if (address_data->normal_i2c) normal_i2c = address_data->normal_i2c; - if (address_data->normal_isa) - normal_isa = address_data->normal_isa; if (address_data->probe) probe = address_data->probe; if (address_data->ignore) ignore = address_data->ignore; - for (addr = 0x00; addr <= (is_isa ? 0xffff : 0x7f); addr++) { - if (!is_isa && i2c_check_addr(adapter, addr)) + 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 @@ -69,7 +61,7 @@ int i2c_detect(struct i2c_adapter *adapter, 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) && !is_isa)) && + (this_force->force[j] == ANY_I2C_BUS)) && (addr == this_force->force[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))) @@ -85,8 +77,7 @@ int i2c_detect(struct i2c_adapter *adapter, right now */ for (i = 0; !found && (ignore[i] != I2C_CLIENT_END); i += 2) { if ( ((adapter_id == ignore[i]) || - ((ignore[i] == ANY_I2C_BUS) && - !is_isa)) && + (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; @@ -97,19 +88,10 @@ int i2c_detect(struct i2c_adapter *adapter, /* Now, we will do a detection, but only if it is in the normal or probe entries */ - if (is_isa) { - for (i = 0; !found && (normal_isa[i] != I2C_CLIENT_ISA_END); i += 1) { - if (addr == normal_isa[i]) { - dev_dbg(&adapter->dev, "found normal isa entry for adapter %d, addr %04x\n", adapter_id, addr); - found = 1; - } - } - } else { - 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 && (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); } } @@ -117,7 +99,7 @@ int i2c_detect(struct i2c_adapter *adapter, !found && (probe[i] != I2C_CLIENT_END); i += 2) { if (((adapter_id == probe[i]) || - ((probe[i] == ANY_I2C_BUS) && !is_isa)) + (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; @@ -128,8 +110,7 @@ int i2c_detect(struct i2c_adapter *adapter, /* OK, so we really should examine this address. First check whether there is some client here at all! */ - if (is_isa || - (i2c_smbus_xfer (adapter, addr, 0, 0, 0, I2C_SMBUS_QUICK, NULL) >= 0)) + if (i2c_smbus_xfer(adapter, addr, 0, 0, 0, I2C_SMBUS_QUICK, NULL) >= 0) if ((err = found_proc(adapter, addr, -1))) return err; } -- cgit v1.2.2 From 5071860aba7fc69279ab822638ed2c2e4549f9fd Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 20 Jul 2005 00:02:32 +0200 Subject: [PATCH] I2C: Separate non-i2c hwmon drivers from i2c-core (7/9) Kill normal_isa in header files, documentation and all chip drivers, as it is no more used. normal_i2c could be renamed to normal, but I decided not to do so at the moment, so as to limit the number of changes. This might be done later as part of the i2c_probe/i2c_detect merge. Signed-off-by: Greg Kroah-Hartman --- Documentation/i2c/porting-clients | 7 ++++--- Documentation/i2c/writing-clients | 35 +++++++++++++++-------------------- drivers/hwmon/adm1021.c | 1 - drivers/hwmon/adm1025.c | 1 - drivers/hwmon/adm1026.c | 1 - drivers/hwmon/adm1031.c | 1 - drivers/hwmon/adm9240.c | 2 -- drivers/hwmon/asb100.c | 3 --- drivers/hwmon/atxp1.c | 1 - drivers/hwmon/ds1621.c | 1 - drivers/hwmon/fscher.c | 1 - drivers/hwmon/fscpos.c | 1 - drivers/hwmon/gl518sm.c | 1 - drivers/hwmon/gl520sm.c | 1 - drivers/hwmon/it87.c | 1 - drivers/hwmon/lm63.c | 1 - drivers/hwmon/lm75.c | 1 - drivers/hwmon/lm77.c | 1 - drivers/hwmon/lm78.c | 1 - drivers/hwmon/lm80.c | 1 - drivers/hwmon/lm83.c | 1 - drivers/hwmon/lm85.c | 1 - drivers/hwmon/lm87.c | 1 - drivers/hwmon/lm90.c | 1 - drivers/hwmon/lm92.c | 1 - drivers/hwmon/max1619.c | 1 - drivers/hwmon/w83781d.c | 1 - drivers/hwmon/w83l785ts.c | 1 - drivers/i2c/chips/ds1337.c | 1 - drivers/i2c/chips/eeprom.c | 1 - drivers/i2c/chips/max6875.c | 1 - drivers/i2c/chips/pca9539.c | 1 - drivers/i2c/chips/pcf8574.c | 1 - drivers/i2c/chips/pcf8591.c | 1 - include/linux/i2c-sensor.h | 36 +++++++++++++++--------------------- include/linux/i2c.h | 8 ++------ 36 files changed, 36 insertions(+), 85 deletions(-) diff --git a/Documentation/i2c/porting-clients b/Documentation/i2c/porting-clients index a7adbdd9ea8a..105c6186b912 100644 --- a/Documentation/i2c/porting-clients +++ b/Documentation/i2c/porting-clients @@ -29,8 +29,8 @@ Technical changes: 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, SENSORS_ISA_END - becomes I2C_CLIENT_ISA_END. +* [Addresses] SENSORS_I2C_END becomes I2C_CLIENT_END, ISA addresses + are no more handled by the i2c core. * [Client data] Get rid of sysctl_id. Try using standard names for register values (for example, temp_os becomes temp_max). You're @@ -72,7 +72,8 @@ Technical changes: name string, which will be filled with a lowercase, short string (typically the driver name, e.g. "lm75"). In i2c-only drivers, drop the i2c_is_isa_adapter check, it's - useless. + useless. Same for isa-only drivers, as the test would always be + true. Only hybrid drivers (which are quite rare) still need it. The errorN labels are reduced to the number needed. If that number is 2 (i2c-only drivers), it is advised that the labels are named exit and exit_free. For i2c+isa drivers, labels should be named diff --git a/Documentation/i2c/writing-clients b/Documentation/i2c/writing-clients index 91664be91ffc..e6b546dd4f7b 100644 --- a/Documentation/i2c/writing-clients +++ b/Documentation/i2c/writing-clients @@ -195,31 +195,28 @@ Probing classes (sensors) ------------------------- If you write a `sensors' driver, you use a slightly different interface. -As well as I2C addresses, we have to cope with ISA addresses. Also, we -use a enum of chip types. Don't forget to include `sensors.h'. +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 SENSORS_I2C_END. + normal_i2c: filled in by the module writer. Terminated by I2C_CLIENT_END. A list of I2C addresses which should normally be examined. - normal_isa: filled in by the module writer. Terminated by SENSORS_ISA_END. - A list of ISA addresses which should normally be examined. - probe: insmod parameter. Initialize this list with SENSORS_I2C_END values. - A list of pairs. The first value is a bus number (SENSORS_ISA_BUS for - the ISA bus, -1 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 SENSORS_I2C_END values. - A list of pairs. The first value is a bus number (SENSORS_ISA_BUS for - the ISA bus, -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. + 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 (SENSORS_ISA_BUS for the ISA bus, - -1 for any I2C bus), the second is the address. + 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. @@ -227,13 +224,11 @@ 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' -and `normal_isa' parameters, and define what chip names are used. -The complete declaration could look like this: +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 }; - /* Scan ISA address 0x290 */ - static unsigned int normal_isa[] = {0x0290,SENSORS_ISA_END}; /* Define chips foo and bar, as well as all module parameters and things */ SENSORS_INSMOD_2(foo,bar); diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c index a483d96e4cef..093d09cc4c14 100644 --- a/drivers/hwmon/adm1021.c +++ b/drivers/hwmon/adm1021.c @@ -34,7 +34,6 @@ static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d, 0x4e, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; /* Insmod parameters */ SENSORS_INSMOD_8(adm1021, adm1023, max1617, max1617a, thmc10, lm84, gl523sm, mc1066); diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c index b68b292c00d4..bdba01e2f3ed 100644 --- a/drivers/hwmon/adm1025.c +++ b/drivers/hwmon/adm1025.c @@ -62,7 +62,6 @@ */ static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; /* * Insmod parameters diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c index eb55133a13ee..8e8b0ef8fff3 100644 --- a/drivers/hwmon/adm1026.c +++ b/drivers/hwmon/adm1026.c @@ -36,7 +36,6 @@ /* Addresses to scan */ static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; /* Insmod parameters */ SENSORS_INSMOD_1(adm1026); diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c index ac3b1542556e..a60187e24830 100644 --- a/drivers/hwmon/adm1031.c +++ b/drivers/hwmon/adm1031.c @@ -61,7 +61,6 @@ /* Addresses to scan */ static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; /* Insmod parameters */ SENSORS_INSMOD_2(adm1030, adm1031); diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c index 7ef61206ba10..d52100027665 100644 --- a/drivers/hwmon/adm9240.c +++ b/drivers/hwmon/adm9240.c @@ -54,8 +54,6 @@ static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; - /* Insmod parameters */ SENSORS_INSMOD_3(adm9240, ds1780, lm81); diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c index 3ab7a2ddafba..d1856acf87a0 100644 --- a/drivers/hwmon/asb100.c +++ b/drivers/hwmon/asb100.c @@ -56,9 +56,6 @@ /* I2C addresses to scan */ static unsigned short normal_i2c[] = { 0x2d, I2C_CLIENT_END }; -/* ISA addresses to scan (none) */ -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; - /* Insmod parameters */ SENSORS_INSMOD_1(asb100); I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: " diff --git a/drivers/hwmon/atxp1.c b/drivers/hwmon/atxp1.c index 5f79f07a4ab8..ced54189a579 100644 --- a/drivers/hwmon/atxp1.c +++ b/drivers/hwmon/atxp1.c @@ -42,7 +42,6 @@ MODULE_AUTHOR("Sebastian Witt "); #define ATXP1_GPIO1MASK 0x0f static unsigned short normal_i2c[] = { 0x37, 0x4e, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; SENSORS_INSMOD_1(atxp1); diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c index 9ed21ac46e97..4a316a7f7980 100644 --- a/drivers/hwmon/ds1621.c +++ b/drivers/hwmon/ds1621.c @@ -34,7 +34,6 @@ /* Addresses to scan */ static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; /* Insmod parameters */ SENSORS_INSMOD_1(ds1621); diff --git a/drivers/hwmon/fscher.c b/drivers/hwmon/fscher.c index b794580a0726..c7caa95c643b 100644 --- a/drivers/hwmon/fscher.c +++ b/drivers/hwmon/fscher.c @@ -40,7 +40,6 @@ */ static unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; /* * Insmod parameters diff --git a/drivers/hwmon/fscpos.c b/drivers/hwmon/fscpos.c index 4cb33b231124..fd75e444e758 100644 --- a/drivers/hwmon/fscpos.c +++ b/drivers/hwmon/fscpos.c @@ -43,7 +43,6 @@ * Addresses to scan */ static unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; /* * Insmod parameters diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c index 49972929a69b..34d85b1e5539 100644 --- a/drivers/hwmon/gl518sm.c +++ b/drivers/hwmon/gl518sm.c @@ -47,7 +47,6 @@ /* Addresses to scan */ static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; /* Insmod parameters */ SENSORS_INSMOD_2(gl518sm_r00, gl518sm_r80); diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c index ce482e17e03c..b129d153deab 100644 --- a/drivers/hwmon/gl520sm.c +++ b/drivers/hwmon/gl520sm.c @@ -38,7 +38,6 @@ MODULE_PARM_DESC(extra_sensor_type, "Type of extra sensor (0=autodetect, 1=tempe /* Addresses to scan */ static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; /* Insmod parameters */ SENSORS_INSMOD_1(gl520sm); diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index 722ef0cd5c00..0a8d795f15c2 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -48,7 +48,6 @@ /* Addresses to scan */ static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; static unsigned short isa_address = 0x290; /* Insmod parameters */ diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c index cba0a40ad667..e19b11fd4816 100644 --- a/drivers/hwmon/lm63.c +++ b/drivers/hwmon/lm63.c @@ -53,7 +53,6 @@ */ static unsigned short normal_i2c[] = { 0x4c, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; /* * Insmod parameters diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index 129c8f213331..54dda7d11ace 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c @@ -32,7 +32,6 @@ /* Addresses to scan */ static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; /* Insmod parameters */ SENSORS_INSMOD_1(lm75); diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c index 15f30fdc75c6..d47aab3b3c05 100644 --- a/drivers/hwmon/lm77.c +++ b/drivers/hwmon/lm77.c @@ -36,7 +36,6 @@ /* Addresses to scan */ static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; /* Insmod parameters */ SENSORS_INSMOD_1(lm77); diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c index c3712f8d9964..784935f77016 100644 --- a/drivers/hwmon/lm78.c +++ b/drivers/hwmon/lm78.c @@ -34,7 +34,6 @@ static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; static unsigned short isa_address = 0x290; /* Insmod parameters */ diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c index dbf8df386250..fa2cb17018cc 100644 --- a/drivers/hwmon/lm80.c +++ b/drivers/hwmon/lm80.c @@ -33,7 +33,6 @@ /* Addresses to scan */ static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; /* Insmod parameters */ SENSORS_INSMOD_1(lm80); diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c index f3f3901c7294..0223b4d2ce1d 100644 --- a/drivers/hwmon/lm83.c +++ b/drivers/hwmon/lm83.c @@ -47,7 +47,6 @@ static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d, 0x4e, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; /* * Insmod parameters diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index 4203f904bbe2..8954d64614ff 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c @@ -35,7 +35,6 @@ /* Addresses to scan */ static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; /* Insmod parameters */ SENSORS_INSMOD_6(lm85b, lm85c, adm1027, adt7463, emc6d100, emc6d102); diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index 7e14858c257b..1dc3bf52b40d 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c @@ -68,7 +68,6 @@ */ static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; /* * Insmod parameters diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index c1e8d0e965f7..4b914ec205fa 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c @@ -91,7 +91,6 @@ */ static unsigned short normal_i2c[] = { 0x4c, 0x4d, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; /* * Insmod parameters diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c index 0fb601c07519..9c43120d6bd7 100644 --- a/drivers/hwmon/lm92.c +++ b/drivers/hwmon/lm92.c @@ -52,7 +52,6 @@ resulting in 4 possible addresses. */ static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; /* Insmod parameters */ SENSORS_INSMOD_1(lm92); diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c index 56c34c2d3619..5f0376575c62 100644 --- a/drivers/hwmon/max1619.c +++ b/drivers/hwmon/max1619.c @@ -39,7 +39,6 @@ static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d, 0x4e, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; /* * Insmod parameters diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c index a4ab819ac360..70718559de75 100644 --- a/drivers/hwmon/w83781d.c +++ b/drivers/hwmon/w83781d.c @@ -50,7 +50,6 @@ static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; static unsigned short isa_address = 0x290; /* Insmod parameters */ diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c index 1f763499dac4..9cd1939cd040 100644 --- a/drivers/hwmon/w83l785ts.c +++ b/drivers/hwmon/w83l785ts.c @@ -49,7 +49,6 @@ */ static unsigned short normal_i2c[] = { 0x2e, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; /* * Insmod parameters diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c index 82cf959989fd..6ac0a6e00769 100644 --- a/drivers/i2c/chips/ds1337.c +++ b/drivers/i2c/chips/ds1337.c @@ -39,7 +39,6 @@ * Functions declaration */ static unsigned short normal_i2c[] = { 0x68, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; SENSORS_INSMOD_1(ds1337); diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c index a2da31b0dd7b..88f83bac3845 100644 --- a/drivers/i2c/chips/eeprom.c +++ b/drivers/i2c/chips/eeprom.c @@ -38,7 +38,6 @@ /* Addresses to scan */ static unsigned short normal_i2c[] = { 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; /* Insmod parameters */ SENSORS_INSMOD_1(eeprom); diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c index f0e306237739..d1d48586b90e 100644 --- a/drivers/i2c/chips/max6875.c +++ b/drivers/i2c/chips/max6875.c @@ -36,7 +36,6 @@ /* Do not scan - the MAX6875 access method will write to some EEPROM chips */ static unsigned short normal_i2c[] = {I2C_CLIENT_END}; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END}; /* Insmod parameters */ SENSORS_INSMOD_1(max6875); diff --git a/drivers/i2c/chips/pca9539.c b/drivers/i2c/chips/pca9539.c index 9f3ad45daae2..c5b052363d9a 100644 --- a/drivers/i2c/chips/pca9539.c +++ b/drivers/i2c/chips/pca9539.c @@ -17,7 +17,6 @@ /* Addresses to scan */ static unsigned short normal_i2c[] = {0x74, 0x75, 0x76, 0x77, I2C_CLIENT_END}; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END}; /* Insmod parameters */ SENSORS_INSMOD_1(pca9539); diff --git a/drivers/i2c/chips/pcf8574.c b/drivers/i2c/chips/pcf8574.c index cfcf64654080..7a1fa7914630 100644 --- a/drivers/i2c/chips/pcf8574.c +++ b/drivers/i2c/chips/pcf8574.c @@ -45,7 +45,6 @@ static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; /* Insmod parameters */ SENSORS_INSMOD_2(pcf8574, pcf8574a); diff --git a/drivers/i2c/chips/pcf8591.c b/drivers/i2c/chips/pcf8591.c index db812ade8564..225b512dd4ad 100644 --- a/drivers/i2c/chips/pcf8591.c +++ b/drivers/i2c/chips/pcf8591.c @@ -29,7 +29,6 @@ /* Addresses to scan */ static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; -static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; /* Insmod parameters */ SENSORS_INSMOD_1(pcf8591); diff --git a/include/linux/i2c-sensor.h b/include/linux/i2c-sensor.h index 21b625204956..ae73b9e789cb 100644 --- a/include/linux/i2c-sensor.h +++ b/include/linux/i2c-sensor.h @@ -27,11 +27,10 @@ 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 or ISA address space filled - fails. - probe: insmod parameter. Initialize this list with I2C_CLIENT_ISA_END values. - A list of pairs. The first value is a bus number (ANY_I2C_ISA_BUS for - the ISA bus, -1 for any I2C bus), the second is the address. + 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 { @@ -40,25 +39,22 @@ struct i2c_force_data { }; /* A structure containing the detect information. - normal_i2c: filled in by the module writer. Terminated by I2C_CLIENT_ISA_END. + normal_i2c: filled in by the module writer. Terminated by I2C_CLIENT_END. A list of I2C addresses which should normally be examined. - normal_isa: filled in by the module writer. Terminated by SENSORS_ISA_END. - A list of ISA addresses which should normally be examined. - probe: insmod parameter. Initialize this list with I2C_CLIENT_ISA_END values. - A list of pairs. The first value is a bus number (ANY_I2C_ISA_BUS for - the ISA bus, -1 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_ISA_END values. - A list of pairs. The first value is a bus number (ANY_I2C_ISA_BUS for - the ISA bus, -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. + 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. force_data: insmod parameters. A list, ending with an element of which the force field is NULL. */ struct i2c_address_data { unsigned short *normal_i2c; - unsigned int *normal_isa; unsigned short *probe; unsigned short *ignore; struct i2c_force_data *forces; @@ -78,7 +74,6 @@ struct i2c_address_data { "List of adapter,address pairs not to scan"); \ static struct i2c_address_data addr_data = { \ .normal_i2c = normal_i2c, \ - .normal_isa = normal_isa, \ .probe = probe, \ .ignore = ignore, \ .forces = forces, \ @@ -242,8 +237,7 @@ struct i2c_address_data { /* 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); for ISA detections, this is not - done. */ + to the SMBus (unless a 'force' matched). */ extern int i2c_detect(struct i2c_adapter *adapter, struct i2c_address_data *address_data, int (*found_proc) (struct i2c_adapter *, int, int)); diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 3be06105034c..39ff363eadec 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -150,12 +150,9 @@ struct i2c_driver { */ struct i2c_client { unsigned int flags; /* div., see below */ - unsigned int addr; /* chip address - NOTE: 7bit */ + unsigned short addr; /* chip address - NOTE: 7bit */ /* addresses are stored in the */ - /* _LOWER_ 7 bits of this char */ - /* addr: unsigned int to make lm_sensors i2c-isa adapter work - more cleanly. It does not take any more memory space, due to - alignment considerations */ + /* _LOWER_ 7 bits */ struct i2c_adapter *adapter; /* the adapter we sit on */ struct i2c_driver *driver; /* and our access routines */ int usage_count; /* How many accesses currently */ @@ -309,7 +306,6 @@ struct i2c_client_address_data { /* Internal numbers to terminate lists */ #define I2C_CLIENT_END 0xfffeU -#define I2C_CLIENT_ISA_END 0xfffefffeU /* The numbers to use to set I2C bus address */ #define ANY_I2C_BUS 0xffff -- cgit v1.2.2 From 02ff982c6911de1484e13a1d765d7bd31a0f8fee Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 20 Jul 2005 00:05:33 +0200 Subject: [PATCH] I2C: Separate non-i2c hwmon drivers from i2c-core (8/9) Kill all uses of i2c_is_isa_adapter except for the hybrid drivers (it87, lm78, w83781d). The i2c-isa adapter not being registered with the i2c core anymore, drivers don't have to fear being erroneously attached to it. Signed-off-by: Greg Kroah-Hartman --- Documentation/i2c/writing-clients | 11 +++++------ drivers/hwmon/adm1021.c | 9 --------- drivers/hwmon/asb100.c | 8 -------- drivers/hwmon/lm75.c | 10 ---------- drivers/hwmon/lm85.c | 5 ----- 5 files changed, 5 insertions(+), 38 deletions(-) diff --git a/Documentation/i2c/writing-clients b/Documentation/i2c/writing-clients index e6b546dd4f7b..522ae01d2e7f 100644 --- a/Documentation/i2c/writing-clients +++ b/Documentation/i2c/writing-clients @@ -315,11 +315,10 @@ For now, you can ignore the `flags' parameter. It is there for future use. const char *type_name = ""; int is_isa = i2c_is_isa_adapter(adapter); - if (is_isa) { + /* Do this only if the chip can additionally be found on the ISA bus + (hybrid chip). */ - /* If this client can't be on the ISA bus at all, we can stop now - (call `goto ERROR0'). But for kicks, we will assume it is all - right. */ + if (is_isa) { /* Discard immediately if this ISA range is already used */ if (check_region(address,FOO_EXTENT)) @@ -495,10 +494,10 @@ much simpler than the attachment code, fortunately! return err; } - /* SENSORS ONLY START */ + /* HYBRID SENSORS CHIP ONLY START */ if i2c_is_isa_client(client) release_region(client->addr,LM78_EXTENT); - /* SENSORS ONLY END */ + /* HYBRID SENSORS CHIP ONLY END */ kfree(client); /* Frees client data too, if allocated at the same time */ return 0; diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c index 093d09cc4c14..2a341390d92e 100644 --- a/drivers/hwmon/adm1021.c +++ b/drivers/hwmon/adm1021.c @@ -198,15 +198,6 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind) int err = 0; const char *type_name = ""; - /* Make sure we aren't probing the ISA bus!! This is just a safety check - at this moment; i2c_detect really won't call us. */ -#ifdef DEBUG - if (i2c_is_isa_adapter(adapter)) { - dev_dbg(&adapter->dev, "adm1021_detect called for an ISA bus adapter?!?\n"); - return 0; - } -#endif - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) goto error0; diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c index d1856acf87a0..290f7d2ac0a8 100644 --- a/drivers/hwmon/asb100.c +++ b/drivers/hwmon/asb100.c @@ -714,14 +714,6 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind) struct i2c_client *new_client; struct asb100_data *data; - /* asb100 is SMBus only */ - if (i2c_is_isa_adapter(adapter)) { - pr_debug("asb100.o: detect failed, " - "cannot attach to legacy adapter!\n"); - err = -ENODEV; - goto ERROR0; - } - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { pr_debug("asb100.o: detect failed, " "smbus byte data not supported!\n"); diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index 54dda7d11ace..a2bebb6b37a6 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c @@ -121,16 +121,6 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, int kind) int err = 0; const char *name = ""; - /* Make sure we aren't probing the ISA bus!! This is just a safety check - at this moment; i2c_detect really won't call us. */ -#ifdef DEBUG - if (i2c_is_isa_adapter(adapter)) { - dev_dbg(&adapter->dev, - "lm75_detect called for an ISA bus adapter?!?\n"); - goto exit; - } -#endif - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) goto exit; diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index 8954d64614ff..5f051c023236 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c @@ -1033,11 +1033,6 @@ int lm85_detect(struct i2c_adapter *adapter, int address, int err = 0; const char *type_name = ""; - if (i2c_is_isa_adapter(adapter)) { - /* This chip has no ISA interface */ - goto ERROR0 ; - }; - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { /* We need to be able to do byte I/O */ -- cgit v1.2.2 From 570aefc361d3315ec6749f573009286106b0b2d8 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 20 Jul 2005 00:09:03 +0200 Subject: [PATCH] I2C: Separate non-i2c hwmon drivers from i2c-core (9/9) Move the definitions of i2c_is_isa_client and i2c_is_isa_adapter from i2c.h to i2c-isa.h. Only hybrid drivers still need them. Signed-off-by: Greg Kroah-Hartman --- include/linux/i2c-isa.h | 7 +++++++ include/linux/i2c.h | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/linux/i2c-isa.h b/include/linux/i2c-isa.h index b5727d7702e1..db793b68356c 100644 --- a/include/linux/i2c-isa.h +++ b/include/linux/i2c-isa.h @@ -26,4 +26,11 @@ extern int i2c_isa_add_driver(struct i2c_driver *driver); extern int i2c_isa_del_driver(struct i2c_driver *driver); +/* Detect whether we are on the isa bus. This is only useful to hybrid + (i2c+isa) drivers. */ +#define i2c_is_isa_client(clientptr) \ + ((clientptr)->adapter->algo->id == I2C_ALGO_ISA) +#define i2c_is_isa_adapter(adapptr) \ + ((adapptr)->algo->id == I2C_ALGO_ISA) + #endif /* _LINUX_I2C_ISA_H */ diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 39ff363eadec..da4faa016b17 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -580,11 +580,4 @@ union i2c_smbus_data { .force = force, \ } -/* Detect whether we are on the isa bus. If this returns true, all i2c - access will fail! */ -#define i2c_is_isa_client(clientptr) \ - ((clientptr)->adapter->algo->id == I2C_ALGO_ISA) -#define i2c_is_isa_adapter(adapptr) \ - ((adapptr)->algo->id == I2C_ALGO_ISA) - #endif /* _LINUX_I2C_H */ -- cgit v1.2.2 From 5563e27d3a42667734e81c1cb8ad72bff76321f6 Mon Sep 17 00:00:00 2001 From: "R.Marek@sh.cvut.cz" Date: Wed, 27 Jul 2005 11:43:47 +0000 Subject: [PATCH] I2C: W83792D driver 1/3 I would like to announce support for W83792D chip. This driver was developed by Winbond Electronics Corp. I added sysfs attributes callbacks infrastructure plus various code fixes and codingstyle cleanups. I would like to thank Winbond for supporting free software. This patch is against 2.6.13rc3 plus hwmon-class and hwmon-split. Separate patch for documantation and hwmon class register will follow. Signed-off-by: Rudolf Marek Signed-off-by: Chunhao Huang Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/Kconfig | 10 + drivers/hwmon/Makefile | 1 + drivers/hwmon/w83792d.c | 1633 +++++++++++++++++++++++++++++++++++++++++++ include/linux/hwmon-sysfs.h | 15 + 4 files changed, 1659 insertions(+) create mode 100644 drivers/hwmon/w83792d.c diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 29583e1f7a20..6483ff696b5a 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -377,6 +377,16 @@ config SENSORS_W83781D This driver can also be built as a module. If so, the module will be called w83781d. +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. + + This driver can also be built as a module. If so, the module + will be called w83792d. + config SENSORS_W83L785TS tristate "Winbond W83L785TS-S" depends on HWMON && I2C && EXPERIMENTAL diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index bd1bd59eb149..187b89d47f83 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_HWMON) += hwmon.o # asb100, then w83781d go first, as they can override other drivers' addresses. obj-$(CONFIG_SENSORS_ASB100) += asb100.o obj-$(CONFIG_SENSORS_W83627HF) += w83627hf.o +obj-$(CONFIG_SENSORS_W83792D) += w83792d.o obj-$(CONFIG_SENSORS_W83781D) += w83781d.o obj-$(CONFIG_SENSORS_ADM1021) += adm1021.o diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c new file mode 100644 index 000000000000..fa43b6fd1212 --- /dev/null +++ b/drivers/hwmon/w83792d.c @@ -0,0 +1,1633 @@ +/* + w83792d.c - Part of lm_sensors, Linux kernel modules for hardware + monitoring + Copyright (C) 2004, 2005 Winbond Electronics Corp. + Chunhao Huang , + Rudolf Marek + + 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. + + Note: + 1. This driver is only for 2.6 kernel, 2.4 kernel need a different driver. + 2. This driver is only for Winbond W83792D C version device, there + are also some motherboards with B version W83792D device. The + calculation method to in6-in7(measured value, limits) is a little + different between C and B version. C or B version can be identified + by CR[0x49h]. +*/ + +/* + Supports following chips: + + Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA + w83792d 9 7 7 3 0x7a 0x5ca3 yes no +*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/* Addresses to scan */ +static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; + +/* Insmod parameters */ +SENSORS_INSMOD_1(w83792d); +I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: " + "{bus, clientaddr, subclientaddr1, subclientaddr2}"); + +static int init; +module_param(init, bool, 0); +MODULE_PARM_DESC(init, "Set to one to force chip initialization"); + +/* The W83792D registers */ +static const u8 W83792D_REG_IN[9] = { + 0x20, /* Vcore A in DataSheet */ + 0x21, /* Vcore B in DataSheet */ + 0x22, /* VIN0 in DataSheet */ + 0x23, /* VIN1 in DataSheet */ + 0x24, /* VIN2 in DataSheet */ + 0x25, /* VIN3 in DataSheet */ + 0x26, /* 5VCC in DataSheet */ + 0xB0, /* 5VSB in DataSheet */ + 0xB1 /* VBAT in DataSheet */ +}; +#define W83792D_REG_LOW_BITS1 0x3E /* Low Bits I in DataSheet */ +#define W83792D_REG_LOW_BITS2 0x3F /* Low Bits II in DataSheet */ +static const u8 W83792D_REG_IN_MAX[9] = { + 0x2B, /* Vcore A High Limit in DataSheet */ + 0x2D, /* Vcore B High Limit in DataSheet */ + 0x2F, /* VIN0 High Limit in DataSheet */ + 0x31, /* VIN1 High Limit in DataSheet */ + 0x33, /* VIN2 High Limit in DataSheet */ + 0x35, /* VIN3 High Limit in DataSheet */ + 0x37, /* 5VCC High Limit in DataSheet */ + 0xB4, /* 5VSB High Limit in DataSheet */ + 0xB6 /* VBAT High Limit in DataSheet */ +}; +static const u8 W83792D_REG_IN_MIN[9] = { + 0x2C, /* Vcore A Low Limit in DataSheet */ + 0x2E, /* Vcore B Low Limit in DataSheet */ + 0x30, /* VIN0 Low Limit in DataSheet */ + 0x32, /* VIN1 Low Limit in DataSheet */ + 0x34, /* VIN2 Low Limit in DataSheet */ + 0x36, /* VIN3 Low Limit in DataSheet */ + 0x38, /* 5VCC Low Limit in DataSheet */ + 0xB5, /* 5VSB Low Limit in DataSheet */ + 0xB7 /* VBAT Low Limit in DataSheet */ +}; +static const u8 W83792D_REG_FAN[7] = { + 0x28, /* FAN 1 Count in DataSheet */ + 0x29, /* FAN 2 Count in DataSheet */ + 0x2A, /* FAN 3 Count in DataSheet */ + 0xB8, /* FAN 4 Count in DataSheet */ + 0xB9, /* FAN 5 Count in DataSheet */ + 0xBA, /* FAN 6 Count in DataSheet */ + 0xBE /* FAN 7 Count in DataSheet */ +}; +static const u8 W83792D_REG_FAN_MIN[7] = { + 0x3B, /* FAN 1 Count Low Limit in DataSheet */ + 0x3C, /* FAN 2 Count Low Limit in DataSheet */ + 0x3D, /* FAN 3 Count Low Limit in DataSheet */ + 0xBB, /* FAN 4 Count Low Limit in DataSheet */ + 0xBC, /* FAN 5 Count Low Limit in DataSheet */ + 0xBD, /* FAN 6 Count Low Limit in DataSheet */ + 0xBF /* FAN 7 Count Low Limit in DataSheet */ +}; +#define W83792D_REG_FAN_CFG 0x84 /* FAN Configuration in DataSheet */ +static const u8 W83792D_REG_FAN_DIV[4] = { + 0x47, /* contains FAN2 and FAN1 Divisor */ + 0x5B, /* contains FAN4 and FAN3 Divisor */ + 0x5C, /* contains FAN6 and FAN5 Divisor */ + 0x9E /* contains FAN7 Divisor. */ +}; +static const u8 W83792D_REG_PWM[7] = { + 0x81, /* FAN 1 Duty Cycle, be used to control */ + 0x83, /* FAN 2 Duty Cycle, be used to control */ + 0x94, /* FAN 3 Duty Cycle, be used to control */ + 0xA3, /* FAN 4 Duty Cycle, be used to control */ + 0xA4, /* FAN 5 Duty Cycle, be used to control */ + 0xA5, /* FAN 6 Duty Cycle, be used to control */ + 0xA6 /* FAN 7 Duty Cycle, be used to control */ +}; +#define W83792D_REG_BANK 0x4E +#define W83792D_REG_TEMP2_CONFIG 0xC2 +#define W83792D_REG_TEMP3_CONFIG 0xCA + +static const u8 W83792D_REG_TEMP1[3] = { + 0x27, /* TEMP 1 in DataSheet */ + 0x39, /* TEMP 1 Over in DataSheet */ + 0x3A, /* TEMP 1 Hyst in DataSheet */ +}; + +static const u8 W83792D_REG_TEMP_ADD[2][6] = { + { 0xC0, /* TEMP 2 in DataSheet */ + 0xC1, /* TEMP 2(0.5 deg) in DataSheet */ + 0xC5, /* TEMP 2 Over High part in DataSheet */ + 0xC6, /* TEMP 2 Over Low part in DataSheet */ + 0xC3, /* TEMP 2 Thyst High part in DataSheet */ + 0xC4 }, /* TEMP 2 Thyst Low part in DataSheet */ + { 0xC8, /* TEMP 3 in DataSheet */ + 0xC9, /* TEMP 3(0.5 deg) in DataSheet */ + 0xCD, /* TEMP 3 Over High part in DataSheet */ + 0xCE, /* TEMP 3 Over Low part in DataSheet */ + 0xCB, /* TEMP 3 Thyst High part in DataSheet */ + 0xCC } /* TEMP 3 Thyst Low part in DataSheet */ +}; + +static const u8 W83792D_REG_THERMAL[3] = { + 0x85, /* SmartFanI: Fan1 target value */ + 0x86, /* SmartFanI: Fan2 target value */ + 0x96 /* SmartFanI: Fan3 target value */ +}; + +static const u8 W83792D_REG_TOLERANCE[3] = { + 0x87, /* (bit3-0)SmartFan Fan1 tolerance */ + 0x87, /* (bit7-4)SmartFan Fan2 tolerance */ + 0x97 /* (bit3-0)SmartFan Fan3 tolerance */ +}; + +static const u8 W83792D_REG_POINTS[3][4] = { + { 0x85, /* SmartFanII: Fan1 temp point 1 */ + 0xE3, /* SmartFanII: Fan1 temp point 2 */ + 0xE4, /* SmartFanII: Fan1 temp point 3 */ + 0xE5 }, /* SmartFanII: Fan1 temp point 4 */ + { 0x86, /* SmartFanII: Fan2 temp point 1 */ + 0xE6, /* SmartFanII: Fan2 temp point 2 */ + 0xE7, /* SmartFanII: Fan2 temp point 3 */ + 0xE8 }, /* SmartFanII: Fan2 temp point 4 */ + { 0x96, /* SmartFanII: Fan3 temp point 1 */ + 0xE9, /* SmartFanII: Fan3 temp point 2 */ + 0xEA, /* SmartFanII: Fan3 temp point 3 */ + 0xEB } /* SmartFanII: Fan3 temp point 4 */ +}; + +static const u8 W83792D_REG_LEVELS[3][4] = { + { 0x88, /* (bit3-0) SmartFanII: Fan1 Non-Stop */ + 0x88, /* (bit7-4) SmartFanII: Fan1 Level 1 */ + 0xE0, /* (bit7-4) SmartFanII: Fan1 Level 2 */ + 0xE0 }, /* (bit3-0) SmartFanII: Fan1 Level 3 */ + { 0x89, /* (bit3-0) SmartFanII: Fan2 Non-Stop */ + 0x89, /* (bit7-4) SmartFanII: Fan2 Level 1 */ + 0xE1, /* (bit7-4) SmartFanII: Fan2 Level 2 */ + 0xE1 }, /* (bit3-0) SmartFanII: Fan2 Level 3 */ + { 0x98, /* (bit3-0) SmartFanII: Fan3 Non-Stop */ + 0x98, /* (bit7-4) SmartFanII: Fan3 Level 1 */ + 0xE2, /* (bit7-4) SmartFanII: Fan3 Level 2 */ + 0xE2 } /* (bit3-0) SmartFanII: Fan3 Level 3 */ +}; + +#define W83792D_REG_CONFIG 0x40 +#define W83792D_REG_VID_FANDIV 0x47 +#define W83792D_REG_CHIPID 0x49 +#define W83792D_REG_WCHIPID 0x58 +#define W83792D_REG_CHIPMAN 0x4F +#define W83792D_REG_PIN 0x4B +#define W83792D_REG_I2C_SUBADDR 0x4A + +#define W83792D_REG_ALARM1 0xA9 /* realtime status register1 */ +#define W83792D_REG_ALARM2 0xAA /* realtime status register2 */ +#define W83792D_REG_ALARM3 0xAB /* realtime status register3 */ +#define W83792D_REG_CHASSIS 0x42 /* Bit 5: Case Open status bit */ +#define W83792D_REG_CHASSIS_CLR 0x44 /* Bit 7: Case Open CLR_CHS/Reset bit */ + +/* control in0/in1 's limit modifiability */ +#define W83792D_REG_VID_IN_B 0x17 + +#define W83792D_REG_VBAT 0x5D +#define W83792D_REG_I2C_ADDR 0x48 + +/* Conversions. Rounding and limit checking is only done on the TO_REG + variants. Note that you should be a bit careful with which arguments + these macros are called: arguments may be evaluated more than once. + Fixing this is just not worth it. */ +#define IN_FROM_REG(nr,val) (((nr)<=1)?(val*2): \ + ((((nr)==6)||((nr)==7))?(val*6):(val*4))) +#define IN_TO_REG(nr,val) (((nr)<=1)?(val/2): \ + ((((nr)==6)||((nr)==7))?(val/6):(val/4))) + +static inline u8 +FAN_TO_REG(long rpm, int div) +{ + if (rpm == 0) + return 255; + rpm = SENSORS_LIMIT(rpm, 1, 1000000); + return SENSORS_LIMIT((1350000 + rpm * div / 2) / (rpm * div), 1, 254); +} + +#define FAN_FROM_REG(val,div) ((val) == 0 ? -1 : \ + ((val) == 255 ? 0 : \ + 1350000 / ((val) * (div)))) + +/* for temp1 */ +#define TEMP1_TO_REG(val) (SENSORS_LIMIT(((val) < 0 ? (val)+0x100*1000 \ + : (val)) / 1000, 0, 0xff)) +#define TEMP1_FROM_REG(val) (((val) & 0x80 ? (val)-0x100 : (val)) * 1000) +/* for temp2 and temp3, because they need addtional resolution */ +#define TEMP_ADD_FROM_REG(val1, val2) \ + ((((val1) & 0x80 ? (val1)-0x100 \ + : (val1)) * 1000) + ((val2 & 0x80) ? 500 : 0)) +#define TEMP_ADD_TO_REG_HIGH(val) \ + (SENSORS_LIMIT(((val) < 0 ? (val)+0x100*1000 \ + : (val)) / 1000, 0, 0xff)) +#define TEMP_ADD_TO_REG_LOW(val) ((val%1000) ? 0x80 : 0x00) + +#define PWM_FROM_REG(val) (val) +#define PWM_TO_REG(val) (SENSORS_LIMIT((val),0,255)) +#define DIV_FROM_REG(val) (1 << (val)) + +static inline u8 +DIV_TO_REG(long val) +{ + int i; + val = SENSORS_LIMIT(val, 1, 128) >> 1; + for (i = 0; i < 6; i++) { + if (val == 0) + break; + val >>= 1; + } + return ((u8) i); +} + +struct w83792d_data { + struct i2c_client client; + struct semaphore lock; + enum chips type; + + struct semaphore update_lock; + char valid; /* !=0 if following fields are valid */ + unsigned long last_updated; /* In jiffies */ + + /* array of 2 pointers to subclients */ + struct i2c_client *lm75[2]; + + u8 in[9]; /* Register value */ + u8 in_max[9]; /* Register value */ + u8 in_min[9]; /* Register value */ + u8 low_bits[2]; /* Additional resolution to voltage in0-6 */ + u8 fan[7]; /* Register value */ + u8 fan_min[7]; /* Register value */ + u8 temp1[3]; /* current, over, thyst */ + u8 temp_add[2][6]; /* Register value */ + u8 fan_div[7]; /* Register encoding, shifted right */ + u8 pwm[7]; /* We only consider the first 3 set of pwm, + although 792 chip has 7 set of pwm. */ + u8 pwmenable[3]; + u8 pwm_mode[7]; /* indicates PWM or DC mode: 1->PWM; 0->DC */ + u32 alarms; /* realtime status register encoding,combined */ + u8 chassis; /* Chassis status */ + u8 chassis_clear; /* CLR_CHS, clear chassis intrusion detection */ + u8 thermal_cruise[3]; /* Smart FanI: Fan1,2,3 target value */ + u8 tolerance[3]; /* Fan1,2,3 tolerance(Smart Fan I/II) */ + u8 sf2_points[3][4]; /* Smart FanII: Fan1,2,3 temperature points */ + u8 sf2_levels[3][4]; /* Smart FanII: Fan1,2,3 duty cycle levels */ +}; + +static int w83792d_attach_adapter(struct i2c_adapter *adapter); +static int w83792d_detect(struct i2c_adapter *adapter, int address, int kind); +static int w83792d_detach_client(struct i2c_client *client); + +static int w83792d_read_value(struct i2c_client *client, u8 register); +static int w83792d_write_value(struct i2c_client *client, u8 register, + u8 value); +static struct w83792d_data *w83792d_update_device(struct device *dev); + +#ifdef DEBUG +static void w83792d_print_debug(struct w83792d_data *data, struct device *dev); +#endif + +static void w83792d_init_client(struct i2c_client *client); + +static struct i2c_driver w83792d_driver = { + .owner = THIS_MODULE, + .name = "w83792d", + .flags = I2C_DF_NOTIFY, + .attach_adapter = w83792d_attach_adapter, + .detach_client = w83792d_detach_client, +}; + +static long in_count_from_reg(int nr, struct w83792d_data *data) +{ + u16 vol_count = data->in[nr]; + u16 low_bits = 0; + vol_count = (vol_count << 2); + switch (nr) + { + case 0: /* vin0 */ + low_bits = (data->low_bits[0]) & 0x03; + break; + case 1: /* vin1 */ + low_bits = ((data->low_bits[0]) & 0x0c) >> 2; + break; + case 2: /* vin2 */ + low_bits = ((data->low_bits[0]) & 0x30) >> 4; + break; + case 3: /* vin3 */ + low_bits = ((data->low_bits[0]) & 0xc0) >> 6; + break; + case 4: /* vin4 */ + low_bits = (data->low_bits[1]) & 0x03; + break; + case 5: /* vin5 */ + low_bits = ((data->low_bits[1]) & 0x0c) >> 2; + break; + case 6: /* vin6 */ + low_bits = ((data->low_bits[1]) & 0x30) >> 4; + default: + break; + } + vol_count = vol_count | low_bits; + return vol_count; +} + +/* following are the sysfs callback functions */ +static ssize_t show_in(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct w83792d_data *data = w83792d_update_device(dev); + return sprintf(buf,"%ld\n", IN_FROM_REG(nr,(in_count_from_reg(nr, data)))); +} + +#define show_in_reg(reg) \ +static ssize_t show_##reg(struct device *dev, struct device_attribute *attr, \ + char *buf) \ +{ \ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ + int nr = sensor_attr->index; \ + struct w83792d_data *data = w83792d_update_device(dev); \ + return sprintf(buf,"%ld\n", (long)(IN_FROM_REG(nr, (data->reg[nr])*4))); \ +} + +show_in_reg(in_min); +show_in_reg(in_max); + +#define store_in_reg(REG, reg) \ +static ssize_t store_in_##reg (struct device *dev, \ + struct device_attribute *attr, \ + const char *buf, size_t count) \ +{ \ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ + int nr = sensor_attr->index; \ + struct i2c_client *client = to_i2c_client(dev); \ + struct w83792d_data *data = i2c_get_clientdata(client); \ + u32 val; \ + \ + val = simple_strtoul(buf, NULL, 10); \ + data->in_##reg[nr] = SENSORS_LIMIT(IN_TO_REG(nr, val)/4, 0, 255); \ + w83792d_write_value(client, W83792D_REG_IN_##REG[nr], data->in_##reg[nr]); \ + \ + return count; \ +} +store_in_reg(MIN, min); +store_in_reg(MAX, max); + +#define sysfs_in_reg(offset) \ +static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in, \ + NULL, offset); \ +static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ + show_in_min, store_in_min, offset); \ +static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ + show_in_max, store_in_max, offset); + +sysfs_in_reg(0); +sysfs_in_reg(1); +sysfs_in_reg(2); +sysfs_in_reg(3); +sysfs_in_reg(4); +sysfs_in_reg(5); +sysfs_in_reg(6); +sysfs_in_reg(7); +sysfs_in_reg(8); + +#define device_create_file_in(client, offset) \ +do { \ +device_create_file(&client->dev, &sensor_dev_attr_in##offset##_input.dev_attr); \ +device_create_file(&client->dev, &sensor_dev_attr_in##offset##_max.dev_attr); \ +device_create_file(&client->dev, &sensor_dev_attr_in##offset##_min.dev_attr); \ +} while (0) + +#define show_fan_reg(reg) \ +static ssize_t show_##reg (struct device *dev, struct device_attribute *attr, \ + char *buf) \ +{ \ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ + int nr = sensor_attr->index - 1; \ + struct w83792d_data *data = w83792d_update_device(dev); \ + return sprintf(buf,"%d\n", \ + FAN_FROM_REG(data->reg[nr], DIV_FROM_REG(data->fan_div[nr]))); \ +} + +show_fan_reg(fan); +show_fan_reg(fan_min); + +static ssize_t +store_fan_min(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index - 1; + struct i2c_client *client = to_i2c_client(dev); + struct w83792d_data *data = i2c_get_clientdata(client); + u32 val; + + val = simple_strtoul(buf, NULL, 10); + data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); + w83792d_write_value(client, W83792D_REG_FAN_MIN[nr], + data->fan_min[nr]); + + return count; +} + +static ssize_t +show_fan_div(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct w83792d_data *data = w83792d_update_device(dev); + return sprintf(buf, "%u\n", DIV_FROM_REG(data->fan_div[nr - 1])); +} + +/* Note: we save and restore the fan minimum here, because its value is + determined in part by the fan divisor. This follows the principle of + least suprise; the user doesn't expect the fan minimum to change just + because the divisor changed. */ +static ssize_t +store_fan_div(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index - 1; + struct i2c_client *client = to_i2c_client(dev); + struct w83792d_data *data = i2c_get_clientdata(client); + unsigned long min; + /*u8 reg;*/ + u8 fan_div_reg = 0; + u8 tmp_fan_div; + + /* Save fan_min */ + min = FAN_FROM_REG(data->fan_min[nr], + DIV_FROM_REG(data->fan_div[nr])); + + data->fan_div[nr] = DIV_TO_REG(simple_strtoul(buf, NULL, 10)); + + fan_div_reg = w83792d_read_value(client, W83792D_REG_FAN_DIV[nr >> 1]); + fan_div_reg &= (nr & 0x01) ? 0x8f : 0xf8; + tmp_fan_div = (nr & 0x01) ? (((data->fan_div[nr]) << 4) & 0x70) + : ((data->fan_div[nr]) & 0x07); + w83792d_write_value(client, W83792D_REG_FAN_DIV[nr >> 1], + fan_div_reg | tmp_fan_div); + + /* Restore fan_min */ + data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); + w83792d_write_value(client, W83792D_REG_FAN_MIN[nr], data->fan_min[nr]); + + return count; +} + +#define sysfs_fan(offset) \ +static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan, NULL, \ + offset); \ +static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ + show_fan_div, store_fan_div, offset); \ +static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ + show_fan_min, store_fan_min, offset); + +sysfs_fan(1); +sysfs_fan(2); +sysfs_fan(3); +sysfs_fan(4); +sysfs_fan(5); +sysfs_fan(6); +sysfs_fan(7); + +#define device_create_file_fan(client, offset) \ +do { \ +device_create_file(&client->dev, &sensor_dev_attr_fan##offset##_input.dev_attr); \ +device_create_file(&client->dev, &sensor_dev_attr_fan##offset##_div.dev_attr); \ +device_create_file(&client->dev, &sensor_dev_attr_fan##offset##_min.dev_attr); \ +} while (0) + + +/* read/write the temperature1, includes measured value and limits */ + +static ssize_t show_temp1(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct w83792d_data *data = w83792d_update_device(dev); + return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->temp1[nr])); +} + +static ssize_t store_temp1(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct i2c_client *client = to_i2c_client(dev); + struct w83792d_data *data = i2c_get_clientdata(client); + s32 val; + + val = simple_strtol(buf, NULL, 10); + + data->temp1[nr] = TEMP1_TO_REG(val); + w83792d_write_value(client, W83792D_REG_TEMP1[nr], + data->temp1[nr]); + + return count; +} + + +static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1, NULL, 0); +static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, show_temp1, + store_temp1, 1); +static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, show_temp1, + store_temp1, 2); + +#define device_create_file_temp1(client) \ +do { \ +device_create_file(&client->dev, &sensor_dev_attr_temp1_input.dev_attr); \ +device_create_file(&client->dev, &sensor_dev_attr_temp1_max.dev_attr); \ +device_create_file(&client->dev, &sensor_dev_attr_temp1_max_hyst.dev_attr); \ +} while (0) + + +/* read/write the temperature2-3, includes measured value and limits */ + +static ssize_t show_temp23(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute_2 *sensor_attr = to_sensor_dev_attr_2(attr); + int nr = sensor_attr->nr; + int index = sensor_attr->index; + struct w83792d_data *data = w83792d_update_device(dev); + return sprintf(buf,"%ld\n", + (long)TEMP_ADD_FROM_REG(data->temp_add[nr][index], + data->temp_add[nr][index+1])); +} + +static ssize_t store_temp23(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct sensor_device_attribute_2 *sensor_attr = to_sensor_dev_attr_2(attr); + int nr = sensor_attr->nr; + int index = sensor_attr->index; + struct i2c_client *client = to_i2c_client(dev); + struct w83792d_data *data = i2c_get_clientdata(client); + s32 val; + + val = simple_strtol(buf, NULL, 10); + + data->temp_add[nr][index] = TEMP_ADD_TO_REG_HIGH(val); + data->temp_add[nr][index+1] = TEMP_ADD_TO_REG_LOW(val); + w83792d_write_value(client, W83792D_REG_TEMP_ADD[nr][index], + data->temp_add[nr][index]); + w83792d_write_value(client, W83792D_REG_TEMP_ADD[nr][index+1], + data->temp_add[nr][index+1]); + + return count; +} + +#define sysfs_temp23(name,idx) \ +static SENSOR_DEVICE_ATTR_2(name##_input, S_IRUGO, show_temp23, NULL, \ + idx, 0); \ +static SENSOR_DEVICE_ATTR_2(name##_max, S_IRUGO | S_IWUSR, \ + show_temp23, store_temp23, idx, 2); \ +static SENSOR_DEVICE_ATTR_2(name##_max_hyst, S_IRUGO | S_IWUSR, \ + show_temp23, store_temp23, idx, 4); + +sysfs_temp23(temp2,0) +sysfs_temp23(temp3,1) + +#define device_create_file_temp_add(client, offset) \ +do { \ +device_create_file(&client->dev, &sensor_dev_attr_temp##offset##_input.dev_attr); \ +device_create_file(&client->dev, &sensor_dev_attr_temp##offset##_max.dev_attr); \ +device_create_file(&client->dev, \ +&sensor_dev_attr_temp##offset##_max_hyst.dev_attr); \ +} while (0) + + +/* get reatime status of all sensors items: voltage, temp, fan */ +static ssize_t +show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct w83792d_data *data = w83792d_update_device(dev); + return sprintf(buf, "%d\n", data->alarms); +} + +static +DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); +#define device_create_file_alarms(client) \ +device_create_file(&client->dev, &dev_attr_alarms); + + + +static ssize_t +show_pwm(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct w83792d_data *data = w83792d_update_device(dev); + return sprintf(buf, "%ld\n", (long) PWM_FROM_REG(data->pwm[nr-1])); +} + +static ssize_t +show_pwmenable(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index - 1; + struct w83792d_data *data = w83792d_update_device(dev); + long pwm_enable_tmp = 1; + + switch (data->pwmenable[nr]) { + case 0: + pwm_enable_tmp = 1; /* manual mode */ + break; + case 1: + pwm_enable_tmp = 3; /*thermal cruise/Smart Fan I */ + break; + case 2: + pwm_enable_tmp = 2; /* Smart Fan II */ + break; + } + + return sprintf(buf, "%ld\n", pwm_enable_tmp); +} + +static ssize_t +store_pwm(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index - 1; + struct i2c_client *client = to_i2c_client(dev); + struct w83792d_data *data = i2c_get_clientdata(client); + u32 val; + + val = simple_strtoul(buf, NULL, 10); + data->pwm[nr] = PWM_TO_REG(val); + w83792d_write_value(client, W83792D_REG_PWM[nr], data->pwm[nr]); + + return count; +} + +static ssize_t +store_pwmenable(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index - 1; + struct i2c_client *client = to_i2c_client(dev); + struct w83792d_data *data = i2c_get_clientdata(client); + u32 val; + u8 fan_cfg_tmp, cfg1_tmp, cfg2_tmp, cfg3_tmp, cfg4_tmp; + + val = simple_strtoul(buf, NULL, 10); + switch (val) { + case 1: + data->pwmenable[nr] = 0; /* manual mode */ + break; + case 2: + data->pwmenable[nr] = 2; /* Smart Fan II */ + break; + case 3: + data->pwmenable[nr] = 1; /* thermal cruise/Smart Fan I */ + break; + default: + return -EINVAL; + } + cfg1_tmp = data->pwmenable[0]; + cfg2_tmp = (data->pwmenable[1]) << 2; + cfg3_tmp = (data->pwmenable[2]) << 4; + cfg4_tmp = w83792d_read_value(client,W83792D_REG_FAN_CFG) & 0xc0; + fan_cfg_tmp = ((cfg4_tmp | cfg3_tmp) | cfg2_tmp) | cfg1_tmp; + w83792d_write_value(client, W83792D_REG_FAN_CFG, fan_cfg_tmp); + + return count; +} + +#define sysfs_pwm(offset) \ +static SENSOR_DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \ + show_pwm, store_pwm, offset); \ +static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \ + show_pwmenable, store_pwmenable, offset); \ + +sysfs_pwm(1); +sysfs_pwm(2); +sysfs_pwm(3); + + +#define device_create_file_pwm(client, offset) \ +do { \ +device_create_file(&client->dev, &sensor_dev_attr_pwm##offset.dev_attr); \ +} while (0) + +#define device_create_file_pwmenable(client, offset) \ +do { \ +device_create_file(&client->dev, &sensor_dev_attr_pwm##offset##_enable.dev_attr); \ +} while (0) + + +static ssize_t +show_pwm_mode(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct w83792d_data *data = w83792d_update_device(dev); + return sprintf(buf, "%d\n", data->pwm_mode[nr-1]); +} + +static ssize_t +store_pwm_mode(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index - 1; + struct i2c_client *client = to_i2c_client(dev); + struct w83792d_data *data = i2c_get_clientdata(client); + u32 val; + u8 pwm_mode_mask = 0; + + val = simple_strtoul(buf, NULL, 10); + data->pwm_mode[nr] = SENSORS_LIMIT(val, 0, 1); + pwm_mode_mask = w83792d_read_value(client, + W83792D_REG_PWM[nr]) & 0x7f; + w83792d_write_value(client, W83792D_REG_PWM[nr], + ((data->pwm_mode[nr]) << 7) | pwm_mode_mask); + + return count; +} + +#define sysfs_pwm_mode(offset) \ +static SENSOR_DEVICE_ATTR(pwm##offset##_mode, S_IRUGO | S_IWUSR, \ + show_pwm_mode, store_pwm_mode, offset); + +sysfs_pwm_mode(1); +sysfs_pwm_mode(2); +sysfs_pwm_mode(3); + +#define device_create_file_pwm_mode(client, offset) \ +do { \ +device_create_file(&client->dev, &sensor_dev_attr_pwm##offset##_mode.dev_attr); \ +} while (0) + + +static ssize_t +show_regs_chassis(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct w83792d_data *data = w83792d_update_device(dev); + return sprintf(buf, "%d\n", data->chassis); +} + +static DEVICE_ATTR(chassis, S_IRUGO, show_regs_chassis, NULL); + +#define device_create_file_chassis(client) \ +do { \ +device_create_file(&client->dev, &dev_attr_chassis); \ +} while (0) + + +static ssize_t +show_chassis_clear(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct w83792d_data *data = w83792d_update_device(dev); + return sprintf(buf, "%d\n", data->chassis_clear); +} + +static ssize_t +store_chassis_clear(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct w83792d_data *data = i2c_get_clientdata(client); + u32 val; + u8 temp1 = 0, temp2 = 0; + + val = simple_strtoul(buf, NULL, 10); + + data->chassis_clear = SENSORS_LIMIT(val, 0 ,1); + temp1 = ((data->chassis_clear) << 7) & 0x80; + temp2 = w83792d_read_value(client, + W83792D_REG_CHASSIS_CLR) & 0x7f; + w83792d_write_value(client, W83792D_REG_CHASSIS_CLR, temp1 | temp2); + + return count; +} + +static DEVICE_ATTR(chassis_clear, S_IRUGO | S_IWUSR, + show_chassis_clear, store_chassis_clear); + +#define device_create_file_chassis_clear(client) \ +do { \ +device_create_file(&client->dev, &dev_attr_chassis_clear); \ +} while (0) + + + +/* For Smart Fan I / Thermal Cruise */ +static ssize_t +show_thermal_cruise(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct w83792d_data *data = w83792d_update_device(dev); + return sprintf(buf, "%ld\n", (long)data->thermal_cruise[nr-1]); +} + +static ssize_t +store_thermal_cruise(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index - 1; + struct i2c_client *client = to_i2c_client(dev); + struct w83792d_data *data = i2c_get_clientdata(client); + u32 val; + u8 target_tmp=0, target_mask=0; + + val = simple_strtoul(buf, NULL, 10); + target_tmp = val; + target_tmp = target_tmp & 0x7f; + target_mask = w83792d_read_value(client, W83792D_REG_THERMAL[nr]) & 0x80; + data->thermal_cruise[nr] = SENSORS_LIMIT(target_tmp, 0, 255); + w83792d_write_value(client, W83792D_REG_THERMAL[nr], + (data->thermal_cruise[nr]) | target_mask); + + return count; +} + +#define sysfs_thermal_cruise(offset) \ +static SENSOR_DEVICE_ATTR(thermal_cruise##offset, S_IRUGO | S_IWUSR, \ + show_thermal_cruise, store_thermal_cruise, offset); + +sysfs_thermal_cruise(1); +sysfs_thermal_cruise(2); +sysfs_thermal_cruise(3); + +#define device_create_file_thermal_cruise(client, offset) \ +do { \ +device_create_file(&client->dev, \ +&sensor_dev_attr_thermal_cruise##offset.dev_attr); \ +} while (0) + + +/* For Smart Fan I/Thermal Cruise and Smart Fan II */ +static ssize_t +show_tolerance(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct w83792d_data *data = w83792d_update_device(dev); + return sprintf(buf, "%ld\n", (long)data->tolerance[nr-1]); +} + +static ssize_t +store_tolerance(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index - 1; + struct i2c_client *client = to_i2c_client(dev); + struct w83792d_data *data = i2c_get_clientdata(client); + u32 val; + u8 tol_tmp, tol_mask; + + val = simple_strtoul(buf, NULL, 10); + tol_mask = w83792d_read_value(client, + W83792D_REG_TOLERANCE[nr]) & ((nr == 1) ? 0x0f : 0xf0); + tol_tmp = SENSORS_LIMIT(val, 0, 15); + tol_tmp &= 0x0f; + data->tolerance[nr] = tol_tmp; + if (nr == 1) { + tol_tmp <<= 4; + } + w83792d_write_value(client, W83792D_REG_TOLERANCE[nr], + tol_mask | tol_tmp); + + return count; +} + +#define sysfs_tolerance(offset) \ +static SENSOR_DEVICE_ATTR(tolerance##offset, S_IRUGO | S_IWUSR, \ + show_tolerance, store_tolerance, offset); + +sysfs_tolerance(1); +sysfs_tolerance(2); +sysfs_tolerance(3); + +#define device_create_file_tolerance(client, offset) \ +do { \ +device_create_file(&client->dev, &sensor_dev_attr_tolerance##offset.dev_attr); \ +} while (0) + + +/* For Smart Fan II */ +static ssize_t +show_sf2_point(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute_2 *sensor_attr = to_sensor_dev_attr_2(attr); + int nr = sensor_attr->nr; + int index = sensor_attr->index; + struct w83792d_data *data = w83792d_update_device(dev); + return sprintf(buf, "%ld\n", (long)data->sf2_points[index-1][nr-1]); +} + +static ssize_t +store_sf2_point(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct sensor_device_attribute_2 *sensor_attr = to_sensor_dev_attr_2(attr); + int nr = sensor_attr->nr - 1; + int index = sensor_attr->index - 1; + struct i2c_client *client = to_i2c_client(dev); + struct w83792d_data *data = i2c_get_clientdata(client); + u32 val; + u8 mask_tmp = 0; + + val = simple_strtoul(buf, NULL, 10); + data->sf2_points[index][nr] = SENSORS_LIMIT(val, 0, 127); + mask_tmp = w83792d_read_value(client, + W83792D_REG_POINTS[index][nr]) & 0x80; + w83792d_write_value(client, W83792D_REG_POINTS[index][nr], + mask_tmp|data->sf2_points[index][nr]); + + return count; +} + +#define sysfs_sf2_point(offset, index) \ +static SENSOR_DEVICE_ATTR_2(sf2_point##offset##_fan##index, S_IRUGO | S_IWUSR, \ + show_sf2_point, store_sf2_point, offset, index); + +sysfs_sf2_point(1, 1); /* Fan1 */ +sysfs_sf2_point(2, 1); /* Fan1 */ +sysfs_sf2_point(3, 1); /* Fan1 */ +sysfs_sf2_point(4, 1); /* Fan1 */ +sysfs_sf2_point(1, 2); /* Fan2 */ +sysfs_sf2_point(2, 2); /* Fan2 */ +sysfs_sf2_point(3, 2); /* Fan2 */ +sysfs_sf2_point(4, 2); /* Fan2 */ +sysfs_sf2_point(1, 3); /* Fan3 */ +sysfs_sf2_point(2, 3); /* Fan3 */ +sysfs_sf2_point(3, 3); /* Fan3 */ +sysfs_sf2_point(4, 3); /* Fan3 */ + +#define device_create_file_sf2_point(client, offset, index) \ +do { \ +device_create_file(&client->dev, \ +&sensor_dev_attr_sf2_point##offset##_fan##index.dev_attr); \ +} while (0) + + +static ssize_t +show_sf2_level(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute_2 *sensor_attr = to_sensor_dev_attr_2(attr); + int nr = sensor_attr->nr; + int index = sensor_attr->index; + struct w83792d_data *data = w83792d_update_device(dev); + return sprintf(buf, "%d\n", + (((data->sf2_levels[index-1][nr]) * 100) / 15)); +} + +static ssize_t +store_sf2_level(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct sensor_device_attribute_2 *sensor_attr = to_sensor_dev_attr_2(attr); + int nr = sensor_attr->nr; + int index = sensor_attr->index - 1; + struct i2c_client *client = to_i2c_client(dev); + struct w83792d_data *data = i2c_get_clientdata(client); + u32 val; + u8 mask_tmp=0, level_tmp=0; + + val = simple_strtoul(buf, NULL, 10); + data->sf2_levels[index][nr] = SENSORS_LIMIT((val * 15) / 100, 0, 15); + mask_tmp = w83792d_read_value(client, W83792D_REG_LEVELS[index][nr]) + & ((nr==3) ? 0xf0 : 0x0f); + if (nr==3) { + level_tmp = data->sf2_levels[index][nr]; + } else { + level_tmp = data->sf2_levels[index][nr] << 4; + } + w83792d_write_value(client, W83792D_REG_LEVELS[index][nr], level_tmp | mask_tmp); + + return count; +} + +#define sysfs_sf2_level(offset, index) \ +static SENSOR_DEVICE_ATTR_2(sf2_level##offset##_fan##index, S_IRUGO | S_IWUSR, \ + show_sf2_level, store_sf2_level, offset, index); + +sysfs_sf2_level(1, 1); /* Fan1 */ +sysfs_sf2_level(2, 1); /* Fan1 */ +sysfs_sf2_level(3, 1); /* Fan1 */ +sysfs_sf2_level(1, 2); /* Fan2 */ +sysfs_sf2_level(2, 2); /* Fan2 */ +sysfs_sf2_level(3, 2); /* Fan2 */ +sysfs_sf2_level(1, 3); /* Fan3 */ +sysfs_sf2_level(2, 3); /* Fan3 */ +sysfs_sf2_level(3, 3); /* Fan3 */ + +#define device_create_file_sf2_level(client, offset, index) \ +do { \ +device_create_file(&client->dev, \ +&sensor_dev_attr_sf2_level##offset##_fan##index.dev_attr); \ +} while (0) + + +/* This function is called when: + * w83792d_driver is inserted (when this module is loaded), for each + available adapter + * when a new adapter is inserted (and w83792d_driver is still present) */ +static int +w83792d_attach_adapter(struct i2c_adapter *adapter) +{ + if (!(adapter->class & I2C_CLASS_HWMON)) + return 0; + return i2c_detect(adapter, &addr_data, w83792d_detect); +} + + +static int +w83792d_create_subclient(struct i2c_adapter *adapter, + struct i2c_client *new_client, int addr, + struct i2c_client **sub_cli) +{ + int err; + struct i2c_client *sub_client; + + (*sub_cli) = sub_client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); + if (!(sub_client)) { + return -ENOMEM; + } + memset(sub_client, 0x00, sizeof(struct i2c_client)); + sub_client->addr = 0x48 + addr; + i2c_set_clientdata(sub_client, NULL); + sub_client->adapter = adapter; + sub_client->driver = &w83792d_driver; + sub_client->flags = 0; + strlcpy(sub_client->name, "w83792d subclient", I2C_NAME_SIZE); + if ((err = i2c_attach_client(sub_client))) { + dev_err(&new_client->dev, "subclient registration " + "at address 0x%x failed\n", sub_client->addr); + kfree(sub_client); + return err; + } + return 0; +} + + +static int +w83792d_detect_subclients(struct i2c_adapter *adapter, int address, int kind, + struct i2c_client *new_client) +{ + int i, id, err; + u8 val; + struct w83792d_data *data = i2c_get_clientdata(new_client); + + id = i2c_adapter_id(adapter); + if (force_subclients[0] == id && force_subclients[1] == address) { + for (i = 2; i <= 3; i++) { + if (force_subclients[i] < 0x48 || + force_subclients[i] > 0x4f) { + dev_err(&new_client->dev, "invalid subclient " + "address %d; must be 0x48-0x4f\n", + force_subclients[i]); + err = -ENODEV; + goto ERROR_SC_0; + } + } + w83792d_write_value(new_client, W83792D_REG_I2C_SUBADDR, + (force_subclients[2] & 0x07) | + ((force_subclients[3] & 0x07) << 4)); + } + + val = w83792d_read_value(new_client, W83792D_REG_I2C_SUBADDR); + if (!(val & 0x08)) { + err = w83792d_create_subclient(adapter, new_client, val & 0x7, + &data->lm75[0]); + if (err < 0) + goto ERROR_SC_0; + } + if (!(val & 0x80)) { + if ((data->lm75[0] != NULL) && + ((val & 0x7) == ((val >> 4) & 0x7))) { + dev_err(&new_client->dev, "duplicate addresses 0x%x, " + "use force_subclient\n", data->lm75[0]->addr); + err = -ENODEV; + goto ERROR_SC_1; + } + err = w83792d_create_subclient(adapter, new_client, + (val >> 4) & 0x7, &data->lm75[1]); + if (err < 0) + goto ERROR_SC_1; + } + + return 0; + +/* Undo inits in case of errors */ + +ERROR_SC_1: + if (data->lm75[0] != NULL) { + i2c_detach_client(data->lm75[0]); + kfree(data->lm75[0]); + } +ERROR_SC_0: + return err; +} + + +static int +w83792d_detect(struct i2c_adapter *adapter, int address, int kind) +{ + int i = 0, val1 = 0, val2; + struct i2c_client *new_client; + struct w83792d_data *data; + int err = 0; + const char *client_name = ""; + + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { + goto ERROR0; + } + + /* OK. For now, we presume we have a valid client. We now create the + client structure, even though we cannot fill it completely yet. + But it allows us to access w83792d_{read,write}_value. */ + + if (!(data = kmalloc(sizeof(struct w83792d_data), GFP_KERNEL))) { + err = -ENOMEM; + goto ERROR0; + } + memset(data, 0, sizeof(struct w83792d_data)); + + new_client = &data->client; + i2c_set_clientdata(new_client, data); + new_client->addr = address; + init_MUTEX(&data->lock); + new_client->adapter = adapter; + new_client->driver = &w83792d_driver; + new_client->flags = 0; + + /* Now, we do the remaining detection. */ + + /* The w83792d may be stuck in some other bank than bank 0. This may + make reading other information impossible. Specify a force=... or + force_*=... parameter, and the Winbond will be reset to the right + bank. */ + if (kind < 0) { + if (w83792d_read_value(new_client, W83792D_REG_CONFIG) & 0x80) { + dev_warn(&new_client->dev, "Detection failed at step " + "3\n"); + goto ERROR1; + } + val1 = w83792d_read_value(new_client, W83792D_REG_BANK); + val2 = w83792d_read_value(new_client, W83792D_REG_CHIPMAN); + /* Check for Winbond ID if in bank 0 */ + if (!(val1 & 0x07)) { /* is Bank0 */ + if (((!(val1 & 0x80)) && (val2 != 0xa3)) || + ((val1 & 0x80) && (val2 != 0x5c))) { + goto ERROR1; + } + } + /* If Winbond chip, address of chip and W83792D_REG_I2C_ADDR + should match */ + if (w83792d_read_value(new_client, + W83792D_REG_I2C_ADDR) != address) { + dev_warn(&new_client->dev, "Detection failed " + "at step 5\n"); + goto ERROR1; + } + } + + /* We have either had a force parameter, or we have already detected the + Winbond. Put it now into bank 0 and Vendor ID High Byte */ + w83792d_write_value(new_client, + W83792D_REG_BANK, + (w83792d_read_value(new_client, + W83792D_REG_BANK) & 0x78) | 0x80); + + /* Determine the chip type. */ + if (kind <= 0) { + /* get vendor ID */ + val2 = w83792d_read_value(new_client, W83792D_REG_CHIPMAN); + if (val2 != 0x5c) { /* the vendor is NOT Winbond */ + goto ERROR1; + } + val1 = w83792d_read_value(new_client, W83792D_REG_WCHIPID); + if (val1 == 0x7a && address >= 0x2c) { + kind = w83792d; + } else { + if (kind == 0) + dev_warn(&new_client->dev, + "w83792d: Ignoring 'force' parameter for" + " unknown chip at adapter %d, address" + " 0x%02x\n", i2c_adapter_id(adapter), + address); + goto ERROR1; + } + } + + if (kind == w83792d) { + client_name = "w83792d"; + } else { + dev_err(&new_client->dev, "w83792d: Internal error: unknown" + " kind (%d)?!?", kind); + goto ERROR1; + } + + /* Fill in the remaining client fields and put into the global list */ + strlcpy(new_client->name, client_name, I2C_NAME_SIZE); + data->type = kind; + + data->valid = 0; + init_MUTEX(&data->update_lock); + + /* Tell the I2C layer a new client has arrived */ + if ((err = i2c_attach_client(new_client))) + goto ERROR1; + + if ((err = w83792d_detect_subclients(adapter, address, + kind, new_client))) + goto ERROR2; + + /* Initialize the chip */ + w83792d_init_client(new_client); + + /* A few vars need to be filled upon startup */ + for (i = 1; i <= 7; i++) { + data->fan_min[i - 1] = w83792d_read_value(new_client, + W83792D_REG_FAN_MIN[i]); + } + + /* Register sysfs hooks */ + device_create_file_in(new_client, 0); + device_create_file_in(new_client, 1); + device_create_file_in(new_client, 2); + device_create_file_in(new_client, 3); + device_create_file_in(new_client, 4); + device_create_file_in(new_client, 5); + device_create_file_in(new_client, 6); + device_create_file_in(new_client, 7); + device_create_file_in(new_client, 8); + + device_create_file_fan(new_client, 1); + device_create_file_fan(new_client, 2); + device_create_file_fan(new_client, 3); + device_create_file_fan(new_client, 4); + device_create_file_fan(new_client, 5); + device_create_file_fan(new_client, 6); + device_create_file_fan(new_client, 7); + + device_create_file_temp1(new_client); /* Temp1 */ + device_create_file_temp_add(new_client, 2); /* Temp2 */ + device_create_file_temp_add(new_client, 3); /* Temp3 */ + + device_create_file_alarms(new_client); + + device_create_file_pwm(new_client, 1); + device_create_file_pwm(new_client, 2); + device_create_file_pwm(new_client, 3); + + device_create_file_pwmenable(new_client, 1); + device_create_file_pwmenable(new_client, 2); + device_create_file_pwmenable(new_client, 3); + + device_create_file_pwm_mode(new_client, 1); + device_create_file_pwm_mode(new_client, 2); + device_create_file_pwm_mode(new_client, 3); + + device_create_file_chassis(new_client); + device_create_file_chassis_clear(new_client); + + device_create_file_thermal_cruise(new_client, 1); + device_create_file_thermal_cruise(new_client, 2); + device_create_file_thermal_cruise(new_client, 3); + + device_create_file_tolerance(new_client, 1); + device_create_file_tolerance(new_client, 2); + device_create_file_tolerance(new_client, 3); + + device_create_file_sf2_point(new_client, 1, 1); /* Fan1 */ + device_create_file_sf2_point(new_client, 2, 1); /* Fan1 */ + device_create_file_sf2_point(new_client, 3, 1); /* Fan1 */ + device_create_file_sf2_point(new_client, 4, 1); /* Fan1 */ + device_create_file_sf2_point(new_client, 1, 2); /* Fan2 */ + device_create_file_sf2_point(new_client, 2, 2); /* Fan2 */ + device_create_file_sf2_point(new_client, 3, 2); /* Fan2 */ + device_create_file_sf2_point(new_client, 4, 2); /* Fan2 */ + device_create_file_sf2_point(new_client, 1, 3); /* Fan3 */ + device_create_file_sf2_point(new_client, 2, 3); /* Fan3 */ + device_create_file_sf2_point(new_client, 3, 3); /* Fan3 */ + device_create_file_sf2_point(new_client, 4, 3); /* Fan3 */ + + device_create_file_sf2_level(new_client, 1, 1); /* Fan1 */ + device_create_file_sf2_level(new_client, 2, 1); /* Fan1 */ + device_create_file_sf2_level(new_client, 3, 1); /* Fan1 */ + device_create_file_sf2_level(new_client, 1, 2); /* Fan2 */ + device_create_file_sf2_level(new_client, 2, 2); /* Fan2 */ + device_create_file_sf2_level(new_client, 3, 2); /* Fan2 */ + device_create_file_sf2_level(new_client, 1, 3); /* Fan3 */ + device_create_file_sf2_level(new_client, 2, 3); /* Fan3 */ + device_create_file_sf2_level(new_client, 3, 3); /* Fan3 */ + + return 0; + +ERROR2: + i2c_detach_client(new_client); +ERROR1: + kfree(data); +ERROR0: + return err; +} + +static int +w83792d_detach_client(struct i2c_client *client) +{ + int err; + + if ((err = i2c_detach_client(client))) { + dev_err(&client->dev, + "Client deregistration failed, client not detached.\n"); + return err; + } + + if (i2c_get_clientdata(client)==NULL) { + /* subclients */ + kfree(client); + } else { + /* main client */ + kfree(i2c_get_clientdata(client)); + } + + return 0; +} + +/* The SMBus locks itself, usually, but nothing may access the Winbond between + bank switches. ISA access must always be locked explicitly! + We ignore the W83792D BUSY flag at this moment - it could lead to deadlocks, + would slow down the W83792D access and should not be necessary. + There are some ugly typecasts here, but the good news is - they should + nowhere else be necessary! */ +static int +w83792d_read_value(struct i2c_client *client, u8 reg) +{ + int res=0; + res = i2c_smbus_read_byte_data(client, reg); + + return res; +} + +static int +w83792d_write_value(struct i2c_client *client, u8 reg, u8 value) +{ + i2c_smbus_write_byte_data(client, reg, value); + return 0; +} + +/* Called when we have found a new W83792D. It should set limits, etc. */ +static void +w83792d_init_client(struct i2c_client *client) +{ + u8 temp2_cfg, temp3_cfg, vid_in_b; + + if (init) { + w83792d_write_value(client, W83792D_REG_CONFIG, 0x80); + } + /* Clear the bit6 of W83792D_REG_VID_IN_B(set it into 0): + W83792D_REG_VID_IN_B bit6 = 0: the high/low limit of + vin0/vin1 can be modified by user; + W83792D_REG_VID_IN_B bit6 = 1: the high/low limit of + vin0/vin1 auto-updated, can NOT be modified by user. */ + vid_in_b = w83792d_read_value(client, W83792D_REG_VID_IN_B); + w83792d_write_value(client, W83792D_REG_VID_IN_B, + vid_in_b & 0xbf); + + temp2_cfg = w83792d_read_value(client, W83792D_REG_TEMP2_CONFIG); + temp3_cfg = w83792d_read_value(client, W83792D_REG_TEMP3_CONFIG); + w83792d_write_value(client, W83792D_REG_TEMP2_CONFIG, + temp2_cfg & 0xe6); + w83792d_write_value(client, W83792D_REG_TEMP3_CONFIG, + temp3_cfg & 0xe6); + + /* Start monitoring */ + w83792d_write_value(client, W83792D_REG_CONFIG, + (w83792d_read_value(client, + W83792D_REG_CONFIG) & 0xf7) + | 0x01); +} + +static struct w83792d_data *w83792d_update_device(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct w83792d_data *data = i2c_get_clientdata(client); + int i, j; + u8 reg_array_tmp[4], pwm_array_tmp[7], reg_tmp; + + down(&data->update_lock); + + if (time_after + (jiffies - data->last_updated, (unsigned long) (HZ * 3)) + || time_before(jiffies, data->last_updated) || !data->valid) { + dev_dbg(dev, "Starting device update\n"); + + /* Update the voltages measured value and limits */ + for (i = 0; i < 9; i++) { + data->in[i] = w83792d_read_value(client, + W83792D_REG_IN[i]); + data->in_max[i] = w83792d_read_value(client, + W83792D_REG_IN_MAX[i]); + data->in_min[i] = w83792d_read_value(client, + W83792D_REG_IN_MIN[i]); + } + data->low_bits[0] = w83792d_read_value(client, + W83792D_REG_LOW_BITS1); + data->low_bits[1] = w83792d_read_value(client, + W83792D_REG_LOW_BITS2); + for (i = 0; i < 7; i++) { + /* Update the Fan measured value and limits */ + data->fan[i] = w83792d_read_value(client, + W83792D_REG_FAN[i]); + data->fan_min[i] = w83792d_read_value(client, + W83792D_REG_FAN_MIN[i]); + /* Update the PWM/DC Value and PWM/DC flag */ + pwm_array_tmp[i] = w83792d_read_value(client, + W83792D_REG_PWM[i]); + data->pwm[i] = pwm_array_tmp[i] & 0x0f; + data->pwm_mode[i] = (pwm_array_tmp[i] >> 7) & 0x01; + } + + reg_tmp = w83792d_read_value(client, W83792D_REG_FAN_CFG); + data->pwmenable[0] = reg_tmp & 0x03; + data->pwmenable[1] = (reg_tmp>>2) & 0x03; + data->pwmenable[2] = (reg_tmp>>4) & 0x03; + + for (i = 0; i < 3; i++) { + data->temp1[i] = w83792d_read_value(client, + W83792D_REG_TEMP1[i]); + } + for (i = 0; i < 2; i++) { + for (j = 0; j < 6; j++) { + data->temp_add[i][j] = w83792d_read_value( + client,W83792D_REG_TEMP_ADD[i][j]); + } + } + + /* Update the Fan Divisor */ + for (i = 0; i < 4; i++) { + reg_array_tmp[i] = w83792d_read_value(client, + W83792D_REG_FAN_DIV[i]); + } + data->fan_div[0] = reg_array_tmp[0] & 0x07; + data->fan_div[1] = (reg_array_tmp[0] >> 4) & 0x07; + data->fan_div[2] = reg_array_tmp[1] & 0x07; + data->fan_div[3] = (reg_array_tmp[1] >> 4) & 0x07; + data->fan_div[4] = reg_array_tmp[2] & 0x07; + data->fan_div[5] = (reg_array_tmp[2] >> 4) & 0x07; + data->fan_div[6] = reg_array_tmp[3] & 0x07; + + /* Update the realtime status */ + data->alarms = w83792d_read_value(client, W83792D_REG_ALARM1) + + (w83792d_read_value(client, W83792D_REG_ALARM2) << 8) + + (w83792d_read_value(client, W83792D_REG_ALARM3) << 16); + + /* Update CaseOpen status and it's CLR_CHS. */ + data->chassis = (w83792d_read_value(client, + W83792D_REG_CHASSIS) >> 5) & 0x01; + data->chassis_clear = (w83792d_read_value(client, + W83792D_REG_CHASSIS_CLR) >> 7) & 0x01; + + /* Update Thermal Cruise/Smart Fan I target value */ + for (i = 0; i < 3; i++) { + data->thermal_cruise[i] = + w83792d_read_value(client, + W83792D_REG_THERMAL[i]) & 0x7f; + } + + /* Update Smart Fan I/II tolerance */ + reg_tmp = w83792d_read_value(client, W83792D_REG_TOLERANCE[0]); + data->tolerance[0] = reg_tmp & 0x0f; + data->tolerance[1] = (reg_tmp >> 4) & 0x0f; + data->tolerance[2] = w83792d_read_value(client, + W83792D_REG_TOLERANCE[2]) & 0x0f; + + /* Update Smart Fan II temperature points */ + for (i = 0; i < 3; i++) { + for (j = 0; j < 4; j++) { + data->sf2_points[i][j] = w83792d_read_value( + client,W83792D_REG_POINTS[i][j]) & 0x7f; + } + } + + /* Update Smart Fan II duty cycle levels */ + for (i = 0; i < 3; i++) { + reg_tmp = w83792d_read_value(client, + W83792D_REG_LEVELS[i][0]); + data->sf2_levels[i][0] = reg_tmp & 0x0f; + data->sf2_levels[i][1] = (reg_tmp >> 4) & 0x0f; + reg_tmp = w83792d_read_value(client, + W83792D_REG_LEVELS[i][2]); + data->sf2_levels[i][2] = (reg_tmp >> 4) & 0x0f; + data->sf2_levels[i][3] = reg_tmp & 0x0f; + } + + data->last_updated = jiffies; + data->valid = 1; + } + + up(&data->update_lock); + +#ifdef DEBUG + w83792d_print_debug(data, dev); +#endif + + return data; +} + +#ifdef DEBUG +static void w83792d_print_debug(struct w83792d_data *data, struct device *dev) +{ + int i=0, j=0; + dev_dbg(dev, "==========The following is the debug message...========\n"); + dev_dbg(dev, "9 set of Voltages: =====>\n"); + for (i=0; i<9; i++) { + dev_dbg(dev, "vin[%d] is: 0x%x\n", i, data->in[i]); + dev_dbg(dev, "vin[%d] max is: 0x%x\n", i, data->in_max[i]); + dev_dbg(dev, "vin[%d] min is: 0x%x\n", i, data->in_min[i]); + } + dev_dbg(dev, "Low Bit1 is: 0x%x\n", data->low_bits[0]); + dev_dbg(dev, "Low Bit2 is: 0x%x\n", data->low_bits[1]); + dev_dbg(dev, "7 set of Fan Counts and Duty Cycles: =====>\n"); + for (i=0; i<7; i++) { + dev_dbg(dev, "fan[%d] is: 0x%x\n", i, data->fan[i]); + dev_dbg(dev, "fan[%d] min is: 0x%x\n", i, data->fan_min[i]); + dev_dbg(dev, "pwm[%d] is: 0x%x\n", i, data->pwm[i]); + dev_dbg(dev, "pwm_mode[%d] is: 0x%x\n", i, data->pwm_mode[i]); + } + dev_dbg(dev, "3 set of Temperatures: =====>\n"); + for (i=0; i<3; i++) { + dev_dbg(dev, "temp1[%d] is: 0x%x\n", i, data->temp1[i]); + } + + for (i=0; i<2; i++) { + for (j=0; j<6; j++) { + dev_dbg(dev, "temp_add[%d][%d] is: 0x%x\n", i, j, + data->temp_add[i][j]); + } + } + + for (i=0; i<7; i++) { + dev_dbg(dev, "fan_div[%d] is: 0x%x\n", i, data->fan_div[i]); + } + dev_dbg(dev, "==========End of the debug message...==================\n"); + dev_dbg(dev, "\n"); +} +#endif + +static int __init +sensors_w83792d_init(void) +{ + return i2c_add_driver(&w83792d_driver); +} + +static void __exit +sensors_w83792d_exit(void) +{ + i2c_del_driver(&w83792d_driver); +} + +MODULE_AUTHOR("Chunhao Huang @ Winbond "); +MODULE_DESCRIPTION("W83792AD/D driver for linux-2.6"); +MODULE_LICENSE("GPL"); + +module_init(sensors_w83792d_init); +module_exit(sensors_w83792d_exit); + diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h index 1b5018a965f5..7eb4004b3601 100644 --- a/include/linux/hwmon-sysfs.h +++ b/include/linux/hwmon-sysfs.h @@ -33,4 +33,19 @@ struct sensor_device_attribute sensor_dev_attr_##_name = { \ .index = _index, \ } +struct sensor_device_attribute_2 { + struct device_attribute dev_attr; + u8 index; + u8 nr; +}; +#define to_sensor_dev_attr_2(_dev_attr) \ + container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr) + +#define SENSOR_DEVICE_ATTR_2(_name,_mode,_show,_store,_nr,_index) \ +struct sensor_device_attribute_2 sensor_dev_attr_##_name = { \ + .dev_attr = __ATTR(_name,_mode,_show,_store), \ + .index = _index, \ + .nr = _nr, \ +} + #endif /* _LINUX_HWMON_SYSFS_H */ -- cgit v1.2.2 From ce785ab460ce8728a9daf337ba8fab3ba692b6aa Mon Sep 17 00:00:00 2001 From: "R.Marek@sh.cvut.cz" Date: Wed, 27 Jul 2005 11:50:18 +0000 Subject: [PATCH] I2C: W83792D add hwmon class register 2/3 This patch adds registration of hwmon class. Tested with help of i2c-stub. Signed-off-by: Rudolf Marek Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/w83792d.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c index fa43b6fd1212..05f9b92ad3e7 100644 --- a/drivers/hwmon/w83792d.c +++ b/drivers/hwmon/w83792d.c @@ -42,7 +42,9 @@ #include #include #include +#include #include +#include /* Addresses to scan */ static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; @@ -267,6 +269,7 @@ DIV_TO_REG(long val) struct w83792d_data { struct i2c_client client; + struct class_device *class_dev; struct semaphore lock; enum chips type; @@ -1289,6 +1292,11 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind) } /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto ERROR3; + } device_create_file_in(new_client, 0); device_create_file_in(new_client, 1); device_create_file_in(new_client, 2); @@ -1361,6 +1369,15 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind) return 0; +ERROR3: + if (data->lm75[0] != NULL) { + i2c_detach_client(data->lm75[0]); + kfree(data->lm75[0]); + } + if (data->lm75[1] != NULL) { + i2c_detach_client(data->lm75[1]); + kfree(data->lm75[1]); + } ERROR2: i2c_detach_client(new_client); ERROR1: @@ -1372,21 +1389,25 @@ ERROR0: static int w83792d_detach_client(struct i2c_client *client) { + struct w83792d_data *data = i2c_get_clientdata(client); int err; + /* main client */ + if (data) + hwmon_device_unregister(data->class_dev); + if ((err = i2c_detach_client(client))) { dev_err(&client->dev, "Client deregistration failed, client not detached.\n"); return err; } - if (i2c_get_clientdata(client)==NULL) { - /* subclients */ + /* main client */ + if (data) + kfree(data); + /* subclient */ + else kfree(client); - } else { - /* main client */ - kfree(i2c_get_clientdata(client)); - } return 0; } -- cgit v1.2.2 From 1ff4e3065b41847b6fe5908b1214cb508dd49e61 Mon Sep 17 00:00:00 2001 From: "R.Marek@sh.cvut.cz" Date: Wed, 27 Jul 2005 09:25:28 +0000 Subject: [PATCH] I2C: W83792D documentation 3/3 This patch adds documentation entry for W83792D chip. Signed-off-by: Rudolf Marek Signed-off-by: Greg Kroah-Hartman --- Documentation/hwmon/w83792d | 174 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 Documentation/hwmon/w83792d diff --git a/Documentation/hwmon/w83792d b/Documentation/hwmon/w83792d new file mode 100644 index 000000000000..8171c285bb55 --- /dev/null +++ b/Documentation/hwmon/w83792d @@ -0,0 +1,174 @@ +Kernel driver w83792d +===================== + +Supported chips: + * Winbond W83792D + Prefix: 'w83792d' + Addresses scanned: I2C 0x2c - 0x2f + Datasheet: http://www.winbond.com.tw/E-WINBONDHTM/partner/PDFresult.asp?Pname=1035 + +Author: Chunhao Huang +Contact: DZShen + + +Module Parameters +----------------- + +* init int + (default 1) + Use 'init=0' to bypass initializing the chip. + Try this if your computer crashes when you load the module. + +* force_subclients=bus,caddr,saddr,saddr + This is used to force the i2c addresses for subclients of + a certain chip. Example usage is `force_subclients=0,0x2f,0x4a,0x4b' + to force the subclients of chip 0x2f on bus 0 to i2c addresses + 0x4a and 0x4b. + + +Description +----------- + +This driver implements support for the Winbond W83792AD/D. + +Detection of the chip can sometimes be foiled because it can be in an +internal state that allows no clean access (Bank with ID register is not +currently selected). If you know the address of the chip, use a 'force' +parameter; this will put it into a more well-behaved state first. + +The driver implements three temperature sensors, seven fan rotation speed +sensors, nine voltage sensors, and two automatic fan regulation +strategies called: Smart Fan I (Thermal Cruise mode) and Smart Fan II. +Automatic fan control mode is possible only for fan1-fan3. Fan4-fan7 can run +synchronized with selected fan (fan1-fan3). This functionality and manual PWM +control for fan4-fan7 is not yet implemented. + +Temperatures are measured in degrees Celsius and measurement resolution is 1 +degC for temp1 and 0.5 degC for temp2 and temp3. An alarm is triggered when +the temperature gets higher than the Overtemperature Shutdown value; it stays +on until the temperature falls below the Hysteresis value. + +Fan rotation speeds are reported in RPM (rotations per minute). An alarm is +triggered if the rotation speed has dropped below a programmable limit. Fan +readings can be divided by a programmable divider (1, 2, 4, 8, 16, 32, 64 or +128) to give the readings more range or accuracy. + +Voltage sensors (also known as IN sensors) report their values in millivolts. +An alarm is triggered if the voltage has crossed a programmable minimum +or maximum limit. + +Alarms are provided as output from "realtime status register". Following bits +are defined: + +bit - alarm on: +0 - in0 +1 - in1 +2 - temp1 +3 - temp2 +4 - temp3 +5 - fan1 +6 - fan2 +7 - fan3 +8 - in2 +9 - in3 +10 - in4 +11 - in5 +12 - in6 +13 - VID change +14 - chassis +15 - fan7 +16 - tart1 +17 - tart2 +18 - tart3 +19 - in7 +20 - in8 +21 - fan4 +22 - fan5 +23 - fan6 + +Tart will be asserted while target temperature cannot be achieved after 3 minutes +of full speed rotation of corresponding fan. + +In addition to the alarms described above, there is a CHAS alarm on the chips +which triggers if your computer case is open (This one is latched, contrary +to realtime alarms). + +The chips only update values each 3 seconds; reading them more often will +do no harm, but will return 'old' values. + + +W83792D PROBLEMS +---------------- +Known problems: + - This driver is only for Winbond W83792D C version device, there + are also some motherboards with B version W83792D device. The + calculation method to in6-in7(measured value, limits) is a little + different between C and B version. C or B version can be identified + by CR[0x49h]. + - The function of vid and vrm has not been finished, because I'm NOT + very familiar with them. Adding support is welcome. +  - The function of chassis open detection needs more tests. + - If you have ASUS server board and chip was not found: Then you will + need to upgrade to latest (or beta) BIOS. If it does not help please + contact us. + +Fan control +----------- + +Manual mode +----------- + +Works as expected. You just need to specify desired PWM/DC value (fan speed) +in appropriate pwm# file. + +Thermal cruise +-------------- + +In this mode, W83792D provides the Smart Fan system to automatically control +fan speed to keep the temperatures of CPU and the system within specific +range. At first a wanted temperature and interval must be set. This is done +via thermal_cruise# file. The tolerance# file serves to create T +- tolerance +interval. The fan speed will be lowered as long as the current temperature +remains below the thermal_cruise# +- tolerance# value. Once the temperature +exceeds the high limit (T+tolerance), the fan will be turned on with a +specific speed set by pwm# and automatically controlled its PWM duty cycle +with the temperature varying. Three conditions may occur: + +(1) If the temperature still exceeds the high limit, PWM duty +cycle will increase slowly. + +(2) If the temperature goes below the high limit, but still above the low +limit (T-tolerance), the fan speed will be fixed at the current speed because +the temperature is in the target range. + +(3) If the temperature goes below the low limit, PWM duty cycle will decrease +slowly to 0 or a preset stop value until the temperature exceeds the low +limit. (The preset stop value handling is not yet implemented in driver) + +Smart Fan II +------------ + +W83792D also provides a special mode for fan. Four temperature points are +available. When related temperature sensors detects the temperature in preset +temperature region (sf2_point@_fan# +- tolerance#) it will cause fans to run +on programmed value from sf2_level@_fan#. You need to set four temperatures +for each fan. + + +/sys files +---------- + +pwm[1-3] - this file stores PWM duty cycle or DC value (fan speed) in range: + 0 (stop) to 255 (full) +pwm[1-3]_enable - this file controls mode of fan/temperature control: + * 0 Disabled + * 1 Manual mode + * 2 Smart Fan II + * 3 Thermal Cruise +pwm[1-3]_mode - Select PWM of DC mode + * 0 DC + * 1 PWM +thermal_cruise[1-3] - Selects the desired temperature for cruise (degC) +tolerance[1-3] - Value in degrees of Celsius (degC) for +- T +sf2_point[1-4]_fan[1-3] - four temperature points for each fan for Smart Fan II +sf2_level[1-3]_fan[1-3] - three PWM/DC levels for each fan for Smart Fan II -- cgit v1.2.2 From 7bef559455fc71f66f8573cc1aafe1dd33966c1c Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 27 Jul 2005 22:14:49 +0200 Subject: [PATCH] I2C: refactor message in i2c_detach_client We could refactor the error message 34 different i2c drivers print if i2c_detach_client() fails in this function itself. Saves quite a few lines of code. Documentation is updated to reflect that change. Note that this patch should be applied after Rudolf Marek's w83792d patches. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- Documentation/i2c/porting-clients | 3 ++- Documentation/i2c/writing-clients | 4 +--- drivers/hwmon/adm1021.c | 4 +--- drivers/hwmon/adm1025.c | 5 +---- drivers/hwmon/adm9240.c | 5 +---- drivers/hwmon/asb100.c | 5 +---- drivers/hwmon/ds1621.c | 5 +---- drivers/hwmon/fscher.c | 5 +---- drivers/hwmon/fscpos.c | 5 +---- drivers/hwmon/gl518sm.c | 5 +---- drivers/hwmon/gl520sm.c | 5 +---- drivers/hwmon/it87.c | 5 +---- drivers/hwmon/lm63.c | 5 +---- drivers/hwmon/lm78.c | 5 +---- drivers/hwmon/lm80.c | 5 +---- drivers/hwmon/lm83.c | 5 +---- drivers/hwmon/lm87.c | 5 +---- drivers/hwmon/lm90.c | 5 +---- drivers/hwmon/lm92.c | 5 +---- drivers/hwmon/max1619.c | 5 +---- drivers/hwmon/pc87360.c | 5 +---- drivers/hwmon/sis5595.c | 5 +---- drivers/hwmon/smsc47b397.c | 5 +---- drivers/hwmon/smsc47m1.c | 5 +---- drivers/hwmon/via686a.c | 5 +---- drivers/hwmon/w83627ehf.c | 5 +---- drivers/hwmon/w83627hf.c | 5 +---- drivers/hwmon/w83781d.c | 5 +---- drivers/hwmon/w83792d.c | 5 +---- drivers/hwmon/w83l785ts.c | 5 +---- drivers/i2c/chips/ds1337.c | 5 +---- drivers/i2c/chips/eeprom.c | 4 +--- drivers/i2c/chips/max6875.c | 4 +--- drivers/i2c/chips/pca9539.c | 4 +--- drivers/i2c/chips/pcf8574.c | 5 +---- drivers/i2c/chips/pcf8591.c | 5 +---- drivers/i2c/i2c-core.c | 6 +++++- 37 files changed, 42 insertions(+), 137 deletions(-) diff --git a/Documentation/i2c/porting-clients b/Documentation/i2c/porting-clients index 105c6186b912..68bcd66e36b1 100644 --- a/Documentation/i2c/porting-clients +++ b/Documentation/i2c/porting-clients @@ -94,7 +94,8 @@ Technical changes: limited to the strictly necessary steps. * [Detach] Get rid of data, remove the call to - i2c_deregister_entry. + i2c_deregister_entry. Do not log an error message if + i2c_detach_client fails, as i2c-core will now do it for you. * [Update] Don't access client->data directly, use i2c_get_clientdata(client) instead. diff --git a/Documentation/i2c/writing-clients b/Documentation/i2c/writing-clients index 522ae01d2e7f..7e2a8f11c220 100644 --- a/Documentation/i2c/writing-clients +++ b/Documentation/i2c/writing-clients @@ -489,10 +489,8 @@ much simpler than the attachment code, fortunately! /* SENSORS ONLY END */ /* Try to detach the client from i2c space */ - if ((err = i2c_detach_client(client))) { - printk("foo.o: Client deregistration failed, client not detached.\n"); + if ((err = i2c_detach_client(client))) return err; - } /* HYBRID SENSORS CHIP ONLY START */ if i2c_is_isa_client(client) diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c index 2a341390d92e..da3e2c9f705f 100644 --- a/drivers/hwmon/adm1021.c +++ b/drivers/hwmon/adm1021.c @@ -328,10 +328,8 @@ static int adm1021_detach_client(struct i2c_client *client) hwmon_device_unregister(data->class_dev); - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, "Client deregistration failed, client not detached.\n"); + if ((err = i2c_detach_client(client))) return err; - } kfree(data); return 0; diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c index bdba01e2f3ed..181dadf42002 100644 --- a/drivers/hwmon/adm1025.c +++ b/drivers/hwmon/adm1025.c @@ -517,11 +517,8 @@ static int adm1025_detach_client(struct i2c_client *client) hwmon_device_unregister(data->class_dev); - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, "Client deregistration failed, " - "client not detached.\n"); + if ((err = i2c_detach_client(client))) return err; - } kfree(data); return 0; diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c index d52100027665..82edf286ebdc 100644 --- a/drivers/hwmon/adm9240.c +++ b/drivers/hwmon/adm9240.c @@ -645,11 +645,8 @@ static int adm9240_detach_client(struct i2c_client *client) hwmon_device_unregister(data->class_dev); - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, "Client deregistration failed, " - "client not detached.\n"); + if ((err = i2c_detach_client(client))) return err; - } kfree(data); return 0; diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c index 290f7d2ac0a8..c6a2c94fad36 100644 --- a/drivers/hwmon/asb100.c +++ b/drivers/hwmon/asb100.c @@ -867,11 +867,8 @@ static int asb100_detach_client(struct i2c_client *client) if (data) hwmon_device_unregister(data->class_dev); - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, "client deregistration failed; " - "client not detached.\n"); + if ((err = i2c_detach_client(client))) return err; - } /* main client */ if (data) diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c index 4a316a7f7980..3ac37e95d2ef 100644 --- a/drivers/hwmon/ds1621.c +++ b/drivers/hwmon/ds1621.c @@ -282,11 +282,8 @@ static int ds1621_detach_client(struct i2c_client *client) hwmon_device_unregister(data->class_dev); - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, "Client deregistration failed, " - "client not detached.\n"); + if ((err = i2c_detach_client(client))) return err; - } kfree(data); diff --git a/drivers/hwmon/fscher.c b/drivers/hwmon/fscher.c index c7caa95c643b..ddf22fbf4ed1 100644 --- a/drivers/hwmon/fscher.c +++ b/drivers/hwmon/fscher.c @@ -383,11 +383,8 @@ static int fscher_detach_client(struct i2c_client *client) hwmon_device_unregister(data->class_dev); - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, "Client deregistration failed, " - "client not detached.\n"); + if ((err = i2c_detach_client(client))) return err; - } kfree(data); return 0; diff --git a/drivers/hwmon/fscpos.c b/drivers/hwmon/fscpos.c index fd75e444e758..489870ad6056 100644 --- a/drivers/hwmon/fscpos.c +++ b/drivers/hwmon/fscpos.c @@ -549,11 +549,8 @@ static int fscpos_detach_client(struct i2c_client *client) hwmon_device_unregister(data->class_dev); - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, "Client deregistration failed, client" - " not detached.\n"); + if ((err = i2c_detach_client(client))) return err; - } kfree(data); return 0; } diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c index 34d85b1e5539..63a2756c283a 100644 --- a/drivers/hwmon/gl518sm.c +++ b/drivers/hwmon/gl518sm.c @@ -492,11 +492,8 @@ static int gl518_detach_client(struct i2c_client *client) hwmon_device_unregister(data->class_dev); - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, "Client deregistration failed, " - "client not detached.\n"); + if ((err = i2c_detach_client(client))) return err; - } kfree(data); return 0; diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c index b129d153deab..ff71eb7ac681 100644 --- a/drivers/hwmon/gl520sm.c +++ b/drivers/hwmon/gl520sm.c @@ -654,11 +654,8 @@ static int gl520_detach_client(struct i2c_client *client) hwmon_device_unregister(data->class_dev); - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, "Client deregistration failed, " - "client not detached.\n"); + if ((err = i2c_detach_client(client))) return err; - } kfree(data); return 0; diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index 0a8d795f15c2..b1719f4097ef 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -945,11 +945,8 @@ static int it87_detach_client(struct i2c_client *client) hwmon_device_unregister(data->class_dev); - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, - "Client deregistration failed, client not detached.\n"); + if ((err = i2c_detach_client(client))) return err; - } if(i2c_is_isa_client(client)) release_region(client->addr, IT87_EXTENT); diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c index e19b11fd4816..736126d73aa2 100644 --- a/drivers/hwmon/lm63.c +++ b/drivers/hwmon/lm63.c @@ -520,11 +520,8 @@ static int lm63_detach_client(struct i2c_client *client) hwmon_device_unregister(data->class_dev); - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, "Client deregistration failed, " - "client not detached\n"); + if ((err = i2c_detach_client(client))) return err; - } kfree(data); return 0; diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c index 784935f77016..21b767a66bbd 100644 --- a/drivers/hwmon/lm78.c +++ b/drivers/hwmon/lm78.c @@ -683,11 +683,8 @@ static int lm78_detach_client(struct i2c_client *client) hwmon_device_unregister(data->class_dev); - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, - "Client deregistration failed, client not detached.\n"); + if ((err = i2c_detach_client(client))) return err; - } if(i2c_is_isa_client(client)) release_region(client->addr, LM78_EXTENT); diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c index fa2cb17018cc..36a0cda36a7d 100644 --- a/drivers/hwmon/lm80.c +++ b/drivers/hwmon/lm80.c @@ -510,11 +510,8 @@ static int lm80_detach_client(struct i2c_client *client) hwmon_device_unregister(data->class_dev); - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, "Client deregistration failed, " - "client not detached.\n"); + if ((err = i2c_detach_client(client))) return err; - } kfree(data); return 0; diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c index 0223b4d2ce1d..f3557f8826a9 100644 --- a/drivers/hwmon/lm83.c +++ b/drivers/hwmon/lm83.c @@ -363,11 +363,8 @@ static int lm83_detach_client(struct i2c_client *client) hwmon_device_unregister(data->class_dev); - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, - "Client deregistration failed, client not detached.\n"); + if ((err = i2c_detach_client(client))) return err; - } kfree(data); return 0; diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index 1dc3bf52b40d..f0ffe58e3670 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c @@ -734,11 +734,8 @@ static int lm87_detach_client(struct i2c_client *client) hwmon_device_unregister(data->class_dev); - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, "Client deregistration failed, " - "client not detached.\n"); + if ((err = i2c_detach_client(client))) return err; - } kfree(data); return 0; diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index 4b914ec205fa..fbf9dac41ee5 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c @@ -562,11 +562,8 @@ static int lm90_detach_client(struct i2c_client *client) hwmon_device_unregister(data->class_dev); - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, "Client deregistration failed, " - "client not detached.\n"); + if ((err = i2c_detach_client(client))) return err; - } kfree(data); return 0; diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c index 9c43120d6bd7..9740ee264051 100644 --- a/drivers/hwmon/lm92.c +++ b/drivers/hwmon/lm92.c @@ -399,11 +399,8 @@ static int lm92_detach_client(struct i2c_client *client) hwmon_device_unregister(data->class_dev); - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, "Client deregistration failed, " - "client not detached.\n"); + if ((err = i2c_detach_client(client))) return err; - } kfree(data); return 0; diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c index 5f0376575c62..a53d7df92ba2 100644 --- a/drivers/hwmon/max1619.c +++ b/drivers/hwmon/max1619.c @@ -322,11 +322,8 @@ static int max1619_detach_client(struct i2c_client *client) hwmon_device_unregister(data->class_dev); - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, "Client deregistration failed, " - "client not detached.\n"); + if ((err = i2c_detach_client(client))) return err; - } kfree(data); return 0; diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c index 4041488de6f1..1f1b3ca23f6f 100644 --- a/drivers/hwmon/pc87360.c +++ b/drivers/hwmon/pc87360.c @@ -984,11 +984,8 @@ static int pc87360_detach_client(struct i2c_client *client) hwmon_device_unregister(data->class_dev); - if ((i = i2c_detach_client(client))) { - dev_err(&client->dev, "Client deregistration failed, " - "client not detached.\n"); + if ((i = i2c_detach_client(client))) return i; - } for (i = 0; i < 3; i++) { if (data->address[i]) { diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c index 67246299a308..55716cb579aa 100644 --- a/drivers/hwmon/sis5595.c +++ b/drivers/hwmon/sis5595.c @@ -618,11 +618,8 @@ static int sis5595_detach_client(struct i2c_client *client) hwmon_device_unregister(data->class_dev); - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, - "Client deregistration failed, client not detached.\n"); + if ((err = i2c_detach_client(client))) return err; - } release_region(client->addr, SIS5595_EXTENT); diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c index dddc94a7649b..7fe71576dea4 100644 --- a/drivers/hwmon/smsc47b397.c +++ b/drivers/hwmon/smsc47b397.c @@ -214,11 +214,8 @@ static int smsc47b397_detach_client(struct i2c_client *client) hwmon_device_unregister(data->class_dev); - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, "Client deregistration failed, " - "client not detached.\n"); + if ((err = i2c_detach_client(client))) return err; - } release_region(client->addr, SMSC_EXTENT); kfree(data); diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c index 8126fdd7cbee..9da5d546e861 100644 --- a/drivers/hwmon/smsc47m1.c +++ b/drivers/hwmon/smsc47m1.c @@ -497,11 +497,8 @@ static int smsc47m1_detach_client(struct i2c_client *client) hwmon_device_unregister(data->class_dev); - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, "Client deregistration failed, " - "client not detached.\n"); + if ((err = i2c_detach_client(client))) return err; - } release_region(client->addr, SMSC_EXTENT); kfree(data); diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c index cd3732c36671..d9251fb0b625 100644 --- a/drivers/hwmon/via686a.c +++ b/drivers/hwmon/via686a.c @@ -700,11 +700,8 @@ static int via686a_detach_client(struct i2c_client *client) hwmon_device_unregister(data->class_dev); - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, - "Client deregistration failed, client not detached.\n"); + if ((err = i2c_detach_client(client))) return err; - } release_region(client->addr, VIA686A_EXTENT); kfree(data); diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c index b14801cd615d..b60efe8f8b26 100644 --- a/drivers/hwmon/w83627ehf.c +++ b/drivers/hwmon/w83627ehf.c @@ -774,11 +774,8 @@ static int w83627ehf_detach_client(struct i2c_client *client) hwmon_device_unregister(data->class_dev); - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, "Client deregistration failed, " - "client not detached.\n"); + if ((err = i2c_detach_client(client))) return err; - } release_region(client->addr, REGION_LENGTH); kfree(data); diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c index 9e31f5559ccc..f1ae0e00691b 100644 --- a/drivers/hwmon/w83627hf.c +++ b/drivers/hwmon/w83627hf.c @@ -1157,11 +1157,8 @@ static int w83627hf_detach_client(struct i2c_client *client) hwmon_device_unregister(data->class_dev); - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, - "Client deregistration failed, client not detached.\n"); + if ((err = i2c_detach_client(client))) return err; - } release_region(client->addr, WINB_EXTENT); kfree(data); diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c index 70718559de75..66835c1e3f68 100644 --- a/drivers/hwmon/w83781d.c +++ b/drivers/hwmon/w83781d.c @@ -1299,11 +1299,8 @@ w83781d_detach_client(struct i2c_client *client) if (i2c_is_isa_client(client)) release_region(client->addr, W83781D_EXTENT); - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, - "Client deregistration failed, client not detached.\n"); + if ((err = i2c_detach_client(client))) return err; - } /* main client */ if (data) diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c index 05f9b92ad3e7..ea0c3519e03a 100644 --- a/drivers/hwmon/w83792d.c +++ b/drivers/hwmon/w83792d.c @@ -1396,11 +1396,8 @@ w83792d_detach_client(struct i2c_client *client) if (data) hwmon_device_unregister(data->class_dev); - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, - "Client deregistration failed, client not detached.\n"); + if ((err = i2c_detach_client(client))) return err; - } /* main client */ if (data) diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c index 9cd1939cd040..213fb170d397 100644 --- a/drivers/hwmon/w83l785ts.c +++ b/drivers/hwmon/w83l785ts.c @@ -267,11 +267,8 @@ static int w83l785ts_detach_client(struct i2c_client *client) hwmon_device_unregister(data->class_dev); - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, "Client deregistration failed, " - "client not detached.\n"); + if ((err = i2c_detach_client(client))) return err; - } kfree(data); return 0; diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c index 6ac0a6e00769..8ab4e2348cda 100644 --- a/drivers/i2c/chips/ds1337.c +++ b/drivers/i2c/chips/ds1337.c @@ -353,11 +353,8 @@ static int ds1337_detach_client(struct i2c_client *client) int err; struct ds1337_data *data = i2c_get_clientdata(client); - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, "Client deregistration failed, " - "client not detached.\n"); + if ((err = i2c_detach_client(client))) return err; - } list_del(&data->list); kfree(data); diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c index 88f83bac3845..9466ada68932 100644 --- a/drivers/i2c/chips/eeprom.c +++ b/drivers/i2c/chips/eeprom.c @@ -230,10 +230,8 @@ static int eeprom_detach_client(struct i2c_client *client) int err; err = i2c_detach_client(client); - if (err) { - dev_err(&client->dev, "Client deregistration failed, client not detached.\n"); + if (err) return err; - } kfree(i2c_get_clientdata(client)); diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c index d1d48586b90e..52fd6bf29133 100644 --- a/drivers/i2c/chips/max6875.c +++ b/drivers/i2c/chips/max6875.c @@ -242,10 +242,8 @@ static int max6875_detach_client(struct i2c_client *client) int err; err = i2c_detach_client(client); - if (err) { - dev_err(&client->dev, "i2c_detach_client() failed\n"); + if (err) return err; - } kfree(i2c_get_clientdata(client)); return 0; } diff --git a/drivers/i2c/chips/pca9539.c b/drivers/i2c/chips/pca9539.c index c5b052363d9a..1500b1842ce5 100644 --- a/drivers/i2c/chips/pca9539.c +++ b/drivers/i2c/chips/pca9539.c @@ -163,10 +163,8 @@ static int pca9539_detach_client(struct i2c_client *client) { int err; - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, "Client deregistration failed.\n"); + if ((err = i2c_detach_client(client))) return err; - } kfree(i2c_get_clientdata(client)); return 0; diff --git a/drivers/i2c/chips/pcf8574.c b/drivers/i2c/chips/pcf8574.c index 7a1fa7914630..a109dfd3dbe7 100644 --- a/drivers/i2c/chips/pcf8574.c +++ b/drivers/i2c/chips/pcf8574.c @@ -185,11 +185,8 @@ static int pcf8574_detach_client(struct i2c_client *client) { int err; - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, - "Client deregistration failed, client not detached.\n"); + if ((err = i2c_detach_client(client))) return err; - } kfree(i2c_get_clientdata(client)); return 0; diff --git a/drivers/i2c/chips/pcf8591.c b/drivers/i2c/chips/pcf8591.c index 225b512dd4ad..7fce0fc048d9 100644 --- a/drivers/i2c/chips/pcf8591.c +++ b/drivers/i2c/chips/pcf8591.c @@ -240,11 +240,8 @@ static int pcf8591_detach_client(struct i2c_client *client) { int err; - if ((err = i2c_detach_client(client))) { - dev_err(&client->dev, - "Client deregistration failed, client not detached.\n"); + if ((err = i2c_detach_client(client))) return err; - } kfree(i2c_get_clientdata(client)); return 0; diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 7a7837ae3114..b0bceb2fb8b1 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -449,8 +449,12 @@ int i2c_detach_client(struct i2c_client *client) struct i2c_adapter *adapter = client->adapter; int res = 0; - if ((client->flags & I2C_CLIENT_ALLOW_USE) && (client->usage_count > 0)) + if ((client->flags & I2C_CLIENT_ALLOW_USE) + && (client->usage_count > 0)) { + dev_warn(&client->dev, "Client [%s] still busy, " + "can't detach\n", client->name); return -EBUSY; + } if (adapter->client_unregister) { res = adapter->client_unregister(client); -- cgit v1.2.2 From e6cfb3ad7209e4f4dcdc14f5fc437db55667041f Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 27 Jul 2005 21:32:02 +0200 Subject: [PATCH] hwmon: tag super-i/o find functions __init Super-I/O find functions in hardware monitoring drivers can be tagged __init as they are only called from functions themselves tagged __init. Two of them (smsc47b397 and w83627ehf) already do, but the other four of them (it87, pc87360, smsc47m1 and w83627hf) did not. This saves a few bytes of memory after the drivers are loaded, 192 in the case of the it87 driver. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/it87.c | 2 +- drivers/hwmon/pc87360.c | 2 +- drivers/hwmon/smsc47m1.c | 2 +- drivers/hwmon/w83627hf.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index b1719f4097ef..ca4f953363f4 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -707,7 +707,7 @@ static int it87_isa_attach_adapter(struct i2c_adapter *adapter) } /* SuperIO detection - will change isa_address if a chip is found */ -static int it87_find(int *address) +static int __init it87_find(int *address) { int err = -ENODEV; diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c index 1f1b3ca23f6f..c66ae4f6e802 100644 --- a/drivers/hwmon/pc87360.c +++ b/drivers/hwmon/pc87360.c @@ -626,7 +626,7 @@ static DEVICE_ATTR(alarms_temp, S_IRUGO, show_temp_alarms, NULL); * Device detection, registration and update */ -static int pc87360_find(int sioaddr, u8 *devid, unsigned short *addresses) +static int __init pc87360_find(int sioaddr, u8 *devid, unsigned short *addresses) { u16 val; int i; diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c index 9da5d546e861..dab22bd75b68 100644 --- a/drivers/hwmon/smsc47m1.c +++ b/drivers/hwmon/smsc47m1.c @@ -345,7 +345,7 @@ fan_present(2); static DEVICE_ATTR(alarms, S_IRUGO, get_alarms, NULL); -static int smsc47m1_find(unsigned short *addr) +static int __init smsc47m1_find(unsigned short *addr) { u8 val; diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c index f1ae0e00691b..0466cc4b760e 100644 --- a/drivers/hwmon/w83627hf.c +++ b/drivers/hwmon/w83627hf.c @@ -958,7 +958,7 @@ device_create_file(&client->dev, &dev_attr_temp##offset##_type); \ } while (0) -static int w83627hf_find(int sioaddr, unsigned short *addr) +static int __init w83627hf_find(int sioaddr, unsigned short *addr) { u16 val; -- cgit v1.2.2 From cdcb19219714c796ddef1202e952566c5f86354d Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Thu, 28 Jul 2005 23:09:40 +0200 Subject: [PATCH] I2C: inline i2c_adapter_id We could inline i2c_adapter_id, as it is really, really short. Doing so saves a few bytes both in i2c-core and in the drivers using this function. before after diff drivers/hwmon/adm1026.ko 41344 41305 -39 drivers/hwmon/asb100.ko 27325 27246 -79 drivers/hwmon/gl518sm.ko 20824 20785 -39 drivers/hwmon/it87.ko 26419 26380 -39 drivers/hwmon/lm78.ko 21424 21385 -39 drivers/hwmon/lm85.ko 41034 40939 -95 drivers/hwmon/w83781d.ko 39561 39514 -47 drivers/hwmon/w83792d.ko 32979 32932 -47 drivers/i2c/i2c-core.ko 24708 24531 -177 Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/i2c-core.c | 9 --------- include/linux/i2c.h | 10 ++++++---- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index b0bceb2fb8b1..20f92e355f56 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -759,14 +759,6 @@ int i2c_probe(struct i2c_adapter *adapter, return 0; } -/* - * return id number for a specific adapter - */ -int i2c_adapter_id(struct i2c_adapter *adap) -{ - return adap->nr; -} - struct i2c_adapter* i2c_get_adapter(int id) { struct i2c_adapter *adapter; @@ -1196,7 +1188,6 @@ EXPORT_SYMBOL(i2c_master_send); EXPORT_SYMBOL(i2c_master_recv); EXPORT_SYMBOL(i2c_control); EXPORT_SYMBOL(i2c_transfer); -EXPORT_SYMBOL(i2c_adapter_id); EXPORT_SYMBOL(i2c_get_adapter); EXPORT_SYMBOL(i2c_put_adapter); EXPORT_SYMBOL(i2c_probe); diff --git a/include/linux/i2c.h b/include/linux/i2c.h index da4faa016b17..ad1c0fb164bc 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -364,10 +364,6 @@ extern int i2c_probe(struct i2c_adapter *adapter, */ extern int i2c_control(struct i2c_client *,unsigned int, unsigned long); -/* This call returns a unique low identifier for each registered adapter, - * or -1 if the adapter was not registered. - */ -extern int i2c_adapter_id(struct i2c_adapter *adap); extern struct i2c_adapter* i2c_get_adapter(int id); extern void i2c_put_adapter(struct i2c_adapter *adap); @@ -384,6 +380,12 @@ static inline int i2c_check_functionality(struct i2c_adapter *adap, u32 func) return (func & i2c_get_functionality(adap)) == func; } +/* Return id number for a specific adapter */ +static inline int i2c_adapter_id(struct i2c_adapter *adap) +{ + return adap->nr; +} + /* * I2C Message - used for pure i2c transaction, also from /dev interface */ -- cgit v1.2.2 From 48edcb65ddcd93b6421831ad133599aacea9724a Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Wed, 10 Aug 2005 08:51:16 +0100 Subject: [PATCH] I2C: i2c-algo-pca -- gracefully handle a busy bus I've been running with this patch for a while now, and while I've never seen it trigger except with buggy hardware I think it is a cleaner way to handle a busy bus. I had -EBUSY until about 10 minutes ago but -EIO seems to be what most of the existing algo drivers will return in the same circumstances. Signed-off-by: Ian Campbell Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/algos/i2c-algo-pca.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c index cc3a952401f2..ff2db0da4417 100644 --- a/drivers/i2c/algos/i2c-algo-pca.c +++ b/drivers/i2c/algos/i2c-algo-pca.c @@ -187,12 +187,14 @@ static int pca_xfer(struct i2c_adapter *i2c_adap, int numbytes = 0; int state; int ret; + int timeout = 100; - state = pca_status(adap); - if ( state != 0xF8 ) { - dev_dbg(&i2c_adap->dev, "bus is not idle. status is %#04x\n", state ); - /* FIXME: what to do. Force stop ? */ - return -EREMOTEIO; + while ((state = pca_status(adap)) != 0xf8 && timeout--) { + msleep(10); + } + if (state != 0xf8) { + dev_dbg(&i2c_adap->dev, "bus is not idle. status is %#04x\n", state); + return -EIO; } DEB1("{{{ XFER %d messages\n", num); -- cgit v1.2.2 From 014e45380a3b96f2ebd8ff0d115b7a33c06d06d1 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Thu, 28 Jul 2005 23:08:43 +0200 Subject: [PATCH] I2C: fix typo in documentation Fix a typo in the i2c documentation: the i2c bus scanning tool found in lm_sensors is called i2cdetect, not i2c_detect. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- Documentation/i2c/functionality | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/i2c/functionality b/Documentation/i2c/functionality index 8a78a95ae04e..41ffefbdc60c 100644 --- a/Documentation/i2c/functionality +++ b/Documentation/i2c/functionality @@ -115,7 +115,7 @@ CHECKING THROUGH /DEV If you try to access an adapter from a userspace program, you will have to use the /dev interface. You will still have to check whether the functionality you need is supported, of course. This is done using -the I2C_FUNCS ioctl. An example, adapted from the lm_sensors i2c_detect +the I2C_FUNCS ioctl. An example, adapted from the lm_sensors i2cdetect program, is below: int file; -- cgit v1.2.2 From b6d7b3d1b5a388b7e9af2629a9ecccedee064078 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 31 Jul 2005 19:02:53 +0200 Subject: [PATCH] I2C: Improve core debugging messages The debugging messages in i2c-core are more confusing than helpful. Some lack their trailing newline, some lack a prefix, some are redundant, some lack precious information. Here is my attempt to introduce some standardization in there. I also changed two messages in i2c-dev to make it clear they come from i2c-dev. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/i2c-core.c | 63 +++++++++++++++++++++----------------------------- drivers/i2c/i2c-dev.c | 5 ++-- 2 files changed, 29 insertions(+), 39 deletions(-) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 20f92e355f56..19d8a994b3b7 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -188,6 +188,8 @@ int i2c_add_adapter(struct i2c_adapter *adap) strlcpy(adap->class_dev.class_id, adap->dev.bus_id, BUS_ID_SIZE); class_device_register(&adap->class_dev); + dev_dbg(&adap->dev, "adapter [%s] registered\n", adap->name); + /* inform drivers of new adapters */ list_for_each(item,&drivers) { driver = list_entry(item, struct i2c_driver, list); @@ -196,8 +198,6 @@ int i2c_add_adapter(struct i2c_adapter *adap) driver->attach_adapter(adap); } - dev_dbg(&adap->dev, "registered as adapter #%d\n", adap->nr); - out_unlock: up(&core_lists); return res; @@ -220,8 +220,8 @@ int i2c_del_adapter(struct i2c_adapter *adap) break; } if (adap_from_list != adap) { - pr_debug("I2C: Attempting to delete an unregistered " - "adapter\n"); + pr_debug("i2c-core: attempting to delete unregistered " + "adapter [%s]\n", adap->name); res = -EINVAL; goto out_unlock; } @@ -230,9 +230,8 @@ int i2c_del_adapter(struct i2c_adapter *adap) driver = list_entry(item, struct i2c_driver, list); if (driver->detach_adapter) if ((res = driver->detach_adapter(adap))) { - dev_warn(&adap->dev, "can't detach adapter " - "while detaching driver %s: driver " - "not detached!\n", driver->name); + dev_err(&adap->dev, "detach_adapter failed " + "for driver [%s]\n", driver->name); goto out_unlock; } } @@ -247,9 +246,8 @@ int i2c_del_adapter(struct i2c_adapter *adap) * must be deleted, as this would cause invalid states. */ if ((res=client->driver->detach_client(client))) { - dev_err(&adap->dev, "adapter not " - "unregistered, because client at " - "address %02x can't be detached. ", + dev_err(&adap->dev, "detach_client failed for client " + "[%s] at address 0x%02x\n", client->name, client->addr); goto out_unlock; } @@ -270,7 +268,7 @@ int i2c_del_adapter(struct i2c_adapter *adap) /* free dynamically allocated bus id */ idr_remove(&i2c_adapter_idr, adap->nr); - dev_dbg(&adap->dev, "adapter unregistered\n"); + dev_dbg(&adap->dev, "adapter [%s] unregistered\n", adap->name); out_unlock: up(&core_lists); @@ -303,7 +301,7 @@ int i2c_add_driver(struct i2c_driver *driver) goto out_unlock; list_add_tail(&driver->list,&drivers); - pr_debug("i2c-core: driver %s registered.\n", driver->name); + pr_debug("i2c-core: driver [%s] registered\n", driver->name); /* now look for instances of driver on our adapters */ if (driver->flags & I2C_DF_NOTIFY) { @@ -331,21 +329,17 @@ int i2c_del_driver(struct i2c_driver *driver) /* Have a look at each adapter, if clients of this driver are still * attached. If so, detach them to be able to kill the driver * afterwards. - */ - pr_debug("i2c-core: unregister_driver - looking for clients.\n"); - /* removing clients does not depend on the notify flag, else + * + * Removing clients does not depend on the notify flag, else * invalid operation might (will!) result, when using stale client * pointers. */ list_for_each(item1,&adapters) { adap = list_entry(item1, struct i2c_adapter, list); - dev_dbg(&adap->dev, "examining adapter\n"); if (driver->detach_adapter) { if ((res = driver->detach_adapter(adap))) { - dev_warn(&adap->dev, "while unregistering " - "dummy driver %s, adapter could " - "not be detached properly; driver " - "not unloaded!",driver->name); + dev_err(&adap->dev, "detach_adapter failed " + "for driver [%s]\n", driver->name); goto out_unlock; } } else { @@ -353,16 +347,13 @@ int i2c_del_driver(struct i2c_driver *driver) client = list_entry(item2, struct i2c_client, list); if (client->driver != driver) continue; - pr_debug("i2c-core.o: detaching client %s:\n", client->name); + dev_dbg(&adap->dev, "detaching client [%s] " + "at 0x%02x\n", client->name, + client->addr); if ((res = driver->detach_client(client))) { - dev_err(&adap->dev, "while " - "unregistering driver " - "`%s', the client at " - "address %02x of " - "adapter could not " - "be detached; driver " - "not unloaded!", - driver->name, + dev_err(&adap->dev, "detach_client " + "failed for client [%s] at " + "0x%02x\n", client->name, client->addr); goto out_unlock; } @@ -372,7 +363,7 @@ int i2c_del_driver(struct i2c_driver *driver) driver_unregister(&driver->driver); list_del(&driver->list); - pr_debug("i2c-core: driver unregistered: %s\n", driver->name); + pr_debug("i2c-core: driver [%s] unregistered\n", driver->name); out_unlock: up(&core_lists); @@ -417,15 +408,12 @@ int i2c_attach_client(struct i2c_client *client) if (adapter->client_register) { if (adapter->client_register(client)) { - dev_warn(&adapter->dev, "warning: client_register " - "seems to have failed for client %02x\n", - client->addr); + dev_dbg(&adapter->dev, "client_register " + "failed for client [%s] at 0x%02x\n", + client->name, client->addr); } } - dev_dbg(&adapter->dev, "client [%s] registered to adapter\n", - client->name); - if (client->flags & I2C_CLIENT_ALLOW_USE) client->usage_count = 0; @@ -436,7 +424,8 @@ int i2c_attach_client(struct i2c_client *client) snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id), "%d-%04x", i2c_adapter_id(adapter), client->addr); - pr_debug("registering %s\n", client->dev.bus_id); + dev_dbg(&adapter->dev, "client [%s] registered with bus id %s\n", + client->name, client->dev.bus_id); device_register(&client->dev); device_create_file(&client->dev, &dev_attr_client_name); diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index bc5d557e5dd9..aa7a4fadef64 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c @@ -434,7 +434,8 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap) devfs_mk_cdev(MKDEV(I2C_MAJOR, i2c_dev->minor), S_IFCHR|S_IRUSR|S_IWUSR, "i2c/%d", i2c_dev->minor); - dev_dbg(&adap->dev, "Registered as minor %d\n", i2c_dev->minor); + pr_debug("i2c-dev: adapter [%s] registered as minor %d\n", + adap->name, i2c_dev->minor); /* register this i2c device with the driver core */ i2c_dev->adap = adap; @@ -471,7 +472,7 @@ static int i2cdev_detach_adapter(struct i2c_adapter *adap) wait_for_completion(&i2c_dev->released); kfree(i2c_dev); - dev_dbg(&adap->dev, "Adapter unregistered\n"); + pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name); return 0; } -- cgit v1.2.2 From 53ae11b08353268c4012ef107bf205a0724d71aa Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Thu, 28 Jul 2005 23:14:59 +0200 Subject: [PATCH] hwmon: move SENSORS_LIMIT to hwmon.h Move SENSORS_LIMIT from i2c-sensor.h to hwmon.h, as it is in no way related to i2c. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/lm75.h | 2 +- include/linux/hwmon.h | 11 +++++++++++ include/linux/i2c-sensor.h | 12 ------------ 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/hwmon/lm75.h b/drivers/hwmon/lm75.h index 63e3f2fb4c21..af7dc650ee15 100644 --- a/drivers/hwmon/lm75.h +++ b/drivers/hwmon/lm75.h @@ -25,7 +25,7 @@ which contains this code, we don't worry about the wasted space. */ -#include +#include /* straight from the datasheet */ #define LM75_TEMP_MIN (-55000) diff --git a/include/linux/hwmon.h b/include/linux/hwmon.h index bf90e6001e3b..0efd994c37f1 100644 --- a/include/linux/hwmon.h +++ b/include/linux/hwmon.h @@ -20,5 +20,16 @@ struct class_device *hwmon_device_register(struct device *dev); void hwmon_device_unregister(struct class_device *cdev); +/* Scale user input to sensible values */ +static inline int SENSORS_LIMIT(long value, long low, long high) +{ + if (value < low) + return low; + else if (value > high) + return high; + else + return value; +} + #endif diff --git a/include/linux/i2c-sensor.h b/include/linux/i2c-sensor.h index ae73b9e789cb..e832d3286a46 100644 --- a/include/linux/i2c-sensor.h +++ b/include/linux/i2c-sensor.h @@ -242,16 +242,4 @@ extern int i2c_detect(struct i2c_adapter *adapter, struct i2c_address_data *address_data, int (*found_proc) (struct i2c_adapter *, int, int)); - -/* This macro is used to scale user-input to sensible values in almost all - chip drivers. */ -static inline int SENSORS_LIMIT(long value, long low, long high) -{ - if (value < low) - return low; - else if (value > high) - return high; - else - return value; -} #endif /* def _LINUX_I2C_SENSOR_H */ -- cgit v1.2.2 From 5cb802293e87035920d47979107af8cf42a2f62a Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Fri, 29 Jul 2005 20:51:54 +0200 Subject: [PATCH] hwmon: lm85: trivial cleanups Remove an unused macro and an outdated comment from the lm85 driver. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/lm85.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index 5f051c023236..248920134fd9 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c @@ -282,15 +282,6 @@ static int ZONE_TO_REG( int zone ) #define PPR_TO_REG(val,fan) (SENSORS_LIMIT((val)-1,0,3)<<(fan *2)) #define PPR_FROM_REG(val,fan) ((((val)>>(fan * 2))&0x03)+1) -/* i2c-vid.h defines vid_from_reg() */ -#define VID_FROM_REG(val,vrm) (vid_from_reg((val),(vrm))) - -/* Unlike some other drivers we DO NOT set initial limits. Use - * the config file to set limits. Some users have reported - * motherboards shutting down when we set limits in a previous - * version of the driver. - */ - /* Chip sampling rates * * Some sensors are not updated more frequently than once per second -- cgit v1.2.2 From 9fc6adfa9adf2be84119a3c2592287f33bd1dff2 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 31 Jul 2005 21:20:43 +0200 Subject: [PATCH] hwmon: hwmon vs i2c, second round (01/11) 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 Signed-off-by: Greg Kroah-Hartman --- 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(-) diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c index a445736d8838..e2d1daf79880 100644 --- a/drivers/i2c/chips/ds1374.c +++ b/drivers/i2c/chips/ds1374.c @@ -53,7 +53,6 @@ static struct i2c_client_address_data addr_data = { .normal_i2c = normal_addr, .probe = ignore, .ignore = ignore, - .force = ignore, }; static ulong ds1374_read_rtc(void) diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c index 778d7e12859d..e516dadc453f 100644 --- a/drivers/i2c/chips/m41t00.c +++ b/drivers/i2c/chips/m41t00.c @@ -42,7 +42,6 @@ static struct i2c_client_address_data addr_data = { .normal_i2c = normal_addr, .probe = ignore, .ignore = ignore, - .force = ignore, }; ulong diff --git a/drivers/i2c/chips/rtc8564.c b/drivers/i2c/chips/rtc8564.c index 588fc2261a91..0b5385c892b1 100644 --- a/drivers/i2c/chips/rtc8564.c +++ b/drivers/i2c/chips/rtc8564.c @@ -67,7 +67,6 @@ static struct i2c_client_address_data addr_data = { .normal_i2c = normal_addr, .probe = ignore, .ignore = ignore, - .force = ignore, }; static int rtc8564_read_mem(struct i2c_client *client, struct mem *mem); diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 19d8a994b3b7..372b5996d045 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -662,6 +662,28 @@ int i2c_control(struct i2c_client *client, * 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 @@ int i2c_probe(struct i2c_adapter *adapter, 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 */ diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c index 48989eda2400..52e32f05d625 100644 --- a/drivers/media/video/adv7170.c +++ b/drivers/media/video/adv7170.c @@ -391,7 +391,6 @@ static struct i2c_client_address_data addr_data = { .normal_i2c = normal_i2c, .probe = &ignore, .ignore = &ignore, - .force = &ignore, }; static struct i2c_driver i2c_driver_adv7170; diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c index f898b6586374..b5ed9544bdea 100644 --- a/drivers/media/video/adv7175.c +++ b/drivers/media/video/adv7175.c @@ -441,7 +441,6 @@ static struct i2c_client_address_data addr_data = { .normal_i2c = normal_i2c, .probe = &ignore, .ignore = &ignore, - .force = &ignore, }; static struct i2c_driver i2c_driver_adv7175; diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c index 8733588f6db3..c6cfa7c48b04 100644 --- a/drivers/media/video/bt819.c +++ b/drivers/media/video/bt819.c @@ -507,7 +507,6 @@ static struct i2c_client_address_data addr_data = { .normal_i2c = normal_i2c, .probe = &ignore, .ignore = &ignore, - .force = &ignore, }; static struct i2c_driver i2c_driver_bt819; diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c index a5d529ccf3ad..c13d28658868 100644 --- a/drivers/media/video/bt856.c +++ b/drivers/media/video/bt856.c @@ -295,7 +295,6 @@ static struct i2c_client_address_data addr_data = { .normal_i2c = normal_i2c, .probe = &ignore, .ignore = &ignore, - .force = &ignore, }; static struct i2c_driver i2c_driver_bt856; diff --git a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c index 22d055d8a695..e116bdbed310 100644 --- a/drivers/media/video/saa7110.c +++ b/drivers/media/video/saa7110.c @@ -470,7 +470,6 @@ static struct i2c_client_address_data addr_data = { .normal_i2c = normal_i2c, .probe = &ignore, .ignore = &ignore, - .force = &ignore, }; static struct i2c_driver i2c_driver_saa7110; diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c index fcd897382fcf..f18df53d98ff 100644 --- a/drivers/media/video/saa7111.c +++ b/drivers/media/video/saa7111.c @@ -489,7 +489,6 @@ static struct i2c_client_address_data addr_data = { .normal_i2c = normal_i2c, .probe = &ignore, .ignore = &ignore, - .force = &ignore, }; static struct i2c_driver i2c_driver_saa7111; diff --git a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c index 2ba997f5ef1d..e0c70f54f073 100644 --- a/drivers/media/video/saa7114.c +++ b/drivers/media/video/saa7114.c @@ -827,7 +827,6 @@ static struct i2c_client_address_data addr_data = { .normal_i2c = normal_i2c, .probe = &ignore, .ignore = &ignore, - .force = &ignore, }; static struct i2c_driver i2c_driver_saa7114; diff --git a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c index 108e7a4a0273..e93412f4407c 100644 --- a/drivers/media/video/saa7185.c +++ b/drivers/media/video/saa7185.c @@ -387,7 +387,6 @@ static struct i2c_client_address_data addr_data = { .normal_i2c = normal_i2c, .probe = &ignore, .ignore = &ignore, - .force = &ignore, }; static struct i2c_driver i2c_driver_saa7185; diff --git a/drivers/media/video/tuner-3036.c b/drivers/media/video/tuner-3036.c index 7d825e510ffd..103def1abe3c 100644 --- a/drivers/media/video/tuner-3036.c +++ b/drivers/media/video/tuner-3036.c @@ -41,7 +41,6 @@ static struct i2c_client_address_data addr_data = { .normal_i2c = normal_i2c, .probe = &ignore, .ignore = &ignore, - .force = &ignore, }; /* ---------------------------------------------------------------------- */ diff --git a/drivers/media/video/vpx3220.c b/drivers/media/video/vpx3220.c index 5dbd9f6bf353..4437bdebe24f 100644 --- a/drivers/media/video/vpx3220.c +++ b/drivers/media/video/vpx3220.c @@ -576,7 +576,6 @@ static struct i2c_client_address_data addr_data = { .normal_i2c = normal_i2c, .probe = &ignore, .ignore = &ignore, - .force = &ignore, }; static struct i2c_driver vpx3220_i2c_driver; diff --git a/include/linux/i2c.h b/include/linux/i2c.h index ad1c0fb164bc..9419bc5584ad 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -48,7 +48,6 @@ struct i2c_algorithm; struct i2c_adapter; struct i2c_client; struct i2c_driver; -struct i2c_client_address_data; union i2c_smbus_data; /* @@ -301,7 +300,7 @@ struct i2c_client_address_data { 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 @@ union i2c_smbus_data { 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 */ -- cgit v1.2.2 From ef8dec5d8b3e96e359f377f35cd8caff42fe6d58 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 31 Jul 2005 21:33:23 +0200 Subject: [PATCH] hwmon: hwmon vs i2c, second round (02/11) 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 Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/i2c-sensor-detect.c | 13 ++-- include/linux/i2c-sensor.h | 133 ++++++++++++++++++---------------------- 2 files changed, 67 insertions(+), 79 deletions(-) diff --git a/drivers/i2c/i2c-sensor-detect.c b/drivers/i2c/i2c-sensor-detect.c index 5aede3ca9cb0..c952926c1482 100644 --- a/drivers/i2c/i2c-sensor-detect.c +++ b/drivers/i2c/i2c-sensor-detect.c @@ -32,7 +32,6 @@ int i2c_detect(struct i2c_adapter *adapter, 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 @@ int i2c_detect(struct i2c_adapter *adapter, /* 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; } diff --git a/include/linux/i2c-sensor.h b/include/linux/i2c-sensor.h index e832d3286a46..4facaa0b9054 100644 --- a/include/linux/i2c-sensor.h +++ b/include/linux/i2c-sensor.h @@ -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 @@ struct i2c_force_data { 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 @@ struct i2c_address_data { 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 @@ struct i2c_address_data { "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 @@ struct i2c_address_data { "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 @@ struct i2c_address_data { 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 @@ struct i2c_address_data { 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 @@ struct i2c_address_data { 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 @@ struct i2c_address_data { 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 @@ struct i2c_address_data { 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 @@ struct i2c_address_data { 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 -- cgit v1.2.2 From b78ec31582c60578ee1d3bb470791d6dde96ccf7 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 31 Jul 2005 21:36:24 +0200 Subject: [PATCH] hwmon: hwmon vs i2c, second round (03/11) 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 Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/i2c-sensor-detect.c | 2 +- include/linux/i2c-sensor.h | 30 +++--------------------------- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/drivers/i2c/i2c-sensor-detect.c b/drivers/i2c/i2c-sensor-detect.c index c952926c1482..70fcf7281988 100644 --- a/drivers/i2c/i2c-sensor-detect.c +++ b/drivers/i2c/i2c-sensor-detect.c @@ -28,7 +28,7 @@ static unsigned short empty[] = {I2C_CLIENT_END}; /* 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; diff --git a/include/linux/i2c-sensor.h b/include/linux/i2c-sensor.h index 4facaa0b9054..fc9284af9fae 100644 --- a/include/linux/i2c-sensor.h +++ b/include/linux/i2c-sensor.h @@ -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 #define SENSORS_MODULE_PARM_FORCE(name) \ I2C_CLIENT_MODULE_PARM(force_ ## name, \ @@ -60,7 +36,7 @@ struct i2c_address_data { "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 @@ struct i2c_address_data { 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 */ -- cgit v1.2.2 From 2ed2dc3c116d26fc6a9384e83d136b15cc203b6c Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 31 Jul 2005 21:42:02 +0200 Subject: [PATCH] hwmon: hwmon vs i2c, second round (04/11) 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 Signed-off-by: Greg Kroah-Hartman --- 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(-) diff --git a/Documentation/i2c/porting-clients b/Documentation/i2c/porting-clients index 68bcd66e36b1..f9099211bd0b 100644 --- a/Documentation/i2c/porting-clients +++ b/Documentation/i2c/porting-clients @@ -66,6 +66,7 @@ Technical changes: 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 diff --git a/Documentation/i2c/writing-clients b/Documentation/i2c/writing-clients index 7e2a8f11c220..43d7928056ae 100644 --- a/Documentation/i2c/writing-clients +++ b/Documentation/i2c/writing-clients @@ -148,7 +148,7 @@ are defined in i2c.h to help you support them, as well as a generic 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 @@ detected at a specific address, another callback is called. 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 @@ are already in use (by some other registered client) are skipped. 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 */ diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c index da3e2c9f705f..21f6dfeb04ac 100644 --- a/drivers/hwmon/adm1021.c +++ b/drivers/hwmon/adm1021.c @@ -187,7 +187,7 @@ static int adm1021_attach_adapter(struct i2c_adapter *adapter) { 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) diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c index 181dadf42002..5b21284df2f8 100644 --- a/drivers/hwmon/adm1025.c +++ b/drivers/hwmon/adm1025.c @@ -314,7 +314,7 @@ static int adm1025_attach_adapter(struct i2c_adapter *adapter) { if (!(adapter->class & I2C_CLASS_HWMON)) return 0; - return i2c_detect(adapter, &addr_data, adm1025_detect); + return i2c_probe(adapter, &addr_data, adm1025_detect); } /* diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c index 8e8b0ef8fff3..f3a78f792919 100644 --- a/drivers/hwmon/adm1026.c +++ b/drivers/hwmon/adm1026.c @@ -321,7 +321,7 @@ int adm1026_attach_adapter(struct i2c_adapter *adapter) 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) diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c index a60187e24830..9221653590a8 100644 --- a/drivers/hwmon/adm1031.c +++ b/drivers/hwmon/adm1031.c @@ -727,10 +727,10 @@ static int adm1031_attach_adapter(struct i2c_adapter *adapter) { 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; diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c index 82edf286ebdc..6b20b28aa3b9 100644 --- a/drivers/hwmon/adm9240.c +++ b/drivers/hwmon/adm9240.c @@ -635,7 +635,7 @@ static int adm9240_attach_adapter(struct i2c_adapter *adapter) { 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) diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c index c6a2c94fad36..a6c6c9d3fddd 100644 --- a/drivers/hwmon/asb100.c +++ b/drivers/hwmon/asb100.c @@ -621,7 +621,7 @@ static int asb100_attach_adapter(struct i2c_adapter *adapter) { 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, diff --git a/drivers/hwmon/atxp1.c b/drivers/hwmon/atxp1.c index ced54189a579..329ddafd524b 100644 --- a/drivers/hwmon/atxp1.c +++ b/drivers/hwmon/atxp1.c @@ -254,7 +254,7 @@ static DEVICE_ATTR(gpio2, S_IRUGO | S_IWUSR, atxp1_showgpio2, atxp1_storegpio2); 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) diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c index 3ac37e95d2ef..a3b3a5887621 100644 --- a/drivers/hwmon/ds1621.c +++ b/drivers/hwmon/ds1621.c @@ -181,10 +181,10 @@ static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_max, set_temp_max); 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) { diff --git a/drivers/hwmon/fscher.c b/drivers/hwmon/fscher.c index ddf22fbf4ed1..5629e68a5ca3 100644 --- a/drivers/hwmon/fscher.c +++ b/drivers/hwmon/fscher.c @@ -289,7 +289,7 @@ static int fscher_attach_adapter(struct i2c_adapter *adapter) { 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) diff --git a/drivers/hwmon/fscpos.c b/drivers/hwmon/fscpos.c index 489870ad6056..edc84f2f6454 100644 --- a/drivers/hwmon/fscpos.c +++ b/drivers/hwmon/fscpos.c @@ -436,7 +436,7 @@ static int fscpos_attach_adapter(struct i2c_adapter *adapter) { 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) diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c index 63a2756c283a..15376a6e0494 100644 --- a/drivers/hwmon/gl518sm.c +++ b/drivers/hwmon/gl518sm.c @@ -348,7 +348,7 @@ static int gl518_attach_adapter(struct i2c_adapter *adapter) { 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) diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c index ff71eb7ac681..18539c9559c6 100644 --- a/drivers/hwmon/gl520sm.c +++ b/drivers/hwmon/gl520sm.c @@ -520,7 +520,7 @@ static int gl520_attach_adapter(struct i2c_adapter *adapter) { 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) diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index ca4f953363f4..d1e04c40e64c 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -698,7 +698,7 @@ static int it87_attach_adapter(struct i2c_adapter *adapter) { 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 @@ exit: 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; diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c index 736126d73aa2..dd2702131aed 100644 --- a/drivers/hwmon/lm63.c +++ b/drivers/hwmon/lm63.c @@ -360,7 +360,7 @@ static int lm63_attach_adapter(struct i2c_adapter *adapter) { if (!(adapter->class & I2C_CLASS_HWMON)) return 0; - return i2c_detect(adapter, &addr_data, lm63_detect); + return i2c_probe(adapter, &addr_data, lm63_detect); } /* diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index a2bebb6b37a6..bd39452db895 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c @@ -109,10 +109,10 @@ static int lm75_attach_adapter(struct i2c_adapter *adapter) { 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; diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c index d47aab3b3c05..52218570f874 100644 --- a/drivers/hwmon/lm77.c +++ b/drivers/hwmon/lm77.c @@ -209,10 +209,10 @@ static int lm77_attach_adapter(struct i2c_adapter *adapter) { 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; diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c index 21b767a66bbd..008fd9310061 100644 --- a/drivers/hwmon/lm78.c +++ b/drivers/hwmon/lm78.c @@ -478,7 +478,7 @@ static int lm78_attach_adapter(struct i2c_adapter *adapter) { 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 @@ static int lm78_isa_attach_adapter(struct i2c_adapter *adapter) 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; diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c index 36a0cda36a7d..500c38f3feae 100644 --- a/drivers/hwmon/lm80.c +++ b/drivers/hwmon/lm80.c @@ -391,7 +391,7 @@ static int lm80_attach_adapter(struct i2c_adapter *adapter) { 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) diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c index f3557f8826a9..5b78d19693e8 100644 --- a/drivers/hwmon/lm83.c +++ b/drivers/hwmon/lm83.c @@ -214,7 +214,7 @@ static int lm83_attach_adapter(struct i2c_adapter *adapter) { if (!(adapter->class & I2C_CLASS_HWMON)) return 0; - return i2c_detect(adapter, &addr_data, lm83_detect); + return i2c_probe(adapter, &addr_data, lm83_detect); } /* diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index 248920134fd9..8976565113f4 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c @@ -1012,7 +1012,7 @@ int lm85_attach_adapter(struct i2c_adapter *adapter) { 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, diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index f0ffe58e3670..af161203ce1d 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c @@ -539,7 +539,7 @@ static int lm87_attach_adapter(struct i2c_adapter *adapter) { if (!(adapter->class & I2C_CLASS_HWMON)) return 0; - return i2c_detect(adapter, &addr_data, lm87_detect); + return i2c_probe(adapter, &addr_data, lm87_detect); } /* diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index fbf9dac41ee5..68155c72a4e4 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c @@ -354,7 +354,7 @@ static int lm90_attach_adapter(struct i2c_adapter *adapter) { if (!(adapter->class & I2C_CLASS_HWMON)) return 0; - return i2c_detect(adapter, &addr_data, lm90_detect); + return i2c_probe(adapter, &addr_data, lm90_detect); } /* diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c index 9740ee264051..7ddc9116d091 100644 --- a/drivers/hwmon/lm92.c +++ b/drivers/hwmon/lm92.c @@ -389,7 +389,7 @@ static int lm92_attach_adapter(struct i2c_adapter *adapter) { 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) diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c index a53d7df92ba2..056506bae5f2 100644 --- a/drivers/hwmon/max1619.c +++ b/drivers/hwmon/max1619.c @@ -180,7 +180,7 @@ static int max1619_attach_adapter(struct i2c_adapter *adapter) { if (!(adapter->class & I2C_CLASS_HWMON)) return 0; - return i2c_detect(adapter, &addr_data, max1619_detect); + return i2c_probe(adapter, &addr_data, max1619_detect); } /* diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c index 66835c1e3f68..f269faeffa47 100644 --- a/drivers/hwmon/w83781d.c +++ b/drivers/hwmon/w83781d.c @@ -869,7 +869,7 @@ w83781d_attach_adapter(struct i2c_adapter *adapter) { 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 diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c index ea0c3519e03a..49e3ccd84bd0 100644 --- a/drivers/hwmon/w83792d.c +++ b/drivers/hwmon/w83792d.c @@ -1076,7 +1076,7 @@ w83792d_attach_adapter(struct i2c_adapter *adapter) { if (!(adapter->class & I2C_CLASS_HWMON)) return 0; - return i2c_detect(adapter, &addr_data, w83792d_detect); + return i2c_probe(adapter, &addr_data, w83792d_detect); } diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c index 213fb170d397..129d4012e8fd 100644 --- a/drivers/hwmon/w83l785ts.c +++ b/drivers/hwmon/w83l785ts.c @@ -142,7 +142,7 @@ static int w83l785ts_attach_adapter(struct i2c_adapter *adapter) { if (!(adapter->class & I2C_CLASS_HWMON)) return 0; - return i2c_detect(adapter, &addr_data, w83l785ts_detect); + return i2c_probe(adapter, &addr_data, w83l785ts_detect); } /* diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c index 8ab4e2348cda..c612f19fc7e6 100644 --- a/drivers/i2c/chips/ds1337.c +++ b/drivers/i2c/chips/ds1337.c @@ -226,7 +226,7 @@ int ds1337_do_command(int bus, int cmd, void *arg) 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); } /* diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c index 9466ada68932..befac01ecda6 100644 --- a/drivers/i2c/chips/eeprom.c +++ b/drivers/i2c/chips/eeprom.c @@ -152,10 +152,10 @@ static struct bin_attribute eeprom_attr = { 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; diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c index 52fd6bf29133..42663f921ecc 100644 --- a/drivers/i2c/chips/max6875.c +++ b/drivers/i2c/chips/max6875.c @@ -161,10 +161,10 @@ static struct bin_attribute user_eeprom_attr = { 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; diff --git a/drivers/i2c/chips/pca9539.c b/drivers/i2c/chips/pca9539.c index 1500b1842ce5..c8ea2a1e1a45 100644 --- a/drivers/i2c/chips/pca9539.c +++ b/drivers/i2c/chips/pca9539.c @@ -108,10 +108,10 @@ static struct attribute_group pca9539_defattr_group = { 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; diff --git a/drivers/i2c/chips/pcf8574.c b/drivers/i2c/chips/pcf8574.c index a109dfd3dbe7..01ec9ce19768 100644 --- a/drivers/i2c/chips/pcf8574.c +++ b/drivers/i2c/chips/pcf8574.c @@ -112,10 +112,10 @@ static DEVICE_ATTR(write, S_IWUSR | S_IRUGO, show_write, set_write); 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; diff --git a/drivers/i2c/chips/pcf8591.c b/drivers/i2c/chips/pcf8591.c index 7fce0fc048d9..dd03f2c725c8 100644 --- a/drivers/i2c/chips/pcf8591.c +++ b/drivers/i2c/chips/pcf8591.c @@ -163,10 +163,10 @@ static DEVICE_ATTR(out0_enable, S_IWUSR | S_IRUGO, */ 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; -- cgit v1.2.2 From 96478ef3f3f71fa929cc905cc794993e312d9a5d Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 31 Jul 2005 21:45:27 +0200 Subject: [PATCH] hwmon: hwmon vs i2c, second round (05/11) The i2c_detect function has no more user, delete it. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- 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(-) delete mode 100644 drivers/i2c/i2c-sensor-detect.c diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile index cd170395a8c7..71d68ad0e5ce 100644 --- a/drivers/i2c/Makefile +++ b/drivers/i2c/Makefile @@ -7,7 +7,7 @@ obj-$(CONFIG_I2C_CHARDEV) += i2c-dev.o 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) diff --git a/drivers/i2c/i2c-sensor-detect.c b/drivers/i2c/i2c-sensor-detect.c deleted file mode 100644 index 70fcf7281988..000000000000 --- a/drivers/i2c/i2c-sensor-detect.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - i2c-sensor-detect.c - Part of lm_sensors, Linux kernel modules for hardware - monitoring - Copyright (c) 1998 - 2001 Frodo Looijaard and - Mark D. Studebaker - - 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 -#include -#include -#include - -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 , " - "Rudolf Marek "); - -MODULE_DESCRIPTION("i2c-sensor driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/i2c/i2c-sensor-vid.c b/drivers/i2c/i2c-sensor-vid.c index 922e22f054bb..b8ef289fc80e 100644 --- a/drivers/i2c/i2c-sensor-vid.c +++ b/drivers/i2c/i2c-sensor-vid.c @@ -96,3 +96,8 @@ int i2c_which_vrm(void) #endif EXPORT_SYMBOL(i2c_which_vrm); + +MODULE_AUTHOR("Rudolf Marek "); + +MODULE_DESCRIPTION("i2c-sensor driver"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/i2c-sensor.h b/include/linux/i2c-sensor.h index fc9284af9fae..1563d445dfd1 100644 --- a/include/linux/i2c-sensor.h +++ b/include/linux/i2c-sensor.h @@ -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 */ -- cgit v1.2.2 From f4b50261207c987913f076d867c2e154d71fd012 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 31 Jul 2005 21:49:03 +0200 Subject: [PATCH] hwmon: hwmon vs i2c, second round (06/11) 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 Signed-off-by: Greg Kroah-Hartman --- 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(-) delete mode 100644 include/linux/i2c-sensor.h diff --git a/Documentation/i2c/porting-clients b/Documentation/i2c/porting-clients index f9099211bd0b..8b819379adcb 100644 --- a/Documentation/i2c/porting-clients +++ b/Documentation/i2c/porting-clients @@ -1,4 +1,4 @@ -Revision 4, 2004-03-30 +Revision 5, 2005-07-29 Jean Delvare Greg KH @@ -17,13 +17,12 @@ yours for best results. Technical changes: -* [Includes] Get rid of "version.h". Replace with - . Includes typically look like that: +* [Includes] Get rid of "version.h" and . + Includes typically look like that: #include #include #include #include - #include #include /* if you need VRM support */ #include /* if you have I/O operations */ Please respect this inclusion order. Some extra headers may be @@ -31,6 +30,7 @@ Technical changes: * [Addresses] SENSORS_I2C_END becomes I2C_CLIENT_END, ISA addresses are no more handled by the i2c core. + SENSORS_INSMOD_ becomes I2C_CLIENT_INSMOD_. * [Client data] Get rid of sysctl_id. Try using standard names for register values (for example, temp_os becomes temp_max). You're diff --git a/Documentation/i2c/writing-clients b/Documentation/i2c/writing-clients index 43d7928056ae..97e138cbb2a9 100644 --- a/Documentation/i2c/writing-clients +++ b/Documentation/i2c/writing-clients @@ -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. @@ -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_. + 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 @@ 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 ----------------------- diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c index 21f6dfeb04ac..e928cdb041cb 100644 --- a/drivers/hwmon/adm1021.c +++ b/drivers/hwmon/adm1021.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include @@ -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 */ diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c index 5b21284df2f8..229fd0de6f9e 100644 --- a/drivers/hwmon/adm1025.c +++ b/drivers/hwmon/adm1025.c @@ -50,7 +50,6 @@ #include #include #include -#include #include #include #include @@ -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 diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c index f3a78f792919..f32f819efcfc 100644 --- a/drivers/hwmon/adm1026.c +++ b/drivers/hwmon/adm1026.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -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 }; diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c index 9221653590a8..58338ed7c8a1 100644 --- a/drivers/hwmon/adm1031.c +++ b/drivers/hwmon/adm1031.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include @@ -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]; diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c index 6b20b28aa3b9..0a742cb88f4c 100644 --- a/drivers/hwmon/adm9240.c +++ b/drivers/hwmon/adm9240.c @@ -45,7 +45,6 @@ #include #include #include -#include #include #include #include @@ -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 diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c index a6c6c9d3fddd..66b0dbd1af0e 100644 --- a/drivers/hwmon/asb100.c +++ b/drivers/hwmon/asb100.c @@ -39,7 +39,6 @@ #include #include #include -#include #include #include #include @@ -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}"); diff --git a/drivers/hwmon/atxp1.c b/drivers/hwmon/atxp1.c index 329ddafd524b..5cf77e67a2ed 100644 --- a/drivers/hwmon/atxp1.c +++ b/drivers/hwmon/atxp1.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -43,7 +42,7 @@ MODULE_AUTHOR("Sebastian Witt "); 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); diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c index a3b3a5887621..b0199e063d0e 100644 --- a/drivers/hwmon/ds1621.c +++ b/drivers/hwmon/ds1621.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include "lm75.h" @@ -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"); diff --git a/drivers/hwmon/fscher.c b/drivers/hwmon/fscher.c index 5629e68a5ca3..eef6061d786b 100644 --- a/drivers/hwmon/fscher.c +++ b/drivers/hwmon/fscher.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include @@ -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 diff --git a/drivers/hwmon/fscpos.c b/drivers/hwmon/fscpos.c index edc84f2f6454..5fc77a5fed07 100644 --- a/drivers/hwmon/fscpos.c +++ b/drivers/hwmon/fscpos.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -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 diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c index 15376a6e0494..256b9323c84b 100644 --- a/drivers/hwmon/gl518sm.c +++ b/drivers/hwmon/gl518sm.c @@ -41,7 +41,6 @@ #include #include #include -#include #include #include @@ -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 */ diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c index 18539c9559c6..de6608a159c3 100644 --- a/drivers/hwmon/gl520sm.c +++ b/drivers/hwmon/gl520sm.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -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. diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index d1e04c40e64c..84877665b66e 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include @@ -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 */ diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c index dd2702131aed..be5c7095ecbb 100644 --- a/drivers/hwmon/lm63.c +++ b/drivers/hwmon/lm63.c @@ -42,7 +42,6 @@ #include #include #include -#include #include #include #include @@ -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 diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index bd39452db895..9a3ebdf583f4 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include "lm75.h" @@ -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 */ diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c index 52218570f874..866eab96a6f6 100644 --- a/drivers/hwmon/lm77.c +++ b/drivers/hwmon/lm77.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include @@ -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 diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c index 008fd9310061..51c0b37c4990 100644 --- a/drivers/hwmon/lm78.c +++ b/drivers/hwmon/lm78.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -37,7 +36,7 @@ static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24, static unsigned short isa_address = 0x290; /* Insmod parameters */ -SENSORS_INSMOD_2(lm78, lm79); +I2C_CLIENT_INSMOD_2(lm78, lm79); /* Many LM78 constants specified below */ diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c index 500c38f3feae..83af8b3a0cac 100644 --- a/drivers/hwmon/lm80.c +++ b/drivers/hwmon/lm80.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include @@ -35,7 +34,7 @@ static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; /* Insmod parameters */ -SENSORS_INSMOD_1(lm80); +I2C_CLIENT_INSMOD_1(lm80); /* Many LM80 constants specified below */ diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c index 5b78d19693e8..d74b2c20c719 100644 --- a/drivers/hwmon/lm83.c +++ b/drivers/hwmon/lm83.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -52,7 +51,7 @@ static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a, * Insmod parameters */ -SENSORS_INSMOD_1(lm83); +I2C_CLIENT_INSMOD_1(lm83); /* * The LM83 registers diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index 8976565113f4..aeb478815f72 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -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 */ diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index af161203ce1d..d0d2464c1b73 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c @@ -57,7 +57,6 @@ #include #include #include -#include #include #include #include @@ -73,7 +72,7 @@ static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; * Insmod parameters */ -SENSORS_INSMOD_1(lm87); +I2C_CLIENT_INSMOD_1(lm87); /* * The LM87 registers diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index 68155c72a4e4..14de05fcd431 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c @@ -75,7 +75,6 @@ #include #include #include -#include #include #include #include @@ -96,7 +95,7 @@ static unsigned short normal_i2c[] = { 0x4c, 0x4d, I2C_CLIENT_END }; * Insmod parameters */ -SENSORS_INSMOD_6(lm90, adm1032, lm99, lm86, max6657, adt7461); +I2C_CLIENT_INSMOD_6(lm90, adm1032, lm99, lm86, max6657, adt7461); /* * The LM90 registers diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c index 7ddc9116d091..647b7c7cd575 100644 --- a/drivers/hwmon/lm92.c +++ b/drivers/hwmon/lm92.c @@ -44,7 +44,6 @@ #include #include #include -#include #include #include @@ -54,7 +53,7 @@ static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 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 */ diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c index 056506bae5f2..16bf71f3a04d 100644 --- a/drivers/hwmon/max1619.c +++ b/drivers/hwmon/max1619.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include @@ -44,7 +43,7 @@ static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a, * Insmod parameters */ -SENSORS_INSMOD_1(max1619); +I2C_CLIENT_INSMOD_1(max1619); /* * The MAX1619 registers diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c index 55716cb579aa..8610bce08244 100644 --- a/drivers/hwmon/sis5595.c +++ b/drivers/hwmon/sis5595.c @@ -56,7 +56,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c index dab22bd75b68..7e699a8ede26 100644 --- a/drivers/hwmon/smsc47m1.c +++ b/drivers/hwmon/smsc47m1.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c index d9251fb0b625..eb84997627c8 100644 --- a/drivers/hwmon/via686a.c +++ b/drivers/hwmon/via686a.c @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c index 0466cc4b760e..2d2fcfb706d7 100644 --- a/drivers/hwmon/w83627hf.c +++ b/drivers/hwmon/w83627hf.c @@ -43,7 +43,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c index f269faeffa47..47607983acfd 100644 --- a/drivers/hwmon/w83781d.c +++ b/drivers/hwmon/w83781d.c @@ -39,7 +39,6 @@ #include #include #include -#include #include #include #include @@ -53,7 +52,7 @@ static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 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}"); diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c index 49e3ccd84bd0..d6d8c0f04e32 100644 --- a/drivers/hwmon/w83792d.c +++ b/drivers/hwmon/w83792d.c @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -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}"); diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c index 129d4012e8fd..133e34ab1d0a 100644 --- a/drivers/hwmon/w83l785ts.c +++ b/drivers/hwmon/w83l785ts.c @@ -36,7 +36,6 @@ #include #include #include -#include #include #include @@ -54,7 +53,7 @@ static unsigned short normal_i2c[] = { 0x2e, I2C_CLIENT_END }; * Insmod parameters */ -SENSORS_INSMOD_1(w83l785ts); +I2C_CLIENT_INSMOD_1(w83l785ts); /* * The W83L785TS-S registers diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c index c612f19fc7e6..9d3175c03395 100644 --- a/drivers/i2c/chips/ds1337.c +++ b/drivers/i2c/chips/ds1337.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include /* get the user-level API */ #include @@ -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); diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c index befac01ecda6..a27420a54c84 100644 --- a/drivers/i2c/chips/eeprom.c +++ b/drivers/i2c/chips/eeprom.c @@ -33,14 +33,13 @@ #include #include #include -#include /* 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 */ diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c index 42663f921ecc..31cee2d34a17 100644 --- a/drivers/i2c/chips/max6875.c +++ b/drivers/i2c/chips/max6875.c @@ -31,14 +31,13 @@ #include #include #include -#include #include /* 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 diff --git a/drivers/i2c/chips/pca9539.c b/drivers/i2c/chips/pca9539.c index c8ea2a1e1a45..225577fdda4d 100644 --- a/drivers/i2c/chips/pca9539.c +++ b/drivers/i2c/chips/pca9539.c @@ -13,13 +13,12 @@ #include #include #include -#include /* 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 { diff --git a/drivers/i2c/chips/pcf8574.c b/drivers/i2c/chips/pcf8574.c index 01ec9ce19768..6525743ff9fd 100644 --- a/drivers/i2c/chips/pcf8574.c +++ b/drivers/i2c/chips/pcf8574.c @@ -39,7 +39,6 @@ #include #include #include -#include /* Addresses to scan */ static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, @@ -47,7 +46,7 @@ static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 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) */ diff --git a/drivers/i2c/chips/pcf8591.c b/drivers/i2c/chips/pcf8591.c index dd03f2c725c8..80f1df9a4500 100644 --- a/drivers/i2c/chips/pcf8591.c +++ b/drivers/i2c/chips/pcf8591.c @@ -24,14 +24,13 @@ #include #include #include -#include /* 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); diff --git a/include/linux/i2c-sensor.h b/include/linux/i2c-sensor.h deleted file mode 100644 index 1563d445dfd1..000000000000 --- a/include/linux/i2c-sensor.h +++ /dev/null @@ -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 - - 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 - -#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 */ diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 9419bc5584ad..3ad3969b6f0d 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -565,24 +565,148 @@ union i2c_smbus_data { 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 */ -- cgit v1.2.2 From 303760b44a7a142cb9f4c9df4609fb63bbda98db Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 31 Jul 2005 21:52:01 +0200 Subject: [PATCH] hwmon: hwmon vs i2c, second round (07/11) 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 Signed-off-by: Greg Kroah-Hartman --- 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(-) create mode 100644 drivers/hwmon/hwmon-vid.c delete mode 100644 drivers/i2c/i2c-sensor-vid.c create mode 100644 include/linux/hwmon-vid.h delete mode 100644 include/linux/i2c-vid.h diff --git a/Documentation/i2c/porting-clients b/Documentation/i2c/porting-clients index 8b819379adcb..5eb8d37cc679 100644 --- a/Documentation/i2c/porting-clients +++ b/Documentation/i2c/porting-clients @@ -23,7 +23,9 @@ Technical changes: #include #include #include - #include /* if you need VRM support */ + #include /* for hardware monitoring drivers */ + #include + #include /* if you need VRM support */ #include /* 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"). diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 6483ff696b5a..35fe7d1d4028 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -19,10 +19,13 @@ config HWMON 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_ADM1021 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_ADM1025 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_ADM1026 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_ADM1031 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_ADM9240 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_ASB100 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_ATXP1 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_DS1621 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_FSCHER 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_FSCPOS 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_GL518SM 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_GL520SM 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_IT87 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_LM63 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_LM75 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_LM77 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_LM78 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_LM80 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_LM83 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_LM85 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_LM87 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_LM90 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_LM92 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_MAX1619 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_PC87360 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_SIS5595 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_SMSC47M1 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_SMSC47B397 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_VIA686A 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_W83781D 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_W83792D 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_W83L785TS 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_W83627HF 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 diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 187b89d47f83..381f1bf04cc5 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -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 diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c index 229fd0de6f9e..526b7ff179eb 100644 --- a/drivers/hwmon/adm1025.c +++ b/drivers/hwmon/adm1025.c @@ -50,8 +50,8 @@ #include #include #include -#include #include +#include #include /* @@ -473,7 +473,7 @@ static void adm1025_init_client(struct i2c_client *client) struct adm1025_data *data = i2c_get_clientdata(client); int i; - data->vrm = i2c_which_vrm(); + data->vrm = vid_which_vrm(); /* * Set high limits diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c index f32f819efcfc..625158110fd4 100644 --- a/drivers/hwmon/adm1026.c +++ b/drivers/hwmon/adm1026.c @@ -28,9 +28,9 @@ #include #include #include -#include -#include #include +#include +#include #include /* Addresses to scan */ @@ -1552,7 +1552,7 @@ int adm1026_detect(struct i2c_adapter *adapter, int address, 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); diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c index 0a742cb88f4c..bc7faef162f7 100644 --- a/drivers/hwmon/adm9240.c +++ b/drivers/hwmon/adm9240.c @@ -45,8 +45,8 @@ #include #include #include -#include #include +#include #include /* Addresses to scan */ @@ -657,7 +657,7 @@ static void adm9240_init_client(struct i2c_client *client) 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); diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c index 66b0dbd1af0e..8e34855a6274 100644 --- a/drivers/hwmon/asb100.c +++ b/drivers/hwmon/asb100.c @@ -39,8 +39,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -973,7 +973,7 @@ static void asb100_init_client(struct i2c_client *client) 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 */ diff --git a/drivers/hwmon/atxp1.c b/drivers/hwmon/atxp1.c index 5cf77e67a2ed..deb4d34c9539 100644 --- a/drivers/hwmon/atxp1.c +++ b/drivers/hwmon/atxp1.c @@ -23,8 +23,8 @@ #include #include #include -#include #include +#include #include MODULE_LICENSE("GPL"); @@ -296,7 +296,7 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind) } /* 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", diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c index de6608a159c3..12fd757066fc 100644 --- a/drivers/hwmon/gl520sm.c +++ b/drivers/hwmon/gl520sm.c @@ -26,8 +26,8 @@ #include #include #include -#include #include +#include #include /* Type of the extra sensor */ @@ -617,7 +617,7 @@ static void gl520_init_client(struct i2c_client *client) 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; diff --git a/drivers/hwmon/hwmon-vid.c b/drivers/hwmon/hwmon-vid.c new file mode 100644 index 000000000000..ce475c93f836 --- /dev/null +++ b/drivers/hwmon/hwmon-vid.c @@ -0,0 +1,103 @@ +/* + hwmon-vid.c - VID/VRM/VRD voltage conversions + + Copyright (c) 2004 Rudolf Marek + + 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 +#include +#include +#include + +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 "); + +MODULE_DESCRIPTION("hwmon-vid driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index 84877665b66e..53cc2b6d6385 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -37,9 +37,9 @@ #include #include #include -#include -#include #include +#include +#include #include #include @@ -919,7 +919,7 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind) } 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); } diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index aeb478815f72..ab214df9624b 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c @@ -28,8 +28,8 @@ #include #include #include -#include #include +#include #include /* Addresses to scan */ @@ -1147,7 +1147,7 @@ int lm85_detect(struct i2c_adapter *adapter, int address, 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); diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index d0d2464c1b73..dca996de4c33 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c @@ -57,8 +57,8 @@ #include #include #include -#include #include +#include #include /* @@ -694,7 +694,7 @@ static void lm87_init_client(struct i2c_client *client) 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)) { diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c index c66ae4f6e802..08fcb5aea764 100644 --- a/drivers/hwmon/pc87360.c +++ b/drivers/hwmon/pc87360.c @@ -39,8 +39,8 @@ #include #include #include -#include #include +#include #include #include diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c index 2d2fcfb706d7..02bd5c0239a2 100644 --- a/drivers/hwmon/w83627hf.c +++ b/drivers/hwmon/w83627hf.c @@ -43,8 +43,8 @@ #include #include #include -#include #include +#include #include #include #include "lm75.h" @@ -1316,7 +1316,7 @@ static void w83627hf_init_client(struct i2c_client *client) 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); diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c index 47607983acfd..4c43337ca780 100644 --- a/drivers/hwmon/w83781d.c +++ b/drivers/hwmon/w83781d.c @@ -39,8 +39,8 @@ #include #include #include -#include #include +#include #include #include #include "lm75.h" @@ -1478,7 +1478,7 @@ w83781d_init_client(struct i2c_client *client) 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); diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c index d6d8c0f04e32..ba0c28015f6a 100644 --- a/drivers/hwmon/w83792d.c +++ b/drivers/hwmon/w83792d.c @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile index 71d68ad0e5ce..71c5a854ac5d 100644 --- a/drivers/i2c/Makefile +++ b/drivers/i2c/Makefile @@ -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 diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig index 43f70dbfc03f..6bd44a44cd28 100644 --- a/drivers/i2c/chips/Kconfig +++ b/drivers/i2c/chips/Kconfig @@ -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_DS1337 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_DS1374 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_EEPROM 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_PCA9539 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_PCF8591 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. diff --git a/drivers/i2c/i2c-sensor-vid.c b/drivers/i2c/i2c-sensor-vid.c deleted file mode 100644 index b8ef289fc80e..000000000000 --- a/drivers/i2c/i2c-sensor-vid.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - i2c-sensor-vid.c - Part of lm_sensors, Linux kernel modules for hardware - monitoring - - Copyright (c) 2004 Rudolf Marek - - 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 -#include -#include - -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 "); - -MODULE_DESCRIPTION("i2c-sensor driver"); -MODULE_LICENSE("GPL"); diff --git a/include/linux/hwmon-vid.h b/include/linux/hwmon-vid.h new file mode 100644 index 000000000000..c45cd872c55e --- /dev/null +++ b/include/linux/hwmon-vid.h @@ -0,0 +1,112 @@ +/* + hwmon-vid.h - VID/VRM/VRD voltage conversions + + Originally part of lm_sensors + Copyright (c) 2002 Mark D. Studebaker + With assistance from Trent Piepho + + 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; + } +} diff --git a/include/linux/i2c-vid.h b/include/linux/i2c-vid.h deleted file mode 100644 index 41d0635e0ba9..000000000000 --- a/include/linux/i2c-vid.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - i2c-vid.h - Part of lm_sensors, Linux kernel modules for hardware - monitoring - Copyright (c) 2002 Mark D. Studebaker - With assistance from Trent Piepho - - 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; - } -} -- cgit v1.2.2 From da97a5a3279340462e8be6612feabc4b28883f87 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 31 Jul 2005 21:54:28 +0200 Subject: [PATCH] hwmon: hwmon vs i2c, second round (08/11) Cleanup hwmon-vid a bit, fixing typos, rewording some comments and reindenting properly at places. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/hwmon-vid.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/hwmon/hwmon-vid.c b/drivers/hwmon/hwmon-vid.c index ce475c93f836..7c8ed0353302 100644 --- a/drivers/hwmon/hwmon-vid.c +++ b/drivers/hwmon/hwmon-vid.c @@ -38,14 +38,14 @@ 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, 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 @@ static int find_vrm(u8 eff_family, u8 eff_model, u8 vendor) 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 @@ int vid_which_vrm(void) 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 @@ int vid_which_vrm(void) } 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) { -- cgit v1.2.2 From ee70d3a33368038d41985474d9e70ac07f19651c Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 31 Jul 2005 21:57:33 +0200 Subject: [PATCH] hwmon: hwmon vs i2c, second round (09/11) Delete DEFAULT_VRM from hwmon-vid.h, it has no more users. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- include/linux/hwmon-vid.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/linux/hwmon-vid.h b/include/linux/hwmon-vid.h index c45cd872c55e..6d9d4f9bad58 100644 --- a/include/linux/hwmon-vid.h +++ b/include/linux/hwmon-vid.h @@ -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; -- cgit v1.2.2 From d0f282706df877f8fd8869419e308d24eedb523b Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Mon, 1 Aug 2005 22:50:08 +0200 Subject: [PATCH] hwmon: hwmon vs i2c, second round (10/11) 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 Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/hwmon-vid.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++ include/linux/hwmon-vid.h | 83 +++++------------------------------------------ 2 files changed, 91 insertions(+), 74 deletions(-) diff --git a/drivers/hwmon/hwmon-vid.c b/drivers/hwmon/hwmon-vid.c index 7c8ed0353302..a54d08699973 100644 --- a/drivers/hwmon/hwmon-vid.c +++ b/drivers/hwmon/hwmon-vid.c @@ -3,6 +3,10 @@ Copyright (c) 2004 Rudolf Marek + Partly imported from i2c-vid.h of the lm_sensors project + Copyright (c) 2002 Mark D. Studebaker + With assistance from Trent Piepho + 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 #include +/* + 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 @@ int vid_which_vrm(void) } #endif +EXPORT_SYMBOL(vid_from_reg); EXPORT_SYMBOL(vid_which_vrm); MODULE_AUTHOR("Rudolf Marek "); diff --git a/include/linux/hwmon-vid.h b/include/linux/hwmon-vid.h index 6d9d4f9bad58..cd4b7a042b86 100644 --- a/include/linux/hwmon-vid.h +++ b/include/linux/hwmon-vid.h @@ -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 @@ static inline int vid_to_reg(int val, int vrm) return -1; } } + +#endif /* _LINUX_HWMON_VID_H */ -- cgit v1.2.2 From 19f673eddb5a406be72989fb57b7f286772b8cf4 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 31 Jul 2005 22:12:09 +0200 Subject: [PATCH] hwmon: hwmon vs i2c, second round (11/11) Use the common vid_from_reg function in lm78 rather than reimplementing it. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/Kconfig | 1 + drivers/hwmon/lm78.c | 10 ++-------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 35fe7d1d4028..138dc50270e3 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -207,6 +207,7 @@ config SENSORS_LM78 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. diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c index 51c0b37c4990..f6730dc3573b 100644 --- a/drivers/hwmon/lm78.c +++ b/drivers/hwmon/lm78.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -106,13 +107,6 @@ static inline int TEMP_FROM_REG(s8 val) 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 DEVICE_ATTR(fan3_div, S_IRUGO, show_fan_3_div, NULL); 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); -- cgit v1.2.2 From 3b6c0634cc989f0735a1541ccf9288947685cab5 Mon Sep 17 00:00:00 2001 From: "R.Marek@sh.cvut.cz" Date: Fri, 5 Aug 2005 15:40:11 +0000 Subject: [PATCH] hwmon: VID table update This patch updates the VID entries, so any future Intel CPU will be detected as unknown rather than 9.0 Signed-off-by: Rudolf Marek Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/hwmon-vid.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/hwmon-vid.c b/drivers/hwmon/hwmon-vid.c index a54d08699973..312769ad4dab 100644 --- a/drivers/hwmon/hwmon-vid.c +++ b/drivers/hwmon/hwmon-vid.c @@ -122,8 +122,11 @@ static struct vrm_model vrm_models[] = { {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, 0x0, 90}, /* P4 */ + {X86_VENDOR_INTEL, 0xF, 0x1, 90}, /* P4 Willamette */ + {X86_VENDOR_INTEL, 0xF, 0x2, 90}, /* P4 Northwood */ {X86_VENDOR_INTEL, 0xF, 0x3, 100}, /* P4 Prescott */ - {X86_VENDOR_INTEL, 0xF, ANY, 90}, /* P4 before Prescott */ + {X86_VENDOR_INTEL, 0xF, 0x4, 100}, /* P4 Prescott */ {X86_VENDOR_INTEL, 0x10,ANY, 0}, /* Itanium 2 */ {X86_VENDOR_UNKNOWN, ANY, ANY, 0} /* stop here */ }; -- cgit v1.2.2 From a89ba0bc02e82920a0f4137aa5d655ac0366cc28 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Tue, 9 Aug 2005 20:17:55 +0200 Subject: [PATCH] I2C: Rewrite i2c_probe i2c_probe was quite complex and slow, so I rewrote it in a more efficient and hopefully clearer way. Note that this slightly changes the way the module parameters are handled. This shouldn't change anything for the most common cases though. For one thing, the function now respects the order of the parameters for address probing. It used to always do lower addresses first. The new approach gives the user more control. For another, ignore addresses don't overrule probe addresses anymore. This could have been restored the way it was at the cost of a few more lines of code, but I don't think it's worth it. Both lists are given as module parameters, so a user would be quite silly to specify the same addresses in both lists. The normal addresses list is the only one that isn't controlled by a module parameter, thus is the only one the user may reasonably want to remove an address from. Another significant change is the fact that i2c_probe() will no more stop when a detection function returns -ENODEV. Just because a driver found a chip it doesn't support isn't a valid reason to stop all probings for this one driver. This closes the long standing lm_sensors ticket #1807. http://www2.lm-sensors.nu/~lm78/readticket.cgi?ticket=1807 I updated the documentation accordingly. In terms of algorithmic complexity, the new code is way better. If I is the ignore address count, P the probe address count, N the normal address count and F the force address count, the old code was doing 128 * (F + I + P + N) iterations max, while the new code does F + P + ((I+1) * N) iterations max. For the most common case where F, I and P are empty, this is down from 128 * N to N. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- Documentation/i2c/writing-clients | 7 +- drivers/i2c/i2c-core.c | 165 ++++++++++++++++++++------------------ 2 files changed, 93 insertions(+), 79 deletions(-) diff --git a/Documentation/i2c/writing-clients b/Documentation/i2c/writing-clients index 97e138cbb2a9..077275722a7c 100644 --- a/Documentation/i2c/writing-clients +++ b/Documentation/i2c/writing-clients @@ -241,9 +241,10 @@ Below, some things are only needed if this is a `sensors' driver. Those parts are between /* SENSORS ONLY START */ and /* SENSORS ONLY END */ markers. -This function should only return an error (any value != 0) if there is -some reason why no more detection should be done anymore. If the -detection just fails for this address, return 0. +Returning an error different from -ENODEV in a detect function will cause +the detection to stop: other addresses and adapters won't be scanned. +This should only be done on fatal or internal errors, such as a memory +shortage or i2c_attach_client failing. For now, you can ignore the `flags' parameter. It is there for future use. diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 372b5996d045..bee0148dfab8 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -662,107 +662,120 @@ int i2c_control(struct i2c_client *client, * 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) +static int i2c_probe_address(struct i2c_adapter *adapter, int addr, int kind, + int (*found_proc) (struct i2c_adapter *, int, int)) { - 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; - } - } + int err; + + /* Make sure the address is valid */ + if (addr < 0x03 || addr > 0x77) { + dev_warn(&adapter->dev, "Invalid probe address 0x%02x\n", + addr); + return -EINVAL; } - return -1; + /* Skip if already in use */ + if (i2c_check_addr(adapter, addr)) + return 0; + + /* Make sure there is something at this address, unless forced */ + if (kind < 0 + && i2c_smbus_xfer(adapter, addr, 0, 0, 0, I2C_SMBUS_QUICK, NULL) < 0) + return 0; + + /* Finally call the custom detection function */ + err = found_proc(adapter, addr, kind); + + /* -ENODEV can be returned if there is a chip at the given address + but it isn't supported by this chip driver. We catch it here as + this isn't an error. */ + return (err == -ENODEV) ? 0 : err; } int i2c_probe(struct i2c_adapter *adapter, struct i2c_client_address_data *address_data, int (*found_proc) (struct i2c_adapter *, int, int)) { - int addr,i,found,err; + int i, err; int adap_id = i2c_adapter_id(adapter); /* Forget it if we can't probe using SMBUS_QUICK */ if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_QUICK)) return -1; - for (addr = 0x00; addr <= 0x7f; addr++) { - - /* Skip if already in use */ - 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; - - 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; - continue; - } - } - - /* If this address is in one of the ignores, we can forget about - it right now */ - for (i = 0; - !found && (address_data->ignore[i] != I2C_CLIENT_END); - i += 2) { - if (((adap_id == address_data->ignore[i]) || - ((address_data->ignore[i] == ANY_I2C_BUS))) && - (addr == address_data->ignore[i+1])) { - dev_dbg(&adapter->dev, "found ignore parameter for adapter %d, " - "addr %04x\n", adap_id ,addr); - found = 1; + /* Force entries are done first, and are not affected by ignore + entries */ + if (address_data->forces) { + unsigned short **forces = address_data->forces; + int kind; + + for (kind = 0; forces[kind]; kind++) { + for (i = 0; forces[kind][i] != I2C_CLIENT_END; + i += 2) { + if (forces[kind][i] == adap_id + || forces[kind][i] == ANY_I2C_BUS) { + dev_dbg(&adapter->dev, "found force " + "parameter for adapter %d, " + "addr 0x%02x, kind %d\n", + adap_id, forces[kind][i + 1], + kind); + err = i2c_probe_address(adapter, + forces[kind][i + 1], + kind, found_proc); + if (err) + return err; + } } } - if (found) - continue; + } - /* Now, we will do a detection, but only if it is in the normal or - probe entries */ - for (i = 0; - !found && (address_data->normal_i2c[i] != I2C_CLIENT_END); - i += 1) { - if (addr == address_data->normal_i2c[i]) { - found = 1; - dev_dbg(&adapter->dev, "found normal i2c entry for adapter %d, " - "addr %02x\n", adap_id, addr); - } + /* Probe entries are done second, and are not affected by ignore + entries either */ + for (i = 0; address_data->probe[i] != I2C_CLIENT_END; i += 2) { + if (address_data->probe[i] == adap_id + || address_data->probe[i] == ANY_I2C_BUS) { + dev_dbg(&adapter->dev, "found probe parameter for " + "adapter %d, addr 0x%02x\n", adap_id, + address_data->probe[i + 1]); + err = i2c_probe_address(adapter, + address_data->probe[i + 1], + -1, found_proc); + if (err) + return err; } + } - for (i = 0; - !found && (address_data->probe[i] != I2C_CLIENT_END); - i += 2) { - if (((adap_id == address_data->probe[i]) || - ((address_data->probe[i] == ANY_I2C_BUS))) && - (addr == address_data->probe[i+1])) { - found = 1; - dev_dbg(&adapter->dev, "found probe parameter for adapter %d, " - "addr %04x\n", adap_id,addr); + /* Normal entries are done last, unless shadowed by an ignore entry */ + for (i = 0; address_data->normal_i2c[i] != I2C_CLIENT_END; i += 1) { + int j, ignore; + + ignore = 0; + for (j = 0; address_data->ignore[j] != I2C_CLIENT_END; + j += 2) { + if ((address_data->ignore[j] == adap_id || + address_data->ignore[j] == ANY_I2C_BUS) + && address_data->ignore[j + 1] + == address_data->normal_i2c[i]) { + dev_dbg(&adapter->dev, "found ignore " + "parameter for adapter %d, " + "addr 0x%02x\n", adap_id, + address_data->ignore[j + 1]); } + ignore = 1; + break; } - if (!found) + if (ignore) 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; + dev_dbg(&adapter->dev, "found normal entry for adapter %d, " + "addr 0x%02x\n", adap_id, + address_data->normal_i2c[i]); + err = i2c_probe_address(adapter, address_data->normal_i2c[i], + -1, found_proc); + if (err) + return err; } + return 0; } -- cgit v1.2.2 From 4c9337da37c877e53a64696fc8524f642d446cba Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Tue, 9 Aug 2005 20:28:10 +0200 Subject: [PATCH] I2C: Centralize 24RF08 corruption prevention The 24RF08 corruption would better be prevented at i2c-core level than at chip driver level, for several reasons: * The second quick write should happen as soon as possible after the first one, so as to limit the risk that another command is issued on the bus inbetween, causing the corruption. * As a matter of fact, the protection code at driver level was reworked at least three times already, which proves how hard it is to get it right there, while it's straightforward at i2c-core level. * It's easy to add a new driver that would need the protection, and forget to add it. This did happen already. * As additional probing addresses can be passed to most i2c chip drivers as module parameters, virtually every i2c chip driver would need the protection if we want to be really safe. * Why duplicate code when we can easily avoid it? Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- Documentation/i2c/porting-clients | 2 ++ drivers/i2c/chips/eeprom.c | 5 ----- drivers/i2c/chips/max6875.c | 5 ----- drivers/i2c/i2c-core.c | 13 ++++++++++--- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Documentation/i2c/porting-clients b/Documentation/i2c/porting-clients index 5eb8d37cc679..4849dfd6961c 100644 --- a/Documentation/i2c/porting-clients +++ b/Documentation/i2c/porting-clients @@ -90,6 +90,8 @@ Technical changes: device_create_file. Move the driver initialization before any sysfs file creation. Drop client->id. + Drop any 24RF08 corruption prevention you find, as this is now done + at the i2c-core level, and doing it twice voids it. * [Init] Limits must not be set by the driver (can be done later in user-space). Chip should not be reset default (although a module diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c index a27420a54c84..d58403a47908 100644 --- a/drivers/i2c/chips/eeprom.c +++ b/drivers/i2c/chips/eeprom.c @@ -161,11 +161,6 @@ int eeprom_detect(struct i2c_adapter *adapter, int address, int kind) struct eeprom_data *data; int err = 0; - /* prevent 24RF08 corruption */ - if (kind < 0) - i2c_smbus_xfer(adapter, address, 0, 0, 0, - I2C_SMBUS_QUICK, NULL); - /* There are three ways we can read the EEPROM data: (1) I2C block reads (faster, but unsupported by most adapters) (2) Consecutive byte reads (100% overhead) diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c index 31cee2d34a17..9e1aeb69abf9 100644 --- a/drivers/i2c/chips/max6875.c +++ b/drivers/i2c/chips/max6875.c @@ -171,11 +171,6 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind) struct max6875_data *data; int err = 0; - /* Prevent 24rf08 corruption (in case of user error) */ - if (kind < 0) - i2c_smbus_xfer(adapter, address, 0, 0, 0, - I2C_SMBUS_QUICK, NULL); - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_BYTE_DATA | I2C_FUNC_SMBUS_READ_BYTE)) return 0; diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index bee0148dfab8..dda472e5e8be 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -679,9 +679,16 @@ static int i2c_probe_address(struct i2c_adapter *adapter, int addr, int kind, return 0; /* Make sure there is something at this address, unless forced */ - if (kind < 0 - && i2c_smbus_xfer(adapter, addr, 0, 0, 0, I2C_SMBUS_QUICK, NULL) < 0) - return 0; + if (kind < 0) { + if (i2c_smbus_xfer(adapter, addr, 0, 0, 0, + I2C_SMBUS_QUICK, NULL) < 0) + return 0; + + /* prevent 24RF08 corruption */ + if ((addr & ~0x0f) == 0x50) + i2c_smbus_xfer(adapter, addr, 0, 0, 0, + I2C_SMBUS_QUICK, NULL); + } /* Finally call the custom detection function */ err = found_proc(adapter, addr, kind); -- cgit v1.2.2 From 975185880d55676b1352047e82a0cb84173c6c28 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Thu, 11 Aug 2005 23:33:24 +0200 Subject: [PATCH] I2C: Kill i2c_algorithm.name (1/7) The name member of the i2c_algorithm is never used, although all drivers conscientiously fill it. We can drop it completely, this structure doesn't need to have a name. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/algos/i2c-algo-bit.c | 1 - drivers/i2c/algos/i2c-algo-ite.c | 1 - drivers/i2c/algos/i2c-algo-pca.c | 1 - drivers/i2c/algos/i2c-algo-pcf.c | 1 - drivers/i2c/algos/i2c-algo-sgi.c | 1 - drivers/i2c/algos/i2c-algo-sibyte.c | 1 - drivers/i2c/busses/i2c-ali1535.c | 1 - drivers/i2c/busses/i2c-ali1563.c | 1 - drivers/i2c/busses/i2c-ali15x3.c | 1 - drivers/i2c/busses/i2c-amd756.c | 1 - drivers/i2c/busses/i2c-amd8111.c | 1 - drivers/i2c/busses/i2c-au1550.c | 1 - drivers/i2c/busses/i2c-i801.c | 1 - drivers/i2c/busses/i2c-ibm_iic.c | 1 - drivers/i2c/busses/i2c-iop3xx.c | 1 - drivers/i2c/busses/i2c-isa.c | 1 - drivers/i2c/busses/i2c-keywest.c | 1 - drivers/i2c/busses/i2c-mpc.c | 1 - drivers/i2c/busses/i2c-mv64xxx.c | 1 - drivers/i2c/busses/i2c-nforce2.c | 1 - drivers/i2c/busses/i2c-piix4.c | 1 - drivers/i2c/busses/i2c-s3c2410.c | 1 - drivers/i2c/busses/i2c-sis5595.c | 1 - drivers/i2c/busses/i2c-sis630.c | 1 - drivers/i2c/busses/i2c-sis96x.c | 1 - drivers/i2c/busses/i2c-stub.c | 1 - drivers/i2c/busses/i2c-viapro.c | 1 - drivers/i2c/busses/scx200_acb.c | 1 - drivers/media/common/saa7146_i2c.c | 1 - drivers/media/dvb/b2c2/flexcop-i2c.c | 1 - drivers/media/dvb/dvb-usb/cxusb.c | 1 - drivers/media/dvb/dvb-usb/dibusb-common.c | 1 - drivers/media/dvb/dvb-usb/digitv.c | 1 - drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c | 1 - drivers/media/video/bttv-i2c.c | 1 - drivers/media/video/saa7134/saa7134-i2c.c | 1 - drivers/usb/media/w9968cf.c | 1 - include/linux/i2c.h | 1 - 38 files changed, 38 deletions(-) diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c index fb5b732238ed..6e1e1601accb 100644 --- a/drivers/i2c/algos/i2c-algo-bit.c +++ b/drivers/i2c/algos/i2c-algo-bit.c @@ -519,7 +519,6 @@ static u32 bit_func(struct i2c_adapter *adap) /* -----exported algorithm data: ------------------------------------- */ static struct i2c_algorithm i2c_bit_algo = { - .name = "Bit-shift algorithm", .id = I2C_ALGO_BIT, .master_xfer = bit_xfer, .functionality = bit_func, diff --git a/drivers/i2c/algos/i2c-algo-ite.c b/drivers/i2c/algos/i2c-algo-ite.c index e6cae39f47aa..a9c2b1115e07 100644 --- a/drivers/i2c/algos/i2c-algo-ite.c +++ b/drivers/i2c/algos/i2c-algo-ite.c @@ -713,7 +713,6 @@ static u32 iic_func(struct i2c_adapter *adap) /* -----exported algorithm data: ------------------------------------- */ static struct i2c_algorithm iic_algo = { - .name = "ITE IIC algorithm", .id = I2C_ALGO_IIC, .master_xfer = iic_xfer, .algo_control = algo_control, /* ioctl */ diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c index ff2db0da4417..16157391cdf5 100644 --- a/drivers/i2c/algos/i2c-algo-pca.c +++ b/drivers/i2c/algos/i2c-algo-pca.c @@ -356,7 +356,6 @@ static int pca_init(struct i2c_algo_pca_data *adap) } static struct i2c_algorithm pca_algo = { - .name = "PCA9564 algorithm", .id = I2C_ALGO_PCA, .master_xfer = pca_xfer, .functionality = pca_func, diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c index 8d087dac32af..eb3e9e39d75b 100644 --- a/drivers/i2c/algos/i2c-algo-pcf.c +++ b/drivers/i2c/algos/i2c-algo-pcf.c @@ -459,7 +459,6 @@ static u32 pcf_func(struct i2c_adapter *adap) /* -----exported algorithm data: ------------------------------------- */ static struct i2c_algorithm pcf_algo = { - .name = "PCF8584 algorithm", .id = I2C_ALGO_PCF, .master_xfer = pcf_xfer, .functionality = pcf_func, diff --git a/drivers/i2c/algos/i2c-algo-sgi.c b/drivers/i2c/algos/i2c-algo-sgi.c index 422721b241e5..55284c9e41dc 100644 --- a/drivers/i2c/algos/i2c-algo-sgi.c +++ b/drivers/i2c/algos/i2c-algo-sgi.c @@ -158,7 +158,6 @@ static u32 sgi_func(struct i2c_adapter *adap) } static struct i2c_algorithm sgi_algo = { - .name = "SGI algorithm", .id = I2C_ALGO_SGI, .master_xfer = sgi_xfer, .functionality = sgi_func, diff --git a/drivers/i2c/algos/i2c-algo-sibyte.c b/drivers/i2c/algos/i2c-algo-sibyte.c index f2785499237b..4ca3e69461bc 100644 --- a/drivers/i2c/algos/i2c-algo-sibyte.c +++ b/drivers/i2c/algos/i2c-algo-sibyte.c @@ -135,7 +135,6 @@ static u32 bit_func(struct i2c_adapter *adap) /* -----exported algorithm data: ------------------------------------- */ static struct i2c_algorithm i2c_sibyte_algo = { - .name = "SiByte algorithm", .id = I2C_ALGO_SIBYTE, .smbus_xfer = smbus_xfer, .algo_control = algo_control, /* ioctl */ diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c index f634a0780cf0..d7e05a1a5125 100644 --- a/drivers/i2c/busses/i2c-ali1535.c +++ b/drivers/i2c/busses/i2c-ali1535.c @@ -472,7 +472,6 @@ static u32 ali1535_func(struct i2c_adapter *adapter) } static struct i2c_algorithm smbus_algorithm = { - .name = "Non-i2c SMBus adapter", .id = I2C_ALGO_SMBUS, .smbus_xfer = ali1535_access, .functionality = ali1535_func, diff --git a/drivers/i2c/busses/i2c-ali1563.c b/drivers/i2c/busses/i2c-ali1563.c index fdd881aee618..48f85e53d7d6 100644 --- a/drivers/i2c/busses/i2c-ali1563.c +++ b/drivers/i2c/busses/i2c-ali1563.c @@ -366,7 +366,6 @@ static void ali1563_shutdown(struct pci_dev *dev) } static struct i2c_algorithm ali1563_algorithm = { - .name = "Non-i2c SMBus adapter", .id = I2C_ALGO_SMBUS, .smbus_xfer = ali1563_access, .functionality = ali1563_func, diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c index 0f781a1a3323..523f0129e4cd 100644 --- a/drivers/i2c/busses/i2c-ali15x3.c +++ b/drivers/i2c/busses/i2c-ali15x3.c @@ -462,7 +462,6 @@ static u32 ali15x3_func(struct i2c_adapter *adapter) } static struct i2c_algorithm smbus_algorithm = { - .name = "Non-I2C SMBus adapter", .id = I2C_ALGO_SMBUS, .smbus_xfer = ali15x3_access, .functionality = ali15x3_func, diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c index 6347ebc6fb53..7cf33325ac14 100644 --- a/drivers/i2c/busses/i2c-amd756.c +++ b/drivers/i2c/busses/i2c-amd756.c @@ -295,7 +295,6 @@ static u32 amd756_func(struct i2c_adapter *adapter) } static struct i2c_algorithm smbus_algorithm = { - .name = "Non-I2C SMBus adapter", .id = I2C_ALGO_SMBUS, .smbus_xfer = amd756_access, .functionality = amd756_func, diff --git a/drivers/i2c/busses/i2c-amd8111.c b/drivers/i2c/busses/i2c-amd8111.c index d6644481d2a0..3b98d3b40042 100644 --- a/drivers/i2c/busses/i2c-amd8111.c +++ b/drivers/i2c/busses/i2c-amd8111.c @@ -323,7 +323,6 @@ static u32 amd8111_func(struct i2c_adapter *adapter) } static struct i2c_algorithm smbus_algorithm = { - .name = "Non-I2C SMBus 2.0 adapter", .id = I2C_ALGO_SMBUS, .smbus_xfer = amd8111_access, .functionality = amd8111_func, diff --git a/drivers/i2c/busses/i2c-au1550.c b/drivers/i2c/busses/i2c-au1550.c index a7ff112e49bf..41fff3531aee 100644 --- a/drivers/i2c/busses/i2c-au1550.c +++ b/drivers/i2c/busses/i2c-au1550.c @@ -283,7 +283,6 @@ au1550_func(struct i2c_adapter *adap) } static struct i2c_algorithm au1550_algo = { - .name = "Au1550 algorithm", .id = I2C_ALGO_AU1550, .master_xfer = au1550_xfer, .functionality = au1550_func, diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 1ab41313ce51..b916317b76a6 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -535,7 +535,6 @@ static u32 i801_func(struct i2c_adapter *adapter) } static struct i2c_algorithm smbus_algorithm = { - .name = "Non-I2C SMBus adapter", .id = I2C_ALGO_SMBUS, .smbus_xfer = i801_access, .functionality = i801_func, diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c index 93ca36dc777e..1a3366287087 100644 --- a/drivers/i2c/busses/i2c-ibm_iic.c +++ b/drivers/i2c/busses/i2c-ibm_iic.c @@ -627,7 +627,6 @@ static u32 iic_func(struct i2c_adapter *adap) } static struct i2c_algorithm iic_algo = { - .name = "IBM IIC algorithm", .id = I2C_ALGO_OCP, .master_xfer = iic_xfer, .functionality = iic_func diff --git a/drivers/i2c/busses/i2c-iop3xx.c b/drivers/i2c/busses/i2c-iop3xx.c index 6b682e903f09..c763039638d9 100644 --- a/drivers/i2c/busses/i2c-iop3xx.c +++ b/drivers/i2c/busses/i2c-iop3xx.c @@ -399,7 +399,6 @@ iop3xx_i2c_func(struct i2c_adapter *adap) } static struct i2c_algorithm iop3xx_i2c_algo = { - .name = "IOP3xx I2C algorithm", .id = I2C_ALGO_IOP3XX, .master_xfer = iop3xx_i2c_master_xfer, .algo_control = iop3xx_i2c_algo_control, diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c index a60f4801757e..bbfd4449b921 100644 --- a/drivers/i2c/busses/i2c-isa.c +++ b/drivers/i2c/busses/i2c-isa.c @@ -43,7 +43,6 @@ static u32 isa_func(struct i2c_adapter *adapter); /* This is the actual algorithm we define */ static struct i2c_algorithm isa_algorithm = { - .name = "ISA bus algorithm", .id = I2C_ALGO_ISA, .functionality = isa_func, }; diff --git a/drivers/i2c/busses/i2c-keywest.c b/drivers/i2c/busses/i2c-keywest.c index 94ae808314f7..2937f115abf1 100644 --- a/drivers/i2c/busses/i2c-keywest.c +++ b/drivers/i2c/busses/i2c-keywest.c @@ -498,7 +498,6 @@ keywest_func(struct i2c_adapter * adapter) /* For now, we only handle combined mode (smbus) */ static struct i2c_algorithm keywest_algorithm = { - .name = "Keywest i2c", .id = I2C_ALGO_SMBUS, .smbus_xfer = keywest_smbus_xfer, .master_xfer = keywest_xfer, diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c index 9ad3e9262e8a..ae988cc8cb48 100644 --- a/drivers/i2c/busses/i2c-mpc.c +++ b/drivers/i2c/busses/i2c-mpc.c @@ -272,7 +272,6 @@ static u32 mpc_functionality(struct i2c_adapter *adap) } static struct i2c_algorithm mpc_algo = { - .name = "MPC algorithm", .id = I2C_ALGO_MPC107, .master_xfer = mpc_xfer, .functionality = mpc_functionality, diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c index 5b852782d2f5..f5927c68784c 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c @@ -433,7 +433,6 @@ mv64xxx_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) } static struct i2c_algorithm mv64xxx_i2c_algo = { - .name = MV64XXX_I2C_CTLR_NAME " algorithm", .id = I2C_ALGO_MV64XXX, .master_xfer = mv64xxx_i2c_xfer, .functionality = mv64xxx_i2c_functionality, diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c index 1df601bb7f4f..44b6dfdd3832 100644 --- a/drivers/i2c/busses/i2c-nforce2.c +++ b/drivers/i2c/busses/i2c-nforce2.c @@ -110,7 +110,6 @@ static u32 nforce2_func(struct i2c_adapter *adapter); static struct i2c_algorithm smbus_algorithm = { - .name = "Non-I2C SMBus adapter", .id = I2C_ALGO_SMBUS, .smbus_xfer = nforce2_access, .functionality = nforce2_func, diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 6d34ee381ce1..976df581e853 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c @@ -399,7 +399,6 @@ static u32 piix4_func(struct i2c_adapter *adapter) } static struct i2c_algorithm smbus_algorithm = { - .name = "Non-I2C SMBus adapter", .id = I2C_ALGO_SMBUS, .smbus_xfer = piix4_access, .functionality = piix4_func, diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index a3b38257cc3d..73a092fb0e7e 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c @@ -568,7 +568,6 @@ static u32 s3c24xx_i2c_func(struct i2c_adapter *adap) /* i2c bus registration info */ static struct i2c_algorithm s3c24xx_i2c_algorithm = { - .name = "S3C2410-I2C-Algorithm", .master_xfer = s3c24xx_i2c_xfer, .functionality = s3c24xx_i2c_func, }; diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c index bbd5e4e52f09..0308ed87e2b9 100644 --- a/drivers/i2c/busses/i2c-sis5595.c +++ b/drivers/i2c/busses/i2c-sis5595.c @@ -357,7 +357,6 @@ static u32 sis5595_func(struct i2c_adapter *adapter) } static struct i2c_algorithm smbus_algorithm = { - .name = "Non-I2C SMBus adapter", .id = I2C_ALGO_SMBUS, .smbus_xfer = sis5595_access, .functionality = sis5595_func, diff --git a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c index f58455e7689e..8708f9044023 100644 --- a/drivers/i2c/busses/i2c-sis630.c +++ b/drivers/i2c/busses/i2c-sis630.c @@ -448,7 +448,6 @@ exit: static struct i2c_algorithm smbus_algorithm = { - .name = "Non-I2C SMBus adapter", .id = I2C_ALGO_SMBUS, .smbus_xfer = sis630_access, .functionality = sis630_func, diff --git a/drivers/i2c/busses/i2c-sis96x.c b/drivers/i2c/busses/i2c-sis96x.c index 6484792e23a1..6e7202ed3265 100644 --- a/drivers/i2c/busses/i2c-sis96x.c +++ b/drivers/i2c/busses/i2c-sis96x.c @@ -249,7 +249,6 @@ static u32 sis96x_func(struct i2c_adapter *adapter) } static struct i2c_algorithm smbus_algorithm = { - .name = "Non-I2C SMBus adapter", .id = I2C_ALGO_SMBUS, .smbus_xfer = sis96x_access, .functionality = sis96x_func, diff --git a/drivers/i2c/busses/i2c-stub.c b/drivers/i2c/busses/i2c-stub.c index 00d94e886955..d7203207754f 100644 --- a/drivers/i2c/busses/i2c-stub.c +++ b/drivers/i2c/busses/i2c-stub.c @@ -109,7 +109,6 @@ static u32 stub_func(struct i2c_adapter *adapter) } static struct i2c_algorithm smbus_algorithm = { - .name = "Non-I2C SMBus adapter", .id = I2C_ALGO_SMBUS, .functionality = stub_func, .smbus_xfer = stub_xfer, diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c index 6b5008005c6f..608ad525e7e1 100644 --- a/drivers/i2c/busses/i2c-viapro.c +++ b/drivers/i2c/busses/i2c-viapro.c @@ -286,7 +286,6 @@ static u32 vt596_func(struct i2c_adapter *adapter) } static struct i2c_algorithm smbus_algorithm = { - .name = "Non-I2C SMBus adapter", .id = I2C_ALGO_SMBUS, .smbus_xfer = vt596_access, .functionality = vt596_func, diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c index a18bdd9aa7ba..b695233d5455 100644 --- a/drivers/i2c/busses/scx200_acb.c +++ b/drivers/i2c/busses/scx200_acb.c @@ -395,7 +395,6 @@ static u32 scx200_acb_func(struct i2c_adapter *adapter) /* For now, we only handle combined mode (smbus) */ static struct i2c_algorithm scx200_acb_algorithm = { - .name = "NatSemi SCx200 ACCESS.bus", .id = I2C_ALGO_SMBUS, .smbus_xfer = scx200_acb_smbus_xfer, .functionality = scx200_acb_func, diff --git a/drivers/media/common/saa7146_i2c.c b/drivers/media/common/saa7146_i2c.c index 781f23f0cbcc..dceda86cd99d 100644 --- a/drivers/media/common/saa7146_i2c.c +++ b/drivers/media/common/saa7146_i2c.c @@ -387,7 +387,6 @@ static int saa7146_i2c_xfer(struct i2c_adapter* adapter, struct i2c_msg *msg, in /* exported algorithm data */ static struct i2c_algorithm saa7146_algo = { - .name = "saa7146 i2c algorithm", .id = I2C_ALGO_SAA7146, .master_xfer = saa7146_i2c_xfer, .functionality = saa7146_i2c_func, diff --git a/drivers/media/dvb/b2c2/flexcop-i2c.c b/drivers/media/dvb/b2c2/flexcop-i2c.c index be4266d4ae91..75f2c94f3190 100644 --- a/drivers/media/dvb/b2c2/flexcop-i2c.c +++ b/drivers/media/dvb/b2c2/flexcop-i2c.c @@ -172,7 +172,6 @@ static u32 flexcop_i2c_func(struct i2c_adapter *adapter) } static struct i2c_algorithm flexcop_algo = { - .name = "FlexCop I2C algorithm", .id = I2C_ALGO_BIT, .master_xfer = flexcop_master_xfer, .functionality = flexcop_i2c_func, diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c index c3e1b661aae6..36fe602f85b6 100644 --- a/drivers/media/dvb/dvb-usb/cxusb.c +++ b/drivers/media/dvb/dvb-usb/cxusb.c @@ -141,7 +141,6 @@ static u32 cxusb_i2c_func(struct i2c_adapter *adapter) } static struct i2c_algorithm cxusb_i2c_algo = { - .name = "Conexant USB I2C algorithm", .id = I2C_ALGO_BIT, .master_xfer = cxusb_i2c_xfer, .functionality = cxusb_i2c_func, diff --git a/drivers/media/dvb/dvb-usb/dibusb-common.c b/drivers/media/dvb/dvb-usb/dibusb-common.c index 9b9d6f8ee74e..c3a639520e8a 100644 --- a/drivers/media/dvb/dvb-usb/dibusb-common.c +++ b/drivers/media/dvb/dvb-usb/dibusb-common.c @@ -156,7 +156,6 @@ static u32 dibusb_i2c_func(struct i2c_adapter *adapter) } struct i2c_algorithm dibusb_i2c_algo = { - .name = "DiBcom USB I2C algorithm", .id = I2C_ALGO_BIT, .master_xfer = dibusb_i2c_xfer, .functionality = dibusb_i2c_func, diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c index 9a676afc1d6e..6e4e1e9158e3 100644 --- a/drivers/media/dvb/dvb-usb/digitv.c +++ b/drivers/media/dvb/dvb-usb/digitv.c @@ -77,7 +77,6 @@ static u32 digitv_i2c_func(struct i2c_adapter *adapter) } static struct i2c_algorithm digitv_i2c_algo = { - .name = "Nebula DigiTV USB I2C algorithm", .id = I2C_ALGO_BIT, .master_xfer = digitv_i2c_xfer, .functionality = digitv_i2c_func, diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c index aa43b5fcb8e7..c337ee546bac 100644 --- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c +++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c @@ -1472,7 +1472,6 @@ static void frontend_init(struct ttusb* ttusb) static struct i2c_algorithm ttusb_dec_algo = { - .name = "ttusb dec i2c algorithm", .id = I2C_ALGO_BIT, .master_xfer = master_xfer, .functionality = functionality, diff --git a/drivers/media/video/bttv-i2c.c b/drivers/media/video/bttv-i2c.c index 234a85563769..dbc96fce7501 100644 --- a/drivers/media/video/bttv-i2c.c +++ b/drivers/media/video/bttv-i2c.c @@ -270,7 +270,6 @@ static int bttv_i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int } static struct i2c_algorithm bttv_algo = { - .name = "bt878", .id = I2C_ALGO_BIT | I2C_HW_B_BT848 /* FIXME */, .master_xfer = bttv_i2c_xfer, .algo_control = algo_control, diff --git a/drivers/media/video/saa7134/saa7134-i2c.c b/drivers/media/video/saa7134/saa7134-i2c.c index 1203b93a572c..1a53c7eb104a 100644 --- a/drivers/media/video/saa7134/saa7134-i2c.c +++ b/drivers/media/video/saa7134/saa7134-i2c.c @@ -370,7 +370,6 @@ static int attach_inform(struct i2c_client *client) } static struct i2c_algorithm saa7134_algo = { - .name = "saa7134", .id = I2C_ALGO_SAA7134, .master_xfer = saa7134_i2c_xfer, .algo_control = algo_control, diff --git a/drivers/usb/media/w9968cf.c b/drivers/usb/media/w9968cf.c index ca9f3a30634f..ad1d6777e226 100644 --- a/drivers/usb/media/w9968cf.c +++ b/drivers/usb/media/w9968cf.c @@ -1573,7 +1573,6 @@ static int w9968cf_i2c_init(struct w9968cf_device* cam) int err = 0; static struct i2c_algorithm algo = { - .name = "W996[87]CF algorithm", .id = I2C_ALGO_SMBUS, .smbus_xfer = w9968cf_i2c_smbus_xfer, .algo_control = w9968cf_i2c_control, diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 3ad3969b6f0d..f04b1fc6a0fa 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -192,7 +192,6 @@ static inline char *i2c_clientname(struct i2c_client *c) * to name two of the most common. */ struct i2c_algorithm { - char name[32]; /* textual description */ unsigned int id; /* If an adapter algorithm can't do I2C-level access, set master_xfer -- cgit v1.2.2 From e51cc6b3a365e170d3ebe51c2308fdd42e027a46 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Thu, 11 Aug 2005 23:36:49 +0200 Subject: [PATCH] I2C: Kill i2c_algorithm.id (2/7) Use the adapter id rather than the algorithm id to detect the i2c-isa pseudo-adapter. This saves one level of dereferencing, and the algorithm ids will soon be gone anyway. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/busses/i2c-isa.c | 1 + include/linux/i2c-isa.h | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c index bbfd4449b921..dc666d7cf45a 100644 --- a/drivers/i2c/busses/i2c-isa.c +++ b/drivers/i2c/busses/i2c-isa.c @@ -50,6 +50,7 @@ static struct i2c_algorithm isa_algorithm = { /* There can only be one... */ static struct i2c_adapter isa_adapter = { .owner = THIS_MODULE, + .id = I2C_ALGO_ISA | I2C_HW_ISA, .class = I2C_CLASS_HWMON, .algo = &isa_algorithm, .name = "ISA main adapter", diff --git a/include/linux/i2c-isa.h b/include/linux/i2c-isa.h index db793b68356c..54c27e88d101 100644 --- a/include/linux/i2c-isa.h +++ b/include/linux/i2c-isa.h @@ -28,9 +28,9 @@ extern int i2c_isa_del_driver(struct i2c_driver *driver); /* Detect whether we are on the isa bus. This is only useful to hybrid (i2c+isa) drivers. */ -#define i2c_is_isa_client(clientptr) \ - ((clientptr)->adapter->algo->id == I2C_ALGO_ISA) #define i2c_is_isa_adapter(adapptr) \ - ((adapptr)->algo->id == I2C_ALGO_ISA) + ((adapptr)->id == (I2C_ALGO_ISA | I2C_HW_ISA)) +#define i2c_is_isa_client(clientptr) \ + i2c_is_isa_adapter((clientptr)->adapter) #endif /* _LINUX_I2C_ISA_H */ -- cgit v1.2.2 From 87c3d7a8bc0ff5c8d4481e509b407b6be1859925 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Thu, 11 Aug 2005 23:38:52 +0200 Subject: [PATCH] I2C: Kill i2c_algorithm.id (3/7) Don't rely on i2c_algorithm.id to alter the i2c adapter's id, use the I2C_ALGO_* value directly instead, because i2c_algorithm will soon have no id member no more. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/algos/i2c-algo-bit.c | 2 +- drivers/i2c/algos/i2c-algo-ite.c | 2 +- drivers/i2c/algos/i2c-algo-pca.c | 2 +- drivers/i2c/algos/i2c-algo-pcf.c | 2 +- drivers/i2c/algos/i2c-algo-sgi.c | 2 +- drivers/i2c/algos/i2c-algo-sibyte.c | 2 +- drivers/i2c/busses/i2c-ibm_iic.c | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c index 6e1e1601accb..b8767382bbac 100644 --- a/drivers/i2c/algos/i2c-algo-bit.c +++ b/drivers/i2c/algos/i2c-algo-bit.c @@ -541,7 +541,7 @@ int i2c_bit_add_bus(struct i2c_adapter *adap) /* register new adapter to i2c module... */ - adap->id |= i2c_bit_algo.id; + adap->id |= I2C_ALGO_BIT; adap->algo = &i2c_bit_algo; adap->timeout = 100; /* default values, should */ diff --git a/drivers/i2c/algos/i2c-algo-ite.c b/drivers/i2c/algos/i2c-algo-ite.c index a9c2b1115e07..6cb02f685db3 100644 --- a/drivers/i2c/algos/i2c-algo-ite.c +++ b/drivers/i2c/algos/i2c-algo-ite.c @@ -738,7 +738,7 @@ int i2c_iic_add_bus(struct i2c_adapter *adap) /* register new adapter to i2c module... */ - adap->id |= iic_algo.id; + adap->id |= I2C_ALGO_IIC; adap->algo = &iic_algo; adap->timeout = 100; /* default values, should */ diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c index 16157391cdf5..79b3c2edcf08 100644 --- a/drivers/i2c/algos/i2c-algo-pca.c +++ b/drivers/i2c/algos/i2c-algo-pca.c @@ -371,7 +371,7 @@ int i2c_pca_add_bus(struct i2c_adapter *adap) /* register new adapter to i2c module... */ - adap->id |= pca_algo.id; + adap->id |= I2C_ALGO_PCA; adap->algo = &pca_algo; adap->timeout = 100; /* default values, should */ diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c index eb3e9e39d75b..fbc0b87fe070 100644 --- a/drivers/i2c/algos/i2c-algo-pcf.c +++ b/drivers/i2c/algos/i2c-algo-pcf.c @@ -476,7 +476,7 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap) /* register new adapter to i2c module... */ - adap->id |= pcf_algo.id; + adap->id |= I2C_ALGO_PCF; adap->algo = &pcf_algo; adap->timeout = 100; /* default values, should */ diff --git a/drivers/i2c/algos/i2c-algo-sgi.c b/drivers/i2c/algos/i2c-algo-sgi.c index 55284c9e41dc..8863a671d977 100644 --- a/drivers/i2c/algos/i2c-algo-sgi.c +++ b/drivers/i2c/algos/i2c-algo-sgi.c @@ -168,7 +168,7 @@ static struct i2c_algorithm sgi_algo = { */ int i2c_sgi_add_bus(struct i2c_adapter *adap) { - adap->id |= sgi_algo.id; + adap->id |= I2C_ALGO_SGI; adap->algo = &sgi_algo; return i2c_add_adapter(adap); diff --git a/drivers/i2c/algos/i2c-algo-sibyte.c b/drivers/i2c/algos/i2c-algo-sibyte.c index 4ca3e69461bc..6cda0a6332d9 100644 --- a/drivers/i2c/algos/i2c-algo-sibyte.c +++ b/drivers/i2c/algos/i2c-algo-sibyte.c @@ -151,7 +151,7 @@ int i2c_sibyte_add_bus(struct i2c_adapter *i2c_adap, int speed) /* register new adapter to i2c module... */ - i2c_adap->id |= i2c_sibyte_algo.id; + i2c_adap->id |= I2C_ALGO_SIBYTE; i2c_adap->algo = &i2c_sibyte_algo; /* Set the frequency to 100 kHz */ diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c index 1a3366287087..ade9b14e6840 100644 --- a/drivers/i2c/busses/i2c-ibm_iic.c +++ b/drivers/i2c/busses/i2c-ibm_iic.c @@ -726,7 +726,7 @@ static int __devinit iic_probe(struct ocp_device *ocp){ adap = &dev->adap; strcpy(adap->name, "IBM IIC"); i2c_set_adapdata(adap, dev); - adap->id = I2C_HW_OCP | iic_algo.id; + adap->id = I2C_ALGO_OCP | I2C_HW_OCP; adap->algo = &iic_algo; adap->client_register = NULL; adap->client_unregister = NULL; -- cgit v1.2.2 From 1d8b9e1bad35fa3ea829990b9056c2a257d8fe79 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Thu, 11 Aug 2005 23:40:19 +0200 Subject: [PATCH] I2C: Kill i2c_algorithm.id (4/7) There are no more users of i2c_algorithm.id, so we can finally drop this structure member. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/algos/i2c-algo-bit.c | 1 - drivers/i2c/algos/i2c-algo-ite.c | 1 - drivers/i2c/algos/i2c-algo-pca.c | 1 - drivers/i2c/algos/i2c-algo-pcf.c | 1 - drivers/i2c/algos/i2c-algo-sgi.c | 1 - drivers/i2c/algos/i2c-algo-sibyte.c | 1 - drivers/i2c/busses/i2c-ali1535.c | 1 - drivers/i2c/busses/i2c-ali1563.c | 1 - drivers/i2c/busses/i2c-ali15x3.c | 1 - drivers/i2c/busses/i2c-amd756.c | 1 - drivers/i2c/busses/i2c-amd8111.c | 1 - drivers/i2c/busses/i2c-au1550.c | 1 - drivers/i2c/busses/i2c-i801.c | 1 - drivers/i2c/busses/i2c-ibm_iic.c | 1 - drivers/i2c/busses/i2c-iop3xx.c | 1 - drivers/i2c/busses/i2c-isa.c | 1 - drivers/i2c/busses/i2c-keywest.c | 1 - drivers/i2c/busses/i2c-mpc.c | 1 - drivers/i2c/busses/i2c-mv64xxx.c | 1 - drivers/i2c/busses/i2c-nforce2.c | 1 - drivers/i2c/busses/i2c-piix4.c | 1 - drivers/i2c/busses/i2c-sis5595.c | 1 - drivers/i2c/busses/i2c-sis630.c | 1 - drivers/i2c/busses/i2c-sis96x.c | 1 - drivers/i2c/busses/i2c-stub.c | 1 - drivers/i2c/busses/i2c-viapro.c | 1 - drivers/i2c/busses/scx200_acb.c | 1 - drivers/media/common/saa7146_i2c.c | 1 - drivers/media/dvb/b2c2/flexcop-i2c.c | 1 - drivers/media/dvb/dvb-usb/cxusb.c | 1 - drivers/media/dvb/dvb-usb/dibusb-common.c | 1 - drivers/media/dvb/dvb-usb/digitv.c | 1 - drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c | 1 - drivers/media/video/bttv-i2c.c | 1 - drivers/media/video/saa7134/saa7134-i2c.c | 1 - drivers/usb/media/w9968cf.c | 1 - include/linux/i2c.h | 2 -- 37 files changed, 38 deletions(-) diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c index b8767382bbac..6060b10ab0ce 100644 --- a/drivers/i2c/algos/i2c-algo-bit.c +++ b/drivers/i2c/algos/i2c-algo-bit.c @@ -519,7 +519,6 @@ static u32 bit_func(struct i2c_adapter *adap) /* -----exported algorithm data: ------------------------------------- */ static struct i2c_algorithm i2c_bit_algo = { - .id = I2C_ALGO_BIT, .master_xfer = bit_xfer, .functionality = bit_func, }; diff --git a/drivers/i2c/algos/i2c-algo-ite.c b/drivers/i2c/algos/i2c-algo-ite.c index 6cb02f685db3..b460e57216e1 100644 --- a/drivers/i2c/algos/i2c-algo-ite.c +++ b/drivers/i2c/algos/i2c-algo-ite.c @@ -713,7 +713,6 @@ static u32 iic_func(struct i2c_adapter *adap) /* -----exported algorithm data: ------------------------------------- */ static struct i2c_algorithm iic_algo = { - .id = I2C_ALGO_IIC, .master_xfer = iic_xfer, .algo_control = algo_control, /* ioctl */ .functionality = iic_func, diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c index 79b3c2edcf08..be2c8abc6682 100644 --- a/drivers/i2c/algos/i2c-algo-pca.c +++ b/drivers/i2c/algos/i2c-algo-pca.c @@ -356,7 +356,6 @@ static int pca_init(struct i2c_algo_pca_data *adap) } static struct i2c_algorithm pca_algo = { - .id = I2C_ALGO_PCA, .master_xfer = pca_xfer, .functionality = pca_func, }; diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c index fbc0b87fe070..95f023ad8c62 100644 --- a/drivers/i2c/algos/i2c-algo-pcf.c +++ b/drivers/i2c/algos/i2c-algo-pcf.c @@ -459,7 +459,6 @@ static u32 pcf_func(struct i2c_adapter *adap) /* -----exported algorithm data: ------------------------------------- */ static struct i2c_algorithm pcf_algo = { - .id = I2C_ALGO_PCF, .master_xfer = pcf_xfer, .functionality = pcf_func, }; diff --git a/drivers/i2c/algos/i2c-algo-sgi.c b/drivers/i2c/algos/i2c-algo-sgi.c index 8863a671d977..142505105d6f 100644 --- a/drivers/i2c/algos/i2c-algo-sgi.c +++ b/drivers/i2c/algos/i2c-algo-sgi.c @@ -158,7 +158,6 @@ static u32 sgi_func(struct i2c_adapter *adap) } static struct i2c_algorithm sgi_algo = { - .id = I2C_ALGO_SGI, .master_xfer = sgi_xfer, .functionality = sgi_func, }; diff --git a/drivers/i2c/algos/i2c-algo-sibyte.c b/drivers/i2c/algos/i2c-algo-sibyte.c index 6cda0a6332d9..c01108ae7b69 100644 --- a/drivers/i2c/algos/i2c-algo-sibyte.c +++ b/drivers/i2c/algos/i2c-algo-sibyte.c @@ -135,7 +135,6 @@ static u32 bit_func(struct i2c_adapter *adap) /* -----exported algorithm data: ------------------------------------- */ static struct i2c_algorithm i2c_sibyte_algo = { - .id = I2C_ALGO_SIBYTE, .smbus_xfer = smbus_xfer, .algo_control = algo_control, /* ioctl */ .functionality = bit_func, diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c index d7e05a1a5125..f021acd2674e 100644 --- a/drivers/i2c/busses/i2c-ali1535.c +++ b/drivers/i2c/busses/i2c-ali1535.c @@ -472,7 +472,6 @@ static u32 ali1535_func(struct i2c_adapter *adapter) } static struct i2c_algorithm smbus_algorithm = { - .id = I2C_ALGO_SMBUS, .smbus_xfer = ali1535_access, .functionality = ali1535_func, }; diff --git a/drivers/i2c/busses/i2c-ali1563.c b/drivers/i2c/busses/i2c-ali1563.c index 48f85e53d7d6..86947504aea1 100644 --- a/drivers/i2c/busses/i2c-ali1563.c +++ b/drivers/i2c/busses/i2c-ali1563.c @@ -366,7 +366,6 @@ static void ali1563_shutdown(struct pci_dev *dev) } static struct i2c_algorithm ali1563_algorithm = { - .id = I2C_ALGO_SMBUS, .smbus_xfer = ali1563_access, .functionality = ali1563_func, }; diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c index 523f0129e4cd..b3f50bff39a0 100644 --- a/drivers/i2c/busses/i2c-ali15x3.c +++ b/drivers/i2c/busses/i2c-ali15x3.c @@ -462,7 +462,6 @@ static u32 ali15x3_func(struct i2c_adapter *adapter) } static struct i2c_algorithm smbus_algorithm = { - .id = I2C_ALGO_SMBUS, .smbus_xfer = ali15x3_access, .functionality = ali15x3_func, }; diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c index 7cf33325ac14..6ad0603384b8 100644 --- a/drivers/i2c/busses/i2c-amd756.c +++ b/drivers/i2c/busses/i2c-amd756.c @@ -295,7 +295,6 @@ static u32 amd756_func(struct i2c_adapter *adapter) } static struct i2c_algorithm smbus_algorithm = { - .id = I2C_ALGO_SMBUS, .smbus_xfer = amd756_access, .functionality = amd756_func, }; diff --git a/drivers/i2c/busses/i2c-amd8111.c b/drivers/i2c/busses/i2c-amd8111.c index 3b98d3b40042..45ea24ba14d5 100644 --- a/drivers/i2c/busses/i2c-amd8111.c +++ b/drivers/i2c/busses/i2c-amd8111.c @@ -323,7 +323,6 @@ static u32 amd8111_func(struct i2c_adapter *adapter) } static struct i2c_algorithm smbus_algorithm = { - .id = I2C_ALGO_SMBUS, .smbus_xfer = amd8111_access, .functionality = amd8111_func, }; diff --git a/drivers/i2c/busses/i2c-au1550.c b/drivers/i2c/busses/i2c-au1550.c index 41fff3531aee..d06edce03bf4 100644 --- a/drivers/i2c/busses/i2c-au1550.c +++ b/drivers/i2c/busses/i2c-au1550.c @@ -283,7 +283,6 @@ au1550_func(struct i2c_adapter *adap) } static struct i2c_algorithm au1550_algo = { - .id = I2C_ALGO_AU1550, .master_xfer = au1550_xfer, .functionality = au1550_func, }; diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index b916317b76a6..709beab76609 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -535,7 +535,6 @@ static u32 i801_func(struct i2c_adapter *adapter) } static struct i2c_algorithm smbus_algorithm = { - .id = I2C_ALGO_SMBUS, .smbus_xfer = i801_access, .functionality = i801_func, }; diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c index ade9b14e6840..f42ab909eb78 100644 --- a/drivers/i2c/busses/i2c-ibm_iic.c +++ b/drivers/i2c/busses/i2c-ibm_iic.c @@ -627,7 +627,6 @@ static u32 iic_func(struct i2c_adapter *adap) } static struct i2c_algorithm iic_algo = { - .id = I2C_ALGO_OCP, .master_xfer = iic_xfer, .functionality = iic_func }; diff --git a/drivers/i2c/busses/i2c-iop3xx.c b/drivers/i2c/busses/i2c-iop3xx.c index c763039638d9..7bd9102db701 100644 --- a/drivers/i2c/busses/i2c-iop3xx.c +++ b/drivers/i2c/busses/i2c-iop3xx.c @@ -399,7 +399,6 @@ iop3xx_i2c_func(struct i2c_adapter *adap) } static struct i2c_algorithm iop3xx_i2c_algo = { - .id = I2C_ALGO_IOP3XX, .master_xfer = iop3xx_i2c_master_xfer, .algo_control = iop3xx_i2c_algo_control, .functionality = iop3xx_i2c_func, diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c index dc666d7cf45a..baae5dbc198e 100644 --- a/drivers/i2c/busses/i2c-isa.c +++ b/drivers/i2c/busses/i2c-isa.c @@ -43,7 +43,6 @@ static u32 isa_func(struct i2c_adapter *adapter); /* This is the actual algorithm we define */ static struct i2c_algorithm isa_algorithm = { - .id = I2C_ALGO_ISA, .functionality = isa_func, }; diff --git a/drivers/i2c/busses/i2c-keywest.c b/drivers/i2c/busses/i2c-keywest.c index 2937f115abf1..5254d2db282c 100644 --- a/drivers/i2c/busses/i2c-keywest.c +++ b/drivers/i2c/busses/i2c-keywest.c @@ -498,7 +498,6 @@ keywest_func(struct i2c_adapter * adapter) /* For now, we only handle combined mode (smbus) */ static struct i2c_algorithm keywest_algorithm = { - .id = I2C_ALGO_SMBUS, .smbus_xfer = keywest_smbus_xfer, .master_xfer = keywest_xfer, .functionality = keywest_func, diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c index ae988cc8cb48..70c5ffaee6a3 100644 --- a/drivers/i2c/busses/i2c-mpc.c +++ b/drivers/i2c/busses/i2c-mpc.c @@ -272,7 +272,6 @@ static u32 mpc_functionality(struct i2c_adapter *adap) } static struct i2c_algorithm mpc_algo = { - .id = I2C_ALGO_MPC107, .master_xfer = mpc_xfer, .functionality = mpc_functionality, }; diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c index f5927c68784c..6e5dd4949237 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c @@ -433,7 +433,6 @@ mv64xxx_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) } static struct i2c_algorithm mv64xxx_i2c_algo = { - .id = I2C_ALGO_MV64XXX, .master_xfer = mv64xxx_i2c_xfer, .functionality = mv64xxx_i2c_functionality, }; diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c index 44b6dfdd3832..e0b7a913431e 100644 --- a/drivers/i2c/busses/i2c-nforce2.c +++ b/drivers/i2c/busses/i2c-nforce2.c @@ -110,7 +110,6 @@ static u32 nforce2_func(struct i2c_adapter *adapter); static struct i2c_algorithm smbus_algorithm = { - .id = I2C_ALGO_SMBUS, .smbus_xfer = nforce2_access, .functionality = nforce2_func, }; diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 976df581e853..6d48a4da7bed 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c @@ -399,7 +399,6 @@ static u32 piix4_func(struct i2c_adapter *adapter) } static struct i2c_algorithm smbus_algorithm = { - .id = I2C_ALGO_SMBUS, .smbus_xfer = piix4_access, .functionality = piix4_func, }; diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c index 0308ed87e2b9..080318d6f54b 100644 --- a/drivers/i2c/busses/i2c-sis5595.c +++ b/drivers/i2c/busses/i2c-sis5595.c @@ -357,7 +357,6 @@ static u32 sis5595_func(struct i2c_adapter *adapter) } static struct i2c_algorithm smbus_algorithm = { - .id = I2C_ALGO_SMBUS, .smbus_xfer = sis5595_access, .functionality = sis5595_func, }; diff --git a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c index 8708f9044023..86f0f448fa0b 100644 --- a/drivers/i2c/busses/i2c-sis630.c +++ b/drivers/i2c/busses/i2c-sis630.c @@ -448,7 +448,6 @@ exit: static struct i2c_algorithm smbus_algorithm = { - .id = I2C_ALGO_SMBUS, .smbus_xfer = sis630_access, .functionality = sis630_func, }; diff --git a/drivers/i2c/busses/i2c-sis96x.c b/drivers/i2c/busses/i2c-sis96x.c index 6e7202ed3265..ead2ff3cf60e 100644 --- a/drivers/i2c/busses/i2c-sis96x.c +++ b/drivers/i2c/busses/i2c-sis96x.c @@ -249,7 +249,6 @@ static u32 sis96x_func(struct i2c_adapter *adapter) } static struct i2c_algorithm smbus_algorithm = { - .id = I2C_ALGO_SMBUS, .smbus_xfer = sis96x_access, .functionality = sis96x_func, }; diff --git a/drivers/i2c/busses/i2c-stub.c b/drivers/i2c/busses/i2c-stub.c index d7203207754f..73f481e93a36 100644 --- a/drivers/i2c/busses/i2c-stub.c +++ b/drivers/i2c/busses/i2c-stub.c @@ -109,7 +109,6 @@ static u32 stub_func(struct i2c_adapter *adapter) } static struct i2c_algorithm smbus_algorithm = { - .id = I2C_ALGO_SMBUS, .functionality = stub_func, .smbus_xfer = stub_xfer, }; diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c index 608ad525e7e1..99d209e0485a 100644 --- a/drivers/i2c/busses/i2c-viapro.c +++ b/drivers/i2c/busses/i2c-viapro.c @@ -286,7 +286,6 @@ static u32 vt596_func(struct i2c_adapter *adapter) } static struct i2c_algorithm smbus_algorithm = { - .id = I2C_ALGO_SMBUS, .smbus_xfer = vt596_access, .functionality = vt596_func, }; diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c index b695233d5455..46b9a7594c99 100644 --- a/drivers/i2c/busses/scx200_acb.c +++ b/drivers/i2c/busses/scx200_acb.c @@ -395,7 +395,6 @@ static u32 scx200_acb_func(struct i2c_adapter *adapter) /* For now, we only handle combined mode (smbus) */ static struct i2c_algorithm scx200_acb_algorithm = { - .id = I2C_ALGO_SMBUS, .smbus_xfer = scx200_acb_smbus_xfer, .functionality = scx200_acb_func, }; diff --git a/drivers/media/common/saa7146_i2c.c b/drivers/media/common/saa7146_i2c.c index dceda86cd99d..e413ee7f267a 100644 --- a/drivers/media/common/saa7146_i2c.c +++ b/drivers/media/common/saa7146_i2c.c @@ -387,7 +387,6 @@ static int saa7146_i2c_xfer(struct i2c_adapter* adapter, struct i2c_msg *msg, in /* exported algorithm data */ static struct i2c_algorithm saa7146_algo = { - .id = I2C_ALGO_SAA7146, .master_xfer = saa7146_i2c_xfer, .functionality = saa7146_i2c_func, }; diff --git a/drivers/media/dvb/b2c2/flexcop-i2c.c b/drivers/media/dvb/b2c2/flexcop-i2c.c index 75f2c94f3190..848910ff3c9c 100644 --- a/drivers/media/dvb/b2c2/flexcop-i2c.c +++ b/drivers/media/dvb/b2c2/flexcop-i2c.c @@ -172,7 +172,6 @@ static u32 flexcop_i2c_func(struct i2c_adapter *adapter) } static struct i2c_algorithm flexcop_algo = { - .id = I2C_ALGO_BIT, .master_xfer = flexcop_master_xfer, .functionality = flexcop_i2c_func, }; diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c index 36fe602f85b6..9e96a188f1e9 100644 --- a/drivers/media/dvb/dvb-usb/cxusb.c +++ b/drivers/media/dvb/dvb-usb/cxusb.c @@ -141,7 +141,6 @@ static u32 cxusb_i2c_func(struct i2c_adapter *adapter) } static struct i2c_algorithm cxusb_i2c_algo = { - .id = I2C_ALGO_BIT, .master_xfer = cxusb_i2c_xfer, .functionality = cxusb_i2c_func, }; diff --git a/drivers/media/dvb/dvb-usb/dibusb-common.c b/drivers/media/dvb/dvb-usb/dibusb-common.c index c3a639520e8a..00b946419b40 100644 --- a/drivers/media/dvb/dvb-usb/dibusb-common.c +++ b/drivers/media/dvb/dvb-usb/dibusb-common.c @@ -156,7 +156,6 @@ static u32 dibusb_i2c_func(struct i2c_adapter *adapter) } struct i2c_algorithm dibusb_i2c_algo = { - .id = I2C_ALGO_BIT, .master_xfer = dibusb_i2c_xfer, .functionality = dibusb_i2c_func, }; diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c index 6e4e1e9158e3..f70e0be0920a 100644 --- a/drivers/media/dvb/dvb-usb/digitv.c +++ b/drivers/media/dvb/dvb-usb/digitv.c @@ -77,7 +77,6 @@ static u32 digitv_i2c_func(struct i2c_adapter *adapter) } static struct i2c_algorithm digitv_i2c_algo = { - .id = I2C_ALGO_BIT, .master_xfer = digitv_i2c_xfer, .functionality = digitv_i2c_func, }; diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c index c337ee546bac..11afec52f31f 100644 --- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c +++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c @@ -1472,7 +1472,6 @@ static void frontend_init(struct ttusb* ttusb) static struct i2c_algorithm ttusb_dec_algo = { - .id = I2C_ALGO_BIT, .master_xfer = master_xfer, .functionality = functionality, }; diff --git a/drivers/media/video/bttv-i2c.c b/drivers/media/video/bttv-i2c.c index dbc96fce7501..82beb5a8a59c 100644 --- a/drivers/media/video/bttv-i2c.c +++ b/drivers/media/video/bttv-i2c.c @@ -270,7 +270,6 @@ static int bttv_i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int } static struct i2c_algorithm bttv_algo = { - .id = I2C_ALGO_BIT | I2C_HW_B_BT848 /* FIXME */, .master_xfer = bttv_i2c_xfer, .algo_control = algo_control, .functionality = functionality, diff --git a/drivers/media/video/saa7134/saa7134-i2c.c b/drivers/media/video/saa7134/saa7134-i2c.c index 1a53c7eb104a..0bb1073d94bd 100644 --- a/drivers/media/video/saa7134/saa7134-i2c.c +++ b/drivers/media/video/saa7134/saa7134-i2c.c @@ -370,7 +370,6 @@ static int attach_inform(struct i2c_client *client) } static struct i2c_algorithm saa7134_algo = { - .id = I2C_ALGO_SAA7134, .master_xfer = saa7134_i2c_xfer, .algo_control = algo_control, .functionality = functionality, diff --git a/drivers/usb/media/w9968cf.c b/drivers/usb/media/w9968cf.c index ad1d6777e226..908cfdf17039 100644 --- a/drivers/usb/media/w9968cf.c +++ b/drivers/usb/media/w9968cf.c @@ -1573,7 +1573,6 @@ static int w9968cf_i2c_init(struct w9968cf_device* cam) int err = 0; static struct i2c_algorithm algo = { - .id = I2C_ALGO_SMBUS, .smbus_xfer = w9968cf_i2c_smbus_xfer, .algo_control = w9968cf_i2c_control, .functionality = w9968cf_i2c_func, diff --git a/include/linux/i2c.h b/include/linux/i2c.h index f04b1fc6a0fa..af4983b488b6 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -192,8 +192,6 @@ static inline char *i2c_clientname(struct i2c_client *c) * to name two of the most common. */ struct i2c_algorithm { - unsigned int id; - /* If an adapter algorithm can't do I2C-level access, set master_xfer to NULL. If an adapter algorithm can do SMBus access, set smbus_xfer. If set to NULL, the SMBus protocol is simulated -- cgit v1.2.2 From c7a46533ff7ef9e1c51bae6e54208527c5275b24 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Thu, 11 Aug 2005 23:41:56 +0200 Subject: [PATCH] I2C: Kill i2c_algorithm.id (5/7) Merge the algorithm id part (16 upper bits) of the i2c adapters ids into the definition of the adapters ids directly. After that, we don't need to OR both ids together for each i2c_adapter structure. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/algos/i2c-algo-bit.c | 2 - drivers/i2c/algos/i2c-algo-ite.c | 2 - drivers/i2c/algos/i2c-algo-pca.c | 2 - drivers/i2c/algos/i2c-algo-pcf.c | 2 - drivers/i2c/algos/i2c-algo-sgi.c | 1 - drivers/i2c/algos/i2c-algo-sibyte.c | 2 - drivers/i2c/busses/i2c-ibm_iic.c | 2 +- drivers/i2c/busses/i2c-isa.c | 2 +- drivers/i2c/busses/i2c-mpc.c | 2 +- drivers/i2c/busses/i2c-mv64xxx.c | 2 +- drivers/media/video/bt832.c | 2 +- drivers/media/video/bttv-i2c.c | 2 +- drivers/media/video/ir-kbd-i2c.c | 2 +- drivers/media/video/ovcamchip/ov6x20.c | 6 +- drivers/media/video/ovcamchip/ov6x30.c | 4 +- drivers/media/video/ovcamchip/ovcamchip_core.c | 8 +- drivers/media/video/tda7432.c | 2 +- drivers/media/video/tda9875.c | 2 +- drivers/media/video/tda9887.c | 4 +- drivers/media/video/tuner-3036.c | 2 +- drivers/media/video/tvaudio.c | 6 +- drivers/media/video/tveeprom.c | 2 +- drivers/media/video/tvmixer.c | 6 +- drivers/usb/media/w9968cf.c | 2 +- drivers/video/matrox/matroxfb_maven.c | 2 +- include/linux/i2c-id.h | 128 ++++++++++++------------- include/linux/i2c-isa.h | 2 +- 27 files changed, 95 insertions(+), 106 deletions(-) diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c index 6060b10ab0ce..df05df1a0ef6 100644 --- a/drivers/i2c/algos/i2c-algo-bit.c +++ b/drivers/i2c/algos/i2c-algo-bit.c @@ -539,8 +539,6 @@ int i2c_bit_add_bus(struct i2c_adapter *adap) DEB2(dev_dbg(&adap->dev, "hw routines registered.\n")); /* register new adapter to i2c module... */ - - adap->id |= I2C_ALGO_BIT; adap->algo = &i2c_bit_algo; adap->timeout = 100; /* default values, should */ diff --git a/drivers/i2c/algos/i2c-algo-ite.c b/drivers/i2c/algos/i2c-algo-ite.c index b460e57216e1..2db7bfc85225 100644 --- a/drivers/i2c/algos/i2c-algo-ite.c +++ b/drivers/i2c/algos/i2c-algo-ite.c @@ -736,8 +736,6 @@ int i2c_iic_add_bus(struct i2c_adapter *adap) adap->name)); /* register new adapter to i2c module... */ - - adap->id |= I2C_ALGO_IIC; adap->algo = &iic_algo; adap->timeout = 100; /* default values, should */ diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c index be2c8abc6682..beb10edfe9c1 100644 --- a/drivers/i2c/algos/i2c-algo-pca.c +++ b/drivers/i2c/algos/i2c-algo-pca.c @@ -369,8 +369,6 @@ int i2c_pca_add_bus(struct i2c_adapter *adap) int rval; /* register new adapter to i2c module... */ - - adap->id |= I2C_ALGO_PCA; adap->algo = &pca_algo; adap->timeout = 100; /* default values, should */ diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c index 95f023ad8c62..6e498df1f717 100644 --- a/drivers/i2c/algos/i2c-algo-pcf.c +++ b/drivers/i2c/algos/i2c-algo-pcf.c @@ -474,8 +474,6 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap) DEB2(dev_dbg(&adap->dev, "hw routines registered.\n")); /* register new adapter to i2c module... */ - - adap->id |= I2C_ALGO_PCF; adap->algo = &pcf_algo; adap->timeout = 100; /* default values, should */ diff --git a/drivers/i2c/algos/i2c-algo-sgi.c b/drivers/i2c/algos/i2c-algo-sgi.c index 142505105d6f..2f8df81317ff 100644 --- a/drivers/i2c/algos/i2c-algo-sgi.c +++ b/drivers/i2c/algos/i2c-algo-sgi.c @@ -167,7 +167,6 @@ static struct i2c_algorithm sgi_algo = { */ int i2c_sgi_add_bus(struct i2c_adapter *adap) { - adap->id |= I2C_ALGO_SGI; adap->algo = &sgi_algo; return i2c_add_adapter(adap); diff --git a/drivers/i2c/algos/i2c-algo-sibyte.c b/drivers/i2c/algos/i2c-algo-sibyte.c index c01108ae7b69..8ed5ad12552f 100644 --- a/drivers/i2c/algos/i2c-algo-sibyte.c +++ b/drivers/i2c/algos/i2c-algo-sibyte.c @@ -149,8 +149,6 @@ int i2c_sibyte_add_bus(struct i2c_adapter *i2c_adap, int speed) struct i2c_algo_sibyte_data *adap = i2c_adap->algo_data; /* register new adapter to i2c module... */ - - i2c_adap->id |= I2C_ALGO_SIBYTE; i2c_adap->algo = &i2c_sibyte_algo; /* Set the frequency to 100 kHz */ diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c index f42ab909eb78..a3ed9590f028 100644 --- a/drivers/i2c/busses/i2c-ibm_iic.c +++ b/drivers/i2c/busses/i2c-ibm_iic.c @@ -725,7 +725,7 @@ static int __devinit iic_probe(struct ocp_device *ocp){ adap = &dev->adap; strcpy(adap->name, "IBM IIC"); i2c_set_adapdata(adap, dev); - adap->id = I2C_ALGO_OCP | I2C_HW_OCP; + adap->id = I2C_HW_OCP; adap->algo = &iic_algo; adap->client_register = NULL; adap->client_unregister = NULL; diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c index baae5dbc198e..bdc6806dafae 100644 --- a/drivers/i2c/busses/i2c-isa.c +++ b/drivers/i2c/busses/i2c-isa.c @@ -49,7 +49,7 @@ static struct i2c_algorithm isa_algorithm = { /* There can only be one... */ static struct i2c_adapter isa_adapter = { .owner = THIS_MODULE, - .id = I2C_ALGO_ISA | I2C_HW_ISA, + .id = I2C_HW_ISA, .class = I2C_CLASS_HWMON, .algo = &isa_algorithm, .name = "ISA main adapter", diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c index 70c5ffaee6a3..f065583ddcf1 100644 --- a/drivers/i2c/busses/i2c-mpc.c +++ b/drivers/i2c/busses/i2c-mpc.c @@ -279,7 +279,7 @@ static struct i2c_algorithm mpc_algo = { static struct i2c_adapter mpc_ops = { .owner = THIS_MODULE, .name = "MPC adapter", - .id = I2C_ALGO_MPC107 | I2C_HW_MPC107, + .id = I2C_HW_MPC107, .algo = &mpc_algo, .class = I2C_CLASS_HWMON, .timeout = 1, diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c index 6e5dd4949237..eb6cc0869938 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c @@ -521,7 +521,7 @@ mv64xxx_i2c_probe(struct device *dev) drv_data->freq_m = pdata->freq_m; drv_data->freq_n = pdata->freq_n; drv_data->irq = platform_get_irq(pd, 0); - drv_data->adapter.id = I2C_ALGO_MV64XXX | I2C_HW_MV64XXX; + drv_data->adapter.id = I2C_HW_MV64XXX; drv_data->adapter.algo = &mv64xxx_i2c_algo; drv_data->adapter.owner = THIS_MODULE; drv_data->adapter.class = I2C_CLASS_HWMON; diff --git a/drivers/media/video/bt832.c b/drivers/media/video/bt832.c index a070417e65e6..67ffed8a7fea 100644 --- a/drivers/media/video/bt832.c +++ b/drivers/media/video/bt832.c @@ -188,7 +188,7 @@ static int bt832_probe(struct i2c_adapter *adap) if (adap->class & I2C_CLASS_TV_ANALOG) return i2c_probe(adap, &addr_data, bt832_attach); #else - if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_BT848)) + if (adap->id == I2C_HW_B_BT848) return i2c_probe(adap, &addr_data, bt832_attach); #endif return 0; diff --git a/drivers/media/video/bttv-i2c.c b/drivers/media/video/bttv-i2c.c index 82beb5a8a59c..1db95f75ac68 100644 --- a/drivers/media/video/bttv-i2c.c +++ b/drivers/media/video/bttv-i2c.c @@ -281,7 +281,7 @@ static struct i2c_adapter bttv_i2c_adap_hw_template = { .class = I2C_CLASS_TV_ANALOG, #endif I2C_DEVNAME("bt878"), - .id = I2C_ALGO_BIT | I2C_HW_B_BT848 /* FIXME */, + .id = I2C_HW_B_BT848 /* FIXME */, .algo = &bttv_algo, .client_register = attach_inform, }; diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c index 9fc5055e001c..c2f32d522668 100644 --- a/drivers/media/video/ir-kbd-i2c.c +++ b/drivers/media/video/ir-kbd-i2c.c @@ -429,7 +429,7 @@ static int ir_probe(struct i2c_adapter *adap) struct i2c_client c; char buf; int i,rc; switch (adap->id) { - case I2C_ALGO_BIT | I2C_HW_B_BT848: + case I2C_HW_B_BT848: probe = probe_bttv; break; case I2C_ALGO_SAA7134: diff --git a/drivers/media/video/ovcamchip/ov6x20.c b/drivers/media/video/ovcamchip/ov6x20.c index 3433619ad93f..b3f4d266cede 100644 --- a/drivers/media/video/ovcamchip/ov6x20.c +++ b/drivers/media/video/ovcamchip/ov6x20.c @@ -164,10 +164,10 @@ static int ov6x20_init(struct i2c_client *c) DDEBUG(4, &c->dev, "entered"); switch (c->adapter->id) { - case I2C_ALGO_SMBUS | I2C_HW_SMBUS_OV511: + case I2C_HW_SMBUS_OV511: rc = ov_write_regvals(c, regvals_init_6x20_511); break; - case I2C_ALGO_SMBUS | I2C_HW_SMBUS_OV518: + case I2C_HW_SMBUS_OV518: rc = ov_write_regvals(c, regvals_init_6x20_518); break; default: @@ -338,7 +338,7 @@ static int ov6x20_mode_init(struct i2c_client *c, struct ovcamchip_window *win) /******** Palette-specific regs ********/ /* OV518 needs 8 bit multiplexed in color mode, and 16 bit in B&W */ - if (c->adapter->id == (I2C_ALGO_SMBUS | I2C_HW_SMBUS_OV518)) { + if (c->adapter->id == I2C_HW_SMBUS_OV518) { if (win->format == VIDEO_PALETTE_GREY) ov_write_mask(c, 0x13, 0x00, 0x20); else diff --git a/drivers/media/video/ovcamchip/ov6x30.c b/drivers/media/video/ovcamchip/ov6x30.c index 44a842379b45..6eab458ab792 100644 --- a/drivers/media/video/ovcamchip/ov6x30.c +++ b/drivers/media/video/ovcamchip/ov6x30.c @@ -301,7 +301,7 @@ static int ov6x30_mode_init(struct i2c_client *c, struct ovcamchip_window *win) /******** Palette-specific regs ********/ if (win->format == VIDEO_PALETTE_GREY) { - if (c->adapter->id == (I2C_ALGO_SMBUS | I2C_HW_SMBUS_OV518)) { + if (c->adapter->id == I2C_HW_SMBUS_OV518) { /* Do nothing - we're already in 8-bit mode */ } else { ov_write_mask(c, 0x13, 0x20, 0x20); @@ -313,7 +313,7 @@ static int ov6x30_mode_init(struct i2c_client *c, struct ovcamchip_window *win) * Therefore, the OV6630 needs to be in 8-bit multiplexed * output mode */ - if (c->adapter->id == (I2C_ALGO_SMBUS | I2C_HW_SMBUS_OV518)) { + if (c->adapter->id == I2C_HW_SMBUS_OV518) { /* Do nothing - we want to stay in 8-bit mode */ /* Warning: Messing with reg 0x13 breaks OV518 color */ } else { diff --git a/drivers/media/video/ovcamchip/ovcamchip_core.c b/drivers/media/video/ovcamchip/ovcamchip_core.c index 54dd5612d3b8..b98c64ab7c58 100644 --- a/drivers/media/video/ovcamchip/ovcamchip_core.c +++ b/drivers/media/video/ovcamchip/ovcamchip_core.c @@ -296,10 +296,10 @@ static int ovcamchip_attach(struct i2c_adapter *adap) * attach to adapters that are known to contain OV camera chips. */ switch (adap->id) { - case (I2C_ALGO_SMBUS | I2C_HW_SMBUS_OV511): - case (I2C_ALGO_SMBUS | I2C_HW_SMBUS_OV518): - case (I2C_ALGO_SMBUS | I2C_HW_SMBUS_OVFX2): - case (I2C_ALGO_SMBUS | I2C_HW_SMBUS_W9968CF): + case I2C_HW_SMBUS_OV511: + case I2C_HW_SMBUS_OV518: + case I2C_HW_SMBUS_OVFX2: + case I2C_HW_SMBUS_W9968CF: PDEBUG(1, "Adapter ID 0x%06x accepted", adap->id); break; default: diff --git a/drivers/media/video/tda7432.c b/drivers/media/video/tda7432.c index 7cb1fb3e66f9..bc6b6c0cea6d 100644 --- a/drivers/media/video/tda7432.c +++ b/drivers/media/video/tda7432.c @@ -328,7 +328,7 @@ static int tda7432_probe(struct i2c_adapter *adap) if (adap->class & I2C_CLASS_TV_ANALOG) return i2c_probe(adap, &addr_data, tda7432_attach); #else - if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_BT848)) + if (adap->id == I2C_HW_B_BT848) return i2c_probe(adap, &addr_data, tda7432_attach); #endif return 0; diff --git a/drivers/media/video/tda9875.c b/drivers/media/video/tda9875.c index 566e1a5ca135..3eaf2e1211e5 100644 --- a/drivers/media/video/tda9875.c +++ b/drivers/media/video/tda9875.c @@ -262,7 +262,7 @@ static int tda9875_probe(struct i2c_adapter *adap) if (adap->class & I2C_CLASS_TV_ANALOG) return i2c_probe(adap, &addr_data, tda9875_attach); #else - if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_BT848)) + if (adap->id == I2C_HW_B_BT848) return i2c_probe(adap, &addr_data, tda9875_attach); #endif return 0; diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c index a28a395d6dfe..f1b1bb5acf70 100644 --- a/drivers/media/video/tda9887.c +++ b/drivers/media/video/tda9887.c @@ -618,8 +618,8 @@ static int tda9887_probe(struct i2c_adapter *adap) return i2c_probe(adap, &addr_data, tda9887_attach); #else switch (adap->id) { - case I2C_ALGO_BIT | I2C_HW_B_BT848: - case I2C_ALGO_BIT | I2C_HW_B_RIVA: + case I2C_HW_B_BT848: + case I2C_HW_B_RIVA: case I2C_ALGO_SAA7134: return i2c_probe(adap, &addr_data, tda9887_attach); break; diff --git a/drivers/media/video/tuner-3036.c b/drivers/media/video/tuner-3036.c index 103def1abe3c..79203595b9c1 100644 --- a/drivers/media/video/tuner-3036.c +++ b/drivers/media/video/tuner-3036.c @@ -165,7 +165,7 @@ static int tuner_probe(struct i2c_adapter *adap) { this_adap = 0; - if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_LP)) + if (adap->id == I2C_HW_B_LP) return i2c_probe(adap, &addr_data, tuner_attach); return 0; } diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c index f42a1efa8fcf..9420b5f52915 100644 --- a/drivers/media/video/tvaudio.c +++ b/drivers/media/video/tvaudio.c @@ -1098,7 +1098,7 @@ static int tda8425_initialize(struct CHIPSTATE *chip) /* extern */ TDA8425_S1_CH1, /* intern */ TDA8425_S1_OFF, /* off */ TDA8425_S1_OFF, /* on */ TDA8425_S1_CH2}; - if (chip->c.adapter->id == (I2C_ALGO_BIT | I2C_HW_B_RIVA)) { + if (chip->c.adapter->id == I2C_HW_B_RIVA) { memcpy (desc->inputmap, inputmap, sizeof (inputmap)); } return 0; @@ -1555,8 +1555,8 @@ static int chip_probe(struct i2c_adapter *adap) return i2c_probe(adap, &addr_data, chip_attach); #else switch (adap->id) { - case I2C_ALGO_BIT | I2C_HW_B_BT848: - case I2C_ALGO_BIT | I2C_HW_B_RIVA: + case I2C_HW_B_BT848: + case I2C_HW_B_RIVA: case I2C_ALGO_SAA7134: return i2c_probe(adap, &addr_data, chip_attach); } diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c index 127ec38ebd60..3c3356a01cc6 100644 --- a/drivers/media/video/tveeprom.c +++ b/drivers/media/video/tveeprom.c @@ -534,7 +534,7 @@ static int tveeprom_attach_adapter (struct i2c_adapter *adapter) { dprintk(1,"%s: id 0x%x\n",__FUNCTION__,adapter->id); - if (adapter->id != (I2C_ALGO_BIT | I2C_HW_B_BT848)) + if (adapter->id != I2C_HW_B_BT848) return 0; return i2c_probe(adapter, &addr_data, tveeprom_detect_client); } diff --git a/drivers/media/video/tvmixer.c b/drivers/media/video/tvmixer.c index 51b99cdbf29e..f0635b19de30 100644 --- a/drivers/media/video/tvmixer.c +++ b/drivers/media/video/tvmixer.c @@ -276,9 +276,9 @@ static int tvmixer_clients(struct i2c_client *client) #else /* TV card ??? */ switch (client->adapter->id) { - case I2C_ALGO_BIT | I2C_HW_SMBUS_VOODOO3: - case I2C_ALGO_BIT | I2C_HW_B_BT848: - case I2C_ALGO_BIT | I2C_HW_B_RIVA: + case I2C_HW_SMBUS_VOODOO3: + case I2C_HW_B_BT848: + case I2C_HW_B_RIVA: /* ok, have a look ... */ break; default: diff --git a/drivers/usb/media/w9968cf.c b/drivers/usb/media/w9968cf.c index 908cfdf17039..83e8dd627154 100644 --- a/drivers/usb/media/w9968cf.c +++ b/drivers/usb/media/w9968cf.c @@ -1579,7 +1579,7 @@ static int w9968cf_i2c_init(struct w9968cf_device* cam) }; static struct i2c_adapter adap = { - .id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_W9968CF, + .id = I2C_HW_SMBUS_W9968CF, .class = I2C_CLASS_CAM_DIGITAL, .owner = THIS_MODULE, .client_register = w9968cf_i2c_attach_inform, diff --git a/drivers/video/matrox/matroxfb_maven.c b/drivers/video/matrox/matroxfb_maven.c index 67f85344f0cc..ad60bbb16cdf 100644 --- a/drivers/video/matrox/matroxfb_maven.c +++ b/drivers/video/matrox/matroxfb_maven.c @@ -1271,7 +1271,7 @@ ERROR0:; } static int maven_attach_adapter(struct i2c_adapter* adapter) { - if (adapter->id == (I2C_ALGO_BIT | I2C_HW_B_G400)) + if (adapter->id == I2C_HW_B_G400) return i2c_probe(adapter, &addr_data, &maven_detect_client); return 0; } diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h index 33f08258f22b..5b72f664cc21 100644 --- a/include/linux/i2c-id.h +++ b/include/linux/i2c-id.h @@ -218,103 +218,103 @@ */ /* --- Bit algorithm adapters */ -#define I2C_HW_B_LP 0x00 /* Parallel port Philips style adapter */ -#define I2C_HW_B_LPC 0x01 /* Parallel port, over control reg. */ -#define I2C_HW_B_SER 0x02 /* Serial line interface */ -#define I2C_HW_B_ELV 0x03 /* ELV Card */ -#define I2C_HW_B_VELLE 0x04 /* Vellemann K8000 */ -#define I2C_HW_B_BT848 0x05 /* BT848 video boards */ -#define I2C_HW_B_WNV 0x06 /* Winnov Videums */ -#define I2C_HW_B_VIA 0x07 /* Via vt82c586b */ -#define I2C_HW_B_HYDRA 0x08 /* Apple Hydra Mac I/O */ -#define I2C_HW_B_G400 0x09 /* Matrox G400 */ -#define I2C_HW_B_I810 0x0a /* Intel I810 */ -#define I2C_HW_B_VOO 0x0b /* 3dfx Voodoo 3 / Banshee */ -#define I2C_HW_B_PPORT 0x0c /* Primitive parallel port adapter */ -#define I2C_HW_B_SAVG 0x0d /* Savage 4 */ -#define I2C_HW_B_SCX200 0x0e /* Nat'l Semi SCx200 I2C */ -#define I2C_HW_B_RIVA 0x10 /* Riva based graphics cards */ -#define I2C_HW_B_IOC 0x11 /* IOC bit-wiggling */ -#define I2C_HW_B_TSUNA 0x12 /* DEC Tsunami chipset */ -#define I2C_HW_B_FRODO 0x13 /* 2d3D, Inc. SA-1110 Development Board */ -#define I2C_HW_B_OMAHA 0x14 /* Omaha I2C interface (ARM) */ -#define I2C_HW_B_GUIDE 0x15 /* Guide bit-basher */ -#define I2C_HW_B_IXP2000 0x16 /* GPIO on IXP2000 systems */ -#define I2C_HW_B_IXP4XX 0x17 /* GPIO on IXP4XX systems */ -#define I2C_HW_B_S3VIA 0x18 /* S3Via ProSavage adapter */ -#define I2C_HW_B_ZR36067 0x19 /* Zoran-36057/36067 based boards */ -#define I2C_HW_B_PCILYNX 0x1a /* TI PCILynx I2C adapter */ -#define I2C_HW_B_CX2388x 0x1b /* connexant 2388x based tv cards */ +#define I2C_HW_B_LP 0x010000 /* Parallel port Philips style */ +#define I2C_HW_B_LPC 0x010001 /* Parallel port control reg. */ +#define I2C_HW_B_SER 0x010002 /* Serial line interface */ +#define I2C_HW_B_ELV 0x010003 /* ELV Card */ +#define I2C_HW_B_VELLE 0x010004 /* Vellemann K8000 */ +#define I2C_HW_B_BT848 0x010005 /* BT848 video boards */ +#define I2C_HW_B_WNV 0x010006 /* Winnov Videums */ +#define I2C_HW_B_VIA 0x010007 /* Via vt82c586b */ +#define I2C_HW_B_HYDRA 0x010008 /* Apple Hydra Mac I/O */ +#define I2C_HW_B_G400 0x010009 /* Matrox G400 */ +#define I2C_HW_B_I810 0x01000a /* Intel I810 */ +#define I2C_HW_B_VOO 0x01000b /* 3dfx Voodoo 3 / Banshee */ +#define I2C_HW_B_PPORT 0x01000c /* Primitive parallel port adapter */ +#define I2C_HW_B_SAVG 0x01000d /* Savage 4 */ +#define I2C_HW_B_SCX200 0x01000e /* Nat'l Semi SCx200 I2C */ +#define I2C_HW_B_RIVA 0x010010 /* Riva based graphics cards */ +#define I2C_HW_B_IOC 0x010011 /* IOC bit-wiggling */ +#define I2C_HW_B_TSUNA 0x010012 /* DEC Tsunami chipset */ +#define I2C_HW_B_FRODO 0x010013 /* 2d3D SA-1110 Development Board */ +#define I2C_HW_B_OMAHA 0x010014 /* Omaha I2C interface (ARM) */ +#define I2C_HW_B_GUIDE 0x010015 /* Guide bit-basher */ +#define I2C_HW_B_IXP2000 0x010016 /* GPIO on IXP2000 systems */ +#define I2C_HW_B_IXP4XX 0x010017 /* GPIO on IXP4XX systems */ +#define I2C_HW_B_S3VIA 0x010018 /* S3Via ProSavage adapter */ +#define I2C_HW_B_ZR36067 0x010019 /* Zoran-36057/36067 based boards */ +#define I2C_HW_B_PCILYNX 0x01001a /* TI PCILynx I2C adapter */ +#define I2C_HW_B_CX2388x 0x01001b /* connexant 2388x based tv cards */ /* --- PCF 8584 based algorithms */ -#define I2C_HW_P_LP 0x00 /* Parallel port interface */ -#define I2C_HW_P_ISA 0x01 /* generic ISA Bus inteface card */ -#define I2C_HW_P_ELEK 0x02 /* Elektor ISA Bus inteface card */ +#define I2C_HW_P_LP 0x020000 /* Parallel port interface */ +#define I2C_HW_P_ISA 0x020001 /* generic ISA Bus inteface card */ +#define I2C_HW_P_ELEK 0x020002 /* Elektor ISA Bus inteface card */ /* --- PCA 9564 based algorithms */ -#define I2C_HW_A_ISA 0x00 /* generic ISA Bus interface card */ +#define I2C_HW_A_ISA 0x1a0000 /* generic ISA Bus interface card */ /* --- ACPI Embedded controller algorithms */ -#define I2C_HW_ACPI_EC 0x00 +#define I2C_HW_ACPI_EC 0x1f0000 /* --- MPC824x PowerPC adapters */ -#define I2C_HW_MPC824X 0x00 /* Motorola 8240 / 8245 */ +#define I2C_HW_MPC824X 0x100001 /* Motorola 8240 / 8245 */ /* --- MPC8xx PowerPC adapters */ -#define I2C_HW_MPC8XX_EPON 0x00 /* Eponymous MPC8xx I2C adapter */ +#define I2C_HW_MPC8XX_EPON 0x110000 /* Eponymous MPC8xx I2C adapter */ /* --- ITE based algorithms */ -#define I2C_HW_I_IIC 0x00 /* controller on the ITE */ +#define I2C_HW_I_IIC 0x080000 /* controller on the ITE */ /* --- PowerPC on-chip adapters */ -#define I2C_HW_OCP 0x00 /* IBM on-chip I2C adapter */ +#define I2C_HW_OCP 0x120000 /* IBM on-chip I2C adapter */ /* --- Broadcom SiByte adapters */ -#define I2C_HW_SIBYTE 0x00 +#define I2C_HW_SIBYTE 0x150000 /* --- SGI adapters */ -#define I2C_HW_SGI_VINO 0x00 -#define I2C_HW_SGI_MACE 0x01 +#define I2C_HW_SGI_VINO 0x160000 +#define I2C_HW_SGI_MACE 0x160001 /* --- XSCALE on-chip adapters */ -#define I2C_HW_IOP3XX 0x00 +#define I2C_HW_IOP3XX 0x140000 /* --- Au1550 PSC adapters adapters */ -#define I2C_HW_AU1550_PSC 0x00 +#define I2C_HW_AU1550_PSC 0x1b0000 /* --- SMBus only adapters */ -#define I2C_HW_SMBUS_PIIX4 0x00 -#define I2C_HW_SMBUS_ALI15X3 0x01 -#define I2C_HW_SMBUS_VIA2 0x02 -#define I2C_HW_SMBUS_VOODOO3 0x03 -#define I2C_HW_SMBUS_I801 0x04 -#define I2C_HW_SMBUS_AMD756 0x05 -#define I2C_HW_SMBUS_SIS5595 0x06 -#define I2C_HW_SMBUS_ALI1535 0x07 -#define I2C_HW_SMBUS_SIS630 0x08 -#define I2C_HW_SMBUS_SIS96X 0x09 -#define I2C_HW_SMBUS_AMD8111 0x0a -#define I2C_HW_SMBUS_SCX200 0x0b -#define I2C_HW_SMBUS_NFORCE2 0x0c -#define I2C_HW_SMBUS_W9968CF 0x0d -#define I2C_HW_SMBUS_OV511 0x0e /* OV511(+) USB 1.1 webcam ICs */ -#define I2C_HW_SMBUS_OV518 0x0f /* OV518(+) USB 1.1 webcam ICs */ -#define I2C_HW_SMBUS_OV519 0x10 /* OV519 USB 1.1 webcam IC */ -#define I2C_HW_SMBUS_OVFX2 0x11 /* Cypress/OmniVision FX2 webcam */ +#define I2C_HW_SMBUS_PIIX4 0x040000 +#define I2C_HW_SMBUS_ALI15X3 0x040001 +#define I2C_HW_SMBUS_VIA2 0x040002 +#define I2C_HW_SMBUS_VOODOO3 0x040003 +#define I2C_HW_SMBUS_I801 0x040004 +#define I2C_HW_SMBUS_AMD756 0x040005 +#define I2C_HW_SMBUS_SIS5595 0x040006 +#define I2C_HW_SMBUS_ALI1535 0x040007 +#define I2C_HW_SMBUS_SIS630 0x040008 +#define I2C_HW_SMBUS_SIS96X 0x040009 +#define I2C_HW_SMBUS_AMD8111 0x04000a +#define I2C_HW_SMBUS_SCX200 0x04000b +#define I2C_HW_SMBUS_NFORCE2 0x04000c +#define I2C_HW_SMBUS_W9968CF 0x04000d +#define I2C_HW_SMBUS_OV511 0x04000e /* OV511(+) USB 1.1 webcam ICs */ +#define I2C_HW_SMBUS_OV518 0x04000f /* OV518(+) USB 1.1 webcam ICs */ +#define I2C_HW_SMBUS_OV519 0x040010 /* OV519 USB 1.1 webcam IC */ +#define I2C_HW_SMBUS_OVFX2 0x040011 /* Cypress/OmniVision FX2 webcam */ /* --- ISA pseudo-adapter */ -#define I2C_HW_ISA 0x00 +#define I2C_HW_ISA 0x050000 /* --- IPMI pseudo-adapter */ -#define I2C_HW_IPMI 0x00 +#define I2C_HW_IPMI 0x0b0000 /* --- IPMB adapter */ -#define I2C_HW_IPMB 0x00 +#define I2C_HW_IPMB 0x0c0000 /* --- MCP107 adapter */ -#define I2C_HW_MPC107 0x00 +#define I2C_HW_MPC107 0x0d0000 /* --- Marvell mv64xxx i2c adapter */ -#define I2C_HW_MV64XXX 0x00 +#define I2C_HW_MV64XXX 0x190000 #endif /* LINUX_I2C_ID_H */ diff --git a/include/linux/i2c-isa.h b/include/linux/i2c-isa.h index 54c27e88d101..67e3598c4cec 100644 --- a/include/linux/i2c-isa.h +++ b/include/linux/i2c-isa.h @@ -29,7 +29,7 @@ extern int i2c_isa_del_driver(struct i2c_driver *driver); /* Detect whether we are on the isa bus. This is only useful to hybrid (i2c+isa) drivers. */ #define i2c_is_isa_adapter(adapptr) \ - ((adapptr)->id == (I2C_ALGO_ISA | I2C_HW_ISA)) + ((adapptr)->id == I2C_HW_ISA) #define i2c_is_isa_client(clientptr) \ i2c_is_isa_adapter((clientptr)->adapter) -- cgit v1.2.2 From 1684a984303abbfc39aa8b59b0fe825c717811a9 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Thu, 11 Aug 2005 23:51:10 +0200 Subject: [PATCH] I2C: Kill i2c_algorithm.id (6/7) In theory, there should be no more users of I2C_ALGO_* at this point. However, it happens that several drivers were using I2C_ALGO_* for adapter ids, so we need to correct these before we can get rid of all the I2C_ALGO_* definitions. Note that this also fixes a bug in media/video/tvaudio.c: /* don't attach on saa7146 based cards, because dedicated drivers are used */ if ((adap->id & I2C_ALGO_SAA7146)) return 0; This test was plain broken, as it would succeed for many more adapters than just the saa7146: any those id would share at least one bit with the saa7146 id. We are really lucky that the few other adapters we want this driver to work with did not fulfill that condition. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/busses/i2c-keywest.c | 1 - drivers/i2c/busses/scx200_acb.c | 2 +- drivers/media/common/saa7146_i2c.c | 2 +- drivers/media/dvb/b2c2/flexcop-i2c.c | 1 - drivers/media/dvb/dvb-usb/dvb-usb-i2c.c | 1 - drivers/media/dvb/pluto2/pluto2.c | 1 - drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c | 1 - drivers/media/video/ir-kbd-i2c.c | 2 +- drivers/media/video/saa7134/saa7134-i2c.c | 2 +- drivers/media/video/tda9840.c | 2 +- drivers/media/video/tda9887.c | 2 +- drivers/media/video/tea6415c.c | 2 +- drivers/media/video/tea6420.c | 2 +- drivers/media/video/tvaudio.c | 4 ++-- drivers/video/aty/radeon_i2c.c | 2 +- drivers/video/nvidia/nv_i2c.c | 3 +-- drivers/video/riva/rivafb-i2c.c | 3 +-- drivers/video/savage/savagefb-i2c.c | 3 +-- include/linux/i2c-id.h | 7 +++++++ include/media/id.h | 5 ----- 20 files changed, 21 insertions(+), 27 deletions(-) diff --git a/drivers/i2c/busses/i2c-keywest.c b/drivers/i2c/busses/i2c-keywest.c index 5254d2db282c..e60ed6f49a62 100644 --- a/drivers/i2c/busses/i2c-keywest.c +++ b/drivers/i2c/busses/i2c-keywest.c @@ -619,7 +619,6 @@ create_iface(struct device_node *np, struct device *dev) sprintf(chan->adapter.name, "%s %d", np->parent->name, i); chan->iface = iface; chan->chan_no = i; - chan->adapter.id = I2C_ALGO_SMBUS; chan->adapter.algo = &keywest_algorithm; chan->adapter.algo_data = NULL; chan->adapter.client_register = NULL; diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c index 46b9a7594c99..a1d580e05361 100644 --- a/drivers/i2c/busses/scx200_acb.c +++ b/drivers/i2c/busses/scx200_acb.c @@ -454,7 +454,7 @@ static int __init scx200_acb_create(int base, int index) i2c_set_adapdata(adapter, iface); snprintf(adapter->name, I2C_NAME_SIZE, "SCx200 ACB%d", index); adapter->owner = THIS_MODULE; - adapter->id = I2C_ALGO_SMBUS; + adapter->id = I2C_HW_SMBUS_SCX200; adapter->algo = &scx200_acb_algorithm; adapter->class = I2C_CLASS_HWMON; diff --git a/drivers/media/common/saa7146_i2c.c b/drivers/media/common/saa7146_i2c.c index e413ee7f267a..6284894505c6 100644 --- a/drivers/media/common/saa7146_i2c.c +++ b/drivers/media/common/saa7146_i2c.c @@ -410,7 +410,7 @@ int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev, struct i2c_adapter *i2c #endif i2c_adapter->algo = &saa7146_algo; i2c_adapter->algo_data = NULL; - i2c_adapter->id = I2C_ALGO_SAA7146; + i2c_adapter->id = I2C_HW_SAA7146; i2c_adapter->timeout = SAA7146_I2C_TIMEOUT; i2c_adapter->retries = SAA7146_I2C_RETRIES; } diff --git a/drivers/media/dvb/b2c2/flexcop-i2c.c b/drivers/media/dvb/b2c2/flexcop-i2c.c index 848910ff3c9c..56495cb6cd02 100644 --- a/drivers/media/dvb/b2c2/flexcop-i2c.c +++ b/drivers/media/dvb/b2c2/flexcop-i2c.c @@ -190,7 +190,6 @@ int flexcop_i2c_init(struct flexcop_device *fc) fc->i2c_adap.class = I2C_CLASS_TV_DIGITAL; fc->i2c_adap.algo = &flexcop_algo; fc->i2c_adap.algo_data = NULL; - fc->i2c_adap.id = I2C_ALGO_BIT; if ((ret = i2c_add_adapter(&fc->i2c_adap)) < 0) return ret; diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c b/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c index 9f0a8d90d146..da970947dfc7 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c +++ b/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c @@ -27,7 +27,6 @@ int dvb_usb_i2c_init(struct dvb_usb_device *d) #endif d->i2c_adap.algo = d->props.i2c_algo; d->i2c_adap.algo_data = NULL; - d->i2c_adap.id = I2C_ALGO_BIT; i2c_set_adapdata(&d->i2c_adap, d); diff --git a/drivers/media/dvb/pluto2/pluto2.c b/drivers/media/dvb/pluto2/pluto2.c index 706e0bcb5ede..85b437bbddcd 100644 --- a/drivers/media/dvb/pluto2/pluto2.c +++ b/drivers/media/dvb/pluto2/pluto2.c @@ -633,7 +633,6 @@ static int __devinit pluto2_probe(struct pci_dev *pdev, i2c_set_adapdata(&pluto->i2c_adap, pluto); strcpy(pluto->i2c_adap.name, DRIVER_NAME); pluto->i2c_adap.owner = THIS_MODULE; - pluto->i2c_adap.id = I2C_ALGO_BIT; pluto->i2c_adap.class = I2C_CLASS_TV_DIGITAL; pluto->i2c_adap.dev.parent = &pdev->dev; pluto->i2c_adap.algo_data = &pluto->i2c_bit; diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c index 11afec52f31f..7daf7b1598a0 100644 --- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c +++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c @@ -1523,7 +1523,6 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i #endif ttusb->i2c_adap.algo = &ttusb_dec_algo; ttusb->i2c_adap.algo_data = NULL; - ttusb->i2c_adap.id = I2C_ALGO_BIT; result = i2c_add_adapter(&ttusb->i2c_adap); if (result) { diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c index c2f32d522668..feccf08bc0e3 100644 --- a/drivers/media/video/ir-kbd-i2c.c +++ b/drivers/media/video/ir-kbd-i2c.c @@ -432,7 +432,7 @@ static int ir_probe(struct i2c_adapter *adap) case I2C_HW_B_BT848: probe = probe_bttv; break; - case I2C_ALGO_SAA7134: + case I2C_HW_SAA7134: probe = probe_saa7134; break; } diff --git a/drivers/media/video/saa7134/saa7134-i2c.c b/drivers/media/video/saa7134/saa7134-i2c.c index 0bb1073d94bd..238ac3fdeb4a 100644 --- a/drivers/media/video/saa7134/saa7134-i2c.c +++ b/drivers/media/video/saa7134/saa7134-i2c.c @@ -381,7 +381,7 @@ static struct i2c_adapter saa7134_adap_template = { .class = I2C_CLASS_TV_ANALOG, #endif I2C_DEVNAME("saa7134"), - .id = I2C_ALGO_SAA7134, + .id = I2C_HW_SAA7134, .algo = &saa7134_algo, .client_register = attach_inform, }; diff --git a/drivers/media/video/tda9840.c b/drivers/media/video/tda9840.c index c29bdfc3244e..c0594e09d63e 100644 --- a/drivers/media/video/tda9840.c +++ b/drivers/media/video/tda9840.c @@ -205,7 +205,7 @@ static int detect(struct i2c_adapter *adapter, int address, int kind) static int attach(struct i2c_adapter *adapter) { /* let's see whether this is a know adapter we can attach to */ - if (adapter->id != I2C_ALGO_SAA7146) { + if (adapter->id != I2C_HW_SAA7146) { dprintk("refusing to probe on unknown adapter [name='%s',id=0x%x]\n", adapter->name, adapter->id); return -ENODEV; } diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c index f1b1bb5acf70..abb96ce464c7 100644 --- a/drivers/media/video/tda9887.c +++ b/drivers/media/video/tda9887.c @@ -620,7 +620,7 @@ static int tda9887_probe(struct i2c_adapter *adap) switch (adap->id) { case I2C_HW_B_BT848: case I2C_HW_B_RIVA: - case I2C_ALGO_SAA7134: + case I2C_HW_SAA7134: return i2c_probe(adap, &addr_data, tda9887_attach); break; } diff --git a/drivers/media/video/tea6415c.c b/drivers/media/video/tea6415c.c index b44db8a7b94d..8334d6ccd0a0 100644 --- a/drivers/media/video/tea6415c.c +++ b/drivers/media/video/tea6415c.c @@ -86,7 +86,7 @@ static int detect(struct i2c_adapter *adapter, int address, int kind) static int attach(struct i2c_adapter *adapter) { /* let's see whether this is a know adapter we can attach to */ - if (adapter->id != I2C_ALGO_SAA7146) { + if (adapter->id != I2C_HW_SAA7146) { dprintk("refusing to probe on unknown adapter [name='%s',id=0x%x]\n", adapter->name, adapter->id); return -ENODEV; } diff --git a/drivers/media/video/tea6420.c b/drivers/media/video/tea6420.c index 48d4db7d507b..9d09d2d23c2e 100644 --- a/drivers/media/video/tea6420.c +++ b/drivers/media/video/tea6420.c @@ -135,7 +135,7 @@ static int tea6420_detect(struct i2c_adapter *adapter, int address, int kind) static int attach(struct i2c_adapter *adapter) { /* let's see whether this is a know adapter we can attach to */ - if (adapter->id != I2C_ALGO_SAA7146) { + if (adapter->id != I2C_HW_SAA7146) { dprintk("refusing to probe on unknown adapter [name='%s',id=0x%x]\n", adapter->name, adapter->id); return -ENODEV; } diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c index 9420b5f52915..f6aab89593ea 100644 --- a/drivers/media/video/tvaudio.c +++ b/drivers/media/video/tvaudio.c @@ -1548,7 +1548,7 @@ static int chip_probe(struct i2c_adapter *adap) { /* don't attach on saa7146 based cards, because dedicated drivers are used */ - if ((adap->id & I2C_ALGO_SAA7146)) + if (adap->id == I2C_HW_SAA7146) return 0; #ifdef I2C_CLASS_TV_ANALOG if (adap->class & I2C_CLASS_TV_ANALOG) @@ -1557,7 +1557,7 @@ static int chip_probe(struct i2c_adapter *adap) switch (adap->id) { case I2C_HW_B_BT848: case I2C_HW_B_RIVA: - case I2C_ALGO_SAA7134: + case I2C_HW_SAA7134: return i2c_probe(adap, &addr_data, chip_attach); } #endif diff --git a/drivers/video/aty/radeon_i2c.c b/drivers/video/aty/radeon_i2c.c index 762244164c81..a9d0414e4655 100644 --- a/drivers/video/aty/radeon_i2c.c +++ b/drivers/video/aty/radeon_i2c.c @@ -75,7 +75,7 @@ static int radeon_setup_i2c_bus(struct radeon_i2c_chan *chan, const char *name) strcpy(chan->adapter.name, name); chan->adapter.owner = THIS_MODULE; - chan->adapter.id = I2C_ALGO_ATI; + chan->adapter.id = I2C_HW_B_RADEON; chan->adapter.algo_data = &chan->algo; chan->adapter.dev.parent = &chan->rinfo->pdev->dev; chan->algo.setsda = radeon_gpio_setsda; diff --git a/drivers/video/nvidia/nv_i2c.c b/drivers/video/nvidia/nv_i2c.c index 3757c1407c19..1a91bffdda26 100644 --- a/drivers/video/nvidia/nv_i2c.c +++ b/drivers/video/nvidia/nv_i2c.c @@ -90,14 +90,13 @@ static int nvidia_gpio_getsda(void *data) return val; } -#define I2C_ALGO_NVIDIA 0x0e0000 static int nvidia_setup_i2c_bus(struct nvidia_i2c_chan *chan, const char *name) { int rc; strcpy(chan->adapter.name, name); chan->adapter.owner = THIS_MODULE; - chan->adapter.id = I2C_ALGO_NVIDIA; + chan->adapter.id = I2C_HW_B_NVIDIA; chan->adapter.algo_data = &chan->algo; chan->adapter.dev.parent = &chan->par->pci_dev->dev; chan->algo.setsda = nvidia_gpio_setsda; diff --git a/drivers/video/riva/rivafb-i2c.c b/drivers/video/riva/rivafb-i2c.c index da1334dfd51d..77151d8e0766 100644 --- a/drivers/video/riva/rivafb-i2c.c +++ b/drivers/video/riva/rivafb-i2c.c @@ -92,14 +92,13 @@ static int riva_gpio_getsda(void* data) return val; } -#define I2C_ALGO_RIVA 0x0e0000 static int riva_setup_i2c_bus(struct riva_i2c_chan *chan, const char *name) { int rc; strcpy(chan->adapter.name, name); chan->adapter.owner = THIS_MODULE; - chan->adapter.id = I2C_ALGO_RIVA; + chan->adapter.id = I2C_HW_B_RIVA; chan->adapter.algo_data = &chan->algo; chan->adapter.dev.parent = &chan->par->pdev->dev; chan->algo.setsda = riva_gpio_setsda; diff --git a/drivers/video/savage/savagefb-i2c.c b/drivers/video/savage/savagefb-i2c.c index 024a0cecff15..847698b5cfe7 100644 --- a/drivers/video/savage/savagefb-i2c.c +++ b/drivers/video/savage/savagefb-i2c.c @@ -137,7 +137,6 @@ static int prosavage_gpio_getsda(void* data) return (0 != (GET_CR_DATA(chan->ioaddr) & PROSAVAGE_I2C_SDA_IN)); } -#define I2C_ALGO_SAVAGE 0x0f0000 static int savage_setup_i2c_bus(struct savagefb_i2c_chan *chan, const char *name) { @@ -147,7 +146,7 @@ static int savage_setup_i2c_bus(struct savagefb_i2c_chan *chan, if (add_bus && chan->par) { strcpy(chan->adapter.name, name); chan->adapter.owner = THIS_MODULE; - chan->adapter.id = I2C_ALGO_SAVAGE; + chan->adapter.id = I2C_HW_B_SAVAGE; chan->adapter.algo_data = &chan->algo; chan->adapter.dev.parent = &chan->par->pcidev->dev; chan->algo.udelay = 40; diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h index 5b72f664cc21..d044e738d383 100644 --- a/include/linux/i2c-id.h +++ b/include/linux/i2c-id.h @@ -245,6 +245,9 @@ #define I2C_HW_B_ZR36067 0x010019 /* Zoran-36057/36067 based boards */ #define I2C_HW_B_PCILYNX 0x01001a /* TI PCILynx I2C adapter */ #define I2C_HW_B_CX2388x 0x01001b /* connexant 2388x based tv cards */ +#define I2C_HW_B_NVIDIA 0x01001c /* nvidia framebuffer driver */ +#define I2C_HW_B_SAVAGE 0x01001d /* savage framebuffer driver */ +#define I2C_HW_B_RADEON 0x01001e /* radeon framebuffer driver */ /* --- PCF 8584 based algorithms */ #define I2C_HW_P_LP 0x020000 /* Parallel port interface */ @@ -317,4 +320,8 @@ /* --- Marvell mv64xxx i2c adapter */ #define I2C_HW_MV64XXX 0x190000 +/* --- Miscellaneous adapters */ +#define I2C_HW_SAA7146 0x060000 /* SAA7146 video decoder bus */ +#define I2C_HW_SAA7134 0x090000 /* SAA7134 video decoder bus */ + #endif /* LINUX_I2C_ID_H */ diff --git a/include/media/id.h b/include/media/id.h index a39a6423914b..801ddef301aa 100644 --- a/include/media/id.h +++ b/include/media/id.h @@ -34,8 +34,3 @@ #ifndef I2C_DRIVERID_SAA6752HS # define I2C_DRIVERID_SAA6752HS I2C_DRIVERID_EXP0+8 #endif - -/* algorithms */ -#ifndef I2C_ALGO_SAA7134 -# define I2C_ALGO_SAA7134 0x090000 -#endif -- cgit v1.2.2 From c2459cf257106cea5adbc83f084b76d0030eb700 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Thu, 11 Aug 2005 23:52:35 +0200 Subject: [PATCH] I2C: Kill i2c_algorithm.id (7/7) The I2C_ALGO_* constants have no more users, delete them. Also update the comments in i2c-id.h so that they reflect the current state of the file. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- include/linux/i2c-id.h | 57 +------------------------------------------------- 1 file changed, 1 insertion(+), 56 deletions(-) diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h index d044e738d383..44f30876a1c9 100644 --- a/include/linux/i2c-id.h +++ b/include/linux/i2c-id.h @@ -1,6 +1,6 @@ /* ------------------------------------------------------------------------- */ /* */ -/* i2c.h - definitions for the i2c-bus interface */ +/* i2c-id.h - identifier values for i2c drivers and adapters */ /* */ /* ------------------------------------------------------------------------- */ /* Copyright (C) 1995-1999 Simon G. Vogl @@ -23,16 +23,6 @@ #ifndef LINUX_I2C_ID_H #define LINUX_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 - * worlds. - * - * These will change often (i.e. additions) , therefore this has been - * separated from the functional interface definitions of the i2c api. - * - */ - /* * ---- Driver types ----------------------------------------------------- * device id name + number function description, i2c address(es) @@ -170,51 +160,6 @@ /* * ---- Adapter types ---------------------------------------------------- - * - * First, we distinguish between several algorithms to access the hardware - * interface types, as a PCF 8584 needs other care than a bit adapter. - */ - -#define I2C_ALGO_NONE 0x000000 -#define I2C_ALGO_BIT 0x010000 /* bit style adapters */ -#define I2C_ALGO_PCF 0x020000 /* PCF 8584 style adapters */ -#define I2C_ALGO_ATI 0x030000 /* ATI video card */ -#define I2C_ALGO_SMBUS 0x040000 -#define I2C_ALGO_ISA 0x050000 /* lm_sensors ISA pseudo-adapter */ -#define I2C_ALGO_SAA7146 0x060000 /* SAA 7146 video decoder bus */ -#define I2C_ALGO_ACB 0x070000 /* ACCESS.bus algorithm */ -#define I2C_ALGO_IIC 0x080000 /* ITE IIC bus */ -#define I2C_ALGO_SAA7134 0x090000 -#define I2C_ALGO_MPC824X 0x0a0000 /* Motorola 8240 / 8245 */ -#define I2C_ALGO_IPMI 0x0b0000 /* IPMI dummy adapter */ -#define I2C_ALGO_IPMB 0x0c0000 /* IPMB adapter */ -#define I2C_ALGO_MPC107 0x0d0000 -#define I2C_ALGO_EC 0x100000 /* ACPI embedded controller */ - -#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_IOP3XX 0x140000 /* XSCALE IOP3XX On-chip I2C alg */ -#define I2C_ALGO_SIBYTE 0x150000 /* Broadcom SiByte SOCs */ -#define I2C_ALGO_SGI 0x160000 /* SGI algorithm */ - -#define I2C_ALGO_USB 0x170000 /* USB algorithm */ -#define I2C_ALGO_VIRT 0x180000 /* Virtual bus adapter */ - -#define I2C_ALGO_MV64XXX 0x190000 /* Marvell mv64xxx i2c ctlr */ -#define I2C_ALGO_PCA 0x1a0000 /* PCA 9564 style adapters */ -#define I2C_ALGO_AU1550 0x1b0000 /* Au1550 PSC algorithm */ - -#define I2C_ALGO_EXP 0x800000 /* experimental */ - -#define I2C_ALGO_MASK 0xff0000 /* Mask for algorithms */ -#define I2C_ALGO_SHIFT 0x10 /* right shift to get index values */ - -#define I2C_HW_ADAPS 0x10000 /* # adapter types */ -#define I2C_HW_MASK 0xffff - - -/* hw specific modules that are defined per algorithm layer */ /* --- Bit algorithm adapters */ -- cgit v1.2.2 From 020789e9cb688ac8b15a9950d25fe45492b23398 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sat, 13 Aug 2005 13:04:32 +0200 Subject: [PATCH] I2C: Outdated i2c_adapter comment Delete an outdated comment about i2c_algorithm.id being computed from algo->id. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- include/linux/i2c.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/linux/i2c.h b/include/linux/i2c.h index af4983b488b6..233c153b12b1 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -219,8 +219,7 @@ struct i2c_algorithm { */ struct i2c_adapter { struct module *owner; - unsigned int id;/* == is algo->id | hwdep.struct->id, */ - /* for registered values see below */ + unsigned int id; unsigned int class; struct i2c_algorithm *algo;/* the algorithm to access the bus */ void *algo_data; -- cgit v1.2.2 From 5b5439652af79106b792faf79b2c1e787e143ba0 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Mon, 15 Aug 2005 19:51:02 +0200 Subject: [PATCH] hwmon: separate maintainer Now that the hardware monitoring drivers are no more part of the i2c subsystem, they probably deserve their own entry in MAINTAINERS. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- MAINTAINERS | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 5899ec1504f3..7e1f67130a16 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -933,6 +933,13 @@ M: khc@pm.waw.pl W: http://www.kernel.org/pub/linux/utils/net/hdlc/ S: Maintained +HARDWARE MONITORING +P: Jean Delvare +M: khali@linux-fr.org +L: lm-sensors@lm-sensors.org +W: http://www.lm-sensors.nu/ +S: Maintained + HARMONY SOUND DRIVER P: Kyle McMartin M: kyle@parisc-linux.org @@ -1014,7 +1021,7 @@ P: William Irwin M: wli@holomorphy.com S: Maintained -I2C AND SENSORS DRIVERS +I2C SUBSYSTEM P: Greg Kroah-Hartman M: greg@kroah.com P: Jean Delvare -- cgit v1.2.2 From fae91e72b79ba9a21f0ce7551a1fd7e8984c85a6 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Mon, 15 Aug 2005 19:57:04 +0200 Subject: [PATCH] I2C: Drop I2C_DEVNAME and i2c_clientname I2C_DEVNAME and i2c_clientname were introduced in 2.5.68 [1] to help media/video driver authors who wanted their code to be compatible with both Linux 2.4 and 2.6. The cause of the incompatibility has gone since [2], so I think we can get rid of them, as they tend to make the code harder to read and longer to preprocess/compile for no more benefit. I'd hope nobody seriously attempts to keep media/video driver compatible across Linux trees anymore, BTW. [1] http://marc.theaimsgroup.com/?l=linux-kernel&m=104930186524598&w=2 [2] http://www.linuxhq.com/kernel/v2.6/0-test3/include/linux/i2c.h Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/media/video/bt832.c | 2 +- drivers/media/video/bttv-i2c.c | 8 ++--- drivers/media/video/cx88/cx88-i2c.c | 8 ++--- drivers/media/video/ir-kbd-i2c.c | 2 +- drivers/media/video/msp3400.c | 4 +-- drivers/media/video/ovcamchip/ovcamchip_core.c | 6 ++-- drivers/media/video/saa7134/saa6752hs.c | 2 +- drivers/media/video/saa7134/saa7134-i2c.c | 6 ++-- drivers/media/video/tda7432.c | 2 +- drivers/media/video/tda9840.c | 2 +- drivers/media/video/tda9875.c | 2 +- drivers/media/video/tda9887.c | 2 +- drivers/media/video/tea6415c.c | 2 +- drivers/media/video/tea6420.c | 2 +- drivers/media/video/tuner-core.c | 2 +- drivers/media/video/tvaudio.c | 41 ++++++++++++-------------- drivers/media/video/tvmixer.c | 8 ++--- drivers/media/video/zoran_card.c | 2 +- drivers/usb/media/w9968cf.c | 8 ++--- include/linux/i2c.h | 7 ----- 20 files changed, 53 insertions(+), 65 deletions(-) diff --git a/drivers/media/video/bt832.c b/drivers/media/video/bt832.c index 67ffed8a7fea..76c1b63ebdf2 100644 --- a/drivers/media/video/bt832.c +++ b/drivers/media/video/bt832.c @@ -241,7 +241,7 @@ static struct i2c_driver driver = { }; static struct i2c_client client_template = { - I2C_DEVNAME("bt832"), + .name = "bt832", .flags = I2C_CLIENT_ALLOW_USE, .driver = &driver, }; diff --git a/drivers/media/video/bttv-i2c.c b/drivers/media/video/bttv-i2c.c index 1db95f75ac68..706dc48df962 100644 --- a/drivers/media/video/bttv-i2c.c +++ b/drivers/media/video/bttv-i2c.c @@ -109,7 +109,7 @@ static struct i2c_adapter bttv_i2c_adap_sw_template = { #ifdef I2C_CLASS_TV_ANALOG .class = I2C_CLASS_TV_ANALOG, #endif - I2C_DEVNAME("bt848"), + .name = "bt848", .id = I2C_HW_B_BT848, .client_register = attach_inform, }; @@ -280,7 +280,7 @@ static struct i2c_adapter bttv_i2c_adap_hw_template = { #ifdef I2C_CLASS_TV_ANALOG .class = I2C_CLASS_TV_ANALOG, #endif - I2C_DEVNAME("bt878"), + .name = "bt878", .id = I2C_HW_B_BT848 /* FIXME */, .algo = &bttv_algo, .client_register = attach_inform, @@ -296,7 +296,7 @@ static int attach_inform(struct i2c_client *client) if (bttv_debug) printk(KERN_DEBUG "bttv%d: %s i2c attach [addr=0x%x,client=%s]\n", btv->c.nr,client->driver->name,client->addr, - i2c_clientname(client)); + client->name); if (!client->driver->command) return 0; @@ -324,7 +324,7 @@ void bttv_call_i2c_clients(struct bttv *btv, unsigned int cmd, void *arg) } static struct i2c_client bttv_i2c_client_template = { - I2C_DEVNAME("bttv internal"), + .name = "bttv internal", }; diff --git a/drivers/media/video/cx88/cx88-i2c.c b/drivers/media/video/cx88/cx88-i2c.c index a628a55299c6..7f598039e025 100644 --- a/drivers/media/video/cx88/cx88-i2c.c +++ b/drivers/media/video/cx88/cx88-i2c.c @@ -95,7 +95,7 @@ static int attach_inform(struct i2c_client *client) struct cx88_core *core = i2c_get_adapdata(client->adapter); dprintk(1, "%s i2c attach [addr=0x%x,client=%s]\n", - client->driver->name,client->addr,i2c_clientname(client)); + client->driver->name, client->addr, client->name); if (!client->driver->command) return 0; @@ -128,7 +128,7 @@ static int detach_inform(struct i2c_client *client) { struct cx88_core *core = i2c_get_adapdata(client->adapter); - dprintk(1, "i2c detach [client=%s]\n", i2c_clientname(client)); + dprintk(1, "i2c detach [client=%s]\n", client->name); return 0; } @@ -152,7 +152,7 @@ static struct i2c_algo_bit_data cx8800_i2c_algo_template = { /* ----------------------------------------------------------------------- */ static struct i2c_adapter cx8800_i2c_adap_template = { - I2C_DEVNAME("cx2388x"), + .name = "cx2388x", .owner = THIS_MODULE, .id = I2C_HW_B_CX2388x, .client_register = attach_inform, @@ -160,7 +160,7 @@ static struct i2c_adapter cx8800_i2c_adap_template = { }; static struct i2c_client cx8800_i2c_client_template = { - I2C_DEVNAME("cx88xx internal"), + .name = "cx88xx internal", }; static char *i2c_devs[128] = { diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c index feccf08bc0e3..1e273ff3f956 100644 --- a/drivers/media/video/ir-kbd-i2c.c +++ b/drivers/media/video/ir-kbd-i2c.c @@ -308,7 +308,7 @@ static struct i2c_driver driver = { static struct i2c_client client_template = { - I2C_DEVNAME("unset"), + .name = "unset", .driver = &driver }; diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c index e956234abf24..ca02f6f14b00 100644 --- a/drivers/media/video/msp3400.c +++ b/drivers/media/video/msp3400.c @@ -1437,7 +1437,7 @@ static struct i2c_driver driver = { static struct i2c_client client_template = { - I2C_DEVNAME("(unset)"), + .name = "(unset)", .flags = I2C_CLIENT_ALLOW_USE, .driver = &driver, }; @@ -1509,7 +1509,7 @@ static int msp_attach(struct i2c_adapter *adap, int addr, int kind) } /* hello world :-) */ - printk(KERN_INFO "msp34xx: init: chip=%s",i2c_clientname(c)); + printk(KERN_INFO "msp34xx: init: chip=%s", c->name); if (HAVE_NICAM(msp)) printk(" +nicam"); if (HAVE_SIMPLE(msp)) diff --git a/drivers/media/video/ovcamchip/ovcamchip_core.c b/drivers/media/video/ovcamchip/ovcamchip_core.c index b98c64ab7c58..2de34ebf0673 100644 --- a/drivers/media/video/ovcamchip/ovcamchip_core.c +++ b/drivers/media/video/ovcamchip/ovcamchip_core.c @@ -314,7 +314,7 @@ static int ovcamchip_attach(struct i2c_adapter *adap) } memcpy(c, &client_template, sizeof *c); c->adapter = adap; - strcpy(i2c_clientname(c), "OV????"); + strcpy(c->name, "OV????"); ov = kmalloc(sizeof *ov, GFP_KERNEL); if (!ov) { @@ -328,7 +328,7 @@ static int ovcamchip_attach(struct i2c_adapter *adap) if (rc < 0) goto error; - strcpy(i2c_clientname(c), chip_names[ov->subtype]); + strcpy(c->name, chip_names[ov->subtype]); PDEBUG(1, "Camera chip detection complete"); @@ -421,7 +421,7 @@ static struct i2c_driver driver = { }; static struct i2c_client client_template = { - I2C_DEVNAME("(unset)"), + .name = "(unset)", .driver = &driver, }; diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c index 79d05ea1b69b..382911c6ef22 100644 --- a/drivers/media/video/saa7134/saa6752hs.c +++ b/drivers/media/video/saa7134/saa6752hs.c @@ -598,7 +598,7 @@ static struct i2c_driver driver = { static struct i2c_client client_template = { - I2C_DEVNAME("saa6752hs"), + .name = "saa6752hs", .flags = I2C_CLIENT_ALLOW_USE, .driver = &driver, }; diff --git a/drivers/media/video/saa7134/saa7134-i2c.c b/drivers/media/video/saa7134/saa7134-i2c.c index 238ac3fdeb4a..eae6b529713f 100644 --- a/drivers/media/video/saa7134/saa7134-i2c.c +++ b/drivers/media/video/saa7134/saa7134-i2c.c @@ -334,7 +334,7 @@ static int attach_inform(struct i2c_client *client) struct tuner_setup tun_setup; d1printk( "%s i2c attach [addr=0x%x,client=%s]\n", - client->driver->name,client->addr,i2c_clientname(client)); + client->driver->name, client->addr, client->name); if (!client->driver->command) return 0; @@ -380,14 +380,14 @@ static struct i2c_adapter saa7134_adap_template = { #ifdef I2C_CLASS_TV_ANALOG .class = I2C_CLASS_TV_ANALOG, #endif - I2C_DEVNAME("saa7134"), + .name = "saa7134", .id = I2C_HW_SAA7134, .algo = &saa7134_algo, .client_register = attach_inform, }; static struct i2c_client saa7134_client_template = { - I2C_DEVNAME("saa7134 internal"), + .name = "saa7134 internal", }; /* ----------------------------------------------------------- */ diff --git a/drivers/media/video/tda7432.c b/drivers/media/video/tda7432.c index bc6b6c0cea6d..255b6088ebf9 100644 --- a/drivers/media/video/tda7432.c +++ b/drivers/media/video/tda7432.c @@ -513,7 +513,7 @@ static struct i2c_driver driver = { static struct i2c_client client_template = { - I2C_DEVNAME("tda7432"), + .name = "tda7432", .driver = &driver, }; diff --git a/drivers/media/video/tda9840.c b/drivers/media/video/tda9840.c index c0594e09d63e..1794686612c6 100644 --- a/drivers/media/video/tda9840.c +++ b/drivers/media/video/tda9840.c @@ -231,7 +231,7 @@ static struct i2c_driver driver = { }; static struct i2c_client client_template = { - I2C_DEVNAME("tda9840"), + .name = "tda9840", .driver = &driver, }; diff --git a/drivers/media/video/tda9875.c b/drivers/media/video/tda9875.c index 3eaf2e1211e5..7e3dcdb262b0 100644 --- a/drivers/media/video/tda9875.c +++ b/drivers/media/video/tda9875.c @@ -384,7 +384,7 @@ static struct i2c_driver driver = { static struct i2c_client client_template = { - I2C_DEVNAME("tda9875"), + .name = "tda9875", .driver = &driver, }; diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c index abb96ce464c7..d60fc562aecd 100644 --- a/drivers/media/video/tda9887.c +++ b/drivers/media/video/tda9887.c @@ -793,7 +793,7 @@ static struct i2c_driver driver = { }; static struct i2c_client client_template = { - I2C_DEVNAME("tda9887"), + .name = "tda9887", .flags = I2C_CLIENT_ALLOW_USE, .driver = &driver, }; diff --git a/drivers/media/video/tea6415c.c b/drivers/media/video/tea6415c.c index 8334d6ccd0a0..ee3688348b66 100644 --- a/drivers/media/video/tea6415c.c +++ b/drivers/media/video/tea6415c.c @@ -200,7 +200,7 @@ static struct i2c_driver driver = { }; static struct i2c_client client_template = { - I2C_DEVNAME("tea6415c"), + .name = "tea6415c", .driver = &driver, }; diff --git a/drivers/media/video/tea6420.c b/drivers/media/video/tea6420.c index 9d09d2d23c2e..17975c19da5e 100644 --- a/drivers/media/video/tea6420.c +++ b/drivers/media/video/tea6420.c @@ -177,7 +177,7 @@ static struct i2c_driver driver = { }; static struct i2c_client client_template = { - I2C_DEVNAME("tea6420"), + .name = "tea6420", .driver = &driver, }; diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index a155e99a263b..3b1893c2ae3b 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c @@ -709,7 +709,7 @@ static struct i2c_driver driver = { }, }; static struct i2c_client client_template = { - I2C_DEVNAME("(tuner unset)"), + .name = "(tuner unset)", .flags = I2C_CLIENT_ALLOW_USE, .driver = &driver, }; diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c index f6aab89593ea..258724b2d6d2 100644 --- a/drivers/media/video/tvaudio.c +++ b/drivers/media/video/tvaudio.c @@ -162,24 +162,23 @@ static int chip_write(struct CHIPSTATE *chip, int subaddr, int val) unsigned char buffer[2]; if (-1 == subaddr) { - dprintk("%s: chip_write: 0x%x\n", - i2c_clientname(&chip->c), val); + dprintk("%s: chip_write: 0x%x\n", chip->c.name, val); chip->shadow.bytes[1] = val; buffer[0] = val; if (1 != i2c_master_send(&chip->c,buffer,1)) { printk(KERN_WARNING "%s: I/O error (write 0x%x)\n", - i2c_clientname(&chip->c), val); + chip->c.name, val); return -1; } } else { dprintk("%s: chip_write: reg%d=0x%x\n", - i2c_clientname(&chip->c), subaddr, val); + chip->c.name, subaddr, val); chip->shadow.bytes[subaddr+1] = val; buffer[0] = subaddr; buffer[1] = val; if (2 != i2c_master_send(&chip->c,buffer,2)) { printk(KERN_WARNING "%s: I/O error (write reg%d=0x%x)\n", - i2c_clientname(&chip->c), subaddr, val); + chip->c.name, subaddr, val); return -1; } } @@ -203,11 +202,10 @@ static int chip_read(struct CHIPSTATE *chip) unsigned char buffer; if (1 != i2c_master_recv(&chip->c,&buffer,1)) { - printk(KERN_WARNING "%s: I/O error (read)\n", - i2c_clientname(&chip->c)); + printk(KERN_WARNING "%s: I/O error (read)\n", chip->c.name); return -1; } - dprintk("%s: chip_read: 0x%x\n",i2c_clientname(&chip->c),buffer); + dprintk("%s: chip_read: 0x%x\n", chip->c.name, buffer); return buffer; } @@ -222,12 +220,11 @@ static int chip_read2(struct CHIPSTATE *chip, int subaddr) write[0] = subaddr; if (2 != i2c_transfer(chip->c.adapter,msgs,2)) { - printk(KERN_WARNING "%s: I/O error (read2)\n", - i2c_clientname(&chip->c)); + printk(KERN_WARNING "%s: I/O error (read2)\n", chip->c.name); return -1; } dprintk("%s: chip_read2: reg%d=0x%x\n", - i2c_clientname(&chip->c),subaddr,read[0]); + chip->c.name, subaddr, read[0]); return read[0]; } @@ -240,7 +237,7 @@ static int chip_cmd(struct CHIPSTATE *chip, char *name, audiocmd *cmd) /* update our shadow register set; print bytes if (debug > 0) */ dprintk("%s: chip_cmd(%s): reg=%d, data:", - i2c_clientname(&chip->c),name,cmd->bytes[0]); + chip->c.name, name, cmd->bytes[0]); for (i = 1; i < cmd->count; i++) { dprintk(" 0x%x",cmd->bytes[i]); chip->shadow.bytes[i+cmd->bytes[0]] = cmd->bytes[i]; @@ -249,7 +246,7 @@ static int chip_cmd(struct CHIPSTATE *chip, char *name, audiocmd *cmd) /* send data to the chip */ if (cmd->count != i2c_master_send(&chip->c,cmd->bytes,cmd->count)) { - printk(KERN_WARNING "%s: I/O error (%s)\n", i2c_clientname(&chip->c), name); + printk(KERN_WARNING "%s: I/O error (%s)\n", chip->c.name, name); return -1; } return 0; @@ -274,9 +271,9 @@ static int chip_thread(void *data) struct CHIPSTATE *chip = data; struct CHIPDESC *desc = chiplist + chip->type; - daemonize("%s",i2c_clientname(&chip->c)); + daemonize("%s", chip->c.name); allow_signal(SIGTERM); - dprintk("%s: thread started\n", i2c_clientname(&chip->c)); + dprintk("%s: thread started\n", chip->c.name); for (;;) { add_wait_queue(&chip->wq, &wait); @@ -288,7 +285,7 @@ static int chip_thread(void *data) try_to_freeze(); if (chip->done || signal_pending(current)) break; - dprintk("%s: thread wakeup\n", i2c_clientname(&chip->c)); + dprintk("%s: thread wakeup\n", chip->c.name); /* don't do anything for radio or if mode != auto */ if (chip->norm == VIDEO_MODE_RADIO || chip->mode != 0) @@ -301,7 +298,7 @@ static int chip_thread(void *data) mod_timer(&chip->wt, jiffies+2*HZ); } - dprintk("%s: thread exiting\n", i2c_clientname(&chip->c)); + dprintk("%s: thread exiting\n", chip->c.name); complete_and_exit(&chip->texit, 0); return 0; } @@ -314,7 +311,7 @@ static void generic_checkmode(struct CHIPSTATE *chip) if (mode == chip->prevmode) return; - dprintk("%s: thread checkmode\n", i2c_clientname(&chip->c)); + dprintk("%s: thread checkmode\n", chip->c.name); chip->prevmode = mode; if (mode & VIDEO_SOUND_STEREO) @@ -1501,7 +1498,7 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind) (desc->flags & CHIP_HAS_INPUTSEL) ? " audiomux" : ""); /* fill required data structures */ - strcpy(i2c_clientname(&chip->c),desc->name); + strcpy(chip->c.name, desc->name); chip->type = desc-chiplist; chip->shadow.count = desc->registers+1; chip->prevmode = -1; @@ -1538,7 +1535,7 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind) chip->tpid = kernel_thread(chip_thread,(void *)chip,0); if (chip->tpid < 0) printk(KERN_WARNING "%s: kernel_thread() failed\n", - i2c_clientname(&chip->c)); + chip->c.name); wake_up_interruptible(&chip->wq); } return 0; @@ -1591,7 +1588,7 @@ static int chip_command(struct i2c_client *client, struct CHIPSTATE *chip = i2c_get_clientdata(client); struct CHIPDESC *desc = chiplist + chip->type; - dprintk("%s: chip_command 0x%x\n",i2c_clientname(&chip->c),cmd); + dprintk("%s: chip_command 0x%x\n", chip->c.name, cmd); switch (cmd) { case AUDC_SET_INPUT: @@ -1702,7 +1699,7 @@ static struct i2c_driver driver = { static struct i2c_client client_template = { - I2C_DEVNAME("(unset)"), + .name = "(unset)", .flags = I2C_CLIENT_ALLOW_USE, .driver = &driver, }; diff --git a/drivers/media/video/tvmixer.c b/drivers/media/video/tvmixer.c index f0635b19de30..a43301a154af 100644 --- a/drivers/media/video/tvmixer.c +++ b/drivers/media/video/tvmixer.c @@ -91,7 +91,7 @@ static int tvmixer_ioctl(struct inode *inode, struct file *file, unsigned int cm if (cmd == SOUND_MIXER_INFO) { mixer_info info; strlcpy(info.id, "tv card", sizeof(info.id)); - strlcpy(info.name, i2c_clientname(client), sizeof(info.name)); + strlcpy(info.name, client->name, sizeof(info.name)); info.modify_counter = 42 /* FIXME */; if (copy_to_user(argp, &info, sizeof(info))) return -EFAULT; @@ -100,7 +100,7 @@ static int tvmixer_ioctl(struct inode *inode, struct file *file, unsigned int cm if (cmd == SOUND_OLD_MIXER_INFO) { _old_mixer_info info; strlcpy(info.id, "tv card", sizeof(info.id)); - strlcpy(info.name, i2c_clientname(client), sizeof(info.name)); + strlcpy(info.name, client->name, sizeof(info.name)); if (copy_to_user(argp, &info, sizeof(info))) return -EFAULT; return 0; @@ -295,7 +295,7 @@ static int tvmixer_clients(struct i2c_client *client) devices[i].dev = NULL; devices[i].minor = -1; printk("tvmixer: %s unregistered (#1)\n", - i2c_clientname(client)); + client->name); return 0; } } @@ -354,7 +354,7 @@ static void __exit tvmixer_cleanup_module(void) if (devices[i].minor != -1) { unregister_sound_mixer(devices[i].minor); printk("tvmixer: %s unregistered (#2)\n", - i2c_clientname(devices[i].dev)); + devices[i].dev->name); } } } diff --git a/drivers/media/video/zoran_card.c b/drivers/media/video/zoran_card.c index 25743085b2d5..eed2acea1779 100644 --- a/drivers/media/video/zoran_card.c +++ b/drivers/media/video/zoran_card.c @@ -737,7 +737,7 @@ static struct i2c_algo_bit_data zoran_i2c_bit_data_template = { }; static struct i2c_adapter zoran_i2c_adapter_template = { - I2C_DEVNAME("zr36057"), + .name = "zr36057", .id = I2C_HW_B_ZR36067, .algo = NULL, .client_register = zoran_i2c_client_register, diff --git a/drivers/usb/media/w9968cf.c b/drivers/usb/media/w9968cf.c index 83e8dd627154..f36c0b6c6e36 100644 --- a/drivers/usb/media/w9968cf.c +++ b/drivers/usb/media/w9968cf.c @@ -1523,7 +1523,6 @@ static u32 w9968cf_i2c_func(struct i2c_adapter* adap) static int w9968cf_i2c_attach_inform(struct i2c_client* client) { struct w9968cf_device* cam = i2c_get_adapdata(client->adapter); - const char* clientname = i2c_clientname(client); int id = client->driver->id, err = 0; if (id == I2C_DRIVERID_OVCAMCHIP) { @@ -1535,12 +1534,12 @@ static int w9968cf_i2c_attach_inform(struct i2c_client* client) } } else { DBG(4, "Rejected client [%s] with driver [%s]", - clientname, client->driver->name) + client->name, client->driver->name) return -EINVAL; } DBG(5, "I2C attach client [%s] with driver [%s]", - clientname, client->driver->name) + client->name, client->driver->name) return 0; } @@ -1549,12 +1548,11 @@ static int w9968cf_i2c_attach_inform(struct i2c_client* client) static int w9968cf_i2c_detach_inform(struct i2c_client* client) { struct w9968cf_device* cam = i2c_get_adapdata(client->adapter); - const char* clientname = i2c_clientname(client); if (cam->sensor_client == client) cam->sensor_client = NULL; - DBG(5, "I2C detach client [%s]", clientname) + DBG(5, "I2C detach client [%s]", client->name) return 0; } diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 233c153b12b1..1ead5195fde4 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -178,13 +178,6 @@ static inline void i2c_set_clientdata (struct i2c_client *dev, void *data) dev_set_drvdata (&dev->dev, data); } -#define I2C_DEVNAME(str) .name = str - -static inline char *i2c_clientname(struct i2c_client *c) -{ - return &c->name[0]; -} - /* * The following structs are for those who like to implement new bus drivers: * i2c_algorithm is the interface to a class of hardware solutions which can -- cgit v1.2.2 From 386625f9f5cd94d10a21241b555b130dcec484fb Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Thu, 25 Aug 2005 16:43:29 +0200 Subject: [PATCH] I2C: Drop debug eeprom dump code in pcilynx The pcilynx driver includes code to dump the contents of an i2c eeprom for debugging purposes. The same can be done from userspace using the i2cdump tool (part of the lm_sensors project) instead, in a more efficient and flexible way. Thus I would suggest that this functionality be simply dropped from the pcilynx driver. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/ieee1394/pcilynx.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/drivers/ieee1394/pcilynx.c b/drivers/ieee1394/pcilynx.c index 36074e6eeebb..6b1ab875333b 100644 --- a/drivers/ieee1394/pcilynx.c +++ b/drivers/ieee1394/pcilynx.c @@ -1464,26 +1464,6 @@ static int __devinit add_card(struct pci_dev *dev, { 0x50, I2C_M_RD, 20, (unsigned char*) lynx->bus_info_block } }; - -#ifdef CONFIG_IEEE1394_VERBOSEDEBUG - union i2c_smbus_data data; - - if (i2c_smbus_xfer(i2c_ad, 80, 0, I2C_SMBUS_WRITE, 0, I2C_SMBUS_BYTE,NULL)) - PRINT(KERN_ERR, lynx->id,"eeprom read start has failed"); - else - { - u16 addr; - for (addr=0x00; addr < 0x100; addr++) { - if (i2c_smbus_xfer(i2c_ad, 80, 0, I2C_SMBUS_READ, 0, I2C_SMBUS_BYTE,& data)) { - PRINT(KERN_ERR, lynx->id, "unable to read i2c %x", addr); - break; - } - else - PRINT(KERN_DEBUG, lynx->id,"got serial eeprom data at %x: %x",addr, data.byte); - } - } -#endif - /* we use i2c_transfer, because i2c_smbus_read_block_data does not work properly and we do it more efficiently in one transaction rather then using several reads */ if (i2c_transfer(i2c_ad, msg, 2) < 0) { -- cgit v1.2.2 From b280dab6d62c8d0434cbc0aaeebf56d1fa4fcc19 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Mon, 29 Aug 2005 21:10:31 +0200 Subject: [PATCH] I2C: Drop probe parameter of i2c-keywest The i2c-keywest driver has a "probe" module parameter which enables bus scanning at load time. This can be done in userspace with the i2cdetect tool (part of the lm_sensors package) instead. What's more, i2cdetect gives more control on the way the bus is scanned, and is safer (i2c-keywest currently scans reserved addresses and doesn't properly handle the famous 24RF08 corruption case.) Thus, I would propose that this module parameter be simply dropped. Signed-off-by: Jean Delvare Acked-by: Benjamin Herrenschmidt Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/busses/i2c-keywest.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/drivers/i2c/busses/i2c-keywest.c b/drivers/i2c/busses/i2c-keywest.c index e60ed6f49a62..37b49c2daf5f 100644 --- a/drivers/i2c/busses/i2c-keywest.c +++ b/drivers/i2c/busses/i2c-keywest.c @@ -87,12 +87,9 @@ static const char *__kw_state_names[] = { }; #endif /* DEBUG */ -static int probe; - MODULE_AUTHOR("Benjamin Herrenschmidt "); MODULE_DESCRIPTION("I2C driver for Apple's Keywest"); MODULE_LICENSE("GPL"); -module_param(probe, bool, 0); #ifdef POLLED_MODE /* Don't schedule, the g5 fan controller is too @@ -632,15 +629,6 @@ create_iface(struct device_node *np, struct device *dev) chan->adapter.name); i2c_set_adapdata(&chan->adapter, NULL); } - if (probe) { - printk("Probe: "); - for (addr = 0x00; addr <= 0x7f; addr++) { - if (i2c_smbus_xfer(&chan->adapter,addr, - 0,0,0,I2C_SMBUS_QUICK,NULL) >= 0) - printk("%02x ", addr); - } - printk("\n"); - } } printk(KERN_INFO "Found KeyWest i2c on \"%s\", %d channel%s, stepping: %d bits\n", -- cgit v1.2.2 From a44e40b4d8c2c6faa2158caf7114e1065fed3b34 Mon Sep 17 00:00:00 2001 From: "Mark A. Greer" Date: Thu, 1 Sep 2005 18:09:54 -0700 Subject: [PATCH] i2c: chips/m41t00.c fixup The 'new_time' variable should be static. Signed-off-by: Mark A. Greer Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/chips/m41t00.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c index e516dadc453f..3f14528a52a9 100644 --- a/drivers/i2c/chips/m41t00.c +++ b/drivers/i2c/chips/m41t00.c @@ -144,7 +144,7 @@ m41t00_set_tlet(ulong arg) return; } -ulong new_time; +static ulong new_time; DECLARE_TASKLET_DISABLED(m41t00_tasklet, m41t00_set_tlet, (ulong)&new_time); -- cgit v1.2.2 From 8e14d6c173f8fff05a94e62669c87c26141766af Mon Sep 17 00:00:00 2001 From: "Mark A. Greer" Date: Thu, 1 Sep 2005 18:12:04 -0700 Subject: [PATCH] i2c: chips/ds1374.c fixup The 'new_time' variable should be static. Signed-off-by: Mark A. Greer Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/chips/ds1374.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c index e2d1daf79880..0936327a946d 100644 --- a/drivers/i2c/chips/ds1374.c +++ b/drivers/i2c/chips/ds1374.c @@ -165,7 +165,7 @@ static void ds1374_set_tlet(ulong arg) "can't confirm time set from rtc chip\n"); } -ulong new_time; +static ulong new_time; DECLARE_TASKLET_DISABLED(ds1374_tasklet, ds1374_set_tlet, (ulong) & new_time); -- cgit v1.2.2 From d1b2f0a9754d3087ee29b3e88b8f20f2d30090d3 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Fri, 2 Sep 2005 21:25:47 +0200 Subject: [PATCH] i2c: bug fix for busses/i2c-mv64xxx.c When an i2c transfer is successful, an incorrect value is returned. This patch fixes that. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/busses/i2c-mv64xxx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c index eb6cc0869938..99abca45fece 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c @@ -423,13 +423,13 @@ static int mv64xxx_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) { struct mv64xxx_i2c_data *drv_data = i2c_get_adapdata(adap); - int i, rc = 0; + int i, rc; for (i=0; i Date: Fri, 2 Sep 2005 21:28:00 +0200 Subject: [PATCH] I2C: Fix sgi_xfer return value The sgi_xfer function returns 0 on success instead of the number of transfered messages as it is supposed to. This patch fixes that. Let's just hope that no client chip driver was relying on this misbehavior. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/algos/i2c-algo-sgi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/algos/i2c-algo-sgi.c b/drivers/i2c/algos/i2c-algo-sgi.c index 2f8df81317ff..932c4fa86c73 100644 --- a/drivers/i2c/algos/i2c-algo-sgi.c +++ b/drivers/i2c/algos/i2c-algo-sgi.c @@ -149,7 +149,7 @@ static int sgi_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, err = i2c_write(adap, p->buf, p->len); } - return err; + return (err < 0) ? err : i; } static u32 sgi_func(struct i2c_adapter *adap) -- cgit v1.2.2 From f0986bd8f390392948db85dac526fb238752372b Mon Sep 17 00:00:00 2001 From: Jim Cromie Date: Fri, 2 Sep 2005 22:52:43 +0200 Subject: [PATCH] hwmon: (1/3) pc87360 driver update Use the new "dynamic sysfs callbacks", as introduced recently by Yani Ioannou, in pc87360. Note that this change isn't indiscriminate. Only those attributes that would benefit from having an index (i.e., those which are macro-repeated) have been converted. This significantly shrinks the size of the module: before: 49235 drivers/hwmon/pc87360.ko after: 32532 drivers/hwmon/pc87360.ko Signed-off-by: Jim Cromie Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/pc87360.c | 775 +++++++++++++++++++++++++----------------------- 1 file changed, 405 insertions(+), 370 deletions(-) diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c index 08fcb5aea764..2e5a659db58c 100644 --- a/drivers/hwmon/pc87360.c +++ b/drivers/hwmon/pc87360.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -245,7 +246,7 @@ static struct i2c_driver pc87360_driver = { * Sysfs stuff */ -static ssize_t set_fan_min(struct device *dev, const char *buf, +static ssize_t _set_fan_min(struct device *dev, const char *buf, size_t count, int nr) { struct i2c_client *client = to_i2c_client(dev); @@ -274,139 +275,155 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, return count; } +static ssize_t show_fan_input(struct device *dev, struct device_attribute *devattr, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct pc87360_data *data = pc87360_update_device(dev); + return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan[attr->index-1], + FAN_DIV_FROM_REG(data->fan_status[attr->index-1]))); +} +static ssize_t show_fan_min(struct device *dev, struct device_attribute *devattr, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct pc87360_data *data = pc87360_update_device(dev); + return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan_min[attr->index-1], + FAN_DIV_FROM_REG(data->fan_status[attr->index-1]))); +} +static ssize_t show_fan_div(struct device *dev, struct device_attribute *devattr, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct pc87360_data *data = pc87360_update_device(dev); + return sprintf(buf, "%u\n", + FAN_DIV_FROM_REG(data->fan_status[attr->index-1])); +} +static ssize_t show_fan_status(struct device *dev, struct device_attribute *devattr, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct pc87360_data *data = pc87360_update_device(dev); + return sprintf(buf, "%u\n", + FAN_STATUS_FROM_REG(data->fan_status[attr->index-1])); +} +static ssize_t set_fan_min(struct device *dev, struct device_attribute *devattr, const char *buf, + size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + return _set_fan_min(dev, buf, count, attr->index-1); +} + #define show_and_set_fan(offset) \ -static ssize_t show_fan##offset##_input(struct device *dev, struct device_attribute *attr, char *buf) \ -{ \ - struct pc87360_data *data = pc87360_update_device(dev); \ - return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan[offset-1], \ - FAN_DIV_FROM_REG(data->fan_status[offset-1]))); \ -} \ -static ssize_t show_fan##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \ -{ \ - struct pc87360_data *data = pc87360_update_device(dev); \ - return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan_min[offset-1], \ - FAN_DIV_FROM_REG(data->fan_status[offset-1]))); \ -} \ -static ssize_t show_fan##offset##_div(struct device *dev, struct device_attribute *attr, char *buf) \ -{ \ - struct pc87360_data *data = pc87360_update_device(dev); \ - return sprintf(buf, "%u\n", \ - FAN_DIV_FROM_REG(data->fan_status[offset-1])); \ -} \ -static ssize_t show_fan##offset##_status(struct device *dev, struct device_attribute *attr, char *buf) \ -{ \ - struct pc87360_data *data = pc87360_update_device(dev); \ - return sprintf(buf, "%u\n", \ - FAN_STATUS_FROM_REG(data->fan_status[offset-1])); \ -} \ -static ssize_t set_fan##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \ - size_t count) \ -{ \ - return set_fan_min(dev, buf, count, offset-1); \ -} \ -static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ - show_fan##offset##_input, NULL); \ -static DEVICE_ATTR(fan##offset##_min, S_IWUSR | S_IRUGO, \ - show_fan##offset##_min, set_fan##offset##_min); \ -static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \ - show_fan##offset##_div, NULL); \ -static DEVICE_ATTR(fan##offset##_status, S_IRUGO, \ - show_fan##offset##_status, NULL); +static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ + show_fan_input, NULL, offset); \ +static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IWUSR | S_IRUGO, \ + show_fan_min, set_fan_min, offset); \ +static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO, \ + show_fan_div, NULL, offset); \ +static SENSOR_DEVICE_ATTR(fan##offset##_status, S_IRUGO, \ + show_fan_status, NULL, offset); show_and_set_fan(1) show_and_set_fan(2) show_and_set_fan(3) +static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct pc87360_data *data = pc87360_update_device(dev); + return sprintf(buf, "%u\n", + PWM_FROM_REG(data->pwm[attr->index-1], + FAN_CONFIG_INVERT(data->fan_conf, + attr->index-1))); +} +static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr, const char *buf, + size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct pc87360_data *data = i2c_get_clientdata(client); + long val = simple_strtol(buf, NULL, 10); + + down(&data->update_lock); + data->pwm[attr->index-1] = PWM_TO_REG(val, + FAN_CONFIG_INVERT(data->fan_conf, attr->index-1)); + pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_PWM(attr->index-1), + data->pwm[attr->index-1]); + up(&data->update_lock); + return count; +} + #define show_and_set_pwm(offset) \ -static ssize_t show_pwm##offset(struct device *dev, struct device_attribute *attr, char *buf) \ -{ \ - struct pc87360_data *data = pc87360_update_device(dev); \ - return sprintf(buf, "%u\n", \ - PWM_FROM_REG(data->pwm[offset-1], \ - FAN_CONFIG_INVERT(data->fan_conf, \ - offset-1))); \ -} \ -static ssize_t set_pwm##offset(struct device *dev, struct device_attribute *attr, const char *buf, \ - size_t count) \ -{ \ - struct i2c_client *client = to_i2c_client(dev); \ - struct pc87360_data *data = i2c_get_clientdata(client); \ - long val = simple_strtol(buf, NULL, 10); \ - \ - down(&data->update_lock); \ - data->pwm[offset-1] = PWM_TO_REG(val, \ - FAN_CONFIG_INVERT(data->fan_conf, offset-1)); \ - pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_PWM(offset-1), \ - data->pwm[offset-1]); \ - up(&data->update_lock); \ - return count; \ -} \ -static DEVICE_ATTR(pwm##offset, S_IWUSR | S_IRUGO, \ - show_pwm##offset, set_pwm##offset); +static SENSOR_DEVICE_ATTR(pwm##offset, S_IWUSR | S_IRUGO, \ + show_pwm, set_pwm, offset); show_and_set_pwm(1) show_and_set_pwm(2) show_and_set_pwm(3) +static ssize_t show_in_input(struct device *dev, struct device_attribute *devattr, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct pc87360_data *data = pc87360_update_device(dev); + return sprintf(buf, "%u\n", IN_FROM_REG(data->in[attr->index], + data->in_vref)); +} +static ssize_t show_in_min(struct device *dev, struct device_attribute *devattr, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct pc87360_data *data = pc87360_update_device(dev); + return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[attr->index], + data->in_vref)); +} +static ssize_t show_in_max(struct device *dev, struct device_attribute *devattr, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct pc87360_data *data = pc87360_update_device(dev); + return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[attr->index], + data->in_vref)); +} +static ssize_t show_in_status(struct device *dev, struct device_attribute *devattr, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct pc87360_data *data = pc87360_update_device(dev); + return sprintf(buf, "%u\n", data->in_status[attr->index]); +} +static ssize_t set_in_min(struct device *dev, struct device_attribute *devattr, const char *buf, + size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct pc87360_data *data = i2c_get_clientdata(client); + long val = simple_strtol(buf, NULL, 10); + + down(&data->update_lock); + data->in_min[attr->index] = IN_TO_REG(val, data->in_vref); + pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_IN_MIN, + data->in_min[attr->index]); + up(&data->update_lock); + return count; +} +static ssize_t set_in_max(struct device *dev, struct device_attribute *devattr, const char *buf, + size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct pc87360_data *data = i2c_get_clientdata(client); + long val = simple_strtol(buf, NULL, 10); + + down(&data->update_lock); + data->in_max[attr->index] = IN_TO_REG(val, + data->in_vref); + pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_IN_MAX, + data->in_max[attr->index]); + up(&data->update_lock); + return count; +} + #define show_and_set_in(offset) \ -static ssize_t show_in##offset##_input(struct device *dev, struct device_attribute *attr, char *buf) \ -{ \ - struct pc87360_data *data = pc87360_update_device(dev); \ - return sprintf(buf, "%u\n", IN_FROM_REG(data->in[offset], \ - data->in_vref)); \ -} \ -static ssize_t show_in##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \ -{ \ - struct pc87360_data *data = pc87360_update_device(dev); \ - return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[offset], \ - data->in_vref)); \ -} \ -static ssize_t show_in##offset##_max(struct device *dev, struct device_attribute *attr, char *buf) \ -{ \ - struct pc87360_data *data = pc87360_update_device(dev); \ - return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[offset], \ - data->in_vref)); \ -} \ -static ssize_t show_in##offset##_status(struct device *dev, struct device_attribute *attr, char *buf) \ -{ \ - struct pc87360_data *data = pc87360_update_device(dev); \ - return sprintf(buf, "%u\n", data->in_status[offset]); \ -} \ -static ssize_t set_in##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \ - size_t count) \ -{ \ - struct i2c_client *client = to_i2c_client(dev); \ - struct pc87360_data *data = i2c_get_clientdata(client); \ - long val = simple_strtol(buf, NULL, 10); \ - \ - down(&data->update_lock); \ - data->in_min[offset] = IN_TO_REG(val, data->in_vref); \ - pc87360_write_value(data, LD_IN, offset, PC87365_REG_IN_MIN, \ - data->in_min[offset]); \ - up(&data->update_lock); \ - return count; \ -} \ -static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \ - size_t count) \ -{ \ - struct i2c_client *client = to_i2c_client(dev); \ - struct pc87360_data *data = i2c_get_clientdata(client); \ - long val = simple_strtol(buf, NULL, 10); \ - \ - down(&data->update_lock); \ - data->in_max[offset] = IN_TO_REG(val, \ - data->in_vref); \ - pc87360_write_value(data, LD_IN, offset, PC87365_REG_IN_MAX, \ - data->in_max[offset]); \ - up(&data->update_lock); \ - return count; \ -} \ -static DEVICE_ATTR(in##offset##_input, S_IRUGO, \ - show_in##offset##_input, NULL); \ -static DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \ - show_in##offset##_min, set_in##offset##_min); \ -static DEVICE_ATTR(in##offset##_max, S_IWUSR | S_IRUGO, \ - show_in##offset##_max, set_in##offset##_max); \ -static DEVICE_ATTR(in##offset##_status, S_IRUGO, \ - show_in##offset##_status, NULL); +static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ + show_in_input, NULL, offset); \ +static SENSOR_DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \ + show_in_min, set_in_min, offset); \ +static SENSOR_DEVICE_ATTR(in##offset##_max, S_IWUSR | S_IRUGO, \ + show_in_max, set_in_max, offset); \ +static SENSOR_DEVICE_ATTR(in##offset##_status, S_IRUGO, \ + show_in_status, NULL, offset); show_and_set_in(0) show_and_set_in(1) show_and_set_in(2) @@ -419,88 +436,97 @@ show_and_set_in(8) show_and_set_in(9) show_and_set_in(10) +static ssize_t show_therm_input(struct device *dev, struct device_attribute *devattr, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct pc87360_data *data = pc87360_update_device(dev); + return sprintf(buf, "%u\n", IN_FROM_REG(data->in[attr->index+7], + data->in_vref)); +} +static ssize_t show_therm_min(struct device *dev, struct device_attribute *devattr, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct pc87360_data *data = pc87360_update_device(dev); + return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[attr->index+7], + data->in_vref)); +} +static ssize_t show_therm_max(struct device *dev, struct device_attribute *devattr, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct pc87360_data *data = pc87360_update_device(dev); + return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[attr->index+7], + data->in_vref)); +} +static ssize_t show_therm_crit(struct device *dev, struct device_attribute *devattr, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct pc87360_data *data = pc87360_update_device(dev); + return sprintf(buf, "%u\n", IN_FROM_REG(data->in_crit[attr->index-4], + data->in_vref)); +} +static ssize_t show_therm_status(struct device *dev, struct device_attribute *devattr, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct pc87360_data *data = pc87360_update_device(dev); + return sprintf(buf, "%u\n", data->in_status[attr->index+7]); +} +static ssize_t set_therm_min(struct device *dev, struct device_attribute *devattr, const char *buf, + size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct pc87360_data *data = i2c_get_clientdata(client); + long val = simple_strtol(buf, NULL, 10); + + down(&data->update_lock); + data->in_min[attr->index+7] = IN_TO_REG(val, data->in_vref); + pc87360_write_value(data, LD_IN, attr->index+7, PC87365_REG_TEMP_MIN, + data->in_min[attr->index+7]); + up(&data->update_lock); + return count; +} +static ssize_t set_therm_max(struct device *dev, struct device_attribute *devattr, const char *buf, + size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct pc87360_data *data = i2c_get_clientdata(client); + long val = simple_strtol(buf, NULL, 10); + + down(&data->update_lock); + data->in_max[attr->index+7] = IN_TO_REG(val, data->in_vref); + pc87360_write_value(data, LD_IN, attr->index+7, PC87365_REG_TEMP_MAX, + data->in_max[attr->index+7]); + up(&data->update_lock); + return count; +} +static ssize_t set_therm_crit(struct device *dev, struct device_attribute *devattr, const char *buf, + size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct pc87360_data *data = i2c_get_clientdata(client); + long val = simple_strtol(buf, NULL, 10); + + down(&data->update_lock); + data->in_crit[attr->index-4] = IN_TO_REG(val, data->in_vref); + pc87360_write_value(data, LD_IN, attr->index+7, PC87365_REG_TEMP_CRIT, + data->in_crit[attr->index-4]); + up(&data->update_lock); + return count; +} + #define show_and_set_therm(offset) \ -static ssize_t show_temp##offset##_input(struct device *dev, struct device_attribute *attr, char *buf) \ -{ \ - struct pc87360_data *data = pc87360_update_device(dev); \ - return sprintf(buf, "%u\n", IN_FROM_REG(data->in[offset+7], \ - data->in_vref)); \ -} \ -static ssize_t show_temp##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \ -{ \ - struct pc87360_data *data = pc87360_update_device(dev); \ - return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[offset+7], \ - data->in_vref)); \ -} \ -static ssize_t show_temp##offset##_max(struct device *dev, struct device_attribute *attr, char *buf) \ -{ \ - struct pc87360_data *data = pc87360_update_device(dev); \ - return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[offset+7], \ - data->in_vref)); \ -} \ -static ssize_t show_temp##offset##_crit(struct device *dev, struct device_attribute *attr, char *buf) \ -{ \ - struct pc87360_data *data = pc87360_update_device(dev); \ - return sprintf(buf, "%u\n", IN_FROM_REG(data->in_crit[offset-4], \ - data->in_vref)); \ -} \ -static ssize_t show_temp##offset##_status(struct device *dev, struct device_attribute *attr, char *buf) \ -{ \ - struct pc87360_data *data = pc87360_update_device(dev); \ - return sprintf(buf, "%u\n", data->in_status[offset+7]); \ -} \ -static ssize_t set_temp##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \ - size_t count) \ -{ \ - struct i2c_client *client = to_i2c_client(dev); \ - struct pc87360_data *data = i2c_get_clientdata(client); \ - long val = simple_strtol(buf, NULL, 10); \ - \ - down(&data->update_lock); \ - data->in_min[offset+7] = IN_TO_REG(val, data->in_vref); \ - pc87360_write_value(data, LD_IN, offset+7, PC87365_REG_TEMP_MIN, \ - data->in_min[offset+7]); \ - up(&data->update_lock); \ - return count; \ -} \ -static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \ - size_t count) \ -{ \ - struct i2c_client *client = to_i2c_client(dev); \ - struct pc87360_data *data = i2c_get_clientdata(client); \ - long val = simple_strtol(buf, NULL, 10); \ - \ - down(&data->update_lock); \ - data->in_max[offset+7] = IN_TO_REG(val, data->in_vref); \ - pc87360_write_value(data, LD_IN, offset+7, PC87365_REG_TEMP_MAX, \ - data->in_max[offset+7]); \ - up(&data->update_lock); \ - return count; \ -} \ -static ssize_t set_temp##offset##_crit(struct device *dev, struct device_attribute *attr, const char *buf, \ - size_t count) \ -{ \ - struct i2c_client *client = to_i2c_client(dev); \ - struct pc87360_data *data = i2c_get_clientdata(client); \ - long val = simple_strtol(buf, NULL, 10); \ - \ - down(&data->update_lock); \ - data->in_crit[offset-4] = IN_TO_REG(val, data->in_vref); \ - pc87360_write_value(data, LD_IN, offset+7, PC87365_REG_TEMP_CRIT, \ - data->in_crit[offset-4]); \ - up(&data->update_lock); \ - return count; \ -} \ -static DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ - show_temp##offset##_input, NULL); \ -static DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \ - show_temp##offset##_min, set_temp##offset##_min); \ -static DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \ - show_temp##offset##_max, set_temp##offset##_max); \ -static DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \ - show_temp##offset##_crit, set_temp##offset##_crit); \ -static DEVICE_ATTR(temp##offset##_status, S_IRUGO, \ - show_temp##offset##_status, NULL); +static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ + show_therm_input, NULL, offset); \ +static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \ + show_therm_min, set_therm_min, offset); \ +static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \ + show_therm_max, set_therm_max, offset); \ +static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \ + show_therm_crit, set_therm_crit, offset); \ +static SENSOR_DEVICE_ATTR(temp##offset##_status, S_IRUGO, \ + show_therm_status, NULL, offset); show_and_set_therm(4) show_and_set_therm(5) show_and_set_therm(6) @@ -533,84 +559,93 @@ static ssize_t show_in_alarms(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR(alarms_in, S_IRUGO, show_in_alarms, NULL); +static ssize_t show_temp_input(struct device *dev, struct device_attribute *devattr, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct pc87360_data *data = pc87360_update_device(dev); + return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[attr->index-1])); +} +static ssize_t show_temp_min(struct device *dev, struct device_attribute *devattr, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct pc87360_data *data = pc87360_update_device(dev); + return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[attr->index-1])); +} +static ssize_t show_temp_max(struct device *dev, struct device_attribute *devattr, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct pc87360_data *data = pc87360_update_device(dev); + return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[attr->index-1])); +} +static ssize_t show_temp_crit(struct device *dev, struct device_attribute *devattr, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct pc87360_data *data = pc87360_update_device(dev); + return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit[attr->index-1])); +} +static ssize_t show_temp_status(struct device *dev, struct device_attribute *devattr, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct pc87360_data *data = pc87360_update_device(dev); + return sprintf(buf, "%d\n", data->temp_status[attr->index-1]); +} +static ssize_t set_temp_min(struct device *dev, struct device_attribute *devattr, const char *buf, + size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct pc87360_data *data = i2c_get_clientdata(client); + long val = simple_strtol(buf, NULL, 10); + + down(&data->update_lock); + data->temp_min[attr->index-1] = TEMP_TO_REG(val); + pc87360_write_value(data, LD_TEMP, attr->index-1, PC87365_REG_TEMP_MIN, + data->temp_min[attr->index-1]); + up(&data->update_lock); + return count; +} +static ssize_t set_temp_max(struct device *dev, struct device_attribute *devattr, const char *buf, + size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct pc87360_data *data = i2c_get_clientdata(client); + long val = simple_strtol(buf, NULL, 10); + + down(&data->update_lock); + data->temp_max[attr->index-1] = TEMP_TO_REG(val); + pc87360_write_value(data, LD_TEMP, attr->index-1, PC87365_REG_TEMP_MAX, + data->temp_max[attr->index-1]); + up(&data->update_lock); + return count; +} +static ssize_t set_temp_crit(struct device *dev, struct device_attribute *devattr, const char *buf, + size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct pc87360_data *data = i2c_get_clientdata(client); + long val = simple_strtol(buf, NULL, 10); + + down(&data->update_lock); + data->temp_crit[attr->index-1] = TEMP_TO_REG(val); + pc87360_write_value(data, LD_TEMP, attr->index-1, PC87365_REG_TEMP_CRIT, + data->temp_crit[attr->index-1]); + up(&data->update_lock); + return count; +} + #define show_and_set_temp(offset) \ -static ssize_t show_temp##offset##_input(struct device *dev, struct device_attribute *attr, char *buf) \ -{ \ - struct pc87360_data *data = pc87360_update_device(dev); \ - return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[offset-1])); \ -} \ -static ssize_t show_temp##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \ -{ \ - struct pc87360_data *data = pc87360_update_device(dev); \ - return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[offset-1])); \ -} \ -static ssize_t show_temp##offset##_max(struct device *dev, struct device_attribute *attr, char *buf) \ -{ \ - struct pc87360_data *data = pc87360_update_device(dev); \ - return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[offset-1])); \ -}\ -static ssize_t show_temp##offset##_crit(struct device *dev, struct device_attribute *attr, char *buf) \ -{ \ - struct pc87360_data *data = pc87360_update_device(dev); \ - return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit[offset-1])); \ -}\ -static ssize_t show_temp##offset##_status(struct device *dev, struct device_attribute *attr, char *buf) \ -{ \ - struct pc87360_data *data = pc87360_update_device(dev); \ - return sprintf(buf, "%d\n", data->temp_status[offset-1]); \ -}\ -static ssize_t set_temp##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \ - size_t count) \ -{ \ - struct i2c_client *client = to_i2c_client(dev); \ - struct pc87360_data *data = i2c_get_clientdata(client); \ - long val = simple_strtol(buf, NULL, 10); \ - \ - down(&data->update_lock); \ - data->temp_min[offset-1] = TEMP_TO_REG(val); \ - pc87360_write_value(data, LD_TEMP, offset-1, PC87365_REG_TEMP_MIN, \ - data->temp_min[offset-1]); \ - up(&data->update_lock); \ - return count; \ -} \ -static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \ - size_t count) \ -{ \ - struct i2c_client *client = to_i2c_client(dev); \ - struct pc87360_data *data = i2c_get_clientdata(client); \ - long val = simple_strtol(buf, NULL, 10); \ - \ - down(&data->update_lock); \ - data->temp_max[offset-1] = TEMP_TO_REG(val); \ - pc87360_write_value(data, LD_TEMP, offset-1, PC87365_REG_TEMP_MAX, \ - data->temp_max[offset-1]); \ - up(&data->update_lock); \ - return count; \ -} \ -static ssize_t set_temp##offset##_crit(struct device *dev, struct device_attribute *attr, const char *buf, \ - size_t count) \ -{ \ - struct i2c_client *client = to_i2c_client(dev); \ - struct pc87360_data *data = i2c_get_clientdata(client); \ - long val = simple_strtol(buf, NULL, 10); \ - \ - down(&data->update_lock); \ - data->temp_crit[offset-1] = TEMP_TO_REG(val); \ - pc87360_write_value(data, LD_TEMP, offset-1, PC87365_REG_TEMP_CRIT, \ - data->temp_crit[offset-1]); \ - up(&data->update_lock); \ - return count; \ -} \ -static DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ - show_temp##offset##_input, NULL); \ -static DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \ - show_temp##offset##_min, set_temp##offset##_min); \ -static DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \ - show_temp##offset##_max, set_temp##offset##_max); \ -static DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \ - show_temp##offset##_crit, set_temp##offset##_crit); \ -static DEVICE_ATTR(temp##offset##_status, S_IRUGO, \ - show_temp##offset##_status, NULL); +static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ + show_temp_input, NULL, offset); \ +static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \ + show_temp_min, set_temp_min, offset); \ +static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \ + show_temp_max, set_temp_max, offset); \ +static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \ + show_temp_crit, set_temp_crit, offset); \ +static SENSOR_DEVICE_ATTR(temp##offset##_status, S_IRUGO, \ + show_temp_status, NULL, offset); show_and_set_temp(1) show_and_set_temp(2) show_and_set_temp(3) @@ -829,50 +864,50 @@ static int pc87360_detect(struct i2c_adapter *adapter) } if (data->innr) { - device_create_file(&new_client->dev, &dev_attr_in0_input); - device_create_file(&new_client->dev, &dev_attr_in1_input); - device_create_file(&new_client->dev, &dev_attr_in2_input); - device_create_file(&new_client->dev, &dev_attr_in3_input); - device_create_file(&new_client->dev, &dev_attr_in4_input); - device_create_file(&new_client->dev, &dev_attr_in5_input); - device_create_file(&new_client->dev, &dev_attr_in6_input); - device_create_file(&new_client->dev, &dev_attr_in7_input); - device_create_file(&new_client->dev, &dev_attr_in8_input); - device_create_file(&new_client->dev, &dev_attr_in9_input); - device_create_file(&new_client->dev, &dev_attr_in10_input); - device_create_file(&new_client->dev, &dev_attr_in0_min); - device_create_file(&new_client->dev, &dev_attr_in1_min); - device_create_file(&new_client->dev, &dev_attr_in2_min); - device_create_file(&new_client->dev, &dev_attr_in3_min); - device_create_file(&new_client->dev, &dev_attr_in4_min); - device_create_file(&new_client->dev, &dev_attr_in5_min); - device_create_file(&new_client->dev, &dev_attr_in6_min); - device_create_file(&new_client->dev, &dev_attr_in7_min); - device_create_file(&new_client->dev, &dev_attr_in8_min); - device_create_file(&new_client->dev, &dev_attr_in9_min); - device_create_file(&new_client->dev, &dev_attr_in10_min); - device_create_file(&new_client->dev, &dev_attr_in0_max); - device_create_file(&new_client->dev, &dev_attr_in1_max); - device_create_file(&new_client->dev, &dev_attr_in2_max); - device_create_file(&new_client->dev, &dev_attr_in3_max); - device_create_file(&new_client->dev, &dev_attr_in4_max); - device_create_file(&new_client->dev, &dev_attr_in5_max); - device_create_file(&new_client->dev, &dev_attr_in6_max); - device_create_file(&new_client->dev, &dev_attr_in7_max); - device_create_file(&new_client->dev, &dev_attr_in8_max); - device_create_file(&new_client->dev, &dev_attr_in9_max); - device_create_file(&new_client->dev, &dev_attr_in10_max); - device_create_file(&new_client->dev, &dev_attr_in0_status); - device_create_file(&new_client->dev, &dev_attr_in1_status); - device_create_file(&new_client->dev, &dev_attr_in2_status); - device_create_file(&new_client->dev, &dev_attr_in3_status); - device_create_file(&new_client->dev, &dev_attr_in4_status); - device_create_file(&new_client->dev, &dev_attr_in5_status); - device_create_file(&new_client->dev, &dev_attr_in6_status); - device_create_file(&new_client->dev, &dev_attr_in7_status); - device_create_file(&new_client->dev, &dev_attr_in8_status); - device_create_file(&new_client->dev, &dev_attr_in9_status); - device_create_file(&new_client->dev, &dev_attr_in10_status); + device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in1_input.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in2_input.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in3_input.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in4_input.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in5_input.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in6_input.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in7_input.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in8_input.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in9_input.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in10_input.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in0_min.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in1_min.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in2_min.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in3_min.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in4_min.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in5_min.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in6_min.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in7_min.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in8_min.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in9_min.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in10_min.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in0_max.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in1_max.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in2_max.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in3_max.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in4_max.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in5_max.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in6_max.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in7_max.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in8_max.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in9_max.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in10_max.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in0_status.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in1_status.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in2_status.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in3_status.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in4_status.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in5_status.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in6_status.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in7_status.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in8_status.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in9_status.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_in10_status.dev_attr); device_create_file(&new_client->dev, &dev_attr_cpu0_vid); device_create_file(&new_client->dev, &dev_attr_vrm); @@ -880,86 +915,86 @@ static int pc87360_detect(struct i2c_adapter *adapter) } if (data->tempnr) { - device_create_file(&new_client->dev, &dev_attr_temp1_input); - device_create_file(&new_client->dev, &dev_attr_temp2_input); - device_create_file(&new_client->dev, &dev_attr_temp1_min); - device_create_file(&new_client->dev, &dev_attr_temp2_min); - device_create_file(&new_client->dev, &dev_attr_temp1_max); - device_create_file(&new_client->dev, &dev_attr_temp2_max); - device_create_file(&new_client->dev, &dev_attr_temp1_crit); - device_create_file(&new_client->dev, &dev_attr_temp2_crit); - device_create_file(&new_client->dev, &dev_attr_temp1_status); - device_create_file(&new_client->dev, &dev_attr_temp2_status); + device_create_file(&new_client->dev, &sensor_dev_attr_temp1_input.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_temp2_input.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_temp1_min.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_temp2_min.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_temp1_max.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_temp2_max.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_temp1_crit.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_temp2_crit.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_temp1_status.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_temp2_status.dev_attr); device_create_file(&new_client->dev, &dev_attr_alarms_temp); } if (data->tempnr == 3) { - device_create_file(&new_client->dev, &dev_attr_temp3_input); - device_create_file(&new_client->dev, &dev_attr_temp3_min); - device_create_file(&new_client->dev, &dev_attr_temp3_max); - device_create_file(&new_client->dev, &dev_attr_temp3_crit); - device_create_file(&new_client->dev, &dev_attr_temp3_status); + device_create_file(&new_client->dev, &sensor_dev_attr_temp3_input.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_temp3_min.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_temp3_max.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_temp3_crit.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_temp3_status.dev_attr); } if (data->innr == 14) { - device_create_file(&new_client->dev, &dev_attr_temp4_input); - device_create_file(&new_client->dev, &dev_attr_temp5_input); - device_create_file(&new_client->dev, &dev_attr_temp6_input); - device_create_file(&new_client->dev, &dev_attr_temp4_min); - device_create_file(&new_client->dev, &dev_attr_temp5_min); - device_create_file(&new_client->dev, &dev_attr_temp6_min); - device_create_file(&new_client->dev, &dev_attr_temp4_max); - device_create_file(&new_client->dev, &dev_attr_temp5_max); - device_create_file(&new_client->dev, &dev_attr_temp6_max); - device_create_file(&new_client->dev, &dev_attr_temp4_crit); - device_create_file(&new_client->dev, &dev_attr_temp5_crit); - device_create_file(&new_client->dev, &dev_attr_temp6_crit); - device_create_file(&new_client->dev, &dev_attr_temp4_status); - device_create_file(&new_client->dev, &dev_attr_temp5_status); - device_create_file(&new_client->dev, &dev_attr_temp6_status); + device_create_file(&new_client->dev, &sensor_dev_attr_temp4_input.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_temp5_input.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_temp6_input.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_temp4_min.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_temp5_min.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_temp6_min.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_temp4_max.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_temp5_max.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_temp6_max.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_temp4_crit.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_temp5_crit.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_temp6_crit.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_temp4_status.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_temp5_status.dev_attr); + device_create_file(&new_client->dev, &sensor_dev_attr_temp6_status.dev_attr); } if (data->fannr) { if (FAN_CONFIG_MONITOR(data->fan_conf, 0)) { device_create_file(&new_client->dev, - &dev_attr_fan1_input); + &sensor_dev_attr_fan1_input.dev_attr); device_create_file(&new_client->dev, - &dev_attr_fan1_min); + &sensor_dev_attr_fan1_min.dev_attr); device_create_file(&new_client->dev, - &dev_attr_fan1_div); + &sensor_dev_attr_fan1_div.dev_attr); device_create_file(&new_client->dev, - &dev_attr_fan1_status); + &sensor_dev_attr_fan1_status.dev_attr); } if (FAN_CONFIG_MONITOR(data->fan_conf, 1)) { device_create_file(&new_client->dev, - &dev_attr_fan2_input); + &sensor_dev_attr_fan2_input.dev_attr); device_create_file(&new_client->dev, - &dev_attr_fan2_min); + &sensor_dev_attr_fan2_min.dev_attr); device_create_file(&new_client->dev, - &dev_attr_fan2_div); + &sensor_dev_attr_fan2_div.dev_attr); device_create_file(&new_client->dev, - &dev_attr_fan2_status); + &sensor_dev_attr_fan2_status.dev_attr); } if (FAN_CONFIG_CONTROL(data->fan_conf, 0)) - device_create_file(&new_client->dev, &dev_attr_pwm1); + device_create_file(&new_client->dev, &sensor_dev_attr_pwm1.dev_attr); if (FAN_CONFIG_CONTROL(data->fan_conf, 1)) - device_create_file(&new_client->dev, &dev_attr_pwm2); + device_create_file(&new_client->dev, &sensor_dev_attr_pwm2.dev_attr); } if (data->fannr == 3) { if (FAN_CONFIG_MONITOR(data->fan_conf, 2)) { device_create_file(&new_client->dev, - &dev_attr_fan3_input); + &sensor_dev_attr_fan3_input.dev_attr); device_create_file(&new_client->dev, - &dev_attr_fan3_min); + &sensor_dev_attr_fan3_min.dev_attr); device_create_file(&new_client->dev, - &dev_attr_fan3_div); + &sensor_dev_attr_fan3_div.dev_attr); device_create_file(&new_client->dev, - &dev_attr_fan3_status); + &sensor_dev_attr_fan3_status.dev_attr); } if (FAN_CONFIG_CONTROL(data->fan_conf, 2)) - device_create_file(&new_client->dev, &dev_attr_pwm3); + device_create_file(&new_client->dev, &sensor_dev_attr_pwm3.dev_attr); } return 0; -- cgit v1.2.2 From 694fa056a60828ef54a5db958468cc600c3b3622 Mon Sep 17 00:00:00 2001 From: Jim Cromie Date: Fri, 2 Sep 2005 22:57:52 +0200 Subject: [PATCH] hwmon: (2/3) pc87360 driver update pc87360: number-skew to init The temp, therm, fan, pwm callbacks all have an offset skew in the code which accommodates attribute numbering conventions under /sys/bus/i2c/devices/9191-6620/ (ie they start at 1) This patch moves that skew into the declaration, and out of the functions (except for therm, where we simplify from 2 skews to 1). The declarative skew is clearer, less error-prone, and more efficient. The use of 11+offset-4 below reflects the fact that the sysfs numbering of these units is 4, 5, 6, but they use internal VLM units 11, 12, 13 to measure the thermistor voltages. There's one remaining skew factor, in *_crit callbacks below, because there are no critical thresholds for voltages 0-10, only for those supporting the thermistors. Signed-off-by: Jim Cromie Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/pc87360.c | 112 ++++++++++++++++++++++++------------------------ 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c index 2e5a659db58c..5e87b2f1f13b 100644 --- a/drivers/hwmon/pc87360.c +++ b/drivers/hwmon/pc87360.c @@ -279,46 +279,46 @@ static ssize_t show_fan_input(struct device *dev, struct device_attribute *devat { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct pc87360_data *data = pc87360_update_device(dev); - return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan[attr->index-1], - FAN_DIV_FROM_REG(data->fan_status[attr->index-1]))); + return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan[attr->index], + FAN_DIV_FROM_REG(data->fan_status[attr->index]))); } static ssize_t show_fan_min(struct device *dev, struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct pc87360_data *data = pc87360_update_device(dev); - return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan_min[attr->index-1], - FAN_DIV_FROM_REG(data->fan_status[attr->index-1]))); + return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan_min[attr->index], + FAN_DIV_FROM_REG(data->fan_status[attr->index]))); } static ssize_t show_fan_div(struct device *dev, struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct pc87360_data *data = pc87360_update_device(dev); return sprintf(buf, "%u\n", - FAN_DIV_FROM_REG(data->fan_status[attr->index-1])); + FAN_DIV_FROM_REG(data->fan_status[attr->index])); } static ssize_t show_fan_status(struct device *dev, struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct pc87360_data *data = pc87360_update_device(dev); return sprintf(buf, "%u\n", - FAN_STATUS_FROM_REG(data->fan_status[attr->index-1])); + FAN_STATUS_FROM_REG(data->fan_status[attr->index])); } static ssize_t set_fan_min(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - return _set_fan_min(dev, buf, count, attr->index-1); + return _set_fan_min(dev, buf, count, attr->index); } #define show_and_set_fan(offset) \ static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ - show_fan_input, NULL, offset); \ + show_fan_input, NULL, offset-1); \ static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IWUSR | S_IRUGO, \ - show_fan_min, set_fan_min, offset); \ + show_fan_min, set_fan_min, offset-1); \ static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO, \ - show_fan_div, NULL, offset); \ + show_fan_div, NULL, offset-1); \ static SENSOR_DEVICE_ATTR(fan##offset##_status, S_IRUGO, \ - show_fan_status, NULL, offset); + show_fan_status, NULL, offset-1); show_and_set_fan(1) show_and_set_fan(2) show_and_set_fan(3) @@ -328,9 +328,9 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, ch struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct pc87360_data *data = pc87360_update_device(dev); return sprintf(buf, "%u\n", - PWM_FROM_REG(data->pwm[attr->index-1], + PWM_FROM_REG(data->pwm[attr->index], FAN_CONFIG_INVERT(data->fan_conf, - attr->index-1))); + attr->index))); } static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) @@ -341,17 +341,17 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr, con long val = simple_strtol(buf, NULL, 10); down(&data->update_lock); - data->pwm[attr->index-1] = PWM_TO_REG(val, - FAN_CONFIG_INVERT(data->fan_conf, attr->index-1)); - pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_PWM(attr->index-1), - data->pwm[attr->index-1]); + data->pwm[attr->index] = PWM_TO_REG(val, + FAN_CONFIG_INVERT(data->fan_conf, attr->index)); + pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_PWM(attr->index), + data->pwm[attr->index]); up(&data->update_lock); return count; } #define show_and_set_pwm(offset) \ static SENSOR_DEVICE_ATTR(pwm##offset, S_IWUSR | S_IRUGO, \ - show_pwm, set_pwm, offset); + show_pwm, set_pwm, offset-1); show_and_set_pwm(1) show_and_set_pwm(2) show_and_set_pwm(3) @@ -440,35 +440,35 @@ static ssize_t show_therm_input(struct device *dev, struct device_attribute *dev { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct pc87360_data *data = pc87360_update_device(dev); - return sprintf(buf, "%u\n", IN_FROM_REG(data->in[attr->index+7], + return sprintf(buf, "%u\n", IN_FROM_REG(data->in[attr->index], data->in_vref)); } static ssize_t show_therm_min(struct device *dev, struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct pc87360_data *data = pc87360_update_device(dev); - return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[attr->index+7], + return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[attr->index], data->in_vref)); } static ssize_t show_therm_max(struct device *dev, struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct pc87360_data *data = pc87360_update_device(dev); - return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[attr->index+7], + return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[attr->index], data->in_vref)); } static ssize_t show_therm_crit(struct device *dev, struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct pc87360_data *data = pc87360_update_device(dev); - return sprintf(buf, "%u\n", IN_FROM_REG(data->in_crit[attr->index-4], + return sprintf(buf, "%u\n", IN_FROM_REG(data->in_crit[attr->index-11], data->in_vref)); } static ssize_t show_therm_status(struct device *dev, struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct pc87360_data *data = pc87360_update_device(dev); - return sprintf(buf, "%u\n", data->in_status[attr->index+7]); + return sprintf(buf, "%u\n", data->in_status[attr->index]); } static ssize_t set_therm_min(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) @@ -479,9 +479,9 @@ static ssize_t set_therm_min(struct device *dev, struct device_attribute *devatt long val = simple_strtol(buf, NULL, 10); down(&data->update_lock); - data->in_min[attr->index+7] = IN_TO_REG(val, data->in_vref); - pc87360_write_value(data, LD_IN, attr->index+7, PC87365_REG_TEMP_MIN, - data->in_min[attr->index+7]); + data->in_min[attr->index] = IN_TO_REG(val, data->in_vref); + pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_MIN, + data->in_min[attr->index]); up(&data->update_lock); return count; } @@ -494,9 +494,9 @@ static ssize_t set_therm_max(struct device *dev, struct device_attribute *devatt long val = simple_strtol(buf, NULL, 10); down(&data->update_lock); - data->in_max[attr->index+7] = IN_TO_REG(val, data->in_vref); - pc87360_write_value(data, LD_IN, attr->index+7, PC87365_REG_TEMP_MAX, - data->in_max[attr->index+7]); + data->in_max[attr->index] = IN_TO_REG(val, data->in_vref); + pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_MAX, + data->in_max[attr->index]); up(&data->update_lock); return count; } @@ -509,24 +509,24 @@ static ssize_t set_therm_crit(struct device *dev, struct device_attribute *devat long val = simple_strtol(buf, NULL, 10); down(&data->update_lock); - data->in_crit[attr->index-4] = IN_TO_REG(val, data->in_vref); - pc87360_write_value(data, LD_IN, attr->index+7, PC87365_REG_TEMP_CRIT, - data->in_crit[attr->index-4]); + data->in_crit[attr->index-11] = IN_TO_REG(val, data->in_vref); + pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_CRIT, + data->in_crit[attr->index-11]); up(&data->update_lock); return count; } #define show_and_set_therm(offset) \ static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ - show_therm_input, NULL, offset); \ + show_therm_input, NULL, 11+offset-4); \ static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \ - show_therm_min, set_therm_min, offset); \ + show_therm_min, set_therm_min, 11+offset-4); \ static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \ - show_therm_max, set_therm_max, offset); \ + show_therm_max, set_therm_max, 11+offset-4); \ static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \ - show_therm_crit, set_therm_crit, offset); \ + show_therm_crit, set_therm_crit, 11+offset-4); \ static SENSOR_DEVICE_ATTR(temp##offset##_status, S_IRUGO, \ - show_therm_status, NULL, offset); + show_therm_status, NULL, 11+offset-4); show_and_set_therm(4) show_and_set_therm(5) show_and_set_therm(6) @@ -563,31 +563,31 @@ static ssize_t show_temp_input(struct device *dev, struct device_attribute *deva { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct pc87360_data *data = pc87360_update_device(dev); - return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[attr->index-1])); + return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[attr->index])); } static ssize_t show_temp_min(struct device *dev, struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct pc87360_data *data = pc87360_update_device(dev); - return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[attr->index-1])); + return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[attr->index])); } static ssize_t show_temp_max(struct device *dev, struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct pc87360_data *data = pc87360_update_device(dev); - return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[attr->index-1])); + return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[attr->index])); } static ssize_t show_temp_crit(struct device *dev, struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct pc87360_data *data = pc87360_update_device(dev); - return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit[attr->index-1])); + return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit[attr->index])); } static ssize_t show_temp_status(struct device *dev, struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct pc87360_data *data = pc87360_update_device(dev); - return sprintf(buf, "%d\n", data->temp_status[attr->index-1]); + return sprintf(buf, "%d\n", data->temp_status[attr->index]); } static ssize_t set_temp_min(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) @@ -598,9 +598,9 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *devattr long val = simple_strtol(buf, NULL, 10); down(&data->update_lock); - data->temp_min[attr->index-1] = TEMP_TO_REG(val); - pc87360_write_value(data, LD_TEMP, attr->index-1, PC87365_REG_TEMP_MIN, - data->temp_min[attr->index-1]); + data->temp_min[attr->index] = TEMP_TO_REG(val); + pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_MIN, + data->temp_min[attr->index]); up(&data->update_lock); return count; } @@ -613,9 +613,9 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *devattr long val = simple_strtol(buf, NULL, 10); down(&data->update_lock); - data->temp_max[attr->index-1] = TEMP_TO_REG(val); - pc87360_write_value(data, LD_TEMP, attr->index-1, PC87365_REG_TEMP_MAX, - data->temp_max[attr->index-1]); + data->temp_max[attr->index] = TEMP_TO_REG(val); + pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_MAX, + data->temp_max[attr->index]); up(&data->update_lock); return count; } @@ -628,24 +628,24 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *devatt long val = simple_strtol(buf, NULL, 10); down(&data->update_lock); - data->temp_crit[attr->index-1] = TEMP_TO_REG(val); - pc87360_write_value(data, LD_TEMP, attr->index-1, PC87365_REG_TEMP_CRIT, - data->temp_crit[attr->index-1]); + data->temp_crit[attr->index] = TEMP_TO_REG(val); + pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_CRIT, + data->temp_crit[attr->index]); up(&data->update_lock); return count; } #define show_and_set_temp(offset) \ static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ - show_temp_input, NULL, offset); \ + show_temp_input, NULL, offset-1); \ static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \ - show_temp_min, set_temp_min, offset); \ + show_temp_min, set_temp_min, offset-1); \ static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \ - show_temp_max, set_temp_max, offset); \ + show_temp_max, set_temp_max, offset-1); \ static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \ - show_temp_crit, set_temp_crit, offset); \ + show_temp_crit, set_temp_crit, offset-1); \ static SENSOR_DEVICE_ATTR(temp##offset##_status, S_IRUGO, \ - show_temp_status, NULL, offset); + show_temp_status, NULL, offset-1); show_and_set_temp(1) show_and_set_temp(2) show_and_set_temp(3) -- cgit v1.2.2 From 11be27ea9bfd0ea7bca797ba6937285d18d426c2 Mon Sep 17 00:00:00 2001 From: Jim Cromie Date: Fri, 2 Sep 2005 23:05:07 +0200 Subject: [PATCH] hwmon: (3/3) pc87360 driver update pc87360: consolidate fan helper This patch consolidates the _set_fan_min() helper routine into the 2 line sysfs-callback wrapper that uses it. Signed-off-by: Jim Cromie Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/pc87360.c | 54 ++++++++++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c index 5e87b2f1f13b..cf2a35799c7c 100644 --- a/drivers/hwmon/pc87360.c +++ b/drivers/hwmon/pc87360.c @@ -246,35 +246,6 @@ static struct i2c_driver pc87360_driver = { * Sysfs stuff */ -static ssize_t _set_fan_min(struct device *dev, const char *buf, - size_t count, int nr) -{ - struct i2c_client *client = to_i2c_client(dev); - struct pc87360_data *data = i2c_get_clientdata(client); - long fan_min = simple_strtol(buf, NULL, 10); - - down(&data->update_lock); - fan_min = FAN_TO_REG(fan_min, FAN_DIV_FROM_REG(data->fan_status[nr])); - - /* If it wouldn't fit, change clock divisor */ - while (fan_min > 255 - && (data->fan_status[nr] & 0x60) != 0x60) { - fan_min >>= 1; - data->fan[nr] >>= 1; - data->fan_status[nr] += 0x20; - } - data->fan_min[nr] = fan_min > 255 ? 255 : fan_min; - pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_MIN(nr), - data->fan_min[nr]); - - /* Write new divider, preserve alarm bits */ - pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_STATUS(nr), - data->fan_status[nr] & 0xF9); - up(&data->update_lock); - - return count; -} - static ssize_t show_fan_input(struct device *dev, struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); @@ -307,7 +278,30 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *devattr, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - return _set_fan_min(dev, buf, count, attr->index); + struct i2c_client *client = to_i2c_client(dev); + struct pc87360_data *data = i2c_get_clientdata(client); + long fan_min = simple_strtol(buf, NULL, 10); + + down(&data->update_lock); + fan_min = FAN_TO_REG(fan_min, FAN_DIV_FROM_REG(data->fan_status[attr->index])); + + /* If it wouldn't fit, change clock divisor */ + while (fan_min > 255 + && (data->fan_status[attr->index] & 0x60) != 0x60) { + fan_min >>= 1; + data->fan[attr->index] >>= 1; + data->fan_status[attr->index] += 0x20; + } + data->fan_min[attr->index] = fan_min > 255 ? 255 : fan_min; + pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_MIN(attr->index), + data->fan_min[attr->index]); + + /* Write new divider, preserve alarm bits */ + pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_STATUS(attr->index), + data->fan_status[attr->index] & 0xF9); + up(&data->update_lock); + + return count; } #define show_and_set_fan(offset) \ -- cgit v1.2.2 From 77ae84554cc0178e03862391599a0cedf96fa4c4 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sat, 3 Sep 2005 10:52:11 +0200 Subject: [PATCH] I2C: Drop the I2C_ACK_TEST ioctl Drop the I2C_ACK_TEST ioctl, which was commented out. It never really existed (not after 1999 anyway), and there is no such thing as a ack test on I2C/SMBus anyway. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- include/linux/i2c.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 1ead5195fde4..be35332b67e6 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -508,9 +508,6 @@ union i2c_smbus_data { #define I2C_FUNCS 0x0705 /* Get the adapter functionality */ #define I2C_RDWR 0x0707 /* Combined R/W transfer (one stop only)*/ #define I2C_PEC 0x0708 /* != 0 for SMBus PEC */ -#if 0 -#define I2C_ACK_TEST 0x0710 /* See if a slave is at a specific address */ -#endif #define I2C_SMBUS 0x0720 /* SMBus-level access */ -- cgit v1.2.2