aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/ltc4245.c
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /drivers/hwmon/ltc4245.c
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'drivers/hwmon/ltc4245.c')
-rw-r--r--drivers/hwmon/ltc4245.c37
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);
394LTC4245_POWER(power3_input, LTC4245_3VSENSE); 391LTC4245_POWER(power3_input, LTC4245_3VSENSE);
395LTC4245_POWER(power4_input, LTC4245_VEESENSE); 392LTC4245_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 */
401static struct attribute *ltc4245_std_attributes[] = { 397static 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
548out_hwmon_device_register: 546out_hwmon_device_register:
549 ltc4245_sysfs_remove_groups(client); 547 ltc4245_sysfs_remove_groups(client);
548out_sysfs_create_groups:
549 kfree(data);
550out_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
579module_i2c_driver(ltc4245_driver); 581static int __init ltc4245_init(void)
582{
583 return i2c_add_driver(&ltc4245_driver);
584}
585
586static void __exit ltc4245_exit(void)
587{
588 i2c_del_driver(&ltc4245_driver);
589}
580 590
581MODULE_AUTHOR("Ira W. Snyder <iws@ovro.caltech.edu>"); 591MODULE_AUTHOR("Ira W. Snyder <iws@ovro.caltech.edu>");
582MODULE_DESCRIPTION("LTC4245 driver"); 592MODULE_DESCRIPTION("LTC4245 driver");
583MODULE_LICENSE("GPL"); 593MODULE_LICENSE("GPL");
594
595module_init(ltc4245_init);
596module_exit(ltc4245_exit);