This patch simplifies code by using the module_platform_driver and SIMPLE_DEV_PM_OPS macros. Signed-off-by: Marc Dietrich <marvin24@xxxxxx> --- drivers/staging/nvec/nvec.c | 27 +++++++++++---------------- drivers/staging/nvec/nvec_kbd.c | 7 +------ drivers/staging/nvec/nvec_leds.c | 14 +------------- drivers/staging/nvec/nvec_power.c | 7 +------ drivers/staging/nvec/nvec_ps2.c | 21 +++++++++++---------- 5 files changed, 25 insertions(+), 51 deletions(-) diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index 082c296..c50c92a 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -698,12 +698,14 @@ static void tegra_init_i2c_slave(struct nvec_chip *nvec) clk_disable(nvec->i2c_clk); } +#ifdef CONFIG_PM_SLEEP static void nvec_disable_i2c_slave(struct nvec_chip *nvec) { disable_irq(nvec->irq); writel(I2C_SL_NEWSL | I2C_SL_NACK, nvec->base + I2C_SL_CNFG); clk_disable(nvec->i2c_clk); } +#endif static void nvec_power_off(void) { @@ -862,10 +864,10 @@ static int __devexit tegra_nvec_remove(struct platform_device *pdev) return 0; } -#ifdef CONFIG_PM - -static int tegra_nvec_suspend(struct platform_device *pdev, pm_message_t state) +#ifdef CONFIG_PM_SLEEP +static int nvec_suspend(struct device *dev) { + struct platform_device *pdev = to_platform_device(dev); struct nvec_chip *nvec = platform_get_drvdata(pdev); struct nvec_msg *msg; @@ -882,8 +884,9 @@ static int tegra_nvec_suspend(struct platform_device *pdev, pm_message_t state) return 0; } -static int tegra_nvec_resume(struct platform_device *pdev) +static int nvec_resume(struct device *dev) { + struct platform_device *pdev = to_platform_device(dev); struct nvec_chip *nvec = platform_get_drvdata(pdev); dev_dbg(nvec->dev, "resuming\n"); @@ -892,12 +895,10 @@ static int tegra_nvec_resume(struct platform_device *pdev) return 0; } - -#else -#define tegra_nvec_suspend NULL -#define tegra_nvec_resume NULL #endif +static const SIMPLE_DEV_PM_OPS(nvec_pm_ops, nvec_suspend, nvec_resume); + /* Match table for of_platform binding */ static const struct of_device_id nvidia_nvec_of_match[] __devinitconst = { { .compatible = "nvidia,nvec", }, @@ -908,21 +909,15 @@ MODULE_DEVICE_TABLE(of, nvidia_nvec_of_match); static struct platform_driver nvec_device_driver = { .probe = tegra_nvec_probe, .remove = __devexit_p(tegra_nvec_remove), - .suspend = tegra_nvec_suspend, - .resume = tegra_nvec_resume, .driver = { .name = "nvec", .owner = THIS_MODULE, + .pm = &nvec_pm_ops, .of_match_table = nvidia_nvec_of_match, } }; -static int __init tegra_nvec_init(void) -{ - return platform_driver_register(&nvec_device_driver); -} - -module_init(tegra_nvec_init); +module_platform_driver(nvec_device_driver); MODULE_ALIAS("platform:nvec"); MODULE_DESCRIPTION("NVIDIA compliant embedded controller interface"); diff --git a/drivers/staging/nvec/nvec_kbd.c b/drivers/staging/nvec/nvec_kbd.c index a4ce5a7..36ef6a6 100644 --- a/drivers/staging/nvec/nvec_kbd.c +++ b/drivers/staging/nvec/nvec_kbd.c @@ -167,12 +167,7 @@ static struct platform_driver nvec_kbd_driver = { }, }; -static int __init nvec_kbd_init(void) -{ - return platform_driver_register(&nvec_kbd_driver); -} - -module_init(nvec_kbd_init); +module_platform_driver(nvec_kbd_driver); MODULE_AUTHOR("Marc Dietrich <marvin24@xxxxxx>"); MODULE_DESCRIPTION("NVEC keyboard driver"); diff --git a/drivers/staging/nvec/nvec_leds.c b/drivers/staging/nvec/nvec_leds.c index 91947fb..53cb571 100644 --- a/drivers/staging/nvec/nvec_leds.c +++ b/drivers/staging/nvec/nvec_leds.c @@ -90,19 +90,7 @@ static struct platform_driver nvec_led_driver = { }, }; -static int __init nvec_led_init(void) -{ - return platform_driver_register(&nvec_led_driver); -} - -module_init(nvec_led_init); - -static void __exit nvec_led_exit(void) -{ - platform_driver_unregister(&nvec_led_driver); -} - -module_exit(nvec_led_exit); +module_platform_driver(nvec_led_driver); MODULE_AUTHOR("Ilya Petrov <ilya.muromec@xxxxxxxxx>"); MODULE_DESCRIPTION("Tegra NVEC LED driver"); diff --git a/drivers/staging/nvec/nvec_power.c b/drivers/staging/nvec/nvec_power.c index a23e548..063f6d5 100644 --- a/drivers/staging/nvec/nvec_power.c +++ b/drivers/staging/nvec/nvec_power.c @@ -415,12 +415,7 @@ static struct platform_driver nvec_power_driver = { } }; -static int __init nvec_power_init(void) -{ - return platform_driver_register(&nvec_power_driver); -} - -module_init(nvec_power_init); +module_platform_driver(nvec_power_driver); MODULE_AUTHOR("Ilya Petrov <ilya.muromec@xxxxxxxxx>"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/nvec/nvec_ps2.c b/drivers/staging/nvec/nvec_ps2.c index d6ceff9..8b66cc0 100644 --- a/drivers/staging/nvec/nvec_ps2.c +++ b/drivers/staging/nvec/nvec_ps2.c @@ -123,8 +123,10 @@ static int __devinit nvec_mouse_probe(struct platform_device *pdev) return 0; } -static int nvec_mouse_suspend(struct platform_device *pdev, pm_message_t state) +#ifdef CONFIG_PM_SLEEP +static int nvec_mouse_suspend(struct device *dev) { + struct platform_device *pdev = to_platform_device(dev); struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent); /* disable mouse */ @@ -136,8 +138,9 @@ static int nvec_mouse_suspend(struct platform_device *pdev, pm_message_t state) return 0; } -static int nvec_mouse_resume(struct platform_device *pdev) +static int nvec_mouse_resume(struct device *dev) { + struct platform_device *pdev = to_platform_device(dev); struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent); ps2_startstreaming(ps2_dev.ser_dev); @@ -147,23 +150,21 @@ static int nvec_mouse_resume(struct platform_device *pdev) return 0; } +#endif + +static const SIMPLE_DEV_PM_OPS(nvec_mouse_pm_ops, nvec_mouse_suspend, + nvec_mouse_resume); static struct platform_driver nvec_mouse_driver = { .probe = nvec_mouse_probe, - .suspend = nvec_mouse_suspend, - .resume = nvec_mouse_resume, .driver = { .name = "nvec-mouse", + .pm = &nvec_mouse_pm_ops, .owner = THIS_MODULE, }, }; -static int __init nvec_mouse_init(void) -{ - return platform_driver_register(&nvec_mouse_driver); -} - -module_init(nvec_mouse_init); +module_platform_driver(nvec_mouse_driver); MODULE_DESCRIPTION("NVEC mouse driver"); MODULE_AUTHOR("Marc Dietrich <marvin24@xxxxxx>"); -- 1.7.9.5 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/devel