diff options
Diffstat (limited to 'drivers/hwmon/gl518sm.c')
-rw-r--r-- | drivers/hwmon/gl518sm.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c index 6bedf729dcf5..256b9323c84b 100644 --- a/drivers/hwmon/gl518sm.c +++ b/drivers/hwmon/gl518sm.c | |||
@@ -41,14 +41,14 @@ | |||
41 | #include <linux/slab.h> | 41 | #include <linux/slab.h> |
42 | #include <linux/jiffies.h> | 42 | #include <linux/jiffies.h> |
43 | #include <linux/i2c.h> | 43 | #include <linux/i2c.h> |
44 | #include <linux/i2c-sensor.h> | 44 | #include <linux/hwmon.h> |
45 | #include <linux/err.h> | ||
45 | 46 | ||
46 | /* Addresses to scan */ | 47 | /* Addresses to scan */ |
47 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; | 48 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; |
48 | static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; | ||
49 | 49 | ||
50 | /* Insmod parameters */ | 50 | /* Insmod parameters */ |
51 | SENSORS_INSMOD_2(gl518sm_r00, gl518sm_r80); | 51 | I2C_CLIENT_INSMOD_2(gl518sm_r00, gl518sm_r80); |
52 | 52 | ||
53 | /* Many GL518 constants specified below */ | 53 | /* Many GL518 constants specified below */ |
54 | 54 | ||
@@ -117,6 +117,7 @@ static inline u8 FAN_TO_REG(long rpm, int div) | |||
117 | /* Each client has this additional data */ | 117 | /* Each client has this additional data */ |
118 | struct gl518_data { | 118 | struct gl518_data { |
119 | struct i2c_client client; | 119 | struct i2c_client client; |
120 | struct class_device *class_dev; | ||
120 | enum chips type; | 121 | enum chips type; |
121 | 122 | ||
122 | struct semaphore update_lock; | 123 | struct semaphore update_lock; |
@@ -346,7 +347,7 @@ static int gl518_attach_adapter(struct i2c_adapter *adapter) | |||
346 | { | 347 | { |
347 | if (!(adapter->class & I2C_CLASS_HWMON)) | 348 | if (!(adapter->class & I2C_CLASS_HWMON)) |
348 | return 0; | 349 | return 0; |
349 | return i2c_detect(adapter, &addr_data, gl518_detect); | 350 | return i2c_probe(adapter, &addr_data, gl518_detect); |
350 | } | 351 | } |
351 | 352 | ||
352 | static int gl518_detect(struct i2c_adapter *adapter, int address, int kind) | 353 | static int gl518_detect(struct i2c_adapter *adapter, int address, int kind) |
@@ -419,6 +420,12 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind) | |||
419 | gl518_init_client((struct i2c_client *) new_client); | 420 | gl518_init_client((struct i2c_client *) new_client); |
420 | 421 | ||
421 | /* Register sysfs hooks */ | 422 | /* Register sysfs hooks */ |
423 | data->class_dev = hwmon_device_register(&new_client->dev); | ||
424 | if (IS_ERR(data->class_dev)) { | ||
425 | err = PTR_ERR(data->class_dev); | ||
426 | goto exit_detach; | ||
427 | } | ||
428 | |||
422 | device_create_file(&new_client->dev, &dev_attr_in0_input); | 429 | device_create_file(&new_client->dev, &dev_attr_in0_input); |
423 | device_create_file(&new_client->dev, &dev_attr_in1_input); | 430 | device_create_file(&new_client->dev, &dev_attr_in1_input); |
424 | device_create_file(&new_client->dev, &dev_attr_in2_input); | 431 | device_create_file(&new_client->dev, &dev_attr_in2_input); |
@@ -450,6 +457,8 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind) | |||
450 | /* OK, this is not exactly good programming practice, usually. But it is | 457 | /* OK, this is not exactly good programming practice, usually. But it is |
451 | very code-efficient in this case. */ | 458 | very code-efficient in this case. */ |
452 | 459 | ||
460 | exit_detach: | ||
461 | i2c_detach_client(new_client); | ||
453 | exit_free: | 462 | exit_free: |
454 | kfree(data); | 463 | kfree(data); |
455 | exit: | 464 | exit: |
@@ -477,16 +486,15 @@ static void gl518_init_client(struct i2c_client *client) | |||
477 | 486 | ||
478 | static int gl518_detach_client(struct i2c_client *client) | 487 | static int gl518_detach_client(struct i2c_client *client) |
479 | { | 488 | { |
489 | struct gl518_data *data = i2c_get_clientdata(client); | ||
480 | int err; | 490 | int err; |
481 | 491 | ||
482 | if ((err = i2c_detach_client(client))) { | 492 | hwmon_device_unregister(data->class_dev); |
483 | dev_err(&client->dev, "Client deregistration failed, " | ||
484 | "client not detached.\n"); | ||
485 | return err; | ||
486 | } | ||
487 | 493 | ||
488 | kfree(i2c_get_clientdata(client)); | 494 | if ((err = i2c_detach_client(client))) |
495 | return err; | ||
489 | 496 | ||
497 | kfree(data); | ||
490 | return 0; | 498 | return 0; |
491 | } | 499 | } |
492 | 500 | ||