linux-mips
[Top] [All Lists]

Re: [PATCH 3/3] MIPS: lantiq: make use of module_platform_driver()

To: John Crispin <blogic@openwrt.org>
Subject: Re: [PATCH 3/3] MIPS: lantiq: make use of module_platform_driver()
From: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
Date: Sat, 18 Feb 2012 00:02:49 +0100
Cc: Ralf Baechle <ralf@linux-mips.org>, linux-mips@linux-mips.org
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=BlBM68LqsaffaL5juZBo/Kid123MzpTnrNRnbd665mg=; b=dJfSmCyVTxvEWigLIV0BM8do0WTJ7FgKBhpPXMuP/v05343C7T+zFBguUCHqphNN0P gbhY4tE/7pgv/jBtSqdELme6kDlwLkSG2PMqDcELW7c/4lJdRtmjmkwEEoDGmYId+G1a 4vgBwWral8aWo7P6kdkaEM7/n0JmMG/EwzH/Q=
In-reply-to: <1329474832-21095-3-git-send-email-blogic@openwrt.org>
References: <1329474832-21095-1-git-send-email-blogic@openwrt.org> <1329474832-21095-3-git-send-email-blogic@openwrt.org>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
Am 17.02.2012 11:33, schrieb John Crispin:
Reduce boilerplate code.

Signed-off-by: John Crispin<blogic@openwrt.org>
---
  drivers/mtd/maps/lantiq-flash.c    |   20 ++------------------
  drivers/net/ethernet/lantiq_etop.c |   20 ++------------------
  drivers/watchdog/lantiq_wdt.c      |   17 ++---------------
  3 files changed, 6 insertions(+), 51 deletions(-)

diff --git a/drivers/mtd/maps/lantiq-flash.c b/drivers/mtd/maps/lantiq-flash.c
index 7b889de..e22436d 100644
--- a/drivers/mtd/maps/lantiq-flash.c
+++ b/drivers/mtd/maps/lantiq-flash.c
@@ -203,6 +203,7 @@ ltq_mtd_remove(struct platform_device *pdev)
  }

  static struct platform_driver ltq_mtd_driver = {
+       .probe = ltq_mtd_probe,

you also need to change __init to __devinit at ltq_mtd_probe. Compiling with CONFIG_DEBUG_SECTION_MISMATCH shows following warning:

WARNING: drivers/mtd/maps/built-in.o(.data+0x0): Section mismatch in reference from the variable ltq_mtd_driver to the function .init.text:ltq_mtd_probe()
    The variable ltq_mtd_driver references
    the function __init ltq_mtd_probe()
    If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:
    *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console


        .remove = __devexit_p(ltq_mtd_remove),
        .driver = {
                .name = "ltq_nor",
@@ -210,24 +211,7 @@ static struct platform_driver ltq_mtd_driver = {
        },
  };

-static int __init
-init_ltq_mtd(void)
-{
-       int ret = platform_driver_probe(&ltq_mtd_driver, ltq_mtd_probe);
-
-       if (ret)
-               pr_err("ltq_nor: error registering platform driver");
-       return ret;
-}
-
-static void __exit
-exit_ltq_mtd(void)
-{
-       platform_driver_unregister(&ltq_mtd_driver);
-}
-
-module_init(init_ltq_mtd);
-module_exit(exit_ltq_mtd);
+module_platform_driver(ltq_mtd_driver);

  MODULE_LICENSE("GPL");
  MODULE_AUTHOR("John Crispin<blogic@openwrt.org>");
diff --git a/drivers/net/ethernet/lantiq_etop.c 
b/drivers/net/ethernet/lantiq_etop.c
index fa2580b..4cfc314 100644
--- a/drivers/net/ethernet/lantiq_etop.c
+++ b/drivers/net/ethernet/lantiq_etop.c
@@ -943,6 +943,7 @@ ltq_etop_remove(struct platform_device *pdev)
  }

  static struct platform_driver ltq_mii_driver = {
+       .probe = ltq_etop_probe,

dito

        .remove = __devexit_p(ltq_etop_remove),
        .driver = {
                .name = "ltq_etop",
@@ -950,24 +951,7 @@ static struct platform_driver ltq_mii_driver = {
        },
  };

-int __init
-init_ltq_etop(void)
-{
-       int ret = platform_driver_probe(&ltq_mii_driver, ltq_etop_probe);
-
-       if (ret)
-               pr_err("ltq_etop: Error registering platfom driver!");
-       return ret;
-}
-
-static void __exit
-exit_ltq_etop(void)
-{
-       platform_driver_unregister(&ltq_mii_driver);
-}
-
-module_init(init_ltq_etop);
-module_exit(exit_ltq_etop);
+module_platform_driver(ltq_mii_driver);

  MODULE_AUTHOR("John Crispin<blogic@openwrt.org>");
  MODULE_DESCRIPTION("Lantiq SoC ETOP");
diff --git a/drivers/watchdog/lantiq_wdt.c b/drivers/watchdog/lantiq_wdt.c
index 05646b8..572ac60 100644
--- a/drivers/watchdog/lantiq_wdt.c
+++ b/drivers/watchdog/lantiq_wdt.c
@@ -227,6 +227,7 @@ ltq_wdt_remove(struct platform_device *pdev)


  static struct platform_driver ltq_wdt_driver = {
+       .probe = ltq_wdt_probe,

dito

        .remove = __devexit_p(ltq_wdt_remove),
        .driver = {
                .name = "ltq_wdt",
@@ -234,21 +235,7 @@ static struct platform_driver ltq_wdt_driver = {
        },
  };

-static int __init
-init_ltq_wdt(void)
-{
-       return platform_driver_probe(&ltq_wdt_driver, ltq_wdt_probe);
-}
-
-static void __exit
-exit_ltq_wdt(void)
-{
-       return platform_driver_unregister(&ltq_wdt_driver);
-}
-
-module_init(init_ltq_wdt);
-module_exit(exit_ltq_wdt);
-
+module_platform_driver(ltq_wdt_driver);
  module_param(nowayout, int, 0);
  MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started");



--
Best regards,
Daniel

<Prev in Thread] Current Thread [Next in Thread>