diff options
Diffstat (limited to 'drivers/hwmon/fscpos.c')
-rw-r--r-- | drivers/hwmon/fscpos.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/drivers/hwmon/fscpos.c b/drivers/hwmon/fscpos.c index 301ae98bd0ad..5fc77a5fed07 100644 --- a/drivers/hwmon/fscpos.c +++ b/drivers/hwmon/fscpos.c | |||
@@ -34,19 +34,19 @@ | |||
34 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
35 | #include <linux/jiffies.h> | 35 | #include <linux/jiffies.h> |
36 | #include <linux/i2c.h> | 36 | #include <linux/i2c.h> |
37 | #include <linux/i2c-sensor.h> | ||
38 | #include <linux/init.h> | 37 | #include <linux/init.h> |
38 | #include <linux/hwmon.h> | ||
39 | #include <linux/err.h> | ||
39 | 40 | ||
40 | /* | 41 | /* |
41 | * Addresses to scan | 42 | * Addresses to scan |
42 | */ | 43 | */ |
43 | static unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END }; | 44 | static unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END }; |
44 | static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; | ||
45 | 45 | ||
46 | /* | 46 | /* |
47 | * Insmod parameters | 47 | * Insmod parameters |
48 | */ | 48 | */ |
49 | SENSORS_INSMOD_1(fscpos); | 49 | I2C_CLIENT_INSMOD_1(fscpos); |
50 | 50 | ||
51 | /* | 51 | /* |
52 | * The FSCPOS registers | 52 | * The FSCPOS registers |
@@ -113,6 +113,7 @@ static struct i2c_driver fscpos_driver = { | |||
113 | */ | 113 | */ |
114 | struct fscpos_data { | 114 | struct fscpos_data { |
115 | struct i2c_client client; | 115 | struct i2c_client client; |
116 | struct class_device *class_dev; | ||
116 | struct semaphore update_lock; | 117 | struct semaphore update_lock; |
117 | char valid; /* 0 until following fields are valid */ | 118 | char valid; /* 0 until following fields are valid */ |
118 | unsigned long last_updated; /* In jiffies */ | 119 | unsigned long last_updated; /* In jiffies */ |
@@ -434,7 +435,7 @@ static int fscpos_attach_adapter(struct i2c_adapter *adapter) | |||
434 | { | 435 | { |
435 | if (!(adapter->class & I2C_CLASS_HWMON)) | 436 | if (!(adapter->class & I2C_CLASS_HWMON)) |
436 | return 0; | 437 | return 0; |
437 | return i2c_detect(adapter, &addr_data, fscpos_detect); | 438 | return i2c_probe(adapter, &addr_data, fscpos_detect); |
438 | } | 439 | } |
439 | 440 | ||
440 | int fscpos_detect(struct i2c_adapter *adapter, int address, int kind) | 441 | int fscpos_detect(struct i2c_adapter *adapter, int address, int kind) |
@@ -496,6 +497,12 @@ int fscpos_detect(struct i2c_adapter *adapter, int address, int kind) | |||
496 | dev_info(&new_client->dev, "Found fscpos chip, rev %u\n", data->revision); | 497 | dev_info(&new_client->dev, "Found fscpos chip, rev %u\n", data->revision); |
497 | 498 | ||
498 | /* Register sysfs hooks */ | 499 | /* Register sysfs hooks */ |
500 | data->class_dev = hwmon_device_register(&new_client->dev); | ||
501 | if (IS_ERR(data->class_dev)) { | ||
502 | err = PTR_ERR(data->class_dev); | ||
503 | goto exit_detach; | ||
504 | } | ||
505 | |||
499 | device_create_file(&new_client->dev, &dev_attr_event); | 506 | device_create_file(&new_client->dev, &dev_attr_event); |
500 | device_create_file(&new_client->dev, &dev_attr_in0_input); | 507 | device_create_file(&new_client->dev, &dev_attr_in0_input); |
501 | device_create_file(&new_client->dev, &dev_attr_in1_input); | 508 | device_create_file(&new_client->dev, &dev_attr_in1_input); |
@@ -526,6 +533,8 @@ int fscpos_detect(struct i2c_adapter *adapter, int address, int kind) | |||
526 | 533 | ||
527 | return 0; | 534 | return 0; |
528 | 535 | ||
536 | exit_detach: | ||
537 | i2c_detach_client(new_client); | ||
529 | exit_free: | 538 | exit_free: |
530 | kfree(data); | 539 | kfree(data); |
531 | exit: | 540 | exit: |
@@ -534,14 +543,14 @@ exit: | |||
534 | 543 | ||
535 | static int fscpos_detach_client(struct i2c_client *client) | 544 | static int fscpos_detach_client(struct i2c_client *client) |
536 | { | 545 | { |
546 | struct fscpos_data *data = i2c_get_clientdata(client); | ||
537 | int err; | 547 | int err; |
538 | 548 | ||
539 | if ((err = i2c_detach_client(client))) { | 549 | hwmon_device_unregister(data->class_dev); |
540 | dev_err(&client->dev, "Client deregistration failed, client" | 550 | |
541 | " not detached.\n"); | 551 | if ((err = i2c_detach_client(client))) |
542 | return err; | 552 | return err; |
543 | } | 553 | kfree(data); |
544 | kfree(i2c_get_clientdata(client)); | ||
545 | return 0; | 554 | return 0; |
546 | } | 555 | } |
547 | 556 | ||