aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/max1668.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/max1668.c
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'drivers/hwmon/max1668.c')
-rw-r--r--drivers/hwmon/max1668.c65
1 files changed, 39 insertions, 26 deletions
diff --git a/drivers/hwmon/max1668.c b/drivers/hwmon/max1668.c
index 666d9f6263e..20d1b2ddffb 100644
--- a/drivers/hwmon/max1668.c
+++ b/drivers/hwmon/max1668.c
@@ -1,23 +1,23 @@
1/* 1/*
2 * Copyright (c) 2011 David George <david.george@ska.ac.za> 2 Copyright (c) 2011 David George <david.george@ska.ac.za>
3 * 3
4 * based on adm1021.c 4 based on adm1021.c
5 * some credit to Christoph Scheurer, but largely a rewrite 5 some credit to Christoph Scheurer, but largely a rewrite
6 * 6
7 * This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version. 10 (at your option) any later version.
11 * 11
12 * This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 GNU General Public License for more details.
16 * 16
17 * You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 20*/
21 21
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/init.h> 23#include <linux/init.h>
@@ -59,7 +59,7 @@ static unsigned short max1668_addr_list[] = {
59#define DEV_ID_MAX1989 0xb 59#define DEV_ID_MAX1989 0xb
60 60
61/* read only mode module parameter */ 61/* read only mode module parameter */
62static bool read_only; 62static int read_only;
63module_param(read_only, bool, 0); 63module_param(read_only, bool, 0);
64MODULE_PARM_DESC(read_only, "Don't set any values, read only mode"); 64MODULE_PARM_DESC(read_only, "Don't set any values, read only mode");
65 65
@@ -335,10 +335,10 @@ static struct attribute *max1668_attribute_unique[] = {
335 NULL 335 NULL
336}; 336};
337 337
338static umode_t max1668_attribute_mode(struct kobject *kobj, 338static mode_t max1668_attribute_mode(struct kobject *kobj,
339 struct attribute *attr, int index) 339 struct attribute *attr, int index)
340{ 340{
341 umode_t ret = S_IRUGO; 341 int ret = S_IRUGO;
342 if (read_only) 342 if (read_only)
343 return ret; 343 return ret;
344 if (attr == &sensor_dev_attr_temp1_max.dev_attr.attr || 344 if (attr == &sensor_dev_attr_temp1_max.dev_attr.attr ||
@@ -411,8 +411,7 @@ static int max1668_probe(struct i2c_client *client,
411 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 411 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
412 return -ENODEV; 412 return -ENODEV;
413 413
414 data = devm_kzalloc(&client->dev, sizeof(struct max1668_data), 414 data = kzalloc(sizeof(struct max1668_data), GFP_KERNEL);
415 GFP_KERNEL);
416 if (!data) 415 if (!data)
417 return -ENOMEM; 416 return -ENOMEM;
418 417
@@ -423,7 +422,7 @@ static int max1668_probe(struct i2c_client *client,
423 /* Register sysfs hooks */ 422 /* Register sysfs hooks */
424 err = sysfs_create_group(&client->dev.kobj, &max1668_group_common); 423 err = sysfs_create_group(&client->dev.kobj, &max1668_group_common);
425 if (err) 424 if (err)
426 return err; 425 goto error_free;
427 426
428 if (data->type == max1668 || data->type == max1989) { 427 if (data->type == max1668 || data->type == max1989) {
429 err = sysfs_create_group(&client->dev.kobj, 428 err = sysfs_create_group(&client->dev.kobj,
@@ -445,6 +444,8 @@ error_sysrem1:
445 sysfs_remove_group(&client->dev.kobj, &max1668_group_unique); 444 sysfs_remove_group(&client->dev.kobj, &max1668_group_unique);
446error_sysrem0: 445error_sysrem0:
447 sysfs_remove_group(&client->dev.kobj, &max1668_group_common); 446 sysfs_remove_group(&client->dev.kobj, &max1668_group_common);
447error_free:
448 kfree(data);
448 return err; 449 return err;
449} 450}
450 451
@@ -458,6 +459,7 @@ static int max1668_remove(struct i2c_client *client)
458 459
459 sysfs_remove_group(&client->dev.kobj, &max1668_group_common); 460 sysfs_remove_group(&client->dev.kobj, &max1668_group_common);
460 461
462 kfree(data);
461 return 0; 463 return 0;
462} 464}
463 465
@@ -482,8 +484,19 @@ static struct i2c_driver max1668_driver = {
482 .address_list = max1668_addr_list, 484 .address_list = max1668_addr_list,
483}; 485};
484 486
485module_i2c_driver(max1668_driver); 487static int __init sensors_max1668_init(void)
488{
489 return i2c_add_driver(&max1668_driver);
490}
491
492static void __exit sensors_max1668_exit(void)
493{
494 i2c_del_driver(&max1668_driver);
495}
486 496
487MODULE_AUTHOR("David George <david.george@ska.ac.za>"); 497MODULE_AUTHOR("David George <david.george@ska.ac.za>");
488MODULE_DESCRIPTION("MAX1668 remote temperature sensor driver"); 498MODULE_DESCRIPTION("MAX1668 remote temperature sensor driver");
489MODULE_LICENSE("GPL"); 499MODULE_LICENSE("GPL");
500
501module_init(sensors_max1668_init)
502module_exit(sensors_max1668_exit)