diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-21 10:37:25 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-21 10:37:25 -0700 |
commit | 31f6765266417c0d99f0e922fe82848a7c9c2ae9 (patch) | |
tree | 2d5914dac0a918baad37decd3845b8c206051420 /drivers/hwmon/ds1621.c | |
parent | Merge tag 'regulator-3.4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator (diff) | |
parent | hwmon: (sch56xx) Add support for the integrated watchdog (v2) (diff) | |
download | linux-dev-31f6765266417c0d99f0e922fe82848a7c9c2ae9.tar.xz linux-dev-31f6765266417c0d99f0e922fe82848a7c9c2ae9.zip |
Merge tag 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
Pull hwmon changes for v3.4 from Guenter Roeck:
"Mostly cleanup. No new drivers this time around, but support for
several chips added to existing drivers: TPS40400, TPS40422, MTD040,
MAX34446, ZL9101M, ZL9117M, and LM96080. Also, added watchdog support
for SCH56xx, and additional attributes for a couple of drivers."
* tag 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: (137 commits)
hwmon: (sch56xx) Add support for the integrated watchdog (v2)
hwmon: (w83627ehf) Add support for temperature offset registers
hwmon: (jc42) Remove unnecessary device IDs
hwmon: (zl6100) Add support for ZL9101M and ZL9117M
hwmon: (adm1275) Add support for ADM1075
hwmon: (max34440) Add support for MAX34446
hwmon: (pmbus) Add more virtual registers
hwmon: (pmbus) Add support for Lineage Power MDT040
hwmon: (pmbus) Add support for TI TPS40400 and TPS40422
hwmon: (max34440) Add support for 'lowest' output voltage attribute
hwmon: (jc42) Convert to use devm_kzalloc
hwmon: (max16065) Convert to use devm_kzalloc
hwmon: (smm665) Convert to use devm_kzalloc
hwmon: (ltc4261) Convert to use devm_kzalloc
hwmon: (pmbus) Simplify remove functions
hwmon: (pmbus) Convert pmbus drivers to use devm_kzalloc
hwmon: (lineage-pem) Convert to use devm_kzalloc
hwmon: (hwmon-vid) Fix checkpatch issues
hwmon: (hwmon-vid) Add new entries to VRM model table
hwmon: (lm80) Add detection of NatSemi/TI LM96080
...
Diffstat (limited to 'drivers/hwmon/ds1621.c')
-rw-r--r-- | drivers/hwmon/ds1621.c | 93 |
1 files changed, 45 insertions, 48 deletions
diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c index ef1ac996752e..f647a3307ebc 100644 --- a/drivers/hwmon/ds1621.c +++ b/drivers/hwmon/ds1621.c @@ -1,25 +1,25 @@ /* - ds1621.c - Part of lm_sensors, Linux kernel modules for hardware - monitoring - Christian W. Zuckschwerdt <zany@triq.net> 2000-11-23 - based on lm75.c by Frodo Looijaard <frodol@dds.nl> - Ported to Linux 2.6 by Aurelien Jarno <aurelien@aurel32.net> with - the help of Jean Delvare <khali@linux-fr.org> - - 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. -*/ + * ds1621.c - Part of lm_sensors, Linux kernel modules for hardware + * monitoring + * Christian W. Zuckschwerdt <zany@triq.net> 2000-11-23 + * based on lm75.c by Frodo Looijaard <frodol@dds.nl> + * Ported to Linux 2.6 by Aurelien Jarno <aurelien@aurel32.net> with + * the help of Jean Delvare <khali@linux-fr.org> + * + * 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 <linux/module.h> #include <linux/init.h> @@ -67,7 +67,7 @@ static const u8 DS1621_REG_TEMP[3] = { /* Conversions */ #define ALARMS_FROM_REG(val) ((val) & \ - (DS1621_ALARM_TEMP_HIGH | DS1621_ALARM_TEMP_LOW)) + (DS1621_ALARM_TEMP_HIGH | DS1621_ALARM_TEMP_LOW)) /* Each client has this additional data */ struct ds1621_data { @@ -93,10 +93,10 @@ static void ds1621_init_client(struct i2c_client *client) new_conf &= ~DS1621_REG_CONFIG_POLARITY; else if (polarity == 1) new_conf |= DS1621_REG_CONFIG_POLARITY; - + if (conf != new_conf) i2c_smbus_write_byte_data(client, DS1621_REG_CONF, new_conf); - + /* start conversion */ i2c_smbus_write_byte(client, DS1621_COM_START); } @@ -155,10 +155,15 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da, struct sensor_device_attribute *attr = to_sensor_dev_attr(da); struct i2c_client *client = to_i2c_client(dev); struct ds1621_data *data = i2c_get_clientdata(client); - u16 val = LM75_TEMP_TO_REG(simple_strtol(buf, NULL, 10)); + long val; + int err; + + err = kstrtol(buf, 10, &val); + if (err) + return err; mutex_lock(&data->update_lock); - data->temp[attr->index] = val; + data->temp[attr->index] = LM75_TEMP_TO_REG(val); i2c_smbus_write_word_swapped(client, DS1621_REG_TEMP[attr->index], data->temp[attr->index]); mutex_unlock(&data->update_lock); @@ -212,14 +217,17 @@ static int ds1621_detect(struct i2c_client *client, int conf, temp; int i; - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA - | I2C_FUNC_SMBUS_WORD_DATA + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA + | I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_WRITE_BYTE)) return -ENODEV; - /* Now, we do the remaining detection. It is lousy. */ - /* The NVB bit should be low if no EEPROM write has been requested - during the latest 10ms, which is highly improbable in our case. */ + /* + * Now, we do the remaining detection. It is lousy. + * + * The NVB bit should be low if no EEPROM write has been requested + * during the latest 10ms, which is highly improbable in our case. + */ conf = i2c_smbus_read_byte_data(client, DS1621_REG_CONF); if (conf < 0 || conf & DS1621_REG_CONFIG_NVB) return -ENODEV; @@ -254,7 +262,8 @@ static int ds1621_probe(struct i2c_client *client, ds1621_init_client(client); /* Register sysfs hooks */ - if ((err = sysfs_create_group(&client->dev.kobj, &ds1621_group))) + err = sysfs_create_group(&client->dev.kobj, &ds1621_group); + if (err) goto exit_free; data->hwmon_dev = hwmon_device_register(&client->dev); @@ -265,11 +274,11 @@ static int ds1621_probe(struct i2c_client *client, return 0; - exit_remove_files: + exit_remove_files: sysfs_remove_group(&client->dev.kobj, &ds1621_group); - exit_free: + exit_free: kfree(data); - exit: + exit: return err; } @@ -305,20 +314,8 @@ static struct i2c_driver ds1621_driver = { .address_list = normal_i2c, }; -static int __init ds1621_init(void) -{ - return i2c_add_driver(&ds1621_driver); -} - -static void __exit ds1621_exit(void) -{ - i2c_del_driver(&ds1621_driver); -} - +module_i2c_driver(ds1621_driver); MODULE_AUTHOR("Christian W. Zuckschwerdt <zany@triq.net>"); MODULE_DESCRIPTION("DS1621 driver"); MODULE_LICENSE("GPL"); - -module_init(ds1621_init); -module_exit(ds1621_exit); |