aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/adm1029.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-03-21 13:37:25 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-21 13:37:25 -0400
commit31f6765266417c0d99f0e922fe82848a7c9c2ae9 (patch)
tree2d5914dac0a918baad37decd3845b8c206051420 /drivers/hwmon/adm1029.c
parentd15d76448bb58c7832e954b6a8f1e301720b7866 (diff)
parent312869ec935ab3bb67b7ba641a7d11230555aff5 (diff)
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/adm1029.c')
-rw-r--r--drivers/hwmon/adm1029.c47
1 files changed, 19 insertions, 28 deletions
diff --git a/drivers/hwmon/adm1029.c b/drivers/hwmon/adm1029.c
index 0b8a3b145bd2..80cc465d8ac7 100644
--- a/drivers/hwmon/adm1029.c
+++ b/drivers/hwmon/adm1029.c
@@ -78,7 +78,7 @@ static const unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d,
78 78
79#define TEMP_FROM_REG(val) ((val) * 1000) 79#define TEMP_FROM_REG(val) ((val) * 1000)
80 80
81#define DIV_FROM_REG(val) ( 1 << (((val) >> 6) - 1)) 81#define DIV_FROM_REG(val) (1 << (((val) >> 6) - 1))
82 82
83/* Registers to be checked by adm1029_update_device() */ 83/* Registers to be checked by adm1029_update_device() */
84static const u8 ADM1029_REG_TEMP[] = { 84static const u8 ADM1029_REG_TEMP[] = {
@@ -200,8 +200,11 @@ static ssize_t set_fan_div(struct device *dev,
200 struct i2c_client *client = to_i2c_client(dev); 200 struct i2c_client *client = to_i2c_client(dev);
201 struct adm1029_data *data = i2c_get_clientdata(client); 201 struct adm1029_data *data = i2c_get_clientdata(client);
202 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 202 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
203 long val = simple_strtol(buf, NULL, 10);
204 u8 reg; 203 u8 reg;
204 long val;
205 int ret = kstrtol(buf, 10, &val);
206 if (ret < 0)
207 return ret;
205 208
206 mutex_lock(&data->update_lock); 209 mutex_lock(&data->update_lock);
207 210
@@ -237,9 +240,9 @@ static ssize_t set_fan_div(struct device *dev,
237} 240}
238 241
239/* 242/*
240Access rights on sysfs, S_IRUGO stand for Is Readable by User, Group and Others 243 * Access rights on sysfs. S_IRUGO: Is Readable by User, Group and Others
241 S_IWUSR stand for Is Writable by User 244 * S_IWUSR: Is Writable by User.
242*/ 245 */
243static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); 246static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0);
244static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1); 247static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1);
245static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2); 248static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2);
@@ -300,7 +303,8 @@ static int adm1029_detect(struct i2c_client *client,
300 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 303 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
301 return -ENODEV; 304 return -ENODEV;
302 305
303 /* ADM1029 doesn't have CHIP ID, check just MAN ID 306 /*
307 * ADM1029 doesn't have CHIP ID, check just MAN ID
304 * For better detection we check also ADM1029_TEMP_DEVICES_INSTALLED, 308 * For better detection we check also ADM1029_TEMP_DEVICES_INSTALLED,
305 * ADM1029_REG_NB_FAN_SUPPORT and compare it with possible values 309 * ADM1029_REG_NB_FAN_SUPPORT and compare it with possible values
306 * documented 310 * documented
@@ -318,8 +322,10 @@ static int adm1029_detect(struct i2c_client *client,
318 return -ENODEV; 322 return -ENODEV;
319 323
320 if ((chip_id & 0xF0) != 0x00) { 324 if ((chip_id & 0xF0) != 0x00) {
321 /* There are no "official" CHIP ID, so actually 325 /*
322 * we use Major/Minor revision for that */ 326 * There are no "official" CHIP ID, so actually
327 * we use Major/Minor revision for that
328 */
323 pr_info("adm1029: Unknown major revision %x, " 329 pr_info("adm1029: Unknown major revision %x, "
324 "please let us know\n", chip_id); 330 "please let us know\n", chip_id);
325 return -ENODEV; 331 return -ENODEV;
@@ -355,7 +361,8 @@ static int adm1029_probe(struct i2c_client *client,
355 } 361 }
356 362
357 /* Register sysfs hooks */ 363 /* Register sysfs hooks */
358 if ((err = sysfs_create_group(&client->dev.kobj, &adm1029_group))) 364 err = sysfs_create_group(&client->dev.kobj, &adm1029_group);
365 if (err)
359 goto exit_free; 366 goto exit_free;
360 367
361 data->hwmon_dev = hwmon_device_register(&client->dev); 368 data->hwmon_dev = hwmon_device_register(&client->dev);
@@ -403,8 +410,8 @@ static int adm1029_remove(struct i2c_client *client)
403} 410}
404 411
405/* 412/*
406function that update the status of the chips (temperature for example) 413 * function that update the status of the chips (temperature for example)
407*/ 414 */
408static struct adm1029_data *adm1029_update_device(struct device *dev) 415static struct adm1029_data *adm1029_update_device(struct device *dev)
409{ 416{
410 struct i2c_client *client = to_i2c_client(dev); 417 struct i2c_client *client = to_i2c_client(dev);
@@ -446,24 +453,8 @@ static struct adm1029_data *adm1029_update_device(struct device *dev)
446 return data; 453 return data;
447} 454}
448 455
449/* 456module_i2c_driver(adm1029_driver);
450 Common module stuff
451*/
452static int __init sensors_adm1029_init(void)
453{
454
455 return i2c_add_driver(&adm1029_driver);
456}
457
458static void __exit sensors_adm1029_exit(void)
459{
460
461 i2c_del_driver(&adm1029_driver);
462}
463 457
464MODULE_AUTHOR("Corentin LABBE <corentin.labbe@geomatys.fr>"); 458MODULE_AUTHOR("Corentin LABBE <corentin.labbe@geomatys.fr>");
465MODULE_DESCRIPTION("adm1029 driver"); 459MODULE_DESCRIPTION("adm1029 driver");
466MODULE_LICENSE("GPL v2"); 460MODULE_LICENSE("GPL v2");
467
468module_init(sensors_adm1029_init);
469module_exit(sensors_adm1029_exit);