* [PATCH 1/3] can: mcp251x: Remove redundant spi driver bus initialization
@ 2013-03-12 12:13 Lars-Peter Clausen
2013-03-12 12:13 ` [PATCH 2/3] can: mcp251x: Use module_spi_driver Lars-Peter Clausen
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Lars-Peter Clausen @ 2013-03-12 12:13 UTC (permalink / raw)
To: Marc Kleine-Budde, Wolfgang Grandegger; +Cc: linux-can, Lars-Peter Clausen
In ancient times it was necessary to manually initialize the bus field of an
spi_driver to spi_bus_type. These days this is done in spi_driver_register() so
we can drop the manual assignment.
The patch was generated using the following coccinelle semantic patch:
// <smpl>
@@
identifier _driver;
@@
struct spi_driver _driver = {
.driver = {
- .bus = &spi_bus_type,
},
};
// </smpl>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/mcp251x.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
index f32b9fc..05e93e8 100644
--- a/drivers/net/can/mcp251x.c
+++ b/drivers/net/can/mcp251x.c
@@ -1207,7 +1207,6 @@ MODULE_DEVICE_TABLE(spi, mcp251x_id_table);
static struct spi_driver mcp251x_can_driver = {
.driver = {
.name = DEVICE_NAME,
- .bus = &spi_bus_type,
.owner = THIS_MODULE,
},
--
1.8.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] can: mcp251x: Use module_spi_driver
2013-03-12 12:13 [PATCH 1/3] can: mcp251x: Remove redundant spi driver bus initialization Lars-Peter Clausen
@ 2013-03-12 12:13 ` Lars-Peter Clausen
2013-03-12 12:13 ` [PATCH 3/3] can: mcp251x: Use dev_pm_ops Lars-Peter Clausen
2013-03-12 12:20 ` [PATCH 1/3] can: mcp251x: Remove redundant spi driver bus initialization Marc Kleine-Budde
2 siblings, 0 replies; 4+ messages in thread
From: Lars-Peter Clausen @ 2013-03-12 12:13 UTC (permalink / raw)
To: Marc Kleine-Budde, Wolfgang Grandegger; +Cc: linux-can, Lars-Peter Clausen
By using module_spi_driver we can eliminate a few lines of boilerplate code.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/net/can/mcp251x.c | 14 +-------------
1 file changed, 1 insertion(+), 13 deletions(-)
diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
index 05e93e8..4dc7b9d 100644
--- a/drivers/net/can/mcp251x.c
+++ b/drivers/net/can/mcp251x.c
@@ -1216,19 +1216,7 @@ static struct spi_driver mcp251x_can_driver = {
.suspend = mcp251x_can_suspend,
.resume = mcp251x_can_resume,
};
-
-static int __init mcp251x_can_init(void)
-{
- return spi_register_driver(&mcp251x_can_driver);
-}
-
-static void __exit mcp251x_can_exit(void)
-{
- spi_unregister_driver(&mcp251x_can_driver);
-}
-
-module_init(mcp251x_can_init);
-module_exit(mcp251x_can_exit);
+module_spi_driver(mcp251x_can_driver);
MODULE_AUTHOR("Chris Elston <celston@katalix.com>, "
"Christian Pellegrin <chripell@evolware.org>");
--
1.8.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] can: mcp251x: Use dev_pm_ops
2013-03-12 12:13 [PATCH 1/3] can: mcp251x: Remove redundant spi driver bus initialization Lars-Peter Clausen
2013-03-12 12:13 ` [PATCH 2/3] can: mcp251x: Use module_spi_driver Lars-Peter Clausen
@ 2013-03-12 12:13 ` Lars-Peter Clausen
2013-03-12 12:20 ` [PATCH 1/3] can: mcp251x: Remove redundant spi driver bus initialization Marc Kleine-Budde
2 siblings, 0 replies; 4+ messages in thread
From: Lars-Peter Clausen @ 2013-03-12 12:13 UTC (permalink / raw)
To: Marc Kleine-Budde, Wolfgang Grandegger; +Cc: linux-can, Lars-Peter Clausen
Use dev_pm_ops instead of the deprecated legacy suspend/resume callbacks.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/net/can/mcp251x.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
index 4dc7b9d..2b620c8 100644
--- a/drivers/net/can/mcp251x.c
+++ b/drivers/net/can/mcp251x.c
@@ -1138,9 +1138,11 @@ static int mcp251x_can_remove(struct spi_device *spi)
return 0;
}
-#ifdef CONFIG_PM
-static int mcp251x_can_suspend(struct spi_device *spi, pm_message_t state)
+#ifdef CONFIG_PM_SLEEP
+
+static int mcp251x_can_suspend(struct device *dev)
{
+ struct spi_device *spi = to_spi_device(dev);
struct mcp251x_platform_data *pdata = spi->dev.platform_data;
struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev);
struct net_device *net = priv->net;
@@ -1170,8 +1172,9 @@ static int mcp251x_can_suspend(struct spi_device *spi, pm_message_t state)
return 0;
}
-static int mcp251x_can_resume(struct spi_device *spi)
+static int mcp251x_can_resume(struct device *dev)
{
+ struct spi_device *spi = to_spi_device(dev);
struct mcp251x_platform_data *pdata = spi->dev.platform_data;
struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev);
@@ -1191,9 +1194,13 @@ static int mcp251x_can_resume(struct spi_device *spi)
enable_irq(spi->irq);
return 0;
}
+
+static SIMPLE_DEV_PM_OPS(mcp251x_can_pm_ops, mcp251x_can_suspend,
+ mcp251x_can_resume);
+#define MCP251X_PM_OPS (&mcp251x_can_pm_ops)
+
#else
-#define mcp251x_can_suspend NULL
-#define mcp251x_can_resume NULL
+#define MCP251X_PM_OPS NULL
#endif
static const struct spi_device_id mcp251x_id_table[] = {
@@ -1208,13 +1215,12 @@ static struct spi_driver mcp251x_can_driver = {
.driver = {
.name = DEVICE_NAME,
.owner = THIS_MODULE,
+ .pm = MCP251X_PM_OPS,
},
.id_table = mcp251x_id_table,
.probe = mcp251x_can_probe,
.remove = mcp251x_can_remove,
- .suspend = mcp251x_can_suspend,
- .resume = mcp251x_can_resume,
};
module_spi_driver(mcp251x_can_driver);
--
1.8.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/3] can: mcp251x: Remove redundant spi driver bus initialization
2013-03-12 12:13 [PATCH 1/3] can: mcp251x: Remove redundant spi driver bus initialization Lars-Peter Clausen
2013-03-12 12:13 ` [PATCH 2/3] can: mcp251x: Use module_spi_driver Lars-Peter Clausen
2013-03-12 12:13 ` [PATCH 3/3] can: mcp251x: Use dev_pm_ops Lars-Peter Clausen
@ 2013-03-12 12:20 ` Marc Kleine-Budde
2 siblings, 0 replies; 4+ messages in thread
From: Marc Kleine-Budde @ 2013-03-12 12:20 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: Wolfgang Grandegger, linux-can
[-- Attachment #1: Type: text/plain, Size: 573 bytes --]
On 03/12/2013 01:13 PM, Lars-Peter Clausen wrote:
> In ancient times it was necessary to manually initialize the bus field of an
> spi_driver to spi_bus_type. These days this is done in spi_driver_register() so
> we can drop the manual assignment.
Applied all three patches.
Tnx,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-03-12 12:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-12 12:13 [PATCH 1/3] can: mcp251x: Remove redundant spi driver bus initialization Lars-Peter Clausen
2013-03-12 12:13 ` [PATCH 2/3] can: mcp251x: Use module_spi_driver Lars-Peter Clausen
2013-03-12 12:13 ` [PATCH 3/3] can: mcp251x: Use dev_pm_ops Lars-Peter Clausen
2013-03-12 12:20 ` [PATCH 1/3] can: mcp251x: Remove redundant spi driver bus initialization Marc Kleine-Budde
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).