All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] wm831x-spi: use id_table rather hand rolled variant handling
@ 2011-09-12 15:45 Peter Korsgaard
  2011-09-12 16:38 ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Korsgaard @ 2011-09-12 15:45 UTC (permalink / raw)
  To: broonie, sameo, linux-kernel; +Cc: Peter Korsgaard

The spi subsystem supports device tables nowadays, so use it.

Only build tested as I don't have the hw.

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
---
 drivers/mfd/wm831x-spi.c |  138 ++++++----------------------------------------
 1 files changed, 17 insertions(+), 121 deletions(-)

diff --git a/drivers/mfd/wm831x-spi.c b/drivers/mfd/wm831x-spi.c
index eed8e4f..2387247 100644
--- a/drivers/mfd/wm831x-spi.c
+++ b/drivers/mfd/wm831x-spi.c
@@ -69,22 +69,8 @@ static int __devinit wm831x_spi_probe(struct spi_device *spi)
 	struct wm831x *wm831x;
 	enum wm831x_parent type;
 
-	/* Currently SPI support for ID tables is unmerged, we're faking it */
-	if (strcmp(spi->modalias, "wm8310") == 0)
-		type = WM8310;
-	else if (strcmp(spi->modalias, "wm8311") == 0)
-		type = WM8311;
-	else if (strcmp(spi->modalias, "wm8312") == 0)
-		type = WM8312;
-	else if (strcmp(spi->modalias, "wm8320") == 0)
-		type = WM8320;
-	else if (strcmp(spi->modalias, "wm8321") == 0)
-		type = WM8321;
-	else if (strcmp(spi->modalias, "wm8325") == 0)
-		type = WM8325;
-	else if (strcmp(spi->modalias, "wm8326") == 0)
-		type = WM8326;
-	else {
+	type = spi_get_device_id(spi)->driver_data;
+	if (!type) {
 		dev_err(&spi->dev, "Unknown device type\n");
 		return -EINVAL;
 	}
@@ -126,128 +112,38 @@ static const struct dev_pm_ops wm831x_spi_pm = {
 	.suspend = wm831x_spi_suspend,
 };
 
-static struct spi_driver wm8310_spi_driver = {
-	.driver = {
-		.name	= "wm8310",
-		.bus	= &spi_bus_type,
-		.owner	= THIS_MODULE,
-		.pm	= &wm831x_spi_pm,
-	},
-	.probe		= wm831x_spi_probe,
-	.remove		= __devexit_p(wm831x_spi_remove),
-};
-
-static struct spi_driver wm8311_spi_driver = {
-	.driver = {
-		.name	= "wm8311",
-		.bus	= &spi_bus_type,
-		.owner	= THIS_MODULE,
-		.pm	= &wm831x_spi_pm,
-	},
-	.probe		= wm831x_spi_probe,
-	.remove		= __devexit_p(wm831x_spi_remove),
+static const struct spi_device_id wm831x_ids[] = {
+	{ "wm8310", WM8310 },
+	{ "wm8311", WM8311 },
+	{ "wm8312", WM8312 },
+	{ "wm8320", WM8320 },
+	{ "wm8321", WM8321 },
+	{ "wm8325", WM8325 },
+	{ "wm8326", WM8326 },
+	{ },
 };
+MODULE_DEVICE_TABLE(spi, wm831x_ids);
 
-static struct spi_driver wm8312_spi_driver = {
+static struct spi_driver wm831x_spi_driver = {
 	.driver = {
-		.name	= "wm8312",
-		.bus	= &spi_bus_type,
-		.owner	= THIS_MODULE,
-		.pm	= &wm831x_spi_pm,
-	},
-	.probe		= wm831x_spi_probe,
-	.remove		= __devexit_p(wm831x_spi_remove),
-};
-
-static struct spi_driver wm8320_spi_driver = {
-	.driver = {
-		.name	= "wm8320",
-		.bus	= &spi_bus_type,
-		.owner	= THIS_MODULE,
-		.pm	= &wm831x_spi_pm,
-	},
-	.probe		= wm831x_spi_probe,
-	.remove		= __devexit_p(wm831x_spi_remove),
-};
-
-static struct spi_driver wm8321_spi_driver = {
-	.driver = {
-		.name	= "wm8321",
-		.bus	= &spi_bus_type,
-		.owner	= THIS_MODULE,
-		.pm	= &wm831x_spi_pm,
-	},
-	.probe		= wm831x_spi_probe,
-	.remove		= __devexit_p(wm831x_spi_remove),
-};
-
-static struct spi_driver wm8325_spi_driver = {
-	.driver = {
-		.name	= "wm8325",
-		.bus	= &spi_bus_type,
-		.owner	= THIS_MODULE,
-		.pm	= &wm831x_spi_pm,
-	},
-	.probe		= wm831x_spi_probe,
-	.remove		= __devexit_p(wm831x_spi_remove),
-};
-
-static struct spi_driver wm8326_spi_driver = {
-	.driver = {
-		.name	= "wm8326",
-		.bus	= &spi_bus_type,
+		.name	= "wm831x",
 		.owner	= THIS_MODULE,
 		.pm	= &wm831x_spi_pm,
 	},
 	.probe		= wm831x_spi_probe,
 	.remove		= __devexit_p(wm831x_spi_remove),
+	.id_table	= wm831x_ids,
 };
 
 static int __init wm831x_spi_init(void)
 {
-	int ret;
-
-	ret = spi_register_driver(&wm8310_spi_driver);
-	if (ret != 0)
-		pr_err("Failed to register WM8310 SPI driver: %d\n", ret);
-
-	ret = spi_register_driver(&wm8311_spi_driver);
-	if (ret != 0)
-		pr_err("Failed to register WM8311 SPI driver: %d\n", ret);
-
-	ret = spi_register_driver(&wm8312_spi_driver);
-	if (ret != 0)
-		pr_err("Failed to register WM8312 SPI driver: %d\n", ret);
-
-	ret = spi_register_driver(&wm8320_spi_driver);
-	if (ret != 0)
-		pr_err("Failed to register WM8320 SPI driver: %d\n", ret);
-
-	ret = spi_register_driver(&wm8321_spi_driver);
-	if (ret != 0)
-		pr_err("Failed to register WM8321 SPI driver: %d\n", ret);
-
-	ret = spi_register_driver(&wm8325_spi_driver);
-	if (ret != 0)
-		pr_err("Failed to register WM8325 SPI driver: %d\n", ret);
-
-	ret = spi_register_driver(&wm8326_spi_driver);
-	if (ret != 0)
-		pr_err("Failed to register WM8326 SPI driver: %d\n", ret);
-
-	return 0;
+	return spi_register_driver(&wm831x_spi_driver);
 }
 subsys_initcall(wm831x_spi_init);
 
 static void __exit wm831x_spi_exit(void)
 {
-	spi_unregister_driver(&wm8326_spi_driver);
-	spi_unregister_driver(&wm8325_spi_driver);
-	spi_unregister_driver(&wm8321_spi_driver);
-	spi_unregister_driver(&wm8320_spi_driver);
-	spi_unregister_driver(&wm8312_spi_driver);
-	spi_unregister_driver(&wm8311_spi_driver);
-	spi_unregister_driver(&wm8310_spi_driver);
+	spi_unregister_driver(&wm831x_spi_driver);
 }
 module_exit(wm831x_spi_exit);
 
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] wm831x-spi: use id_table rather hand rolled variant handling
  2011-09-12 15:45 [PATCH] wm831x-spi: use id_table rather hand rolled variant handling Peter Korsgaard
@ 2011-09-12 16:38 ` Mark Brown
  2011-09-12 16:47   ` Peter Korsgaard
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2011-09-12 16:38 UTC (permalink / raw)
  To: Peter Korsgaard; +Cc: sameo, linux-kernel

On Mon, Sep 12, 2011 at 05:45:02PM +0200, Peter Korsgaard wrote:
> The spi subsystem supports device tables nowadays, so use it.
> 
> Only build tested as I don't have the hw.
> 
> Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>

Non-bugfix patches like this should always be submitted against the
latest code in -next unless the subsystem is being unusual.  I can tell
you're not working against the latest -next becuase it has a version of
this in it already.  :)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] wm831x-spi: use id_table rather hand rolled variant handling
  2011-09-12 16:38 ` Mark Brown
@ 2011-09-12 16:47   ` Peter Korsgaard
  2011-09-12 16:54     ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Korsgaard @ 2011-09-12 16:47 UTC (permalink / raw)
  To: Mark Brown; +Cc: sameo, linux-kernel

>>>>> "Mark" == Mark Brown <broonie@opensource.wolfsonmicro.com> writes:

Hi,

 Mark> Non-bugfix patches like this should always be submitted against the
 Mark> latest code in -next unless the subsystem is being unusual.  I can tell
 Mark> you're not working against the latest -next becuase it has a version of
 Mark> this in it already.  :)

Argh, sorry - I just noticed it while looking at something else in mfd/.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] wm831x-spi: use id_table rather hand rolled variant handling
  2011-09-12 16:47   ` Peter Korsgaard
@ 2011-09-12 16:54     ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2011-09-12 16:54 UTC (permalink / raw)
  To: Peter Korsgaard; +Cc: sameo, linux-kernel

On Mon, Sep 12, 2011 at 06:47:32PM +0200, Peter Korsgaard wrote:

> Argh, sorry - I just noticed it while looking at something else in mfd/.

No problem, just pointing out that the patch is already there and the
-next thing.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-09-12 16:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-12 15:45 [PATCH] wm831x-spi: use id_table rather hand rolled variant handling Peter Korsgaard
2011-09-12 16:38 ` Mark Brown
2011-09-12 16:47   ` Peter Korsgaard
2011-09-12 16:54     ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.