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(-) (limited to 'drivers/i2c/chips') diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c index 0230375f72e..4d4ace4b805 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.3 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(-) (limited to 'drivers/i2c/chips') diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c index 4d4ace4b805..1a7993e6354 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.3 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 ----- 1 file changed, 5 deletions(-) (limited to 'drivers/i2c/chips') diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c index 1a7993e6354..35a8e921529 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) { -- cgit v1.2.3 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(-) (limited to 'drivers/i2c/chips') diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c index 35a8e921529..f0e30623773 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.3 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 --- 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 - 6 files changed, 6 deletions(-) (limited to 'drivers/i2c/chips') diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c index 82cf959989f..6ac0a6e0076 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 a2da31b0dd7..88f83bac384 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 f0e30623773..d1d48586b90 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 9f3ad45daae..c5b052363d9 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 cfcf6465408..7a1fa791463 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 db812ade856..225b512dd4a 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); -- cgit v1.2.3 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 --- 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 +---- 6 files changed, 6 insertions(+), 21 deletions(-) (limited to 'drivers/i2c/chips') diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c index 6ac0a6e0076..8ab4e2348cd 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 88f83bac384..9466ada6893 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 d1d48586b90..52fd6bf2913 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 c5b052363d9..1500b1842ce 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 7a1fa791463..a109dfd3dbe 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 225b512dd4a..7fce0fc048d 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; -- cgit v1.2.3 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 - 3 files changed, 3 deletions(-) (limited to 'drivers/i2c/chips') diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c index a445736d883..e2d1daf7988 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 778d7e12859..e516dadc453 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 588fc2261a9..0b5385c892b 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); -- cgit v1.2.3 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 --- 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 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) (limited to 'drivers/i2c/chips') diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c index 8ab4e2348cd..c612f19fc7e 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 9466ada6893..befac01ecda 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 52fd6bf2913..42663f921ec 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 1500b1842ce..c8ea2a1e1a4 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 a109dfd3dbe..01ec9ce1976 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 7fce0fc048d..dd03f2c725c 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.3 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 --- 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 +-- 6 files changed, 6 insertions(+), 12 deletions(-) (limited to 'drivers/i2c/chips') diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c index c612f19fc7e..9d3175c0339 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 befac01ecda..a27420a54c8 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 42663f921ec..31cee2d34a1 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 c8ea2a1e1a4..225577fdda4 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 01ec9ce1976..6525743ff9f 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 dd03f2c725c..80f1df9a450 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); -- cgit v1.2.3 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 --- drivers/i2c/chips/Kconfig | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'drivers/i2c/chips') diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig index 43f70dbfc03..6bd44a44cd2 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. -- cgit v1.2.3 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 --- drivers/i2c/chips/eeprom.c | 5 ----- drivers/i2c/chips/max6875.c | 5 ----- 2 files changed, 10 deletions(-) (limited to 'drivers/i2c/chips') diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c index a27420a54c8..d58403a4790 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 31cee2d34a1..9e1aeb69abf 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; -- cgit v1.2.3 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(-) (limited to 'drivers/i2c/chips') diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c index e516dadc453..3f14528a52a 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.3 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(-) (limited to 'drivers/i2c/chips') diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c index e2d1daf7988..0936327a946 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.3 From 82ca76b6b160b6fce46f78c069f87fe1a4dc0778 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Tue, 6 Sep 2005 15:18:35 -0700 Subject: [PATCH] drivers: convert kcalloc to kzalloc This patch converts kcalloc(1, ...) calls to use the new kzalloc() function. Signed-off-by: Pekka Enberg Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/i2c/chips/isp1301_omap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/i2c/chips') diff --git a/drivers/i2c/chips/isp1301_omap.c b/drivers/i2c/chips/isp1301_omap.c index 354a2629567..8ee56d4b389 100644 --- a/drivers/i2c/chips/isp1301_omap.c +++ b/drivers/i2c/chips/isp1301_omap.c @@ -1489,7 +1489,7 @@ static int isp1301_probe(struct i2c_adapter *bus, int address, int kind) if (the_transceiver) return 0; - isp = kcalloc(1, sizeof *isp, GFP_KERNEL); + isp = kzalloc(sizeof *isp, GFP_KERNEL); if (!isp) return 0; -- cgit v1.2.3