diff options
author | Anton Vorontsov <avorontsov@ru.mvista.com> | 2009-09-22 19:46:05 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-23 10:39:43 -0400 |
commit | d2a5c10f806b089a6e6f10deefd01dc4ce67940d (patch) | |
tree | 4d5057fc31ba051d0c8e2c2775c31cb0551e664a | |
parent | 225d8b248843d1b3fbcf616d5e7d9544463aca3e (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>
-rw-r--r-- | drivers/hwmon/adcxx.c | 101 |
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 | ||
160 | static int __devinit adcxx_probe(struct spi_device *spi, int channels) | 161 | static 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 | ||
207 | static int __devinit adcxx1s_probe(struct spi_device *spi) | ||
208 | { | ||
209 | return adcxx_probe(spi, 1); | ||
210 | } | ||
211 | |||
212 | static int __devinit adcxx2s_probe(struct spi_device *spi) | ||
213 | { | ||
214 | return adcxx_probe(spi, 2); | ||
215 | } | ||
216 | |||
217 | static int __devinit adcxx4s_probe(struct spi_device *spi) | ||
218 | { | ||
219 | return adcxx_probe(spi, 4); | ||
220 | } | ||
221 | |||
222 | static int __devinit adcxx8s_probe(struct spi_device *spi) | ||
223 | { | ||
224 | return adcxx_probe(spi, 8); | ||
225 | } | ||
226 | |||
227 | static int __devexit adcxx_remove(struct spi_device *spi) | 209 | static 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 | ||
244 | static struct spi_driver adcxx1s_driver = { | 226 | static 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 | }; |
233 | MODULE_DEVICE_TABLE(spi, adcxx_ids); | ||
252 | 234 | ||
253 | static struct spi_driver adcxx2s_driver = { | 235 | static 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 | |||
262 | static 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 | |||
271 | static 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 | ||
280 | static int __init init_adcxx(void) | 245 | static 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 | |||
301 | reg_8_failed: | ||
302 | spi_unregister_driver(&adcxx4s_driver); | ||
303 | reg_4_failed: | ||
304 | spi_unregister_driver(&adcxx2s_driver); | ||
305 | reg_2_failed: | ||
306 | spi_unregister_driver(&adcxx1s_driver); | ||
307 | reg_1_failed: | ||
308 | return status; | ||
309 | } | 248 | } |
310 | 249 | ||
311 | static void __exit exit_adcxx(void) | 250 | static 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 | ||
319 | module_init(init_adcxx); | 255 | module_init(init_adcxx); |
@@ -322,8 +258,3 @@ module_exit(exit_adcxx); | |||
322 | MODULE_AUTHOR("Marc Pignat"); | 258 | MODULE_AUTHOR("Marc Pignat"); |
323 | MODULE_DESCRIPTION("National Semiconductor adcxx8sxxx Linux driver"); | 259 | MODULE_DESCRIPTION("National Semiconductor adcxx8sxxx Linux driver"); |
324 | MODULE_LICENSE("GPL"); | 260 | MODULE_LICENSE("GPL"); |
325 | |||
326 | MODULE_ALIAS("adcxx1s"); | ||
327 | MODULE_ALIAS("adcxx2s"); | ||
328 | MODULE_ALIAS("adcxx4s"); | ||
329 | MODULE_ALIAS("adcxx8s"); | ||