From: Davide Rizzo Date: Mon, 23 Mar 2009 16:29:09 +0000 Subject: Re: [lm-sensors] LM95241 Driver proposal Message-Id: <8447d6730903230929m491591cfi78280715ab1270de@mail.gmail.com> MIME-Version: 1 Content-Type: multipart/mixed; boundary="===============2277600053434456250==" List-Id: References: <20090322170810.7350923b.akpm@linux-foundation.org> In-Reply-To: <20090322170810.7350923b.akpm@linux-foundation.org> To: lm-sensors@vger.kernel.org --===============2277600053434456250== Content-Type: multipart/alternative; boundary=0015174c34a21f6b240465cbc41b --0015174c34a21f6b240465cbc41b Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 2009/3/23 Andrew Morton > > +/* Conversions and various macros */ > > +#define TEMP_FROM_REG(val_h, val_l) (((val_h) & 0x80 ? (val_h) - 0x100 : > \ > > + (val_h)) * 1000 + (val_l) * 1000 / 256) > > This macro is inefficient or buggy when pass an expression which has > side-effects, because it evaulates an argument multiple times. > > Please just turn it into a plain old lower-case C function. > Ok, rewritten > > +#define show_type(flag) \ > > +static ssize_t show_type##flag(struct device *dev, \ > > + struct device_attribute *attr, char > *buf) \ > > +{ \ > > + struct i2c_client *client = to_i2c_client(dev); \ > > + struct lm95241_data *data = i2c_get_clientdata(client); \ > > +\ > > + snprintf(buf, PAGE_SIZE - 1, \ > > + data->model & R##flag##MS_MASK ? "1\n" : "2\n"); \ > > + return strlen(buf); \ > > +} > > +show_type(1); > > +show_type(2); > > + > > +#define show_min(flag) \ > > +static ssize_t show_min##flag(struct device *dev, \ > > + struct device_attribute *attr, char *buf) \ > > +{ \ > > + struct i2c_client *client = to_i2c_client(dev); \ > > + struct lm95241_data *data = i2c_get_clientdata(client); \ > > +\ > > + snprintf(buf, PAGE_SIZE - 1, \ > > + data->config & R##flag##DF_MASK ? \ > > + "-127000\n" : "0\n"); \ > > + return strlen(buf); \ > > +} > > +show_min(1); > > +show_min(2); > > hm. Is this still the preferred way of implementing these sysfs handlers? > Rewritten without using macros, much easier to read now... > > +static struct attribute *lm95241_attributes[] = { > > + &dev_attr_temp1_input.attr, > > + &dev_attr_temp2_input.attr, > > + &dev_attr_temp3_input.attr, > > + &dev_attr_temp2_type.attr, > > + &dev_attr_temp3_type.attr, > > + &dev_attr_temp2_min.attr, > > + &dev_attr_temp3_min.attr, > > + &dev_attr_temp2_max.attr, > > + &dev_attr_temp3_max.attr, > > + &dev_attr_rate.attr, > > + NULL > > +}; > > Should this use an attribute group? > Yes, didn't I ? Here follows the updated patch: ----------------------------------------------- This patch implements the hwmon driver for the National Semiconductor LM95241 triple temperature sensors chip Signed-off-by: Davide Rizzo --- diff -urNp linux-2.6.28.5/drivers/hwmon/Kconfig linux-2.6.28.5.elpa/drivers/hwmon/Kconfig --- linux-2.6.28.5/drivers/hwmon/Kconfig 2008-12-25 00:26:37.000000000 +0100 +++ linux-2.6.28.5.elpa/drivers/hwmon/Kconfig 2009-01-04 08:07:39.000000000 +0100 @@ -548,6 +548,15 @@ config SENSORS_LM93 This driver can also be built as a module. If so, the module will be called lm93. +config SENSORS_LM95241 + tristate "National Semiconductor LM95241 sensor chip" + depends on I2C + help + If you say yes here you get support for LM95241 sensor chip. + + This driver can also be built as a module. If so, the module + will be called lm95241. + config SENSORS_MAX1111 tristate "Maxim MAX1111 Multichannel, Serial 8-bit ADC chip" depends on SPI_MASTER diff -urNp linux-2.6.28.5/drivers/hwmon/lm95241.c linux-2.6.28.5.elpa/drivers/hwmon/lm95241.c --- linux-2.6.28.5/drivers/hwmon/lm95241.c 1970-01-01 01:00:00.000000000 +0100 +++ linux-2.6.28.5.elpa/drivers/hwmon/lm95241.c 2009-03-23 17:13:21.000000000 +0100 @@ -0,0 +1,553 @@ +/* + * lm95241.c - Part of lm_sensors, Linux kernel modules for hardware monitoring + * Copyright (C) 2008 Davide Rizzo + * + * The LM95241 is a sensor chip made by National Semiconductors. + * It reports up to three temperatures (its own plus up to two external ones). + * Complete datasheet can be obtained from National's website at: + * http://www.national.com/ds.cgi/LM/LM95241.pdf + * + * 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 +#include +#include +#include +#include +#include +#include + +static const unsigned short normal_i2c[] = { + 0x19, 0x2a, 0x2b, I2C_CLIENT_END}; + +/* Insmod parameters */ +I2C_CLIENT_INSMOD_1(lm95241); + +/* LM95241 registers */ +#define LM95241_REG_R_MAN_ID 0xFE +#define LM95241_REG_R_CHIP_ID 0xFF +#define LM95241_REG_R_STATUS 0x02 +#define LM95241_REG_RW_CONFIG 0x03 +#define LM95241_REG_RW_REM_FILTER 0x06 +#define LM95241_REG_RW_TRUTHERM 0x07 +#define LM95241_REG_W_ONE_SHOT 0x0F +#define LM95241_REG_R_LOCAL_TEMPH 0x10 +#define LM95241_REG_R_REMOTE1_TEMPH 0x11 +#define LM95241_REG_R_REMOTE2_TEMPH 0x12 +#define LM95241_REG_R_LOCAL_TEMPL 0x20 +#define LM95241_REG_R_REMOTE1_TEMPL 0x21 +#define LM95241_REG_R_REMOTE2_TEMPL 0x22 +#define LM95241_REG_RW_REMOTE_MODEL 0x30 + +/* LM95241 specific bitfields */ +#define CFG_STOP 0x40 +#define CFG_CR0076 0x00 +#define CFG_CR0182 0x10 +#define CFG_CR1000 0x20 +#define CFG_CR2700 0x30 +#define R1MS_SHIFT 0 +#define R2MS_SHIFT 2 +#define R1MS_MASK (0x01 << (R1MS_SHIFT)) +#define R2MS_MASK (0x01 << (R2MS_SHIFT)) +#define R1DF_SHIFT 1 +#define R2DF_SHIFT 2 +#define R1DF_MASK (0x01 << (R1DF_SHIFT)) +#define R2DF_MASK (0x01 << (R2DF_SHIFT)) +#define R1FE_MASK 0x01 +#define R2FE_MASK 0x05 +#define TT1_SHIFT 0 +#define TT2_SHIFT 4 +#define TT_OFF 0 +#define TT_ON 1 +#define TT_MASK 7 +#define MANUFACTURER_ID 0x01 +#define DEFAULT_REVISION 0xA4 + +/* Functions declaration */ +static int lm95241_attach_adapter(struct i2c_adapter *adapter); +static int lm95241_detect(struct i2c_adapter *adapter, int address, + int kind); +static void lm95241_init_client(struct i2c_client *client); +static int lm95241_detach_client(struct i2c_client *client); +static struct lm95241_data *lm95241_update_device(struct device *dev); + +/* Driver data (common to all clients) */ +static struct i2c_driver lm95241_driver = { + .driver = { + .name = "lm95241", + }, + .attach_adapter = lm95241_attach_adapter, + .detach_client = lm95241_detach_client, +}; + +/* Client data (each client gets its own) */ +struct lm95241_data { + struct i2c_client client; + struct device *hwmon_dev; + struct mutex update_lock; + unsigned long last_updated, rate; /* in jiffies */ + char valid; /* zero until following fields are valid */ + /* registers values */ + u8 local_h, local_l; /* local */ + u8 remote1_h, remote1_l; /* remote1 */ + u8 remote2_h, remote2_l; /* remote2 */ + u8 config, model, trutherm; +}; + +static ssize_t show_input(struct device *dev, + struct device_attribute *attr, char *buf); +static ssize_t show_rate(struct device *dev, struct device_attribute *attr, + char *buf); +static ssize_t set_rate(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count); +static ssize_t show_type(struct device *dev, struct device_attribute *attr, + char *buf); +static ssize_t show_min(struct device *dev, struct device_attribute *attr, + char *buf); +static ssize_t show_max(struct device *dev, struct device_attribute *attr, + char *buf); +static ssize_t set_type(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count); +static ssize_t set_min(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count); +static ssize_t set_max(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count); + +static DEVICE_ATTR(temp1_input, S_IRUGO, show_input, NULL); +static DEVICE_ATTR(temp2_input, S_IRUGO, show_input, NULL); +static DEVICE_ATTR(temp3_input, S_IRUGO, show_input, NULL); +static DEVICE_ATTR(temp2_type, S_IWUSR | S_IRUGO, show_type, set_type); +static DEVICE_ATTR(temp3_type, S_IWUSR | S_IRUGO, show_type, set_type); +static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_min, set_min); +static DEVICE_ATTR(temp3_min, S_IWUSR | S_IRUGO, show_min, set_min); +static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_max, set_max); +static DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_max, set_max); +static DEVICE_ATTR(rate, S_IWUSR | S_IRUGO, show_rate, set_rate); + +static struct attribute *lm95241_attributes[] = { + &dev_attr_temp1_input.attr, + &dev_attr_temp2_input.attr, + &dev_attr_temp3_input.attr, + &dev_attr_temp2_type.attr, + &dev_attr_temp3_type.attr, + &dev_attr_temp2_min.attr, + &dev_attr_temp3_min.attr, + &dev_attr_temp2_max.attr, + &dev_attr_temp3_max.attr, + &dev_attr_rate.attr, + NULL +}; + +static const struct attribute_group lm95241_group = { + .attrs = lm95241_attributes, +}; + +/* Conversions */ +static int TempFromReg(u8 val_h, u8 val_l) +{ + if (val_h & 0x80) + return val_h - 0x100; + return val_h * 1000 + val_l * 1000 / 256; +} + +/* Sysfs stuff */ +static ssize_t show_input(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct lm95241_data *data = lm95241_update_device(dev); + int value; + + if (attr == &dev_attr_temp1_input) + value = TempFromReg(data->local_h, data->local_l); + else if (attr == &dev_attr_temp2_input) + value = TempFromReg(data->remote1_h, data->remote1_l); + else + value = TempFromReg(data->remote2_h, data->remote2_l); + snprintf(buf, PAGE_SIZE - 1, "%d\n", value); + return strlen(buf); +} + +static ssize_t show_rate(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct lm95241_data *data = lm95241_update_device(dev); + + snprintf(buf, PAGE_SIZE - 1, "%lu\n", 1000 * data->rate / HZ); + return strlen(buf); +} + +static ssize_t set_rate(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct lm95241_data *data = i2c_get_clientdata(client); + + strict_strtol(buf, 10, &data->rate); + data->rate = data->rate * HZ / 1000; + return count; +} + +static ssize_t show_type(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct lm95241_data *data = i2c_get_clientdata(client); + + if (attr == &dev_attr_temp2_type) + snprintf(buf, PAGE_SIZE - 1, + data->model & R1MS_MASK ? "1\n" : "2\n"); + else + snprintf(buf, PAGE_SIZE - 1, + data->model & R2MS_MASK ? "1\n" : "2\n"); + return strlen(buf); +} + +static ssize_t show_min(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct lm95241_data *data = i2c_get_clientdata(client); + + if (attr == &dev_attr_temp2_min) + snprintf(buf, PAGE_SIZE - 1, + data->config & R1DF_MASK ? "-127000\n" : "0\n"); + else + snprintf(buf, PAGE_SIZE - 1, + data->config & R2DF_MASK ? "-127000\n" : "0\n"); + return strlen(buf); +} + +static ssize_t show_max(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct lm95241_data *data = i2c_get_clientdata(client); + + if (attr == &dev_attr_temp2_max) + snprintf(buf, PAGE_SIZE - 1, + data->config & R1DF_MASK ? "127000\n" : "255000\n"); + else + snprintf(buf, PAGE_SIZE - 1, + data->config & R2DF_MASK ? "127000\n" : "255000\n"); + return strlen(buf); +} + +static ssize_t set_type(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct lm95241_data *data = i2c_get_clientdata(client); + long val; + + strict_strtol(buf, 10, &val); + if ((val == 1) || (val == 2)) { + int shift; + u8 mask; + if (attr == &dev_attr_temp2_type) { + shift = TT1_SHIFT; + mask = R1MS_MASK; + } else { + shift = TT2_SHIFT; + mask = R2MS_MASK; + } + + mutex_lock(&data->update_lock); + + data->trutherm &= ~(TT_MASK << shift); + if (val == 1) { + data->model |= mask; + data->trutherm |= (TT_ON << shift); + } else { + data->model &= ~mask; + data->trutherm |= (TT_OFF << shift); + } + + data->valid = 0; + + i2c_smbus_write_byte_data(client, LM95241_REG_RW_REMOTE_MODEL, + data->model); + i2c_smbus_write_byte_data(client, LM95241_REG_RW_TRUTHERM, + data->trutherm); + + mutex_unlock(&data->update_lock); + + } + return count; +} + +static ssize_t set_min(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct lm95241_data *data = i2c_get_clientdata(client); + long val; + u8 mask; + + strict_strtol(buf, 10, &val); + if (attr == &dev_attr_temp2_min) + mask = R1DF_MASK; + else + mask = R2DF_MASK; + + mutex_lock(&data->update_lock); + + if (val < 0) + data->config |= mask; + else + data->config &= mask; + data->valid = 0; + + i2c_smbus_write_byte_data(client, LM95241_REG_RW_CONFIG, data->config); + + mutex_unlock(&data->update_lock); + + return count; +} + +static ssize_t set_max(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct lm95241_data *data = i2c_get_clientdata(client); + long val; + u8 mask; + + strict_strtol(buf, 10, &val); + if (attr == &dev_attr_temp2_max) + mask = R1DF_MASK; + else + mask = R2DF_MASK; + + mutex_lock(&data->update_lock); + + if (val <= 127000) + data->config |= R1DF_MASK; + else + data->config &= ~R2DF_MASK; + data->valid = 0; + + i2c_smbus_write_byte_data(client, LM95241_REG_RW_CONFIG, data->config); + + mutex_unlock(&data->update_lock); + + return count; +} + +/* Init/exit code */ +static int lm95241_attach_adapter(struct i2c_adapter *adapter) +{ + if (!(adapter->class & I2C_CLASS_HWMON)) + return 0; + return i2c_probe(adapter, &addr_data, lm95241_detect); +} + +/* + * The following function does more than just detection. If detection + * succeeds, it also registers the new chip. + */ +static int lm95241_detect(struct i2c_adapter *adapter, int address, int kind) +{ + struct i2c_client *new_client; + struct lm95241_data *data; + int err = 0; + const char *name = ""; + + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) + goto exit; + + data = kzalloc(sizeof(struct lm95241_data), GFP_KERNEL); + if (!data) { + err = -ENOMEM; + goto exit; + } + + /* The common I2C client data is placed right before the + LM95241-specific data. */ + new_client = &data->client; + i2c_set_clientdata(new_client, data); + new_client->addr = address; + new_client->adapter = adapter; + new_client->driver = &lm95241_driver; + new_client->flags = 0; + + /* + * Now we do the remaining detection. A negative kind means that + * the driver was loaded with no force parameter (default), so we + * must both detect and identify the chip. A zero kind means that + * the driver was loaded with the force parameter, the detection + * step shall be skipped. A positive kind means that the driver + * was loaded with the force parameter and a given kind of chip is + * requested, so both the detection and the identification steps + * are skipped. + */ + if (kind < 0) { /* detection */ + if ((i2c_smbus_read_byte_data(new_client, LM95241_REG_R_MAN_ID) + != MANUFACTURER_ID) + || (i2c_smbus_read_byte_data(new_client, LM95241_REG_R_CHIP_ID) + < DEFAULT_REVISION)) { + dev_dbg(&adapter->dev, + "LM95241 detection failed at 0x%02x.\n", + address); + goto exit_free; + } + } + + if (kind <= 0) { /* identification */ + if ((i2c_smbus_read_byte_data(new_client, LM95241_REG_R_MAN_ID) + == MANUFACTURER_ID) + && (i2c_smbus_read_byte_data(new_client, LM95241_REG_R_CHIP_ID) + >= DEFAULT_REVISION)) { + + kind = lm95241; + + if (kind <= 0) { /* identification failed */ + dev_info(&adapter->dev, "Unsupported chip\n"); + goto exit_free; + } + } + } + + if (kind == lm95241) + name = "lm95241"; + + /* We can fill in the remaining client fields */ + strlcpy(new_client->name, name, I2C_NAME_SIZE); + data->valid = 0; + mutex_init(&data->update_lock); + + /* Tell the I2C layer a new client has arrived */ + err = i2c_attach_client(new_client); + if (err) + goto exit_free; + + /* Initialize the LM95241 chip */ + lm95241_init_client(new_client); + + /* Register sysfs hooks */ + err = sysfs_create_group(&new_client->dev.kobj, &lm95241_group); + if (err) + goto exit_detach; + + data->hwmon_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->hwmon_dev)) { + err = PTR_ERR(data->hwmon_dev); + goto exit_remove_files; + } + + return 0; + +exit_remove_files: + sysfs_remove_group(&new_client->dev.kobj, &lm95241_group); +exit_detach: + i2c_detach_client(new_client); +exit_free: + kfree(data); +exit: + return err; +} + +static void lm95241_init_client(struct i2c_client *client) +{ + struct lm95241_data *data = i2c_get_clientdata(client); + + data->rate = HZ; /* 1 sec default */ + data->valid = 0; + data->config = CFG_CR0076; + data->model = 0; + data->trutherm = (TT_OFF << TT1_SHIFT) | (TT_OFF << TT2_SHIFT); + + i2c_smbus_write_byte_data(client, LM95241_REG_RW_CONFIG, + data->config); + i2c_smbus_write_byte_data(client, LM95241_REG_RW_REM_FILTER, + R1FE_MASK | R2FE_MASK); + i2c_smbus_write_byte_data(client, LM95241_REG_RW_TRUTHERM, + data->trutherm); + i2c_smbus_write_byte_data(client, LM95241_REG_RW_REMOTE_MODEL, + data->model); +} + +static int lm95241_detach_client(struct i2c_client *client) +{ + struct lm95241_data *data = i2c_get_clientdata(client); + int err; + + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &lm95241_group); + + err = i2c_detach_client(client); + if (err) + return err; + + kfree(data); + return 0; +} + +static struct lm95241_data *lm95241_update_device(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct lm95241_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + if (time_after(jiffies, data->last_updated + data->rate) || + !data->valid) { + dev_dbg(&client->dev, "Updating lm95241 data.\n"); + data->local_h = + i2c_smbus_read_byte_data(client, + LM95241_REG_R_LOCAL_TEMPH); + data->local_l = + i2c_smbus_read_byte_data(client, + LM95241_REG_R_LOCAL_TEMPL); + data->remote1_h = + i2c_smbus_read_byte_data(client, + LM95241_REG_R_REMOTE1_TEMPH); + data->remote1_l = + i2c_smbus_read_byte_data(client, + LM95241_REG_R_REMOTE1_TEMPL); + data->remote2_h = + i2c_smbus_read_byte_data(client, + LM95241_REG_R_REMOTE2_TEMPH); + data->remote2_l = + i2c_smbus_read_byte_data(client, + LM95241_REG_R_REMOTE2_TEMPL); + data->last_updated = jiffies; + data->valid = 1; + } + + mutex_unlock(&data->update_lock); + + return data; +} + +static int __init sensors_lm95241_init(void) +{ + return i2c_add_driver(&lm95241_driver); +} + +static void __exit sensors_lm95241_exit(void) +{ + i2c_del_driver(&lm95241_driver); +} + +MODULE_AUTHOR("Davide Rizzo "); +MODULE_DESCRIPTION("LM95241 sensor driver"); +MODULE_LICENSE("GPL"); + +module_init(sensors_lm95241_init); +module_exit(sensors_lm95241_exit); diff -urNp linux-2.6.28.5/drivers/hwmon/Makefile linux-2.6.28.5.elpa/drivers/hwmon/Makefile --- linux-2.6.28.5/drivers/hwmon/Makefile 2008-12-25 00:26:37.000000000 +0100 +++ linux-2.6.28.5.elpa/drivers/hwmon/Makefile 2009-01-04 08:14:42.000000000 +0100 @@ -62,6 +62,7 @@ obj-$(CONFIG_SENSORS_LM87) += lm87.o obj-$(CONFIG_SENSORS_LM90) += lm90.o obj-$(CONFIG_SENSORS_LM92) += lm92.o obj-$(CONFIG_SENSORS_LM93) += lm93.o +obj-$(CONFIG_SENSORS_LM95241) += lm95241.o obj-$(CONFIG_SENSORS_MAX1111) += max1111.o obj-$(CONFIG_SENSORS_MAX1619) += max1619.o obj-$(CONFIG_SENSORS_MAX6650) += max6650.o --0015174c34a21f6b240465cbc41b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
2009/3/23 Andrew Morton <akpm@linux-foundation.org>= ;


> +/* Conversions and various macros */
> +#define TEMP_FROM_REG(val_h, val_l) (((val_h) & 0x80 ? (val_h) - = 0x100 : \
> + =C2=A0 =C2=A0(val_h)) * 1000 + (val_l) * 1000 / 256)

This macro is inefficient or buggy when pass an expression which has<= br> side-effects, because it evaulates an argument multiple times.

Please just turn it into a plain old lower-case C function.

Ok, rewritten

=C2=A0
> +#define show_type(flag) \
> +static ssize_t show_type##flag(struct device *dev, \
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0struct device_attribute *attr,= char *buf) \
> +{ \
> + =C2=A0 =C2=A0 struct i2c_client *client =3D to_i2c_client(dev); \ > + =C2=A0 =C2=A0 struct lm95241_data *data =3D i2c_get_clientdata(clien= t); \
> +\
> + =C2=A0 =C2=A0 snprintf(buf, PAGE_SIZE - 1, \
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 data->model & R##fl= ag##MS_MASK ? "1\n" : "2\n"); \
> + =C2=A0 =C2=A0 return strlen(buf); \
> +}
> +show_type(1);
> +show_type(2);
> +
> +#define show_min(flag) \
> +static ssize_t show_min##flag(struct device *dev, \
> + =C2=A0 =C2=A0struct device_attribute *attr, char *buf) \
> +{ \
> + =C2=A0 =C2=A0 struct i2c_client *client =3D to_i2c_client(dev); \ > + =C2=A0 =C2=A0 struct lm95241_data *data =3D i2c_get_clientdata(clien= t); \
> +\
> + =C2=A0 =C2=A0 snprintf(buf, PAGE_SIZE - 1, \
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 data->config & R##f= lag##DF_MASK ? =C2=A0 =C2=A0 =C2=A0 \
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "-127000\n" : &q= uot;0\n"); \
> + =C2=A0 =C2=A0 return strlen(buf); \
> +}
> +show_min(1);
> +show_min(2);

hm. =C2=A0Is this still the preferred way of implementing these sysfs= handlers?

Rewritten without using macros, much easier to read n= ow...

=C2=A0
> +static struct attribute *lm95241_attributes[] =3D {
> + =C2=A0 =C2=A0 &dev_attr_temp1_input.attr,
> + =C2=A0 =C2=A0 &dev_attr_temp2_input.attr,
> + =C2=A0 =C2=A0 &dev_attr_temp3_input.attr,
> + =C2=A0 =C2=A0 &dev_attr_temp2_type.attr,
> + =C2=A0 =C2=A0 &dev_attr_temp3_type.attr,
> + =C2=A0 =C2=A0 &dev_attr_temp2_min.attr,
> + =C2=A0 =C2=A0 &dev_attr_temp3_min.attr,
> + =C2=A0 =C2=A0 &dev_attr_temp2_max.attr,
> + =C2=A0 =C2=A0 &dev_attr_temp3_max.attr,
> + =C2=A0 =C2=A0 &dev_attr_rate.attr,
> + =C2=A0 =C2=A0 NULL
> +};

Should this use an attribute group?

Yes, didn't I ?

Here follows the updated p= atch:
-----------------------------------------------

This patch= implements the hwmon driver for the National Semiconductor LM95241
=C2=A0triple temperature sensors chip

Signed-off-by: Davide Rizzo &l= t;elpa-rizzo@gmail.com>
-= --
diff -urNp linux-2.6.28.5/drivers/hwmon/Kconfig linux-2.6.28.5.elpa/d= rivers/hwmon/Kconfig
--- linux-2.6.28.5/drivers/hwmon/Kconfig=C2=A0=C2=A0=C2=A0 2008-12-25 00:26= :37.000000000 +0100
+++ linux-2.6.28.5.elpa/drivers/hwmon/Kconfig=C2=A0= =C2=A0=C2=A0 2009-01-04 08:07:39.000000000 +0100
@@ -548,6 +548,15 @@ co= nfig SENSORS_LM93
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0 This driver can also b= e built as a module.=C2=A0 If so, the module
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0 will be called lm93.
=C2=A0
+config S= ENSORS_LM95241
+=C2=A0=C2=A0=C2=A0 tristate "National Semiconductor= LM95241 sensor chip"
+=C2=A0=C2=A0=C2=A0 depends on I2C
+=C2=A0= =C2=A0=C2=A0 help
+=C2=A0=C2=A0=C2=A0 =C2=A0 If you say yes here you get= support for LM95241 sensor chip.
+
+=C2=A0=C2=A0=C2=A0 =C2=A0 This driver can also be built as a module.= =C2=A0 If so, the module
+=C2=A0=C2=A0=C2=A0 =C2=A0 will be called lm952= 41.
+
=C2=A0config SENSORS_MAX1111
=C2=A0=C2=A0=C2=A0=C2=A0 trista= te "Maxim MAX1111 Multichannel, Serial 8-bit ADC chip"
=C2=A0=C2=A0=C2=A0=C2=A0 depends on SPI_MASTER
diff -urNp linux-2.6.28.5= /drivers/hwmon/lm95241.c linux-2.6.28.5.elpa/drivers/hwmon/lm95241.c
---= linux-2.6.28.5/drivers/hwmon/lm95241.c=C2=A0=C2=A0=C2=A0 1970-01-01 01:00:= 00.000000000 +0100
+++ linux-2.6.28.5.elpa/drivers/hwmon/lm95241.c=C2=A0= =C2=A0=C2=A0 2009-03-23 17:13:21.000000000 +0100
@@ -0,0 +1,553 @@
+/*
+ * lm95241.c - Part of lm_sensors, Linux kerne= l modules for hardware monitoring
+ * Copyright (C) 2008 Davide Rizzo &l= t;elpa.rizzo@gmail.com>
+ *
+ * The LM95241 is a sensor chip made by National Semiconductors.+ * It reports up to three temperatures (its own plus up to two external o= nes).
+ * Complete datasheet can be obtained from National's website= at:
+ *=C2=A0=C2=A0 h= ttp://www.national.com/ds.cgi/LM/LM95241.pdf
+ *
+ * This program= is free software; you can redistribute it and/or modify
+ * it under th= e 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 distrib= uted in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; w= ithout even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.=C2=A0 See the
+= * GNU General Public License for more details.
+ *
+ * You should ha= ve 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.
+ */
+<= br>+#include <linux/module.h>
+#include <linux/init.h>
+#= include <linux/slab.h>
+#include <linux/jiffies.h>
+#incl= ude <linux/i2c.h>
+#include <linux/hwmon.h>
+#include <linux/hwmon-sysfs.h>+#include <linux/err.h>
+#include <linux/mutex.h>
+#incl= ude <linux/sysfs.h>
+
+static const unsigned short normal_i2c[]= =3D {
+=C2=A0=C2=A0=C2=A0 0x19, 0x2a, 0x2b, I2C_CLIENT_END};
+
+/* Insmod p= arameters */
+I2C_CLIENT_INSMOD_1(lm95241);
+
+/* LM95241 register= s */
+#define LM95241_REG_R_MAN_ID=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 = 0xFE
+#define LM95241_REG_R_CHIP_ID=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0= 0xFF
+#define LM95241_REG_R_STATUS=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 0x02
= +#define LM95241_REG_RW_CONFIG=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 0x03+#define LM95241_REG_RW_REM_FILTER=C2=A0=C2=A0=C2=A0 0x06
+#define LM95= 241_REG_RW_TRUTHERM=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 0x07
+#define L= M95241_REG_W_ONE_SHOT=C2=A0 =C2=A0=C2=A0=C2=A0 0x0F
+#define LM95241_REG_R_LOCAL_TEMPH=C2=A0=C2=A0=C2=A0 0x10
+#define LM952= 41_REG_R_REMOTE1_TEMPH=C2=A0=C2=A0=C2=A0 0x11
+#define LM95241_REG_R_REM= OTE2_TEMPH=C2=A0=C2=A0=C2=A0 0x12
+#define LM95241_REG_R_LOCAL_TEMPL=C2= =A0=C2=A0=C2=A0 0x20
+#define LM95241_REG_R_REMOTE1_TEMPL=C2=A0=C2=A0=C2= =A0 0x21
+#define LM95241_REG_R_REMOTE2_TEMPL=C2=A0=C2=A0=C2=A0 0x22
+#define LM9= 5241_REG_RW_REMOTE_MODEL=C2=A0=C2=A0=C2=A0 0x30
+
+/* LM95241 specifi= c bitfields */
+#define CFG_STOP 0x40
+#define CFG_CR0076 0x00
+#d= efine CFG_CR0182 0x10
+#define CFG_CR1000 0x20
+#define CFG_CR2700 0x30
+#define R1MS_SHIFT 0
+#define R2MS_SHIFT 2<= br>+#define R1MS_MASK (0x01 << (R1MS_SHIFT))
+#define R2MS_MASK (0= x01 << (R2MS_SHIFT))
+#define R1DF_SHIFT 1
+#define R2DF_SHIFT = 2
+#define R1DF_MASK (0x01 << (R1DF_SHIFT))
+#define R2DF_MASK (0x01= << (R2DF_SHIFT))
+#define R1FE_MASK 0x01
+#define R2FE_MASK 0x= 05
+#define TT1_SHIFT 0
+#define TT2_SHIFT 4
+#define TT_OFF 0
+#define TT_ON 1
+#define TT_MASK 7
+#define MANUFACTURER_ID 0x01
= +#define DEFAULT_REVISION 0xA4
+
+/* Functions declaration */
+sta= tic int lm95241_attach_adapter(struct i2c_adapter *adapter);
+static int= lm95241_detect(struct i2c_adapter *adapter, int address,
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 int kind);=
+static void lm95241_init_client(struct i2c_client *client);
+static= int lm95241_detach_client(struct i2c_client *client);
+static struct lm= 95241_data *lm95241_update_device(struct device *dev);
+
+/* Driver data (common to all clients) */
+static struct i2c_drive= r lm95241_driver =3D {
+=C2=A0=C2=A0=C2=A0 .driver =3D {
+=C2=A0=C2= =A0=C2=A0 =C2=A0=C2=A0=C2=A0 .name=C2=A0=C2=A0 =3D "lm95241",
= +=C2=A0=C2=A0=C2=A0 },
+=C2=A0=C2=A0=C2=A0 .attach_adapter =3D lm95241_a= ttach_adapter,
+=C2=A0=C2=A0=C2=A0 .detach_client=C2=A0 =3D lm95241_detach_client,
+};<= br>+
+/* Client data (each client gets its own) */
+struct lm95241_da= ta {
+=C2=A0=C2=A0=C2=A0 struct i2c_client client;
+=C2=A0=C2=A0=C2= =A0 struct device *hwmon_dev;
+=C2=A0=C2=A0=C2=A0 struct mutex update_lo= ck;
+=C2=A0=C2=A0=C2=A0 unsigned long last_updated, rate; /* in jiffies */
+= =C2=A0=C2=A0=C2=A0 char valid; /* zero until following fields are valid */<= br>+=C2=A0=C2=A0=C2=A0 /* registers values */
+=C2=A0=C2=A0=C2=A0 u8 loc= al_h, local_l; /* local */
+=C2=A0=C2=A0=C2=A0 u8 remote1_h, remote1_l; = /* remote1 */
+=C2=A0=C2=A0=C2=A0 u8 remote2_h, remote2_l; /* remote2 */
+=C2=A0=C2=A0= =C2=A0 u8 config, model, trutherm;
+};
+
+static ssize_t show_inpu= t(struct device *dev,
+=C2=A0=C2=A0=C2=A0 struct device_attribute *attr,= char *buf);
+static ssize_t show_rate(struct device *dev, struct device= _attribute *attr,
+=C2=A0=C2=A0=C2=A0 char *buf);
+static ssize_t set_rate(struct device *= dev, struct device_attribute *attr,
+=C2=A0=C2=A0=C2=A0 const char *buf,= size_t count);
+static ssize_t show_type(struct device *dev, struct dev= ice_attribute *attr,
+=C2=A0=C2=A0=C2=A0 char *buf);
+static ssize_t show_min(struct device *dev, struct device_attribute *attr,=
+=C2=A0=C2=A0=C2=A0 char *buf);
+static ssize_t show_max(struct devi= ce *dev, struct device_attribute *attr,
+=C2=A0=C2=A0=C2=A0 char *buf);<= br>+static ssize_t set_type(struct device *dev, struct device_attribute *at= tr,
+=C2=A0=C2=A0=C2=A0 const char *buf, size_t count);
+static ssize_t set_= min(struct device *dev, struct device_attribute *attr,
+=C2=A0=C2=A0=C2= =A0 const char *buf, size_t count);
+static ssize_t set_max(struct devic= e *dev, struct device_attribute *attr,
+=C2=A0=C2=A0=C2=A0 const char *buf, size_t count);
+
+static DEVICE_= ATTR(temp1_input, S_IRUGO, show_input, NULL);
+static DEVICE_ATTR(temp2_= input, S_IRUGO, show_input, NULL);
+static DEVICE_ATTR(temp3_input, S_IR= UGO, show_input, NULL);
+static DEVICE_ATTR(temp2_type, S_IWUSR | S_IRUGO, show_type, set_type);+static DEVICE_ATTR(temp3_type, S_IWUSR | S_IRUGO, show_type, set_type);+static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_min, set_min);
+static DEVICE_ATTR(temp3_min, S_IWUSR | S_IRUGO, show_min, set_min);
+s= tatic DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_max, set_max);
+sta= tic DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_max, set_max);
+stati= c DEVICE_ATTR(rate, S_IWUSR | S_IRUGO, show_rate, set_rate);
+
+static struct attribute *lm95241_attributes[] =3D {
+=C2=A0=C2=A0= =C2=A0 &dev_attr_temp1_input.attr,
+=C2=A0=C2=A0=C2=A0 &dev_attr= _temp2_input.attr,
+=C2=A0=C2=A0=C2=A0 &dev_attr_temp3_input.attr,+=C2=A0=C2=A0=C2=A0 &dev_attr_temp2_type.attr,
+=C2=A0=C2=A0=C2=A0= &dev_attr_temp3_type.attr,
+=C2=A0=C2=A0=C2=A0 &dev_attr_temp2_min.attr,
+=C2=A0=C2=A0=C2=A0 &a= mp;dev_attr_temp3_min.attr,
+=C2=A0=C2=A0=C2=A0 &dev_attr_temp2_max.= attr,
+=C2=A0=C2=A0=C2=A0 &dev_attr_temp3_max.attr,
+=C2=A0=C2=A0= =C2=A0 &dev_attr_rate.attr,
+=C2=A0=C2=A0=C2=A0 NULL
+};
+
= +static const struct attribute_group lm95241_group =3D {
+=C2=A0=C2=A0=C2=A0 .attrs =3D lm95241_attributes,
+};
+
+/* Conve= rsions */
+static int TempFromReg(u8 val_h, u8 val_l)
+{
+=C2=A0= =C2=A0=C2=A0 if (val_h & 0x80)
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 return val_h - 0x100;
+=C2=A0=C2=A0=C2=A0 return val_h * 1000 + val_= l * 1000 / 256;
+}
+
+/* Sysfs stuff */
+static ssize_t show_input(struct device *= dev,
+=C2=A0=C2=A0=C2=A0 struct device_attribute *attr, char *buf)
+{=
+=C2=A0=C2=A0=C2=A0 struct lm95241_data *data =3D lm95241_update_device= (dev);
+=C2=A0=C2=A0=C2=A0 int value;
+
+=C2=A0=C2=A0=C2=A0 if (attr =3D=3D &dev_attr_temp1_input)
+=C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 value =3D TempFromReg(data->local_h, = data->local_l);
+=C2=A0=C2=A0=C2=A0 else if (attr =3D=3D &dev_att= r_temp2_input)
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 value =3D TempFrom= Reg(data->remote1_h, data->remote1_l);
+=C2=A0=C2=A0=C2=A0 else
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 value = =3D TempFromReg(data->remote2_h, data->remote2_l);
+=C2=A0=C2=A0= =C2=A0 snprintf(buf, PAGE_SIZE - 1, "%d\n", value);
+=C2=A0=C2= =A0=C2=A0 return strlen(buf);
+}
+
+static ssize_t show_rate(struc= t device *dev, struct device_attribute *attr,
+=C2=A0=C2=A0=C2=A0 char *buf)
+{
+=C2=A0=C2=A0=C2=A0 struct lm95241_= data *data =3D lm95241_update_device(dev);
+
+=C2=A0=C2=A0=C2=A0 snpr= intf(buf, PAGE_SIZE - 1, "%lu\n", 1000 * data->rate / HZ);
= +=C2=A0=C2=A0=C2=A0 return strlen(buf);
+}
+
+static ssize_t set_r= ate(struct device *dev, struct device_attribute *attr,
+=C2=A0=C2=A0=C2=A0 const char *buf, size_t count)
+{
+=C2=A0=C2=A0= =C2=A0 struct i2c_client *client =3D to_i2c_client(dev);
+=C2=A0=C2=A0= =C2=A0 struct lm95241_data *data =3D i2c_get_clientdata(client);
+
+= =C2=A0=C2=A0=C2=A0 strict_strtol(buf, 10, &data->rate);
+=C2=A0=C2=A0=C2=A0 data->rate =3D data->rate * HZ / 1000;
+=C2=A0= =C2=A0=C2=A0 return count;
+}
+
+static ssize_t show_type(struct d= evice *dev, struct device_attribute *attr,
+=C2=A0=C2=A0=C2=A0 char *buf= )
+{
+=C2=A0=C2=A0=C2=A0 struct i2c_client *client =3D to_i2c_client(= dev);
+=C2=A0=C2=A0=C2=A0 struct lm95241_data *data =3D i2c_get_clientdata(client= );
+
+=C2=A0=C2=A0=C2=A0 if (attr =3D=3D &dev_attr_temp2_type)+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 snprintf(buf, PAGE_SIZE - 1,
+= =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 data->model &am= p; R1MS_MASK ? "1\n" : "2\n");
+=C2=A0=C2=A0=C2=A0 else
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 snprintf= (buf, PAGE_SIZE - 1,
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0= =C2=A0 data->model & R2MS_MASK ? "1\n" : "2\n");=
+=C2=A0=C2=A0=C2=A0 return strlen(buf);
+}
+
+static ssize_t s= how_min(struct device *dev, struct device_attribute *attr,
+=C2=A0=C2=A0=C2=A0 char *buf)
+{
+=C2=A0=C2=A0=C2=A0 struct i2c_clie= nt *client =3D to_i2c_client(dev);
+=C2=A0=C2=A0=C2=A0 struct lm95241_da= ta *data =3D i2c_get_clientdata(client);
+
+=C2=A0=C2=A0=C2=A0 if (at= tr =3D=3D &dev_attr_temp2_min)
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 snprintf(buf, PAGE_SIZE - 1,
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 data->config &= amp; R1DF_MASK ? "-127000\n" : "0\n");
+=C2=A0=C2=A0= =C2=A0 else
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 snprintf(buf, PAGE_SI= ZE - 1,
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 data-&= gt;config & R2DF_MASK ? "-127000\n" : "0\n");
+=C2=A0=C2=A0=C2=A0 return strlen(buf);
+}
+
+static ssize_t show_= max(struct device *dev, struct device_attribute *attr,
+=C2=A0=C2=A0=C2= =A0 char *buf)
+{
+=C2=A0=C2=A0=C2=A0 struct i2c_client *client =3D t= o_i2c_client(dev);
+=C2=A0=C2=A0=C2=A0 struct lm95241_data *data =3D i2c= _get_clientdata(client);
+
+=C2=A0=C2=A0=C2=A0 if (attr =3D=3D &dev_attr_temp2_max)
+=C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 snprintf(buf, PAGE_SIZE - 1,
+=C2=A0= =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 data->config & R1= DF_MASK ? "127000\n" : "255000\n");
+=C2=A0=C2=A0=C2= =A0 else
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 snprintf(buf, PAGE_SIZE = - 1,
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 data->config &= amp; R2DF_MASK ? "127000\n" : "255000\n");
+=C2=A0= =C2=A0=C2=A0 return strlen(buf);
+}
+
+static ssize_t set_type(str= uct device *dev, struct device_attribute *attr,
+=C2=A0=C2=A0=C2=A0 cons= t char *buf, size_t count)
+{
+=C2=A0=C2=A0=C2=A0 struct i2c_client *client =3D to_i2c_client(dev);=
+=C2=A0=C2=A0=C2=A0 struct lm95241_data *data =3D i2c_get_clientdata(cl= ient);
+=C2=A0=C2=A0=C2=A0 long val;
+
+=C2=A0=C2=A0=C2=A0 strict_= strtol(buf, 10, &val);
+=C2=A0=C2=A0=C2=A0 if ((val =3D=3D 1) || (va= l =3D=3D 2)) {
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 int shift;
+=C2=A0=C2=A0=C2=A0 = =C2=A0=C2=A0=C2=A0 u8 mask;
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 if (a= ttr =3D=3D &dev_attr_temp2_type) {
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0= =C2=A0 =C2=A0=C2=A0=C2=A0 shift =3D TT1_SHIFT;
+=C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 mask =3D R1MS_MASK;
+=C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 } else {
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 = =C2=A0=C2=A0=C2=A0 shift =3D TT2_SHIFT;
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 mask =3D R2MS_MAS= K;
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 }
+
+=C2=A0=C2=A0=C2=A0 = =C2=A0=C2=A0=C2=A0 mutex_lock(&data->update_lock);
+
+=C2=A0= =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 data->trutherm &=3D ~(TT_MASK <&l= t; shift);
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 if (val =3D=3D 1) {+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 data->model |= =3D mask;
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 data->trutherm= |=3D (TT_ON << shift);
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 } e= lse {
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 data->= ;model &=3D ~mask;
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2= =A0=C2=A0 data->trutherm |=3D (TT_OFF << shift);
+=C2=A0=C2=A0= =C2=A0 =C2=A0=C2=A0=C2=A0 }
+
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 = data->valid =3D 0;
+
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 i2c_smbus_write_byte_data(clien= t, LM95241_REG_RW_REMOTE_MODEL,
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 = =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 data->mo= del);
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 i2c_smbus_write_byte_data(c= lient, LM95241_REG_RW_TRUTHERM,
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 = =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 data->tr= utherm);
+
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 mutex_unlock(&data->upda= te_lock);
+
+=C2=A0=C2=A0=C2=A0 }
+=C2=A0=C2=A0=C2=A0 return count= ;
+}
+
+static ssize_t set_min(struct device *dev, struct device_a= ttribute *attr,
+=C2=A0=C2=A0=C2=A0 const char *buf, size_t count)
+{
+=C2=A0=C2=A0=C2=A0 struct i2c_client *client =3D to_i2c_client(dev);=
+=C2=A0=C2=A0=C2=A0 struct lm95241_data *data =3D i2c_get_clientdata(cl= ient);
+=C2=A0=C2=A0=C2=A0 long val;
+=C2=A0=C2=A0=C2=A0 u8 mask;
= +
+=C2=A0=C2=A0=C2=A0 strict_strtol(buf, 10, &val);
+=C2=A0=C2=A0= =C2=A0 if (attr =3D=3D &dev_attr_temp2_min)
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 mask =3D R1DF_MASK;
+=C2=A0=C2=A0= =C2=A0 else
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 mask =3D R2DF_MASK;+
+=C2=A0=C2=A0=C2=A0 mutex_lock(&data->update_lock);
+
+= =C2=A0=C2=A0=C2=A0 if (val < 0)
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 data->config |=3D mask;
+=C2=A0=C2=A0=C2=A0 else
+=C2=A0=C2=A0= =C2=A0 =C2=A0=C2=A0=C2=A0 data->config &=3D mask;
+=C2=A0=C2=A0=C2=A0 data->valid =3D 0;
+
+=C2=A0=C2=A0=C2=A0 i2c_s= mbus_write_byte_data(client, LM95241_REG_RW_CONFIG, data->config);
+<= br>+=C2=A0=C2=A0=C2=A0 mutex_unlock(&data->update_lock);
+
+= =C2=A0=C2=A0=C2=A0 return count;
+}
+
+static ssize_t set_max(stru= ct device *dev, struct device_attribute *attr,
+=C2=A0=C2=A0=C2=A0 const char *buf, size_t count)
+{
+=C2=A0=C2=A0= =C2=A0 struct i2c_client *client =3D to_i2c_client(dev);
+=C2=A0=C2=A0= =C2=A0 struct lm95241_data *data =3D i2c_get_clientdata(client);
+=C2=A0= =C2=A0=C2=A0 long val;
+=C2=A0=C2=A0=C2=A0 u8 mask;
+
+=C2=A0=C2= =A0=C2=A0 strict_strtol(buf, 10, &val);
+=C2=A0=C2=A0=C2=A0 if (attr =3D=3D &dev_attr_temp2_max)
+=C2=A0=C2= =A0=C2=A0 =C2=A0=C2=A0=C2=A0 mask =3D R1DF_MASK;
+=C2=A0=C2=A0=C2=A0 els= e
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 mask =3D R2DF_MASK;
+
+= =C2=A0=C2=A0=C2=A0 mutex_lock(&data->update_lock);
+
+=C2=A0= =C2=A0=C2=A0 if (val <=3D 127000)
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 data->config |=3D R1DF_MASK;
+=C2=A0=C2=A0=C2=A0 else
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 data->= ;config &=3D ~R2DF_MASK;
+=C2=A0=C2=A0=C2=A0 data->valid =3D 0;+
+=C2=A0=C2=A0=C2=A0 i2c_smbus_write_byte_data(client, LM95241_REG_RW= _CONFIG, data->config);
+
+=C2=A0=C2=A0=C2=A0 mutex_unlock(&da= ta->update_lock);
+
+=C2=A0=C2=A0=C2=A0 return count;
+}
+
+/* Init/exit code */<= br>+static int lm95241_attach_adapter(struct i2c_adapter *adapter)
+{+=C2=A0=C2=A0=C2=A0 if (!(adapter->class & I2C_CLASS_HWMON))
+= =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 return 0;
+=C2=A0=C2=A0=C2=A0 retu= rn i2c_probe(adapter, &addr_data, lm95241_detect);
+}
+
+/*
+ * The following function does more than just detection.= If detection
+ * succeeds, it also registers the new chip.
+ */
+= static int lm95241_detect(struct i2c_adapter *adapter, int address, int kin= d)
+{
+=C2=A0=C2=A0=C2=A0 struct i2c_client *new_client;
+=C2=A0=C2=A0= =C2=A0 struct lm95241_data *data;
+=C2=A0=C2=A0=C2=A0 int err =3D 0;
= +=C2=A0=C2=A0=C2=A0 const char *name =3D "";
+
+=C2=A0=C2= =A0=C2=A0 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))<= br>+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto exit;
+
+=C2=A0=C2=A0=C2=A0 data =3D kzalloc(sizeof(struct lm95241_data), GFP_= KERNEL);
+=C2=A0=C2=A0=C2=A0 if (!data) {
+=C2=A0=C2=A0=C2=A0 =C2=A0= =C2=A0=C2=A0 err =3D -ENOMEM;
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 got= o exit;
+=C2=A0=C2=A0=C2=A0 }
+
+=C2=A0=C2=A0=C2=A0 /* The common = I2C client data is placed right before the
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 LM95241-specific data. */
+=C2=A0=C2=A0= =C2=A0 new_client =3D &data->client;
+=C2=A0=C2=A0=C2=A0 i2c_set_= clientdata(new_client, data);
+=C2=A0=C2=A0=C2=A0 new_client->addr = =3D address;
+=C2=A0=C2=A0=C2=A0 new_client->adapter =3D adapter;
= +=C2=A0=C2=A0=C2=A0 new_client->driver =3D &lm95241_driver;
+=C2=A0=C2=A0=C2=A0 new_client->flags =3D 0;
+
+=C2=A0=C2=A0=C2=A0= /*
+=C2=A0=C2=A0=C2=A0 =C2=A0* Now we do the remaining detection. A neg= ative kind means that
+=C2=A0=C2=A0=C2=A0 =C2=A0* the driver was loaded = with no force parameter (default), so we
+=C2=A0=C2=A0=C2=A0 =C2=A0* mus= t both detect and identify the chip. A zero kind means that
+=C2=A0=C2=A0=C2=A0 =C2=A0* the driver was loaded with the force parameter,= the detection
+=C2=A0=C2=A0=C2=A0 =C2=A0* step shall be skipped. A posi= tive kind means that the driver
+=C2=A0=C2=A0=C2=A0 =C2=A0* was loaded w= ith the force parameter and a given kind of chip is
+=C2=A0=C2=A0=C2=A0 = =C2=A0* requested, so both the detection and the identification steps
+=C2=A0=C2=A0=C2=A0 =C2=A0* are skipped.
+=C2=A0=C2=A0=C2=A0 =C2=A0*/+=C2=A0=C2=A0=C2=A0 if (kind < 0) {=C2=A0=C2=A0=C2=A0 /* detection */+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 if ((i2c_smbus_read_byte_data(new_= client, LM95241_REG_R_MAN_ID)
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0 !=3D MANUFACTURER_ID)
+=C2=A0=C2=A0=C2=A0 =C2=A0= =C2=A0=C2=A0 || (i2c_smbus_read_byte_data(new_client, LM95241_REG_R_CHIP_ID= )
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 < DEFAULT_REVI= SION)) {
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 dev_d= bg(&adapter->dev,
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0= =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 "LM95241 detection failed at 0x%02x.\n= ",
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0= =C2=A0=C2=A0 address);
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2= =A0=C2=A0 goto exit_free;
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 }
+=C2=A0=C2=A0=C2=A0 }
+
+= =C2=A0=C2=A0=C2=A0 if (kind <=3D 0) { /* identification */
+=C2=A0=C2= =A0=C2=A0 =C2=A0=C2=A0=C2=A0 if ((i2c_smbus_read_byte_data(new_client, LM95= 241_REG_R_MAN_ID)
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0=C2=A0 =3D=3D MANUFACTURER_ID)
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0= && (i2c_smbus_read_byte_data(new_client, LM95241_REG_R_CHIP_ID) +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 >=3D DEFAULT_R= EVISION)) {
+
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 kind =3D lm95241;
+
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0= =C2=A0=C2=A0 if (kind <=3D 0) { /* identification failed */
+=C2=A0= =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 dev_i= nfo(&adapter->dev, "Unsupported chip\n");
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 goto exit_free;
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0= =C2=A0 }
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 }
+=C2=A0=C2=A0=C2=A0= }
+
+=C2=A0=C2=A0=C2=A0 if (kind =3D=3D lm95241)
+=C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 name =3D "lm95241";
+
+=C2=A0=C2=A0= =C2=A0 /* We can fill in the remaining client fields */
+=C2=A0=C2=A0=C2= =A0 strlcpy(new_client->name, name, I2C_NAME_SIZE);
+=C2=A0=C2=A0=C2=A0 data->valid =3D 0;
+=C2=A0=C2=A0=C2=A0 mutex_init= (&data->update_lock);
+
+=C2=A0=C2=A0=C2=A0 /* Tell the I2C la= yer a new client has arrived */
+=C2=A0=C2=A0=C2=A0 err =3D i2c_attach_c= lient(new_client);
+=C2=A0=C2=A0=C2=A0 if (err)
+=C2=A0=C2=A0=C2=A0 = =C2=A0=C2=A0=C2=A0 goto exit_free;
+
+=C2=A0=C2=A0=C2=A0 /* Initialize the LM95241 chip */
+=C2=A0=C2=A0= =C2=A0 lm95241_init_client(new_client);
+
+=C2=A0=C2=A0=C2=A0 /* Regi= ster sysfs hooks */
+=C2=A0=C2=A0=C2=A0 err =3D sysfs_create_group(&= new_client->dev.kobj, &lm95241_group);
+=C2=A0=C2=A0=C2=A0 if (er= r)
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto exit_detach;
+
+=C2=A0=C2= =A0=C2=A0 data->hwmon_dev =3D hwmon_device_register(&new_client->= dev);
+=C2=A0=C2=A0=C2=A0 if (IS_ERR(data->hwmon_dev)) {
+=C2=A0= =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D PTR_ERR(data->hwmon_dev);
+= =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto exit_remove_files;
+=C2=A0=C2=A0=C2=A0 }
+
+=C2=A0=C2=A0=C2=A0 return 0;
+
+exit_r= emove_files:
+=C2=A0=C2=A0=C2=A0 sysfs_remove_group(&new_client->= dev.kobj, &lm95241_group);
+exit_detach:
+=C2=A0=C2=A0=C2=A0 i2c_= detach_client(new_client);
+exit_free:
+=C2=A0=C2=A0=C2=A0 kfree(data= );
+exit:
+=C2=A0=C2=A0=C2=A0 return err;
+}
+
+static void lm9524= 1_init_client(struct i2c_client *client)
+{
+=C2=A0=C2=A0=C2=A0 struc= t lm95241_data *data =3D i2c_get_clientdata(client);
+
+=C2=A0=C2=A0= =C2=A0 data->rate =3D HZ;=C2=A0=C2=A0=C2=A0 /* 1 sec default */
+=C2=A0=C2=A0=C2=A0 data->valid =3D 0;
+=C2=A0=C2=A0=C2=A0 data->c= onfig =3D CFG_CR0076;
+=C2=A0=C2=A0=C2=A0 data->model =3D 0;
+=C2= =A0=C2=A0=C2=A0 data->trutherm =3D (TT_OFF << TT1_SHIFT) | (TT_OFF= << TT2_SHIFT);
+
+=C2=A0=C2=A0=C2=A0 i2c_smbus_write_byte_data= (client, LM95241_REG_RW_CONFIG,
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0 data->config);
+=C2=A0=C2=A0=C2=A0 i2c_smbus_write_byte_da= ta(client, LM95241_REG_RW_REM_FILTER,
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0= =C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 R1FE_MASK | R2FE_MASK);=
+=C2=A0=C2=A0=C2=A0 i2c_smbus_write_byte_data(client, LM95241_REG_RW_TR= UTHERM,
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0 data->trutherm);
+=C2=A0=C2=A0=C2=A0 i2c_smbus_write_byte_= data(client, LM95241_REG_RW_REMOTE_MODEL,
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2= =A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 data->model);
= +}
+
+static int lm95241_detach_client(struct i2c_client *client)
+{
+=C2=A0=C2=A0=C2=A0 struct lm95241_data *data =3D i2c_get_clientdata(= client);
+=C2=A0=C2=A0=C2=A0 int err;
+
+=C2=A0=C2=A0=C2=A0 hwmon_= device_unregister(data->hwmon_dev);
+=C2=A0=C2=A0=C2=A0 sysfs_remove_= group(&client->dev.kobj, &lm95241_group);
+
+=C2=A0=C2=A0=C2=A0 err =3D i2c_detach_client(client);
+=C2=A0=C2=A0=C2= =A0 if (err)
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 return err;
+
= +=C2=A0=C2=A0=C2=A0 kfree(data);
+=C2=A0=C2=A0=C2=A0 return 0;
+}
= +
+static struct lm95241_data *lm95241_update_device(struct device *dev)=
+{
+=C2=A0=C2=A0=C2=A0 struct i2c_client *client =3D to_i2c_client(d= ev);
+=C2=A0=C2=A0=C2=A0 struct lm95241_data *data =3D i2c_get_clientdata(client= );
+
+=C2=A0=C2=A0=C2=A0 mutex_lock(&data->update_lock);
+<= br>+=C2=A0=C2=A0=C2=A0 if (time_after(jiffies, data->last_updated + data= ->rate) ||
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 !data->valid) {<= br> +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 dev_dbg(&client->dev, "U= pdating lm95241 data.\n");
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 d= ata->local_h =3D
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0= =C2=A0 i2c_smbus_read_byte_data(client,
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0= =C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2= =A0=C2=A0 =C2=A0LM95241_REG_R_LOCAL_TEMPH);
+=C2=A0=C2=A0=C2=A0 =C2=A0= =C2=A0=C2=A0 data->local_l =3D
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 i2c_smbus_read_by= te_data(client,
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0LM95241_= REG_R_LOCAL_TEMPL);
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 data->remo= te1_h =3D
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 i2c_= smbus_read_byte_data(client,
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 = =C2=A0LM95241_REG_R_REMOTE1_TEMPH);
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 data->remote1_l =3D
+=C2=A0=C2= =A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 i2c_smbus_read_byte_data(cl= ient,
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0= =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0LM95241_REG_R_REMO= TE1_TEMPL);
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 data->remote2_h = =3D
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 i2c_smbus_= read_byte_data(client,
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0LM95241_REG_R_REMOTE2_TEMPH= );
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 data->remote2_l =3D
+=C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 i2c_smbus_read_byte_d= ata(client,
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 = =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0LM95241_REG_= R_REMOTE2_TEMPL);
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 data->last_u= pdated =3D jiffies;
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 data->valid =3D 1;
+=C2=A0=C2= =A0=C2=A0 }
+
+=C2=A0=C2=A0=C2=A0 mutex_unlock(&data->update_l= ock);
+
+=C2=A0=C2=A0=C2=A0 return data;
+}
+
+static int __= init sensors_lm95241_init(void)
+{
+=C2=A0=C2=A0=C2=A0 return i2c_add= _driver(&lm95241_driver);
+}
+
+static void __exit sensors_lm95241_exit(void)
+{
+=C2=A0= =C2=A0=C2=A0 i2c_del_driver(&lm95241_driver);
+}
+
+MODULE_AUT= HOR("Davide Rizzo <elpa.riz= zo@gmail.com>");
+MODULE_DESCRIPTION("LM95241 sensor driver");
+MODULE_LICENSE(= "GPL");
+
+module_init(sensors_lm95241_init);
+module_ex= it(sensors_lm95241_exit);
diff -urNp linux-2.6.28.5/drivers/hwmon/Makefi= le linux-2.6.28.5.elpa/drivers/hwmon/Makefile
--- linux-2.6.28.5/drivers/hwmon/Makefile=C2=A0=C2=A0=C2=A0 2008-12-25 00:2= 6:37.000000000 +0100
+++ linux-2.6.28.5.elpa/drivers/hwmon/Makefile=C2= =A0=C2=A0=C2=A0 2009-01-04 08:14:42.000000000 +0100
@@ -62,6 +62,7 @@ ob= j-$(CONFIG_SENSORS_LM87)=C2=A0=C2=A0=C2=A0 +=3D lm87.o
=C2=A0obj-$(CONFIG_SENSORS_LM90)=C2=A0=C2=A0=C2=A0 +=3D lm90.o
=C2=A0obj= -$(CONFIG_SENSORS_LM92)=C2=A0=C2=A0=C2=A0 +=3D lm92.o
=C2=A0obj-$(CONFIG= _SENSORS_LM93)=C2=A0=C2=A0=C2=A0 +=3D lm93.o
+obj-$(CONFIG_SENSORS_LM952= 41)=C2=A0=C2=A0=C2=A0 +=3D lm95241.o
=C2=A0obj-$(CONFIG_SENSORS_MAX1111)= =C2=A0=C2=A0=C2=A0 +=3D max1111.o
=C2=A0obj-$(CONFIG_SENSORS_MAX1619)=C2=A0=C2=A0=C2=A0 +=3D max1619.o
=C2= =A0obj-$(CONFIG_SENSORS_MAX6650)=C2=A0=C2=A0=C2=A0 +=3D max6650.o

--0015174c34a21f6b240465cbc41b-- --===============2277600053434456250== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ lm-sensors mailing list lm-sensors@lm-sensors.org http://lists.lm-sensors.org/mailman/listinfo/lm-sensors --===============2277600053434456250==--