On Mon, 2004-04-12 at 21:28, Jean Delvare wrote: > > > First of all: which MAX663x chips is the driver for? MAX6629-MAX6632 > > > are non-I2C chips according to Maxim-IC, so I guess it's > > > MAX6633-MAX6635? > > > > MAX663x == any max663*. Maxim-IC produces only MAX6633-MAX6635 devices > > matching this regexp. > > You did not read me carefully. There's a MAX6629-MAX6632 family: > http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2577/ln/en > Same kind of chips, different interface. I don't insist on particular name, this was just for clarification. Will rename it into max6635.c > Which is why I think it's important to clearly state which chips you are > supporting, like you did. > > > > > + * The GNU GPL is contained in /usr/doc/copyright/GPL on a Debian > > > > + * system and in the file COPYING in the Linux kernel source. > > > > > > This doesn't belong to kernel code IMHO. > > > > It does. > > Let me rephrase then. The kernel code is kernel code ;) It doesn't > depend on a distribution. > > The usual GPL disclaimer in front of the file is OK, it's even required. > But your additional "pointer" to the file, especially for a specific > distribution, doesn't make sense and won't be accepted. Remember that > your driver will be part of the lm_sensors project (BTW you header > should mention that, see the other drivers) so neither Debian's > /usr/doc/copyright/GPL not "the file COPYING in the Linux kernel source" > are part of the package. The COPYING file is part of the lm_sensors > package and people pretty well know where it is. Ok, i don't insist on it and will remove footer of copyright note about files. And will add lm_sensors notation. > > > > + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | > > > > I2C_FUNC_SMBUS_WORD_DATA))+ { > > > > + printk(KERN_ERR "Adapter doesn't support functionality.\n"); > > > > + goto error1; > > > > + } > > > > > > That's not an error. As you load an i2c chip driver, all adapters > > > will be scanned. This may include adapters that don't support these > > > functionalities (and so they just can't have a MAX6633 on them). I > > > wouldn't even print a message. > > > > What about situation when chip is connected to unsupported adapter or > > adapter which doesn't provide needed functionality? > > Any reading/writing will confuse bus and reader/writer. > > I think chip should not work if it is not connected to the right > > adapter. > > I don't say that you should skip the test. Just don't make it an error, > i.e. exit in silence. > > The case where the chip is connected to an unsupported (I would say > unsupporting) adapter is a hardware design issue, we are not supposed to > handle that. If you really want to warn the user about it, it has to be > a debug message. > Ok, I have removed this error path, only warning. > > Without explicit fflush() one can't read output just after error with > > our embedded init. > > Or may be i2cdump doesn't like big endian ppc32 and cross-compilation. > > Don't know where exit happens in i2cdump. > > Oh, OK. That's a special system you have here. I guess you also don't > intend to use sensors/libsensors, but only read/write the values through > procfs? Actually this part was created for Linux kernel and community. We use it in a different way. > Will you be able to run sensors-detect to test my detection function on > your samples? Nope. It doesn't have any kind of scripting languages. > I would like you to test the 8-registers cycling in the driver itself. > In your detection function, just read limits registers + 8 and see if > you read the same four values. If can even be better to do that 32 > times, to test the whole range. That's always interesting to ensure that > you are probing the right chip like that, especially when there's no > identification dedicated registers. See lm75.c for an example. 00: 0004 0005 0002 0003 <- registers 00: 000f 0014 000a 0005 08: 0000 0000 0000 0000 10: 000f 0014 000a 0005 18: 0000 0000 0000 0000 20: 000f 0014 000a 0005 28: 0000 0000 0000 0000 30: 000f 0014 000a 0005 38: 0000 0000 0000 0000 40: 000f 0014 000a 0005 48: 0000 0000 0000 0000 50: 000f 0014 000a 0005 58: 0000 0000 0000 0000 60: 000f 0014 000a 0005 68: 0000 0000 0000 0000 70: 000f 0014 000a 0005 78: 0000 0000 0000 0000 80: 0000 0000 0000 0000 88: 0000 0000 0000 0000 90: 0000 0000 0000 0000 98: 0000 0000 0000 0000 a0: 0000 0000 0000 0000 a8: 0000 0000 0000 0000 b0: 0000 0000 0000 0000 b8: 0000 0000 0000 0000 c0: 0000 0000 0000 0000 c8: 0000 0000 0000 0000 d0: 0000 0000 0000 0000 d8: 0000 0000 0000 0000 e0: 0000 0000 0000 0000 e8: 0000 0000 0000 0000 f0: 0000 0000 0000 0000 f8: 0000 0000 0000 0000 > > Actually there is race here, since update may only happen in process > > context but any userspace reading is not protected. > > Now update_lock is using for protecting max663x_data when writing into > > it. > > You're right, our drivers suffer from a race condition (although in most > cases it works fine). We're thinking of a solutions, just need some more > time to implement it. > > > now one can read 5 values and write 4 values: > > read: max, hyst, low, high, temp > > write: max, hyst, low, high. > > OK, fine with me. > > > Please review and comment. > > If all design and technical issues are resloved I will make a patch > > against lm_sensors tree. > > A few more things: > > > +#define reg2temp(temp) ((temp & 0x8000)?(255 - (temp >> 7)):(temp >> 7)) > > +#define temp2reg(temp) ((temp < 0)?(((temp + 255) << 7) | 0x8000):(temp << 7)) > > These conversion functions look broken for negative temperatures, please > check it. And even for positive ones, the ">> 7" looks like you are > working with 9-bit values, while the chip is supposed to handle 12-bit > ones (or even 13 with the sign?). > > Likewise, I'm surprised by the fact that you export the values to > userspace with a single decimal place. If I'm correct and you have 5 > bits for the non-integer part, you're losing a significant part of this > resolution when doing that. Chip uses two's-complement format with 1LSB corresponding to 0.0625 and 1MSB as sign. So with this conversation we lose ~0.5 degree. I just don't know how this accuracy should be presented in current i2c /proc processing. > > + temp_low = swap_bytes(i2c_smbus_read_word_data(client, MAX663x_LOW)); > > + temp_high = swap_bytes(i2c_smbus_read_word_data(client, MAX663x_HIGH)); > > + temp_hyst = swap_bytes(i2c_smbus_read_word_data(client, MAX663x_HYST)); > > + temp_max = swap_bytes(i2c_smbus_read_word_data(client, MAX663x_MAX)); > > + > > + return (!(temp_low & 0x7f) && !(temp_high & 0x7f) && !(temp_hyst & 0x7f) && !(temp_max & 0x7f)); > > You don't need swap_bytes here, if would be faster without it, don't you think? It is called only once in load time, and main idea was to store this values as cache if they are valid. I think it should be implemented in this way, or not? > > error3: > > + max663x_id--; > > kfree(new_client); > > Interesting. None of our drivers do that. Not a big issue though. > > And, again, please mass-rename max663x to max6635 (or any other). We > don't like 'x' in the driver names, function names, constant names, etc. Ok. Thank you. -- Evgeniy Polaykov ( s0mbre ) Crash is better than data corruption. -- Art Grabowski -------------- next part -------------- --- /dev/null 2003-01-30 13:24:37.000000000 +0300 +++ kernel/chips/max6635.c 2004-04-13 12:20:57.000000000 +0400 @@ -0,0 +1,286 @@ +/* + * max6635.c - Part of lm_sensors, Linux kernel modules for hardware monitoring. + * + * 2003-2004 Copyright (c) Evgeniy Polyakov <johnpol at 2ka.mipt.ru> + * All rights reserved. + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +/* + * Driver for Maxim-IC MAX6633, MAX6634, MAX6635 temperature sensors. + */ + +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/module.h> +#include <linux/slab.h> +#include <linux/i2c.h> +#include <linux/i2c-proc.h> + +#define MAX6635_TEMP 0x00 +#define MAX6635_CONTROL 0x01 +#define MAX6635_HYST 0x02 +#define MAX6635_MAX 0x03 +#define MAX6635_LOW 0x04 +#define MAX6635_HIGH 0x05 + +static int max6635_attach_adapter(struct i2c_adapter *); +static int max6635_detect(struct i2c_adapter *, int, unsigned short, int); +static int max6635_detach_client(struct i2c_client *); +static void max6635_update(unsigned long); +void max6635_temp(struct i2c_client *, int, int, int *, long *); +static int max6635_check(struct i2c_client *); + + +static ctl_table max6635_ctl_table[] = +{ + {0x1000, "temp", NULL, 0, 0644, NULL, &i2c_proc_real, &i2c_sysctl_real, NULL, &max6635_temp}, + {0} +}; + +static unsigned short normal_i2c[] = { SENSORS_I2C_END }; +static unsigned short normal_i2c_range[] = { 0x48, 0x4f, SENSORS_I2C_END }; +static unsigned int normal_isa[] = { SENSORS_ISA_END }; +static unsigned int normal_isa_range[] = { SENSORS_ISA_END }; + +SENSORS_INSMOD_1(max6635); + +static int max6635_id; + +struct max6635_data { + struct semaphore update_lock; + char valid; + unsigned long last_updated; + u16 temp; + u16 temp_max, temp_low, temp_high, temp_hyst; + u8 control; + u16 address; +}; + +static struct i2c_driver max6635_driver = { + .name = "max6635", + .flags = I2C_DF_NOTIFY, + .attach_adapter = max6635_attach_adapter, + .detach_client = max6635_detach_client, +}; + +#define reg2temp(temp) ((temp & 0x8000)?(255 - (temp >> 7)):(temp >> 7)) +#define temp2reg(temp) ((temp < 0)?(((temp + 255) << 7) | 0x8000):(temp << 7)) + +static __inline__ u16 swap_bytes(u16 val) +{ + return (val >> 8) | (val << 8); +} + +static int max6635_attach_adapter(struct i2c_adapter *adapter) +{ + return i2c_detect(adapter, &addr_data, max6635_detect); +} + +static int max6635_check(struct i2c_client *client) +{ + struct max6635_data *data = client->data; + + data->temp_low = swap_bytes(i2c_smbus_read_word_data(client, MAX6635_LOW)); + data->temp_high = swap_bytes(i2c_smbus_read_word_data(client, MAX6635_HIGH)); + data->temp_hyst = swap_bytes(i2c_smbus_read_word_data(client, MAX6635_HYST)); + data->temp_max = swap_bytes(i2c_smbus_read_word_data(client, MAX6635_MAX)); + + return (!(data->temp_low & 0x7f) && !(data->temp_high & 0x7f) && + !(data->temp_hyst & 0x7f) && !(data->temp_max & 0x7f)); +} + +static int max6635_detect(struct i2c_adapter *adapter, int address, unsigned short flags, int kind) +{ + struct i2c_client *new_client = NULL; + struct max6635_data *data = NULL; + int err = 0; + char type_name[32]; + + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) + printk(KERN_WARNING "Adapter doesn't support functionality.\n"); + + new_client = kmalloc(sizeof(*new_client), GFP_KERNEL); + if (!new_client) + { + printk(KERN_ERR "Failed to create new max6635 I2C client.\n"); + err = -ENOMEM; + goto error1; + } + data = kmalloc(sizeof(*data), GFP_KERNEL); + if (!data) + { + printk(KERN_ERR "Failed to create new private data for max6635 sensor.\n"); + err = -ENOMEM; + goto error2; + } + + memset(new_client, 0, sizeof(*new_client)); + memset(data, 0, sizeof(*data)); + + data->address = address; + + new_client->data = data; + new_client->addr = address; + new_client->adapter = adapter; + new_client->driver = &max6635_driver; + new_client->flags = 0; + new_client->id = max6635_id++; + + strncpy(new_client->name, "max6635", sizeof(new_client->name)); + data->valid = 0; + init_MUTEX(&data->update_lock); + + if (!max6635_check(new_client)) + { + printk(KERN_ERR "It doesn't look like MAX6635 chip.\n"); + err = -ENODEV; + goto error3; + } + + + err = i2c_attach_client(new_client); + if (err) + { + printk(KERN_ERR "Failed to attach max6635 I2C client to I2C bus, err=%d.\n", err); + goto error3; + } + + snprintf(type_name, sizeof(type_name), "max6635"); + err = i2c_register_entry(new_client, type_name, max6635_ctl_table, THIS_MODULE); + if (err < 0) + { + printk(KERN_ERR "Failed to register new entry for max6635 sensor. err=%d\n", err); + goto error4; + } + + printk(KERN_INFO "Found max6635 I2C temperature sensor.\n"); + + return 0; + +error4: + i2c_detach_client(new_client); +error3: + max6635_id--; + kfree(new_client); +error2: + kfree(data); +error1: + return err; +} + +static int max6635_detach_client(struct i2c_client *client) +{ + struct max6635_data *data = client->data; + int err; + + err = i2c_detach_client(client); + if (err) + { + printk(KERN_ERR "Client deregistration failed, client not detached.\n"); + return err; + } + + kfree(client); + kfree(data); + return 0; +} + +void max6635_update(unsigned long __data) +{ + struct i2c_client *client = (struct i2c_client *)__data; + struct max6635_data *data = client->data; + + if (down_interruptible(&data->update_lock)) + return; + + data->temp = swap_bytes(i2c_smbus_read_word_data(client, MAX6635_TEMP)); + data->control = i2c_smbus_read_byte_data(client, MAX6635_CONTROL); + data->temp_low = swap_bytes(i2c_smbus_read_word_data(client, MAX6635_LOW)); + data->temp_high = swap_bytes(i2c_smbus_read_word_data(client, MAX6635_HIGH)); + data->temp_hyst = swap_bytes(i2c_smbus_read_word_data(client, MAX6635_HYST)); + data->temp_max = swap_bytes(i2c_smbus_read_word_data(client, MAX6635_MAX)); + + data->last_updated = jiffies; + + up(&data->update_lock); +} + +void max6635_temp(struct i2c_client *client, int operation, int ctl_name, int *nrels_mag, long *results) +{ + struct max6635_data *data = client->data; + + if (operation == SENSORS_PROC_REAL_INFO) + *nrels_mag = 1; + else if (operation == SENSORS_PROC_REAL_READ) + { + max6635_update((unsigned long)client); + + results[0] = reg2temp(data->temp_max); + results[1] = reg2temp(data->temp_hyst); + results[2] = reg2temp(data->temp_low); + results[3] = reg2temp(data->temp_high); + results[4] = reg2temp(data->temp); + *nrels_mag = 5; + } + else if (operation == SENSORS_PROC_REAL_WRITE) + { + if (!down_interruptible(&data->update_lock)) + { + if (*nrels_mag >= 1) + { + data->temp_max = temp2reg(results[0]); + i2c_smbus_write_word_data(client, MAX6635_MAX, swap_bytes(data->temp_max)); + } + if (*nrels_mag >= 2) + { + data->temp_hyst = temp2reg(results[1]); + i2c_smbus_write_word_data(client, MAX6635_HYST, swap_bytes(data->temp_hyst)); + } + if (*nrels_mag >= 3) + { + data->temp_low = temp2reg(results[2]); + i2c_smbus_write_word_data(client, MAX6635_LOW, swap_bytes(data->temp_low)); + } + if (*nrels_mag >= 4) + { + data->temp_high = temp2reg(results[3]); + i2c_smbus_write_word_data(client, MAX6635_HIGH, swap_bytes(data->temp_high)); + } + + up(&data->update_lock); + } + } +} + +static int __init max6635_init(void) +{ + return i2c_add_driver(&max6635_driver); +} + +static void __exit max6635_exit(void) +{ + i2c_del_driver(&max6635_driver); +} + + +MODULE_AUTHOR("Evgeniy Polyakov <johnpol at 2ka.mipt.ru>"); +MODULE_DESCRIPTION("MAX663{5,4,3} temerature sensor"); +MODULE_LICENSE("GPL"); + +module_init(max6635_init); +module_exit(max6635_exit); -------------- next part -------------- ===== drivers/i2c/max663x.c 1.3 vs edited ===== --- 1.3/drivers/i2c/max663x.c Mon Apr 12 20:51:20 2004 +++ edited/drivers/i2c/max663x.c Tue Apr 13 12:20:04 2004 @@ -1,5 +1,5 @@ /* - * max663x.c + * max6635.c - Part of lm_sensors, Linux kernel modules for hardware monitoring. * * 2003-2004 Copyright (c) Evgeniy Polyakov <johnpol at 2ka.mipt.ru> * All rights reserved. @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * The GNU GPL is contained in /usr/doc/copyright/GPL on a Debian - * system and in the file COPYING in the Linux kernel source. - * */ /* @@ -34,24 +31,24 @@ #include <linux/i2c.h> #include <linux/i2c-proc.h> -#define MAX663x_TEMP 0x00 -#define MAX663x_CONTROL 0x01 -#define MAX663x_HYST 0x02 -#define MAX663x_MAX 0x03 -#define MAX663x_LOW 0x04 -#define MAX663x_HIGH 0x05 - -static int max663x_attach_adapter(struct i2c_adapter *); -static int max663x_detect(struct i2c_adapter *, int, unsigned short, int); -static int max663x_detach_client(struct i2c_client *); -static void max663x_update(unsigned long); -void max663x_temp(struct i2c_client *, int, int, int *, long *); -static int max663x_check(struct i2c_client *); +#define MAX6635_TEMP 0x00 +#define MAX6635_CONTROL 0x01 +#define MAX6635_HYST 0x02 +#define MAX6635_MAX 0x03 +#define MAX6635_LOW 0x04 +#define MAX6635_HIGH 0x05 + +static int max6635_attach_adapter(struct i2c_adapter *); +static int max6635_detect(struct i2c_adapter *, int, unsigned short, int); +static int max6635_detach_client(struct i2c_client *); +static void max6635_update(unsigned long); +void max6635_temp(struct i2c_client *, int, int, int *, long *); +static int max6635_check(struct i2c_client *); -static ctl_table max663x_ctl_table[] = +static ctl_table max6635_ctl_table[] = { - {0x1000, "temp", NULL, 0, 0644, NULL, &i2c_proc_real, &i2c_sysctl_real, NULL, &max663x_temp}, + {0x1000, "temp", NULL, 0, 0644, NULL, &i2c_proc_real, &i2c_sysctl_real, NULL, &max6635_temp}, {0} }; @@ -60,11 +57,11 @@ static unsigned int normal_isa[] = { SENSORS_ISA_END }; static unsigned int normal_isa_range[] = { SENSORS_ISA_END }; -SENSORS_INSMOD_1(max663x); +SENSORS_INSMOD_1(max6635); -static int max663x_id; +static int max6635_id; -struct max663x_data { +struct max6635_data { struct semaphore update_lock; char valid; unsigned long last_updated; @@ -74,11 +71,11 @@ u16 address; }; -static struct i2c_driver max663x_driver = { - .name = "max663x", +static struct i2c_driver max6635_driver = { + .name = "max6635", .flags = I2C_DF_NOTIFY, - .attach_adapter = max663x_attach_adapter, - .detach_client = max663x_detach_client, + .attach_adapter = max6635_attach_adapter, + .detach_client = max6635_detach_client, }; #define reg2temp(temp) ((temp & 0x8000)?(255 - (temp >> 7)):(temp >> 7)) @@ -89,48 +86,45 @@ return (val >> 8) | (val << 8); } -static int max663x_attach_adapter(struct i2c_adapter *adapter) +static int max6635_attach_adapter(struct i2c_adapter *adapter) { - return i2c_detect(adapter, &addr_data, max663x_detect); + return i2c_detect(adapter, &addr_data, max6635_detect); } -static int max663x_check(struct i2c_client *client) +static int max6635_check(struct i2c_client *client) { - u16 temp_low, temp_high, temp_max, temp_hyst; + struct max6635_data *data = client->data; - temp_low = swap_bytes(i2c_smbus_read_word_data(client, MAX663x_LOW)); - temp_high = swap_bytes(i2c_smbus_read_word_data(client, MAX663x_HIGH)); - temp_hyst = swap_bytes(i2c_smbus_read_word_data(client, MAX663x_HYST)); - temp_max = swap_bytes(i2c_smbus_read_word_data(client, MAX663x_MAX)); + data->temp_low = swap_bytes(i2c_smbus_read_word_data(client, MAX6635_LOW)); + data->temp_high = swap_bytes(i2c_smbus_read_word_data(client, MAX6635_HIGH)); + data->temp_hyst = swap_bytes(i2c_smbus_read_word_data(client, MAX6635_HYST)); + data->temp_max = swap_bytes(i2c_smbus_read_word_data(client, MAX6635_MAX)); - return (!(temp_low & 0x7f) && !(temp_high & 0x7f) && !(temp_hyst & 0x7f) && !(temp_max & 0x7f)); + return (!(data->temp_low & 0x7f) && !(data->temp_high & 0x7f) && + !(data->temp_hyst & 0x7f) && !(data->temp_max & 0x7f)); } -static int max663x_detect(struct i2c_adapter *adapter, int address, unsigned short flags, int kind) +static int max6635_detect(struct i2c_adapter *adapter, int address, unsigned short flags, int kind) { struct i2c_client *new_client = NULL; - struct max663x_data *data = NULL; + struct max6635_data *data = NULL; int err = 0; char type_name[32]; if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) - { - printk(KERN_ERR "Adapter doesn't support functionality.\n"); - err = -EINVAL; - goto error1; - } + printk(KERN_WARNING "Adapter doesn't support functionality.\n"); new_client = kmalloc(sizeof(*new_client), GFP_KERNEL); if (!new_client) { - printk(KERN_ERR "Failed to create new max663x I2C client.\n"); + printk(KERN_ERR "Failed to create new max6635 I2C client.\n"); err = -ENOMEM; goto error1; } data = kmalloc(sizeof(*data), GFP_KERNEL); if (!data) { - printk(KERN_ERR "Failed to create new private data for max663x sensor.\n"); + printk(KERN_ERR "Failed to create new private data for max6635 sensor.\n"); err = -ENOMEM; goto error2; } @@ -143,17 +137,17 @@ new_client->data = data; new_client->addr = address; new_client->adapter = adapter; - new_client->driver = &max663x_driver; + new_client->driver = &max6635_driver; new_client->flags = 0; - new_client->id = max663x_id++; + new_client->id = max6635_id++; - strncpy(new_client->name, "max663x", sizeof(new_client->name)); + strncpy(new_client->name, "max6635", sizeof(new_client->name)); data->valid = 0; init_MUTEX(&data->update_lock); - if (!max663x_check(new_client)) + if (!max6635_check(new_client)) { - printk(KERN_ERR "It doesn't look like MAX663x chip.\n"); + printk(KERN_ERR "It doesn't look like MAX6635 chip.\n"); err = -ENODEV; goto error3; } @@ -162,28 +156,26 @@ err = i2c_attach_client(new_client); if (err) { - printk(KERN_ERR "Failed to attach max663x I2C client to I2C bus, err=%d.\n", err); + printk(KERN_ERR "Failed to attach max6635 I2C client to I2C bus, err=%d.\n", err); goto error3; } - snprintf(type_name, sizeof(type_name), "max663x"); - err = i2c_register_entry(new_client, type_name, max663x_ctl_table, THIS_MODULE); + snprintf(type_name, sizeof(type_name), "max6635"); + err = i2c_register_entry(new_client, type_name, max6635_ctl_table, THIS_MODULE); if (err < 0) { - printk(KERN_ERR "Failed to register new entry for max663x sensor. err=%d\n", err); + printk(KERN_ERR "Failed to register new entry for max6635 sensor. err=%d\n", err); goto error4; } - max663x_update((unsigned long)new_client); - - printk(KERN_INFO "Found max663x I2C temperature sensor.\n"); + printk(KERN_INFO "Found max6635 I2C temperature sensor.\n"); return 0; error4: i2c_detach_client(new_client); error3: - max663x_id--; + max6635_id--; kfree(new_client); error2: kfree(data); @@ -191,9 +183,9 @@ return err; } -static int max663x_detach_client(struct i2c_client *client) +static int max6635_detach_client(struct i2c_client *client) { - struct max663x_data *data = client->data; + struct max6635_data *data = client->data; int err; err = i2c_detach_client(client); @@ -208,35 +200,35 @@ return 0; } -void max663x_update(unsigned long __data) +void max6635_update(unsigned long __data) { struct i2c_client *client = (struct i2c_client *)__data; - struct max663x_data *data = client->data; + struct max6635_data *data = client->data; if (down_interruptible(&data->update_lock)) return; - data->temp = swap_bytes(i2c_smbus_read_word_data(client, MAX663x_TEMP)); - data->control = i2c_smbus_read_byte_data(client, MAX663x_CONTROL); - data->temp_low = swap_bytes(i2c_smbus_read_word_data(client, MAX663x_LOW)); - data->temp_high = swap_bytes(i2c_smbus_read_word_data(client, MAX663x_HIGH)); - data->temp_hyst = swap_bytes(i2c_smbus_read_word_data(client, MAX663x_HYST)); - data->temp_max = swap_bytes(i2c_smbus_read_word_data(client, MAX663x_MAX)); + data->temp = swap_bytes(i2c_smbus_read_word_data(client, MAX6635_TEMP)); + data->control = i2c_smbus_read_byte_data(client, MAX6635_CONTROL); + data->temp_low = swap_bytes(i2c_smbus_read_word_data(client, MAX6635_LOW)); + data->temp_high = swap_bytes(i2c_smbus_read_word_data(client, MAX6635_HIGH)); + data->temp_hyst = swap_bytes(i2c_smbus_read_word_data(client, MAX6635_HYST)); + data->temp_max = swap_bytes(i2c_smbus_read_word_data(client, MAX6635_MAX)); data->last_updated = jiffies; up(&data->update_lock); } -void max663x_temp(struct i2c_client *client, int operation, int ctl_name, int *nrels_mag, long *results) +void max6635_temp(struct i2c_client *client, int operation, int ctl_name, int *nrels_mag, long *results) { - struct max663x_data *data = client->data; + struct max6635_data *data = client->data; if (operation == SENSORS_PROC_REAL_INFO) *nrels_mag = 1; else if (operation == SENSORS_PROC_REAL_READ) { - max663x_update((unsigned long)client); + max6635_update((unsigned long)client); results[0] = reg2temp(data->temp_max); results[1] = reg2temp(data->temp_hyst); @@ -252,22 +244,22 @@ if (*nrels_mag >= 1) { data->temp_max = temp2reg(results[0]); - i2c_smbus_write_word_data(client, MAX663x_MAX, swap_bytes(data->temp_max)); + i2c_smbus_write_word_data(client, MAX6635_MAX, swap_bytes(data->temp_max)); } if (*nrels_mag >= 2) { data->temp_hyst = temp2reg(results[1]); - i2c_smbus_write_word_data(client, MAX663x_HYST, swap_bytes(data->temp_hyst)); + i2c_smbus_write_word_data(client, MAX6635_HYST, swap_bytes(data->temp_hyst)); } if (*nrels_mag >= 3) { data->temp_low = temp2reg(results[2]); - i2c_smbus_write_word_data(client, MAX663x_LOW, swap_bytes(data->temp_low)); + i2c_smbus_write_word_data(client, MAX6635_LOW, swap_bytes(data->temp_low)); } if (*nrels_mag >= 4) { data->temp_high = temp2reg(results[3]); - i2c_smbus_write_word_data(client, MAX663x_HIGH, swap_bytes(data->temp_high)); + i2c_smbus_write_word_data(client, MAX6635_HIGH, swap_bytes(data->temp_high)); } up(&data->update_lock); @@ -275,20 +267,20 @@ } } -static int __init max663x_init(void) +static int __init max6635_init(void) { - return i2c_add_driver(&max663x_driver); + return i2c_add_driver(&max6635_driver); } -static void __exit max663x_exit(void) +static void __exit max6635_exit(void) { - i2c_del_driver(&max663x_driver); + i2c_del_driver(&max6635_driver); } MODULE_AUTHOR("Evgeniy Polyakov <johnpol at 2ka.mipt.ru>"); -MODULE_DESCRIPTION("MAX663x temerature sensor"); +MODULE_DESCRIPTION("MAX663{5,4,3} temerature sensor"); MODULE_LICENSE("GPL"); -module_init(max663x_init); -module_exit(max663x_exit); +module_init(max6635_init); +module_exit(max6635_exit); -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040413/271a27be/attachment.bin