diff options
author | Vivien Didelot <vivien.didelot@savoirfairelinux.com> | 2012-08-30 21:46:19 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2012-09-24 00:08:34 -0400 |
commit | edec5af7c5cba4a8c00c0c52fbad3b83217122da (patch) | |
tree | 3bb7118aa36527a500caf3a936bc99bfec453fe2 /drivers | |
parent | 6c1fe725fd76f4328e22c146d3a36513963a01ea (diff) |
hwmon: (sht15) remove multiple driver registration
Declare an array of platform_device_id, instead of registering a driver
for each supported chip. This makes the code cleaner.
Also add a module description.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hwmon/sht15.c | 94 |
1 files changed, 23 insertions, 71 deletions
diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c index e4614644408b..c8245c01fd53 100644 --- a/drivers/hwmon/sht15.c +++ b/drivers/hwmon/sht15.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * sht15.c - support for the SHT15 Temperature and Humidity Sensor | 2 | * sht15.c - support for the SHT15 Temperature and Humidity Sensor |
3 | * | 3 | * |
4 | * Portions Copyright (c) 2010-2011 Savoir-faire Linux Inc. | 4 | * Portions Copyright (c) 2010-2012 Savoir-faire Linux Inc. |
5 | * Jerome Oufella <jerome.oufella@savoirfairelinux.com> | 5 | * Jerome Oufella <jerome.oufella@savoirfairelinux.com> |
6 | * Vivien Didelot <vivien.didelot@savoirfairelinux.com> | 6 | * Vivien Didelot <vivien.didelot@savoirfairelinux.com> |
7 | * | 7 | * |
@@ -53,6 +53,9 @@ | |||
53 | #define SHT15_STATUS_HEATER 0x04 | 53 | #define SHT15_STATUS_HEATER 0x04 |
54 | #define SHT15_STATUS_LOW_BATTERY 0x40 | 54 | #define SHT15_STATUS_LOW_BATTERY 0x40 |
55 | 55 | ||
56 | /* List of supported chips */ | ||
57 | enum sht15_chips { sht10, sht11, sht15, sht71, sht75 }; | ||
58 | |||
56 | /* Actions the driver may be doing */ | 59 | /* Actions the driver may be doing */ |
57 | enum sht15_state { | 60 | enum sht15_state { |
58 | SHT15_READING_NOTHING, | 61 | SHT15_READING_NOTHING, |
@@ -1024,77 +1027,26 @@ static int __devexit sht15_remove(struct platform_device *pdev) | |||
1024 | return 0; | 1027 | return 0; |
1025 | } | 1028 | } |
1026 | 1029 | ||
1027 | /* | 1030 | static struct platform_device_id sht15_device_ids[] = { |
1028 | * sht_drivers simultaneously refers to __devinit and __devexit function | 1031 | { "sht10", sht10 }, |
1029 | * which causes spurious section mismatch warning. So use __refdata to | 1032 | { "sht11", sht11 }, |
1030 | * get rid from this. | 1033 | { "sht15", sht15 }, |
1031 | */ | 1034 | { "sht71", sht71 }, |
1032 | static struct platform_driver __refdata sht_drivers[] = { | 1035 | { "sht75", sht75 }, |
1033 | { | 1036 | { } |
1034 | .driver = { | ||
1035 | .name = "sht10", | ||
1036 | .owner = THIS_MODULE, | ||
1037 | }, | ||
1038 | .probe = sht15_probe, | ||
1039 | .remove = __devexit_p(sht15_remove), | ||
1040 | }, { | ||
1041 | .driver = { | ||
1042 | .name = "sht11", | ||
1043 | .owner = THIS_MODULE, | ||
1044 | }, | ||
1045 | .probe = sht15_probe, | ||
1046 | .remove = __devexit_p(sht15_remove), | ||
1047 | }, { | ||
1048 | .driver = { | ||
1049 | .name = "sht15", | ||
1050 | .owner = THIS_MODULE, | ||
1051 | }, | ||
1052 | .probe = sht15_probe, | ||
1053 | .remove = __devexit_p(sht15_remove), | ||
1054 | }, { | ||
1055 | .driver = { | ||
1056 | .name = "sht71", | ||
1057 | .owner = THIS_MODULE, | ||
1058 | }, | ||
1059 | .probe = sht15_probe, | ||
1060 | .remove = __devexit_p(sht15_remove), | ||
1061 | }, { | ||
1062 | .driver = { | ||
1063 | .name = "sht75", | ||
1064 | .owner = THIS_MODULE, | ||
1065 | }, | ||
1066 | .probe = sht15_probe, | ||
1067 | .remove = __devexit_p(sht15_remove), | ||
1068 | }, | ||
1069 | }; | 1037 | }; |
1038 | MODULE_DEVICE_TABLE(platform, sht15_device_ids); | ||
1070 | 1039 | ||
1071 | static int __init sht15_init(void) | 1040 | static struct platform_driver sht15_driver = { |
1072 | { | 1041 | .driver = { |
1073 | int ret; | 1042 | .name = "sht15", |
1074 | int i; | 1043 | .owner = THIS_MODULE, |
1075 | 1044 | }, | |
1076 | for (i = 0; i < ARRAY_SIZE(sht_drivers); i++) { | 1045 | .probe = sht15_probe, |
1077 | ret = platform_driver_register(&sht_drivers[i]); | 1046 | .remove = __devexit_p(sht15_remove), |
1078 | if (ret) | 1047 | .id_table = sht15_device_ids, |
1079 | goto error_unreg; | 1048 | }; |
1080 | } | 1049 | module_platform_driver(sht15_driver); |
1081 | |||
1082 | return 0; | ||
1083 | |||
1084 | error_unreg: | ||
1085 | while (--i >= 0) | ||
1086 | platform_driver_unregister(&sht_drivers[i]); | ||
1087 | |||
1088 | return ret; | ||
1089 | } | ||
1090 | module_init(sht15_init); | ||
1091 | |||
1092 | static void __exit sht15_exit(void) | ||
1093 | { | ||
1094 | int i; | ||
1095 | for (i = ARRAY_SIZE(sht_drivers) - 1; i >= 0; i--) | ||
1096 | platform_driver_unregister(&sht_drivers[i]); | ||
1097 | } | ||
1098 | module_exit(sht15_exit); | ||
1099 | 1050 | ||
1100 | MODULE_LICENSE("GPL"); | 1051 | MODULE_LICENSE("GPL"); |
1052 | MODULE_DESCRIPTION("Sensirion SHT15 temperature and humidity sensor driver"); | ||