aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/fscher.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/fscher.c')
-rw-r--r--drivers/hwmon/fscher.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/drivers/hwmon/fscher.c b/drivers/hwmon/fscher.c
index da411741c2c5..eef6061d786b 100644
--- a/drivers/hwmon/fscher.c
+++ b/drivers/hwmon/fscher.c
@@ -31,20 +31,20 @@
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/jiffies.h> 32#include <linux/jiffies.h>
33#include <linux/i2c.h> 33#include <linux/i2c.h>
34#include <linux/i2c-sensor.h> 34#include <linux/hwmon.h>
35#include <linux/err.h>
35 36
36/* 37/*
37 * Addresses to scan 38 * Addresses to scan
38 */ 39 */
39 40
40static unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END }; 41static unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END };
41static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
42 42
43/* 43/*
44 * Insmod parameters 44 * Insmod parameters
45 */ 45 */
46 46
47SENSORS_INSMOD_1(fscher); 47I2C_CLIENT_INSMOD_1(fscher);
48 48
49/* 49/*
50 * The FSCHER registers 50 * The FSCHER registers
@@ -132,6 +132,7 @@ static struct i2c_driver fscher_driver = {
132 132
133struct fscher_data { 133struct fscher_data {
134 struct i2c_client client; 134 struct i2c_client client;
135 struct class_device *class_dev;
135 struct semaphore update_lock; 136 struct semaphore update_lock;
136 char valid; /* zero until following fields are valid */ 137 char valid; /* zero until following fields are valid */
137 unsigned long last_updated; /* in jiffies */ 138 unsigned long last_updated; /* in jiffies */
@@ -287,7 +288,7 @@ static int fscher_attach_adapter(struct i2c_adapter *adapter)
287{ 288{
288 if (!(adapter->class & I2C_CLASS_HWMON)) 289 if (!(adapter->class & I2C_CLASS_HWMON))
289 return 0; 290 return 0;
290 return i2c_detect(adapter, &addr_data, fscher_detect); 291 return i2c_probe(adapter, &addr_data, fscher_detect);
291} 292}
292 293
293static int fscher_detect(struct i2c_adapter *adapter, int address, int kind) 294static int fscher_detect(struct i2c_adapter *adapter, int address, int kind)
@@ -341,6 +342,12 @@ static int fscher_detect(struct i2c_adapter *adapter, int address, int kind)
341 fscher_init_client(new_client); 342 fscher_init_client(new_client);
342 343
343 /* Register sysfs hooks */ 344 /* Register sysfs hooks */
345 data->class_dev = hwmon_device_register(&new_client->dev);
346 if (IS_ERR(data->class_dev)) {
347 err = PTR_ERR(data->class_dev);
348 goto exit_detach;
349 }
350
344 device_create_file_revision(new_client); 351 device_create_file_revision(new_client);
345 device_create_file_alarms(new_client); 352 device_create_file_alarms(new_client);
346 device_create_file_control(new_client); 353 device_create_file_control(new_client);
@@ -360,6 +367,8 @@ static int fscher_detect(struct i2c_adapter *adapter, int address, int kind)
360 367
361 return 0; 368 return 0;
362 369
370exit_detach:
371 i2c_detach_client(new_client);
363exit_free: 372exit_free:
364 kfree(data); 373 kfree(data);
365exit: 374exit:
@@ -368,15 +377,15 @@ exit:
368 377
369static int fscher_detach_client(struct i2c_client *client) 378static int fscher_detach_client(struct i2c_client *client)
370{ 379{
380 struct fscher_data *data = i2c_get_clientdata(client);
371 int err; 381 int err;
372 382
373 if ((err = i2c_detach_client(client))) { 383 hwmon_device_unregister(data->class_dev);
374 dev_err(&client->dev, "Client deregistration failed, " 384
375 "client not detached.\n"); 385 if ((err = i2c_detach_client(client)))
376 return err; 386 return err;
377 }
378 387
379 kfree(i2c_get_clientdata(client)); 388 kfree(data);
380 return 0; 389 return 0;
381} 390}
382 391