diff options
Diffstat (limited to 'drivers/hwmon/atxp1.c')
| -rw-r--r-- | drivers/hwmon/atxp1.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/drivers/hwmon/atxp1.c b/drivers/hwmon/atxp1.c index ba843f8c4cef..0ccdd0750c44 100644 --- a/drivers/hwmon/atxp1.c +++ b/drivers/hwmon/atxp1.c | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | #include <linux/hwmon-vid.h> | 27 | #include <linux/hwmon-vid.h> |
| 28 | #include <linux/err.h> | 28 | #include <linux/err.h> |
| 29 | #include <linux/mutex.h> | 29 | #include <linux/mutex.h> |
| 30 | #include <linux/sysfs.h> | ||
| 30 | 31 | ||
| 31 | MODULE_LICENSE("GPL"); | 32 | MODULE_LICENSE("GPL"); |
| 32 | MODULE_DESCRIPTION("System voltages control via Attansic ATXP1"); | 33 | MODULE_DESCRIPTION("System voltages control via Attansic ATXP1"); |
| @@ -250,6 +251,17 @@ static ssize_t atxp1_storegpio2(struct device *dev, struct device_attribute *att | |||
| 250 | */ | 251 | */ |
| 251 | static DEVICE_ATTR(gpio2, S_IRUGO | S_IWUSR, atxp1_showgpio2, atxp1_storegpio2); | 252 | static DEVICE_ATTR(gpio2, S_IRUGO | S_IWUSR, atxp1_showgpio2, atxp1_storegpio2); |
| 252 | 253 | ||
| 254 | static struct attribute *atxp1_attributes[] = { | ||
| 255 | &dev_attr_gpio1.attr, | ||
| 256 | &dev_attr_gpio2.attr, | ||
| 257 | &dev_attr_cpu0_vid.attr, | ||
| 258 | NULL | ||
| 259 | }; | ||
| 260 | |||
| 261 | static const struct attribute_group atxp1_group = { | ||
| 262 | .attrs = atxp1_attributes, | ||
| 263 | }; | ||
| 264 | |||
| 253 | 265 | ||
| 254 | static int atxp1_attach_adapter(struct i2c_adapter *adapter) | 266 | static int atxp1_attach_adapter(struct i2c_adapter *adapter) |
| 255 | { | 267 | { |
| @@ -319,21 +331,23 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind) | |||
| 319 | goto exit_free; | 331 | goto exit_free; |
| 320 | } | 332 | } |
| 321 | 333 | ||
| 334 | /* Register sysfs hooks */ | ||
| 335 | if ((err = sysfs_create_group(&new_client->dev.kobj, &atxp1_group))) | ||
| 336 | goto exit_detach; | ||
| 337 | |||
| 322 | data->class_dev = hwmon_device_register(&new_client->dev); | 338 | data->class_dev = hwmon_device_register(&new_client->dev); |
| 323 | if (IS_ERR(data->class_dev)) { | 339 | if (IS_ERR(data->class_dev)) { |
| 324 | err = PTR_ERR(data->class_dev); | 340 | err = PTR_ERR(data->class_dev); |
| 325 | goto exit_detach; | 341 | goto exit_remove_files; |
| 326 | } | 342 | } |
| 327 | 343 | ||
| 328 | device_create_file(&new_client->dev, &dev_attr_gpio1); | ||
| 329 | device_create_file(&new_client->dev, &dev_attr_gpio2); | ||
| 330 | device_create_file(&new_client->dev, &dev_attr_cpu0_vid); | ||
| 331 | |||
| 332 | dev_info(&new_client->dev, "Using VRM: %d.%d\n", | 344 | dev_info(&new_client->dev, "Using VRM: %d.%d\n", |
| 333 | data->vrm / 10, data->vrm % 10); | 345 | data->vrm / 10, data->vrm % 10); |
| 334 | 346 | ||
| 335 | return 0; | 347 | return 0; |
| 336 | 348 | ||
| 349 | exit_remove_files: | ||
| 350 | sysfs_remove_group(&new_client->dev.kobj, &atxp1_group); | ||
| 337 | exit_detach: | 351 | exit_detach: |
| 338 | i2c_detach_client(new_client); | 352 | i2c_detach_client(new_client); |
| 339 | exit_free: | 353 | exit_free: |
| @@ -348,6 +362,7 @@ static int atxp1_detach_client(struct i2c_client * client) | |||
| 348 | int err; | 362 | int err; |
| 349 | 363 | ||
| 350 | hwmon_device_unregister(data->class_dev); | 364 | hwmon_device_unregister(data->class_dev); |
| 365 | sysfs_remove_group(&client->dev.kobj, &atxp1_group); | ||
| 351 | 366 | ||
| 352 | err = i2c_detach_client(client); | 367 | err = i2c_detach_client(client); |
| 353 | 368 | ||
