From 8f996607824dba3c808bb7ed3f8f82670120383e Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Fri, 5 Apr 2013 20:35:43 +0000 Subject: net: ethernet: ks8851: use spi_get_drvdata() and spi_set_drvdata() Use the wrapper functions for getting and setting the driver data using spi_device instead of using dev_{get|set}_drvdata with &spi->dev, so we can directly pass a struct spi_device. Signed-off-by: Jingoo Han Signed-off-by: David S. Miller --- drivers/net/ethernet/micrel/ks8851.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/net/ethernet/micrel/ks8851.c') diff --git a/drivers/net/ethernet/micrel/ks8851.c b/drivers/net/ethernet/micrel/ks8851.c index 8fb481252e2c..4a3b4995f19a 100644 --- a/drivers/net/ethernet/micrel/ks8851.c +++ b/drivers/net/ethernet/micrel/ks8851.c @@ -1367,7 +1367,7 @@ static int ks8851_read_selftest(struct ks8851_net *ks) #ifdef CONFIG_PM static int ks8851_suspend(struct spi_device *spi, pm_message_t state) { - struct ks8851_net *ks = dev_get_drvdata(&spi->dev); + struct ks8851_net *ks = spi_get_drvdata(spi); struct net_device *dev = ks->netdev; if (netif_running(dev)) { @@ -1380,7 +1380,7 @@ static int ks8851_suspend(struct spi_device *spi, pm_message_t state) static int ks8851_resume(struct spi_device *spi) { - struct ks8851_net *ks = dev_get_drvdata(&spi->dev); + struct ks8851_net *ks = spi_get_drvdata(spi); struct net_device *dev = ks->netdev; if (netif_running(dev)) { @@ -1456,7 +1456,7 @@ static int ks8851_probe(struct spi_device *spi) SET_ETHTOOL_OPS(ndev, &ks8851_ethtool_ops); SET_NETDEV_DEV(ndev, &spi->dev); - dev_set_drvdata(&spi->dev, ks); + spi_set_drvdata(spi, ks); ndev->if_port = IF_PORT_100BASET; ndev->netdev_ops = &ks8851_netdev_ops; @@ -1516,7 +1516,7 @@ err_irq: static int ks8851_remove(struct spi_device *spi) { - struct ks8851_net *priv = dev_get_drvdata(&spi->dev); + struct ks8851_net *priv = spi_get_drvdata(spi); if (netif_msg_drv(priv)) dev_info(&spi->dev, "remove\n"); -- cgit v1.2.3 From 0582ce92a09e826c1ac62d7e8dbc2dd72f6f99c3 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 6 Apr 2013 23:33:03 +0000 Subject: net: ks8851: Use module_spi_driver By using module_spi_driver we can eliminate a few lines of boilerplate code. Signed-off-by: Lars-Peter Clausen Signed-off-by: David S. Miller --- drivers/net/ethernet/micrel/ks8851.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'drivers/net/ethernet/micrel/ks8851.c') diff --git a/drivers/net/ethernet/micrel/ks8851.c b/drivers/net/ethernet/micrel/ks8851.c index 4a3b4995f19a..3fd65c8a929e 100644 --- a/drivers/net/ethernet/micrel/ks8851.c +++ b/drivers/net/ethernet/micrel/ks8851.c @@ -1538,19 +1538,7 @@ static struct spi_driver ks8851_driver = { .suspend = ks8851_suspend, .resume = ks8851_resume, }; - -static int __init ks8851_init(void) -{ - return spi_register_driver(&ks8851_driver); -} - -static void __exit ks8851_exit(void) -{ - spi_unregister_driver(&ks8851_driver); -} - -module_init(ks8851_init); -module_exit(ks8851_exit); +module_spi_driver(ks8851_driver); MODULE_DESCRIPTION("KS8851 Network driver"); MODULE_AUTHOR("Ben Dooks "); -- cgit v1.2.3 From d5b40921aa09a0ccc24867a035ec0f13730a1e34 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 6 Apr 2013 23:33:04 +0000 Subject: net: ks8851: Use dev_pm_ops Use dev_pm_ops instead of the deprecated legacy suspend/resume callbacks. Signed-off-by: Lars-Peter Clausen Signed-off-by: David S. Miller --- drivers/net/ethernet/micrel/ks8851.c | 37 +++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) (limited to 'drivers/net/ethernet/micrel/ks8851.c') diff --git a/drivers/net/ethernet/micrel/ks8851.c b/drivers/net/ethernet/micrel/ks8851.c index 3fd65c8a929e..da6496055a1b 100644 --- a/drivers/net/ethernet/micrel/ks8851.c +++ b/drivers/net/ethernet/micrel/ks8851.c @@ -1364,35 +1364,39 @@ static int ks8851_read_selftest(struct ks8851_net *ks) /* driver bus management functions */ -#ifdef CONFIG_PM -static int ks8851_suspend(struct spi_device *spi, pm_message_t state) +#ifdef CONFIG_PM_SLEEP + +static int ks8851_suspend(struct device *dev) { - struct ks8851_net *ks = spi_get_drvdata(spi); - struct net_device *dev = ks->netdev; + struct ks8851_net *ks = dev_get_drvdata(dev); + struct net_device *netdev = ks->netdev; - if (netif_running(dev)) { - netif_device_detach(dev); - ks8851_net_stop(dev); + if (netif_running(netdev)) { + netif_device_detach(netdev); + ks8851_net_stop(netdev); } return 0; } -static int ks8851_resume(struct spi_device *spi) +static int ks8851_resume(struct device *dev) { - struct ks8851_net *ks = spi_get_drvdata(spi); - struct net_device *dev = ks->netdev; + struct ks8851_net *ks = dev_get_drvdata(dev); + struct net_device *netdev = ks->netdev; - if (netif_running(dev)) { - ks8851_net_open(dev); - netif_device_attach(dev); + if (netif_running(netdev)) { + ks8851_net_open(netdev); + netif_device_attach(netdev); } return 0; } + +static SIMPLE_DEV_PM_OPS(ks8851_pm_ops, ks8851_suspend, ks8851_resume); +#define KS8851_PM_OPS (&ks8851_pm_ops) + #else -#define ks8851_suspend NULL -#define ks8851_resume NULL +#define KS8851_PM_OPS NULL #endif static int ks8851_probe(struct spi_device *spi) @@ -1532,11 +1536,10 @@ static struct spi_driver ks8851_driver = { .driver = { .name = "ks8851", .owner = THIS_MODULE, + .pm = KS8851_PM_OPS, }, .probe = ks8851_probe, .remove = ks8851_remove, - .suspend = ks8851_suspend, - .resume = ks8851_resume, }; module_spi_driver(ks8851_driver); -- cgit v1.2.3 From 8ac2b3c0e270f9792edc15fb66808143eb48a53f Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Tue, 16 Apr 2013 09:28:31 +0000 Subject: ks8851: Remove unneeded PM_OPS definitions SIMPLE_DEV_PM_OPS macro can handle !CONFIG_PM_SLEEP case nicely, so there is no need to define PM_OPS for both CONFIG_PM_SLEEP and !CONFIG_PM_SLEEP cases. Remove the unneeded definitions. Cc: Lars-Peter Clausen Signed-off-by: Fabio Estevam Signed-off-by: David S. Miller --- drivers/net/ethernet/micrel/ks8851.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'drivers/net/ethernet/micrel/ks8851.c') diff --git a/drivers/net/ethernet/micrel/ks8851.c b/drivers/net/ethernet/micrel/ks8851.c index da6496055a1b..727b546a9eb8 100644 --- a/drivers/net/ethernet/micrel/ks8851.c +++ b/drivers/net/ethernet/micrel/ks8851.c @@ -1391,13 +1391,9 @@ static int ks8851_resume(struct device *dev) return 0; } +#endif static SIMPLE_DEV_PM_OPS(ks8851_pm_ops, ks8851_suspend, ks8851_resume); -#define KS8851_PM_OPS (&ks8851_pm_ops) - -#else -#define KS8851_PM_OPS NULL -#endif static int ks8851_probe(struct spi_device *spi) { @@ -1536,7 +1532,7 @@ static struct spi_driver ks8851_driver = { .driver = { .name = "ks8851", .owner = THIS_MODULE, - .pm = KS8851_PM_OPS, + .pm = &ks8851_pm_ops, }, .probe = ks8851_probe, .remove = ks8851_remove, -- cgit v1.2.3