diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
commit | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch) | |
tree | a8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /drivers/hwmon/ltc4245.c | |
parent | 406089d01562f1e2bf9f089fd7637009ebaad589 (diff) |
Patched in Tegra support.
Diffstat (limited to 'drivers/hwmon/ltc4245.c')
-rw-r--r-- | drivers/hwmon/ltc4245.c | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/drivers/hwmon/ltc4245.c b/drivers/hwmon/ltc4245.c index 3653f79dc2d..65930832930 100644 --- a/drivers/hwmon/ltc4245.c +++ b/drivers/hwmon/ltc4245.c | |||
@@ -21,7 +21,6 @@ | |||
21 | #include <linux/i2c.h> | 21 | #include <linux/i2c.h> |
22 | #include <linux/hwmon.h> | 22 | #include <linux/hwmon.h> |
23 | #include <linux/hwmon-sysfs.h> | 23 | #include <linux/hwmon-sysfs.h> |
24 | #include <linux/jiffies.h> | ||
25 | #include <linux/i2c/ltc4245.h> | 24 | #include <linux/i2c/ltc4245.h> |
26 | 25 | ||
27 | /* Here are names of the chip's registers (a.k.a. commands) */ | 26 | /* Here are names of the chip's registers (a.k.a. commands) */ |
@@ -215,8 +214,7 @@ static unsigned int ltc4245_get_current(struct device *dev, u8 reg) | |||
215 | unsigned int voltage; | 214 | unsigned int voltage; |
216 | unsigned int curr; | 215 | unsigned int curr; |
217 | 216 | ||
218 | /* | 217 | /* The strange looking conversions that follow are fixed-point |
219 | * The strange looking conversions that follow are fixed-point | ||
220 | * math, since we cannot do floating point in the kernel. | 218 | * math, since we cannot do floating point in the kernel. |
221 | * | 219 | * |
222 | * Step 1: convert sense register to microVolts | 220 | * Step 1: convert sense register to microVolts |
@@ -319,8 +317,7 @@ static ssize_t ltc4245_show_gpio(struct device *dev, | |||
319 | return snprintf(buf, PAGE_SIZE, "%u\n", val * 10); | 317 | return snprintf(buf, PAGE_SIZE, "%u\n", val * 10); |
320 | } | 318 | } |
321 | 319 | ||
322 | /* | 320 | /* These macros are used below in constructing device attribute objects |
323 | * These macros are used below in constructing device attribute objects | ||
324 | * for use with sysfs_create_group() to make a sysfs device file | 321 | * for use with sysfs_create_group() to make a sysfs device file |
325 | * for each register. | 322 | * for each register. |
326 | */ | 323 | */ |
@@ -394,8 +391,7 @@ LTC4245_POWER(power2_input, LTC4245_5VSENSE); | |||
394 | LTC4245_POWER(power3_input, LTC4245_3VSENSE); | 391 | LTC4245_POWER(power3_input, LTC4245_3VSENSE); |
395 | LTC4245_POWER(power4_input, LTC4245_VEESENSE); | 392 | LTC4245_POWER(power4_input, LTC4245_VEESENSE); |
396 | 393 | ||
397 | /* | 394 | /* Finally, construct an array of pointers to members of the above objects, |
398 | * Finally, construct an array of pointers to members of the above objects, | ||
399 | * as required for sysfs_create_group() | 395 | * as required for sysfs_create_group() |
400 | */ | 396 | */ |
401 | static struct attribute *ltc4245_std_attributes[] = { | 397 | static struct attribute *ltc4245_std_attributes[] = { |
@@ -520,9 +516,11 @@ static int ltc4245_probe(struct i2c_client *client, | |||
520 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 516 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
521 | return -ENODEV; | 517 | return -ENODEV; |
522 | 518 | ||
523 | data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); | 519 | data = kzalloc(sizeof(*data), GFP_KERNEL); |
524 | if (!data) | 520 | if (!data) { |
525 | return -ENOMEM; | 521 | ret = -ENOMEM; |
522 | goto out_kzalloc; | ||
523 | } | ||
526 | 524 | ||
527 | i2c_set_clientdata(client, data); | 525 | i2c_set_clientdata(client, data); |
528 | mutex_init(&data->update_lock); | 526 | mutex_init(&data->update_lock); |
@@ -535,7 +533,7 @@ static int ltc4245_probe(struct i2c_client *client, | |||
535 | /* Register sysfs hooks */ | 533 | /* Register sysfs hooks */ |
536 | ret = ltc4245_sysfs_create_groups(client); | 534 | ret = ltc4245_sysfs_create_groups(client); |
537 | if (ret) | 535 | if (ret) |
538 | return ret; | 536 | goto out_sysfs_create_groups; |
539 | 537 | ||
540 | data->hwmon_dev = hwmon_device_register(&client->dev); | 538 | data->hwmon_dev = hwmon_device_register(&client->dev); |
541 | if (IS_ERR(data->hwmon_dev)) { | 539 | if (IS_ERR(data->hwmon_dev)) { |
@@ -547,6 +545,9 @@ static int ltc4245_probe(struct i2c_client *client, | |||
547 | 545 | ||
548 | out_hwmon_device_register: | 546 | out_hwmon_device_register: |
549 | ltc4245_sysfs_remove_groups(client); | 547 | ltc4245_sysfs_remove_groups(client); |
548 | out_sysfs_create_groups: | ||
549 | kfree(data); | ||
550 | out_kzalloc: | ||
550 | return ret; | 551 | return ret; |
551 | } | 552 | } |
552 | 553 | ||
@@ -556,6 +557,7 @@ static int ltc4245_remove(struct i2c_client *client) | |||
556 | 557 | ||
557 | hwmon_device_unregister(data->hwmon_dev); | 558 | hwmon_device_unregister(data->hwmon_dev); |
558 | ltc4245_sysfs_remove_groups(client); | 559 | ltc4245_sysfs_remove_groups(client); |
560 | kfree(data); | ||
559 | 561 | ||
560 | return 0; | 562 | return 0; |
561 | } | 563 | } |
@@ -576,8 +578,19 @@ static struct i2c_driver ltc4245_driver = { | |||
576 | .id_table = ltc4245_id, | 578 | .id_table = ltc4245_id, |
577 | }; | 579 | }; |
578 | 580 | ||
579 | module_i2c_driver(ltc4245_driver); | 581 | static int __init ltc4245_init(void) |
582 | { | ||
583 | return i2c_add_driver(<c4245_driver); | ||
584 | } | ||
585 | |||
586 | static void __exit ltc4245_exit(void) | ||
587 | { | ||
588 | i2c_del_driver(<c4245_driver); | ||
589 | } | ||
580 | 590 | ||
581 | MODULE_AUTHOR("Ira W. Snyder <iws@ovro.caltech.edu>"); | 591 | MODULE_AUTHOR("Ira W. Snyder <iws@ovro.caltech.edu>"); |
582 | MODULE_DESCRIPTION("LTC4245 driver"); | 592 | MODULE_DESCRIPTION("LTC4245 driver"); |
583 | MODULE_LICENSE("GPL"); | 593 | MODULE_LICENSE("GPL"); |
594 | |||
595 | module_init(ltc4245_init); | ||
596 | module_exit(ltc4245_exit); | ||