diff options
Diffstat (limited to 'drivers/hwmon/fscher.c')
-rw-r--r-- | drivers/hwmon/fscher.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/hwmon/fscher.c b/drivers/hwmon/fscher.c index da411741c2c5..b794580a0726 100644 --- a/drivers/hwmon/fscher.c +++ b/drivers/hwmon/fscher.c | |||
@@ -32,6 +32,8 @@ | |||
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/i2c-sensor.h> |
35 | #include <linux/hwmon.h> | ||
36 | #include <linux/err.h> | ||
35 | 37 | ||
36 | /* | 38 | /* |
37 | * Addresses to scan | 39 | * Addresses to scan |
@@ -132,6 +134,7 @@ static struct i2c_driver fscher_driver = { | |||
132 | 134 | ||
133 | struct fscher_data { | 135 | struct fscher_data { |
134 | struct i2c_client client; | 136 | struct i2c_client client; |
137 | struct class_device *class_dev; | ||
135 | struct semaphore update_lock; | 138 | struct semaphore update_lock; |
136 | char valid; /* zero until following fields are valid */ | 139 | char valid; /* zero until following fields are valid */ |
137 | unsigned long last_updated; /* in jiffies */ | 140 | unsigned long last_updated; /* in jiffies */ |
@@ -341,6 +344,12 @@ static int fscher_detect(struct i2c_adapter *adapter, int address, int kind) | |||
341 | fscher_init_client(new_client); | 344 | fscher_init_client(new_client); |
342 | 345 | ||
343 | /* Register sysfs hooks */ | 346 | /* Register sysfs hooks */ |
347 | data->class_dev = hwmon_device_register(&new_client->dev); | ||
348 | if (IS_ERR(data->class_dev)) { | ||
349 | err = PTR_ERR(data->class_dev); | ||
350 | goto exit_detach; | ||
351 | } | ||
352 | |||
344 | device_create_file_revision(new_client); | 353 | device_create_file_revision(new_client); |
345 | device_create_file_alarms(new_client); | 354 | device_create_file_alarms(new_client); |
346 | device_create_file_control(new_client); | 355 | device_create_file_control(new_client); |
@@ -360,6 +369,8 @@ static int fscher_detect(struct i2c_adapter *adapter, int address, int kind) | |||
360 | 369 | ||
361 | return 0; | 370 | return 0; |
362 | 371 | ||
372 | exit_detach: | ||
373 | i2c_detach_client(new_client); | ||
363 | exit_free: | 374 | exit_free: |
364 | kfree(data); | 375 | kfree(data); |
365 | exit: | 376 | exit: |
@@ -368,15 +379,18 @@ exit: | |||
368 | 379 | ||
369 | static int fscher_detach_client(struct i2c_client *client) | 380 | static int fscher_detach_client(struct i2c_client *client) |
370 | { | 381 | { |
382 | struct fscher_data *data = i2c_get_clientdata(client); | ||
371 | int err; | 383 | int err; |
372 | 384 | ||
385 | hwmon_device_unregister(data->class_dev); | ||
386 | |||
373 | if ((err = i2c_detach_client(client))) { | 387 | if ((err = i2c_detach_client(client))) { |
374 | dev_err(&client->dev, "Client deregistration failed, " | 388 | dev_err(&client->dev, "Client deregistration failed, " |
375 | "client not detached.\n"); | 389 | "client not detached.\n"); |
376 | return err; | 390 | return err; |
377 | } | 391 | } |
378 | 392 | ||
379 | kfree(i2c_get_clientdata(client)); | 393 | kfree(data); |
380 | return 0; | 394 | return 0; |
381 | } | 395 | } |
382 | 396 | ||