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/max1668.c | |
parent | 406089d01562f1e2bf9f089fd7637009ebaad589 (diff) |
Patched in Tegra support.
Diffstat (limited to 'drivers/hwmon/max1668.c')
-rw-r--r-- | drivers/hwmon/max1668.c | 65 |
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 */ |
62 | static bool read_only; | 62 | static int read_only; |
63 | module_param(read_only, bool, 0); | 63 | module_param(read_only, bool, 0); |
64 | MODULE_PARM_DESC(read_only, "Don't set any values, read only mode"); | 64 | MODULE_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 | ||
338 | static umode_t max1668_attribute_mode(struct kobject *kobj, | 338 | static 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); |
446 | error_sysrem0: | 445 | error_sysrem0: |
447 | sysfs_remove_group(&client->dev.kobj, &max1668_group_common); | 446 | sysfs_remove_group(&client->dev.kobj, &max1668_group_common); |
447 | error_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 | ||
485 | module_i2c_driver(max1668_driver); | 487 | static int __init sensors_max1668_init(void) |
488 | { | ||
489 | return i2c_add_driver(&max1668_driver); | ||
490 | } | ||
491 | |||
492 | static void __exit sensors_max1668_exit(void) | ||
493 | { | ||
494 | i2c_del_driver(&max1668_driver); | ||
495 | } | ||
486 | 496 | ||
487 | MODULE_AUTHOR("David George <david.george@ska.ac.za>"); | 497 | MODULE_AUTHOR("David George <david.george@ska.ac.za>"); |
488 | MODULE_DESCRIPTION("MAX1668 remote temperature sensor driver"); | 498 | MODULE_DESCRIPTION("MAX1668 remote temperature sensor driver"); |
489 | MODULE_LICENSE("GPL"); | 499 | MODULE_LICENSE("GPL"); |
500 | |||
501 | module_init(sensors_max1668_init) | ||
502 | module_exit(sensors_max1668_exit) | ||