aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/ltc4151.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/ltc4151.c
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'drivers/hwmon/ltc4151.c')
-rw-r--r--drivers/hwmon/ltc4151.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/drivers/hwmon/ltc4151.c b/drivers/hwmon/ltc4151.c
index 4319a94f549..4ac06b75aa6 100644
--- a/drivers/hwmon/ltc4151.c
+++ b/drivers/hwmon/ltc4151.c
@@ -36,7 +36,6 @@
36#include <linux/i2c.h> 36#include <linux/i2c.h>
37#include <linux/hwmon.h> 37#include <linux/hwmon.h>
38#include <linux/hwmon-sysfs.h> 38#include <linux/hwmon-sysfs.h>
39#include <linux/jiffies.h>
40 39
41/* chip registers */ 40/* chip registers */
42#define LTC4151_SENSE_H 0x00 41#define LTC4151_SENSE_H 0x00
@@ -155,8 +154,7 @@ static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, \
155static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, \ 154static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, \
156 ltc4151_show_value, NULL, LTC4151_SENSE_H); 155 ltc4151_show_value, NULL, LTC4151_SENSE_H);
157 156
158/* 157/* Finally, construct an array of pointers to members of the above objects,
159 * Finally, construct an array of pointers to members of the above objects,
160 * as required for sysfs_create_group() 158 * as required for sysfs_create_group()
161 */ 159 */
162static struct attribute *ltc4151_attributes[] = { 160static struct attribute *ltc4151_attributes[] = {
@@ -182,9 +180,11 @@ static int ltc4151_probe(struct i2c_client *client,
182 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 180 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
183 return -ENODEV; 181 return -ENODEV;
184 182
185 data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); 183 data = kzalloc(sizeof(*data), GFP_KERNEL);
186 if (!data) 184 if (!data) {
187 return -ENOMEM; 185 ret = -ENOMEM;
186 goto out_kzalloc;
187 }
188 188
189 i2c_set_clientdata(client, data); 189 i2c_set_clientdata(client, data);
190 mutex_init(&data->update_lock); 190 mutex_init(&data->update_lock);
@@ -192,7 +192,7 @@ static int ltc4151_probe(struct i2c_client *client,
192 /* Register sysfs hooks */ 192 /* Register sysfs hooks */
193 ret = sysfs_create_group(&client->dev.kobj, &ltc4151_group); 193 ret = sysfs_create_group(&client->dev.kobj, &ltc4151_group);
194 if (ret) 194 if (ret)
195 return ret; 195 goto out_sysfs_create_group;
196 196
197 data->hwmon_dev = hwmon_device_register(&client->dev); 197 data->hwmon_dev = hwmon_device_register(&client->dev);
198 if (IS_ERR(data->hwmon_dev)) { 198 if (IS_ERR(data->hwmon_dev)) {
@@ -204,6 +204,9 @@ static int ltc4151_probe(struct i2c_client *client,
204 204
205out_hwmon_device_register: 205out_hwmon_device_register:
206 sysfs_remove_group(&client->dev.kobj, &ltc4151_group); 206 sysfs_remove_group(&client->dev.kobj, &ltc4151_group);
207out_sysfs_create_group:
208 kfree(data);
209out_kzalloc:
207 return ret; 210 return ret;
208} 211}
209 212
@@ -214,6 +217,8 @@ static int ltc4151_remove(struct i2c_client *client)
214 hwmon_device_unregister(data->hwmon_dev); 217 hwmon_device_unregister(data->hwmon_dev);
215 sysfs_remove_group(&client->dev.kobj, &ltc4151_group); 218 sysfs_remove_group(&client->dev.kobj, &ltc4151_group);
216 219
220 kfree(data);
221
217 return 0; 222 return 0;
218} 223}
219 224
@@ -233,8 +238,19 @@ static struct i2c_driver ltc4151_driver = {
233 .id_table = ltc4151_id, 238 .id_table = ltc4151_id,
234}; 239};
235 240
236module_i2c_driver(ltc4151_driver); 241static int __init ltc4151_init(void)
242{
243 return i2c_add_driver(&ltc4151_driver);
244}
245
246static void __exit ltc4151_exit(void)
247{
248 i2c_del_driver(&ltc4151_driver);
249}
237 250
238MODULE_AUTHOR("Per Dalen <per.dalen@appeartv.com>"); 251MODULE_AUTHOR("Per Dalen <per.dalen@appeartv.com>");
239MODULE_DESCRIPTION("LTC4151 driver"); 252MODULE_DESCRIPTION("LTC4151 driver");
240MODULE_LICENSE("GPL"); 253MODULE_LICENSE("GPL");
254
255module_init(ltc4151_init);
256module_exit(ltc4151_exit);