aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm80.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/lm80.c')
-rw-r--r--drivers/hwmon/lm80.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c
index 8100595feb44..83af8b3a0cac 100644
--- a/drivers/hwmon/lm80.c
+++ b/drivers/hwmon/lm80.c
@@ -26,15 +26,15 @@
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/jiffies.h> 27#include <linux/jiffies.h>
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <linux/i2c-sensor.h> 29#include <linux/hwmon.h>
30#include <linux/err.h>
30 31
31/* Addresses to scan */ 32/* Addresses to scan */
32static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 33static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c,
33 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; 34 0x2d, 0x2e, 0x2f, I2C_CLIENT_END };
34static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
35 35
36/* Insmod parameters */ 36/* Insmod parameters */
37SENSORS_INSMOD_1(lm80); 37I2C_CLIENT_INSMOD_1(lm80);
38 38
39/* Many LM80 constants specified below */ 39/* Many LM80 constants specified below */
40 40
@@ -107,6 +107,7 @@ static inline long TEMP_FROM_REG(u16 temp)
107 107
108struct lm80_data { 108struct lm80_data {
109 struct i2c_client client; 109 struct i2c_client client;
110 struct class_device *class_dev;
110 struct semaphore update_lock; 111 struct semaphore update_lock;
111 char valid; /* !=0 if following fields are valid */ 112 char valid; /* !=0 if following fields are valid */
112 unsigned long last_updated; /* In jiffies */ 113 unsigned long last_updated; /* In jiffies */
@@ -389,7 +390,7 @@ static int lm80_attach_adapter(struct i2c_adapter *adapter)
389{ 390{
390 if (!(adapter->class & I2C_CLASS_HWMON)) 391 if (!(adapter->class & I2C_CLASS_HWMON))
391 return 0; 392 return 0;
392 return i2c_detect(adapter, &addr_data, lm80_detect); 393 return i2c_probe(adapter, &addr_data, lm80_detect);
393} 394}
394 395
395int lm80_detect(struct i2c_adapter *adapter, int address, int kind) 396int lm80_detect(struct i2c_adapter *adapter, int address, int kind)
@@ -451,6 +452,12 @@ int lm80_detect(struct i2c_adapter *adapter, int address, int kind)
451 data->fan_min[1] = lm80_read_value(new_client, LM80_REG_FAN_MIN(2)); 452 data->fan_min[1] = lm80_read_value(new_client, LM80_REG_FAN_MIN(2));
452 453
453 /* Register sysfs hooks */ 454 /* Register sysfs hooks */
455 data->class_dev = hwmon_device_register(&new_client->dev);
456 if (IS_ERR(data->class_dev)) {
457 err = PTR_ERR(data->class_dev);
458 goto error_detach;
459 }
460
454 device_create_file(&new_client->dev, &dev_attr_in0_min); 461 device_create_file(&new_client->dev, &dev_attr_in0_min);
455 device_create_file(&new_client->dev, &dev_attr_in1_min); 462 device_create_file(&new_client->dev, &dev_attr_in1_min);
456 device_create_file(&new_client->dev, &dev_attr_in2_min); 463 device_create_file(&new_client->dev, &dev_attr_in2_min);
@@ -487,6 +494,8 @@ int lm80_detect(struct i2c_adapter *adapter, int address, int kind)
487 494
488 return 0; 495 return 0;
489 496
497error_detach:
498 i2c_detach_client(new_client);
490error_free: 499error_free:
491 kfree(data); 500 kfree(data);
492exit: 501exit:
@@ -495,15 +504,15 @@ exit:
495 504
496static int lm80_detach_client(struct i2c_client *client) 505static int lm80_detach_client(struct i2c_client *client)
497{ 506{
507 struct lm80_data *data = i2c_get_clientdata(client);
498 int err; 508 int err;
499 509
500 if ((err = i2c_detach_client(client))) { 510 hwmon_device_unregister(data->class_dev);
501 dev_err(&client->dev, "Client deregistration failed, " 511
502 "client not detached.\n"); 512 if ((err = i2c_detach_client(client)))
503 return err; 513 return err;
504 }
505 514
506 kfree(i2c_get_clientdata(client)); 515 kfree(data);
507 return 0; 516 return 0;
508} 517}
509 518