aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/adcxx.c
diff options
context:
space:
mode:
authorAnton Vorontsov <avorontsov@ru.mvista.com>2009-09-22 19:46:05 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-09-23 10:39:43 -0400
commitd2a5c10f806b089a6e6f10deefd01dc4ce67940d (patch)
tree4d5057fc31ba051d0c8e2c2775c31cb0551e664a /drivers/hwmon/adcxx.c
parent225d8b248843d1b3fbcf616d5e7d9544463aca3e (diff)
hwmon: adxx: convert to device table matching
Make the code a little bit nicer, and shorter. Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com> Cc: Marc Pignat <marc.pignat@hevs.ch> Cc: David Brownell <dbrownell@users.sourceforge.net> Cc: David Woodhouse <dwmw2@infradead.org> Cc: Grant Likely <grant.likely@secretlab.ca> Cc: Jean Delvare <khali@linux-fr.org> Cc: Ben Dooks <ben-linux@fluff.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Acked-by: Marc Pignat <marc.pignat@hevs.ch> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/hwmon/adcxx.c')
-rw-r--r--drivers/hwmon/adcxx.c101
1 files changed, 16 insertions, 85 deletions
diff --git a/drivers/hwmon/adcxx.c b/drivers/hwmon/adcxx.c
index 242294db3db6..5e9e095f1136 100644
--- a/drivers/hwmon/adcxx.c
+++ b/drivers/hwmon/adcxx.c
@@ -43,6 +43,7 @@
43#include <linux/hwmon.h> 43#include <linux/hwmon.h>
44#include <linux/hwmon-sysfs.h> 44#include <linux/hwmon-sysfs.h>
45#include <linux/mutex.h> 45#include <linux/mutex.h>
46#include <linux/mod_devicetable.h>
46#include <linux/spi/spi.h> 47#include <linux/spi/spi.h>
47 48
48#define DRVNAME "adcxx" 49#define DRVNAME "adcxx"
@@ -157,8 +158,9 @@ static struct sensor_device_attribute ad_input[] = {
157 158
158/*----------------------------------------------------------------------*/ 159/*----------------------------------------------------------------------*/
159 160
160static int __devinit adcxx_probe(struct spi_device *spi, int channels) 161static int __devinit adcxx_probe(struct spi_device *spi)
161{ 162{
163 int channels = spi_get_device_id(spi)->driver_data;
162 struct adcxx *adc; 164 struct adcxx *adc;
163 int status; 165 int status;
164 int i; 166 int i;
@@ -204,26 +206,6 @@ out_err:
204 return status; 206 return status;
205} 207}
206 208
207static int __devinit adcxx1s_probe(struct spi_device *spi)
208{
209 return adcxx_probe(spi, 1);
210}
211
212static int __devinit adcxx2s_probe(struct spi_device *spi)
213{
214 return adcxx_probe(spi, 2);
215}
216
217static int __devinit adcxx4s_probe(struct spi_device *spi)
218{
219 return adcxx_probe(spi, 4);
220}
221
222static int __devinit adcxx8s_probe(struct spi_device *spi)
223{
224 return adcxx_probe(spi, 8);
225}
226
227static int __devexit adcxx_remove(struct spi_device *spi) 209static int __devexit adcxx_remove(struct spi_device *spi)
228{ 210{
229 struct adcxx *adc = dev_get_drvdata(&spi->dev); 211 struct adcxx *adc = dev_get_drvdata(&spi->dev);
@@ -241,79 +223,33 @@ static int __devexit adcxx_remove(struct spi_device *spi)
241 return 0; 223 return 0;
242} 224}
243 225
244static struct spi_driver adcxx1s_driver = { 226static const struct spi_device_id adcxx_ids[] = {
245 .driver = { 227 { "adcxx1s", 1 },
246 .name = "adcxx1s", 228 { "adcxx2s", 2 },
247 .owner = THIS_MODULE, 229 { "adcxx4s", 4 },
248 }, 230 { "adcxx8s", 8 },
249 .probe = adcxx1s_probe, 231 { },
250 .remove = __devexit_p(adcxx_remove),
251}; 232};
233MODULE_DEVICE_TABLE(spi, adcxx_ids);
252 234
253static struct spi_driver adcxx2s_driver = { 235static struct spi_driver adcxx_driver = {
254 .driver = { 236 .driver = {
255 .name = "adcxx2s", 237 .name = "adcxx",
256 .owner = THIS_MODULE, 238 .owner = THIS_MODULE,
257 }, 239 },
258 .probe = adcxx2s_probe, 240 .id_table = adcxx_ids,
259 .remove = __devexit_p(adcxx_remove), 241 .probe = adcxx_probe,
260};
261
262static struct spi_driver adcxx4s_driver = {
263 .driver = {
264 .name = "adcxx4s",
265 .owner = THIS_MODULE,
266 },
267 .probe = adcxx4s_probe,
268 .remove = __devexit_p(adcxx_remove),
269};
270
271static struct spi_driver adcxx8s_driver = {
272 .driver = {
273 .name = "adcxx8s",
274 .owner = THIS_MODULE,
275 },
276 .probe = adcxx8s_probe,
277 .remove = __devexit_p(adcxx_remove), 242 .remove = __devexit_p(adcxx_remove),
278}; 243};
279 244
280static int __init init_adcxx(void) 245static int __init init_adcxx(void)
281{ 246{
282 int status; 247 return spi_register_driver(&adcxx_driver);
283 status = spi_register_driver(&adcxx1s_driver);
284 if (status)
285 goto reg_1_failed;
286
287 status = spi_register_driver(&adcxx2s_driver);
288 if (status)
289 goto reg_2_failed;
290
291 status = spi_register_driver(&adcxx4s_driver);
292 if (status)
293 goto reg_4_failed;
294
295 status = spi_register_driver(&adcxx8s_driver);
296 if (status)
297 goto reg_8_failed;
298
299 return status;
300
301reg_8_failed:
302 spi_unregister_driver(&adcxx4s_driver);
303reg_4_failed:
304 spi_unregister_driver(&adcxx2s_driver);
305reg_2_failed:
306 spi_unregister_driver(&adcxx1s_driver);
307reg_1_failed:
308 return status;
309} 248}
310 249
311static void __exit exit_adcxx(void) 250static void __exit exit_adcxx(void)
312{ 251{
313 spi_unregister_driver(&adcxx1s_driver); 252 spi_unregister_driver(&adcxx_driver);
314 spi_unregister_driver(&adcxx2s_driver);
315 spi_unregister_driver(&adcxx4s_driver);
316 spi_unregister_driver(&adcxx8s_driver);
317} 253}
318 254
319module_init(init_adcxx); 255module_init(init_adcxx);
@@ -322,8 +258,3 @@ module_exit(exit_adcxx);
322MODULE_AUTHOR("Marc Pignat"); 258MODULE_AUTHOR("Marc Pignat");
323MODULE_DESCRIPTION("National Semiconductor adcxx8sxxx Linux driver"); 259MODULE_DESCRIPTION("National Semiconductor adcxx8sxxx Linux driver");
324MODULE_LICENSE("GPL"); 260MODULE_LICENSE("GPL");
325
326MODULE_ALIAS("adcxx1s");
327MODULE_ALIAS("adcxx2s");
328MODULE_ALIAS("adcxx4s");
329MODULE_ALIAS("adcxx8s");