From: Anton Vorontsov <avorontsov@ru.mvista.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: David Brownell <dbrownell@users.sourceforge.net>,
linux-kernel@vger.kernel.org, lm-sensors@lm-sensors.org,
linuxppc-dev@ozlabs.org, linux-mtd@lists.infradead.org,
Jean Delvare <khali@linux-fr.org>,
David Woodhouse <dwmw2@infradead.org>
Subject: [PATCH 6/7] hwmon: adxx: Convert to device table matching
Date: Wed, 29 Jul 2009 21:05:14 +0400 [thread overview]
Message-ID: <20090729170514.GF4803@oksana.dev.rtsoft.ru> (raw)
In-Reply-To: <20090729170345.GA26787@oksana.dev.rtsoft.ru>
This patch makes the code a little bit nicer, and shorter.
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
drivers/hwmon/adcxx.c | 106 ++++++++-----------------------------------------
1 files changed, 17 insertions(+), 89 deletions(-)
diff --git a/drivers/hwmon/adcxx.c b/drivers/hwmon/adcxx.c
index b01c0d5..6b3b057 100644
--- a/drivers/hwmon/adcxx.c
+++ b/drivers/hwmon/adcxx.c
@@ -43,6 +43,7 @@
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/mutex.h>
+#include <linux/mod_devicetable.h>
#include <linux/spi/spi.h>
#define DRVNAME "adcxx"
@@ -157,8 +158,10 @@ static struct sensor_device_attribute ad_input[] = {
/*----------------------------------------------------------------------*/
-static int __devinit adcxx_probe(struct spi_device *spi, int channels)
+static int __devinit adcxx_probe(struct spi_device *spi,
+ const struct spi_device_id *id)
{
+ int channels = (int)id->data;
struct adcxx *adc;
int status;
int i;
@@ -204,30 +207,6 @@ out_err:
return status;
}
-static int __devinit adcxx1s_probe(struct spi_device *spi,
- const struct spi_device_id *id)
-{
- return adcxx_probe(spi, 1);
-}
-
-static int __devinit adcxx2s_probe(struct spi_device *spi,
- const struct spi_device_id *id)
-{
- return adcxx_probe(spi, 2);
-}
-
-static int __devinit adcxx4s_probe(struct spi_device *spi,
- const struct spi_device_id *id)
-{
- return adcxx_probe(spi, 4);
-}
-
-static int __devinit adcxx8s_probe(struct spi_device *spi,
- const struct spi_device_id *id)
-{
- return adcxx_probe(spi, 8);
-}
-
static int __devexit adcxx_remove(struct spi_device *spi)
{
struct adcxx *adc = dev_get_drvdata(&spi->dev);
@@ -245,79 +224,33 @@ static int __devexit adcxx_remove(struct spi_device *spi)
return 0;
}
-static struct spi_driver adcxx1s_driver = {
- .driver = {
- .name = "adcxx1s",
- .owner = THIS_MODULE,
- },
- .probe = adcxx1s_probe,
- .remove = __devexit_p(adcxx_remove),
+static const struct spi_device_id adcxx_ids[] = {
+ { "adcxx1s", (void *)1 },
+ { "adcxx2s", (void *)2 },
+ { "adcxx4s", (void *)4 },
+ { "adcxx8s", (void *)8 },
+ { },
};
+MODULE_DEVICE_TABLE(spi, adcxx_ids);
-static struct spi_driver adcxx2s_driver = {
+static struct spi_driver adcxx_driver = {
.driver = {
- .name = "adcxx2s",
+ .name = "adcxx",
.owner = THIS_MODULE,
},
- .probe = adcxx2s_probe,
- .remove = __devexit_p(adcxx_remove),
-};
-
-static struct spi_driver adcxx4s_driver = {
- .driver = {
- .name = "adcxx4s",
- .owner = THIS_MODULE,
- },
- .probe = adcxx4s_probe,
- .remove = __devexit_p(adcxx_remove),
-};
-
-static struct spi_driver adcxx8s_driver = {
- .driver = {
- .name = "adcxx8s",
- .owner = THIS_MODULE,
- },
- .probe = adcxx8s_probe,
+ .id_table = adcxx_ids,
+ .probe = adcxx_probe,
.remove = __devexit_p(adcxx_remove),
};
static int __init init_adcxx(void)
{
- int status;
- status = spi_register_driver(&adcxx1s_driver);
- if (status)
- goto reg_1_failed;
-
- status = spi_register_driver(&adcxx2s_driver);
- if (status)
- goto reg_2_failed;
-
- status = spi_register_driver(&adcxx4s_driver);
- if (status)
- goto reg_4_failed;
-
- status = spi_register_driver(&adcxx8s_driver);
- if (status)
- goto reg_8_failed;
-
- return status;
-
-reg_8_failed:
- spi_unregister_driver(&adcxx4s_driver);
-reg_4_failed:
- spi_unregister_driver(&adcxx2s_driver);
-reg_2_failed:
- spi_unregister_driver(&adcxx1s_driver);
-reg_1_failed:
- return status;
+ return spi_register_driver(&adcxx_driver);
}
static void __exit exit_adcxx(void)
{
- spi_unregister_driver(&adcxx1s_driver);
- spi_unregister_driver(&adcxx2s_driver);
- spi_unregister_driver(&adcxx4s_driver);
- spi_unregister_driver(&adcxx8s_driver);
+ spi_unregister_driver(&adcxx_driver);
}
module_init(init_adcxx);
@@ -326,8 +259,3 @@ module_exit(exit_adcxx);
MODULE_AUTHOR("Marc Pignat");
MODULE_DESCRIPTION("National Semiconductor adcxx8sxxx Linux driver");
MODULE_LICENSE("GPL");
-
-MODULE_ALIAS("spi:adcxx1s");
-MODULE_ALIAS("spi:adcxx2s");
-MODULE_ALIAS("spi:adcxx4s");
-MODULE_ALIAS("spi:adcxx8s");
--
1.6.3.3
next prev parent reply other threads:[~2009-07-29 17:05 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-29 17:03 [PATCH 0/7] Device table matching for SPI subsystem Anton Vorontsov
2009-07-29 17:04 ` [PATCH 1/7] spi: Add support for device table matching Anton Vorontsov
2009-07-29 21:44 ` Ben Dooks
2009-07-29 22:32 ` Anton Vorontsov
2009-07-29 22:40 ` Anton Vorontsov
2009-07-30 2:12 ` Anton Vorontsov
2009-08-04 2:21 ` David Brownell
2009-08-05 1:06 ` Anton Vorontsov
2009-07-29 17:05 ` [PATCH 2/7] mtd: m25p80: Convert to " Anton Vorontsov
2009-07-29 17:05 ` [PATCH 3/7] of: Remove "stm,m25p40" alias Anton Vorontsov
2009-07-29 17:05 ` [PATCH 4/7] spi: Prefix modalias with "spi:" Anton Vorontsov
2009-08-12 4:12 ` Mike Frysinger
2009-07-29 17:05 ` [PATCH 5/7] spi: Merge probe and probe_id callbacks Anton Vorontsov
2009-07-29 17:05 ` Anton Vorontsov [this message]
2009-07-29 17:05 ` [PATCH 7/7] hwmon: lm70: Convert to device table matching Anton Vorontsov
2009-08-04 2:16 ` [PATCH 0/7] Device table matching for SPI subsystem David Brownell
2009-08-05 0:54 ` Anton Vorontsov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090729170514.GF4803@oksana.dev.rtsoft.ru \
--to=avorontsov@ru.mvista.com \
--cc=akpm@linux-foundation.org \
--cc=dbrownell@users.sourceforge.net \
--cc=dwmw2@infradead.org \
--cc=khali@linux-fr.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=lm-sensors@lm-sensors.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).