aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm92.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/lm92.c')
-rw-r--r--drivers/hwmon/lm92.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c
index 215c8e40ffdd..647b7c7cd575 100644
--- a/drivers/hwmon/lm92.c
+++ b/drivers/hwmon/lm92.c
@@ -44,17 +44,16 @@
44#include <linux/init.h> 44#include <linux/init.h>
45#include <linux/slab.h> 45#include <linux/slab.h>
46#include <linux/i2c.h> 46#include <linux/i2c.h>
47#include <linux/i2c-sensor.h> 47#include <linux/hwmon.h>
48 48#include <linux/err.h>
49 49
50/* The LM92 and MAX6635 have 2 two-state pins for address selection, 50/* The LM92 and MAX6635 have 2 two-state pins for address selection,
51 resulting in 4 possible addresses. */ 51 resulting in 4 possible addresses. */
52static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 52static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b,
53 I2C_CLIENT_END }; 53 I2C_CLIENT_END };
54static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
55 54
56/* Insmod parameters */ 55/* Insmod parameters */
57SENSORS_INSMOD_1(lm92); 56I2C_CLIENT_INSMOD_1(lm92);
58 57
59/* The LM92 registers */ 58/* The LM92 registers */
60#define LM92_REG_CONFIG 0x01 /* 8-bit, RW */ 59#define LM92_REG_CONFIG 0x01 /* 8-bit, RW */
@@ -96,6 +95,7 @@ static struct i2c_driver lm92_driver;
96/* Client data (each client gets its own) */ 95/* Client data (each client gets its own) */
97struct lm92_data { 96struct lm92_data {
98 struct i2c_client client; 97 struct i2c_client client;
98 struct class_device *class_dev;
99 struct semaphore update_lock; 99 struct semaphore update_lock;
100 char valid; /* zero until following fields are valid */ 100 char valid; /* zero until following fields are valid */
101 unsigned long last_updated; /* in jiffies */ 101 unsigned long last_updated; /* in jiffies */
@@ -359,6 +359,12 @@ static int lm92_detect(struct i2c_adapter *adapter, int address, int kind)
359 lm92_init_client(new_client); 359 lm92_init_client(new_client);
360 360
361 /* Register sysfs hooks */ 361 /* Register sysfs hooks */
362 data->class_dev = hwmon_device_register(&new_client->dev);
363 if (IS_ERR(data->class_dev)) {
364 err = PTR_ERR(data->class_dev);
365 goto exit_detach;
366 }
367
362 device_create_file(&new_client->dev, &dev_attr_temp1_input); 368 device_create_file(&new_client->dev, &dev_attr_temp1_input);
363 device_create_file(&new_client->dev, &dev_attr_temp1_crit); 369 device_create_file(&new_client->dev, &dev_attr_temp1_crit);
364 device_create_file(&new_client->dev, &dev_attr_temp1_crit_hyst); 370 device_create_file(&new_client->dev, &dev_attr_temp1_crit_hyst);
@@ -370,6 +376,8 @@ static int lm92_detect(struct i2c_adapter *adapter, int address, int kind)
370 376
371 return 0; 377 return 0;
372 378
379exit_detach:
380 i2c_detach_client(new_client);
373exit_free: 381exit_free:
374 kfree(data); 382 kfree(data);
375exit: 383exit:
@@ -380,20 +388,20 @@ static int lm92_attach_adapter(struct i2c_adapter *adapter)
380{ 388{
381 if (!(adapter->class & I2C_CLASS_HWMON)) 389 if (!(adapter->class & I2C_CLASS_HWMON))
382 return 0; 390 return 0;
383 return i2c_detect(adapter, &addr_data, lm92_detect); 391 return i2c_probe(adapter, &addr_data, lm92_detect);
384} 392}
385 393
386static int lm92_detach_client(struct i2c_client *client) 394static int lm92_detach_client(struct i2c_client *client)
387{ 395{
396 struct lm92_data *data = i2c_get_clientdata(client);
388 int err; 397 int err;
389 398
390 if ((err = i2c_detach_client(client))) { 399 hwmon_device_unregister(data->class_dev);
391 dev_err(&client->dev, "Client deregistration failed, " 400
392 "client not detached.\n"); 401 if ((err = i2c_detach_client(client)))
393 return err; 402 return err;
394 }
395 403
396 kfree(i2c_get_clientdata(client)); 404 kfree(data);
397 return 0; 405 return 0;
398} 406}
399 407