diff options
author | Linus Torvalds <torvalds@evo.osdl.org> | 2005-09-06 03:31:02 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@evo.osdl.org> | 2005-09-06 03:31:02 -0400 |
commit | 8566cfc9fe0934f52ddedc12b083176116c13978 (patch) | |
tree | b0f92fd0982a4dabaa2c108f4f1d130d2cff6798 /drivers/hwmon/lm63.c | |
parent | 7bdb2b6aca356c765bb697a4e9e7599357ee1542 (diff) | |
parent | 77ae84554cc0178e03862391599a0cedf96fa4c4 (diff) |
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/i2c-2.6
Diffstat (limited to 'drivers/hwmon/lm63.c')
-rw-r--r-- | drivers/hwmon/lm63.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c index 7c6f9ea5a254..be5c7095ecbb 100644 --- a/drivers/hwmon/lm63.c +++ b/drivers/hwmon/lm63.c | |||
@@ -42,8 +42,9 @@ | |||
42 | #include <linux/slab.h> | 42 | #include <linux/slab.h> |
43 | #include <linux/jiffies.h> | 43 | #include <linux/jiffies.h> |
44 | #include <linux/i2c.h> | 44 | #include <linux/i2c.h> |
45 | #include <linux/i2c-sensor.h> | ||
46 | #include <linux/hwmon-sysfs.h> | 45 | #include <linux/hwmon-sysfs.h> |
46 | #include <linux/hwmon.h> | ||
47 | #include <linux/err.h> | ||
47 | 48 | ||
48 | /* | 49 | /* |
49 | * Addresses to scan | 50 | * Addresses to scan |
@@ -51,13 +52,12 @@ | |||
51 | */ | 52 | */ |
52 | 53 | ||
53 | static unsigned short normal_i2c[] = { 0x4c, I2C_CLIENT_END }; | 54 | static unsigned short normal_i2c[] = { 0x4c, I2C_CLIENT_END }; |
54 | static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; | ||
55 | 55 | ||
56 | /* | 56 | /* |
57 | * Insmod parameters | 57 | * Insmod parameters |
58 | */ | 58 | */ |
59 | 59 | ||
60 | SENSORS_INSMOD_1(lm63); | 60 | I2C_CLIENT_INSMOD_1(lm63); |
61 | 61 | ||
62 | /* | 62 | /* |
63 | * The LM63 registers | 63 | * The LM63 registers |
@@ -152,6 +152,7 @@ static struct i2c_driver lm63_driver = { | |||
152 | 152 | ||
153 | struct lm63_data { | 153 | struct lm63_data { |
154 | struct i2c_client client; | 154 | struct i2c_client client; |
155 | struct class_device *class_dev; | ||
155 | struct semaphore update_lock; | 156 | struct semaphore update_lock; |
156 | char valid; /* zero until following fields are valid */ | 157 | char valid; /* zero until following fields are valid */ |
157 | unsigned long last_updated; /* in jiffies */ | 158 | unsigned long last_updated; /* in jiffies */ |
@@ -358,7 +359,7 @@ static int lm63_attach_adapter(struct i2c_adapter *adapter) | |||
358 | { | 359 | { |
359 | if (!(adapter->class & I2C_CLASS_HWMON)) | 360 | if (!(adapter->class & I2C_CLASS_HWMON)) |
360 | return 0; | 361 | return 0; |
361 | return i2c_detect(adapter, &addr_data, lm63_detect); | 362 | return i2c_probe(adapter, &addr_data, lm63_detect); |
362 | } | 363 | } |
363 | 364 | ||
364 | /* | 365 | /* |
@@ -437,6 +438,12 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind) | |||
437 | lm63_init_client(new_client); | 438 | lm63_init_client(new_client); |
438 | 439 | ||
439 | /* Register sysfs hooks */ | 440 | /* Register sysfs hooks */ |
441 | data->class_dev = hwmon_device_register(&new_client->dev); | ||
442 | if (IS_ERR(data->class_dev)) { | ||
443 | err = PTR_ERR(data->class_dev); | ||
444 | goto exit_detach; | ||
445 | } | ||
446 | |||
440 | if (data->config & 0x04) { /* tachometer enabled */ | 447 | if (data->config & 0x04) { /* tachometer enabled */ |
441 | device_create_file(&new_client->dev, | 448 | device_create_file(&new_client->dev, |
442 | &sensor_dev_attr_fan1_input.dev_attr); | 449 | &sensor_dev_attr_fan1_input.dev_attr); |
@@ -462,6 +469,8 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind) | |||
462 | 469 | ||
463 | return 0; | 470 | return 0; |
464 | 471 | ||
472 | exit_detach: | ||
473 | i2c_detach_client(new_client); | ||
465 | exit_free: | 474 | exit_free: |
466 | kfree(data); | 475 | kfree(data); |
467 | exit: | 476 | exit: |
@@ -505,15 +514,15 @@ static void lm63_init_client(struct i2c_client *client) | |||
505 | 514 | ||
506 | static int lm63_detach_client(struct i2c_client *client) | 515 | static int lm63_detach_client(struct i2c_client *client) |
507 | { | 516 | { |
517 | struct lm63_data *data = i2c_get_clientdata(client); | ||
508 | int err; | 518 | int err; |
509 | 519 | ||
510 | if ((err = i2c_detach_client(client))) { | 520 | hwmon_device_unregister(data->class_dev); |
511 | dev_err(&client->dev, "Client deregistration failed, " | 521 | |
512 | "client not detached\n"); | 522 | if ((err = i2c_detach_client(client))) |
513 | return err; | 523 | return err; |
514 | } | ||
515 | 524 | ||
516 | kfree(i2c_get_clientdata(client)); | 525 | kfree(data); |
517 | return 0; | 526 | return 0; |
518 | } | 527 | } |
519 | 528 | ||