mtd: gpmi-nand: Convert to platform driver
Subsystems (3)
Fabio Estevam
reviewerPATCH 1/2 mtd: gpmi-nand: Convert to platform driver
From: Fabio Estevam <[email protected]>
Using module_platform_driver() makes the code smaller and cleaner.
---
This patch depends on: "mtd: gpmi-nand: Improve logging style"
drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-)
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +7 -22
@@ -1651,6 +1651,8 @@ static int __devinit gpmi_nand_probe(struct platform_device *pdev)if (ret) goto exit_nfc_init; +dev_info (this->dev,"driver registered.\n" ); +return 0 ; exit_nfc_init:
@@ -1658,10 +1660,12 @@ exit_nfc_init: exit_acquire_resources:platform_set_drvdata (pdev,NULL );kfree (this); +dev_err (this->dev,"driver registration failed: %d\n" , ret); +return ret; } -static int __exit gpmi_nand_remove(struct platform_device *pdev) +static int __devexit gpmi_nand_remove(struct platform_device *pdev) {struct gpmi_nand_data *this =platform_get_drvdata (pdev);
@@ -1678,29 +1682,10 @@ static struct platform_driver gpmi_nand_driver = { .of_match_table = gpmi_nand_id_table, }, .probe = gpmi_nand_probe, - .remove = __exit_p(gpmi_nand_remove), + .remove = __devexit_p(gpmi_nand_remove), .id_table = gpmi_ids, }; - -static int __init gpmi_nand_init (void ) -{ -int err; - - err =platform_driver_register (&gpmi_nand_driver); -if (err ==0 ) -pr_info ("driver registered.\n" ); -else -pr_err ("driver registration failed.\n" ); -return err; -} - -static void __exit gpmi_nand_exit(void) -{ -platform_driver_unregister (&gpmi_nand_driver); -} - -module_init (gpmi_nand_init); -module_exit (gpmi_nand_exit); +module_platform_driver (gpmi_nand_driver);MODULE_AUTHOR ("Freescale Semiconductor, Inc." );MODULE_DESCRIPTION ("i.MX GPMI NAND Flash Controller Driver" );
Signature · 1 line
1.7.9.5
Fabio Estevam
reviewerPATCH 2/2 mtd: mxc_nand: Convert to platform driver
From: Fabio Estevam <[email protected]>
Using module_platform_driver() makes the code smaller and cleaner.
--- drivers/mtd/nand/mxc_nand.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-)
drivers/mtd/nand/mxc_nand.c +3 -15
@@ -1389,7 +1389,7 @@ static int __init mxcnd_probe_pdata(struct mxc_nand_host *host)return 0 ; } -static int __init mxcnd_probe (struct platform_device *pdev) +static int __devinit mxcnd_probe (struct platform_device *pdev) {struct nand_chip *this;struct mtd_info *mtd;
@@ -1581,22 +1581,10 @@ static struct platform_driver mxcnd_driver = { .owner = THIS_MODULE, .of_match_table = of_match_ptr(mxcnd_dt_ids), }, + .probe = mxcnd_probe, .remove = __devexit_p(mxcnd_remove), }; - -static int __init mxc_nd_init (void ) -{ -return platform_driver_probe (&mxcnd_driver, mxcnd_probe); -} - -static void __exit mxc_nd_cleanup(void) -{ -/* Unregister the device structure */ -platform_driver_unregister (&mxcnd_driver); -} - -module_init (mxc_nd_init); -module_exit (mxc_nd_cleanup); +module_platform_driver (mxcnd_driver);MODULE_AUTHOR ("Freescale Semiconductor, Inc." );MODULE_DESCRIPTION ("MXC NAND MTD driver" );
Signature · 1 line
1.7.9.5
Dear Fabio Estevam,
Quoted 3 lines
From: Fabio Estevam <[email protected]>
Using
module_platform_driver()makes the code smaller and cleaner.
You did not document the dev_info() etc. addition, dunno if it's important or not.
Otherwise,
Quoted 57 lines
Signed-off-by Fabio Estevam <[email protected]>---
This patch depends on: "mtd: gpmi-nand: Improve logging style"drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 29+++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-)
(quoted diff) +0
-0
b/drivers/mtd/nand/gpmi-nand/gpmi-nand.cindex 9493507..5999b15 100644drivers/mtd/nand/gpmi-nand/gpmi-nand.c +6
-16@@ -1651,6 +1651,8 @@ static int __devinit gpmi_nand_probe(struct platform_device *pdev) if (ret) goto exit_nfc_init; + dev_info(this->dev, "driver registered.\n"); + return 0; exit_nfc_init:@@ -1658,10 +1660,12 @@ exit_nfc_init: exit_acquire_resources:platform_set_drvdata (pdev,NULL );kfree (this); +dev_err (this->dev,"driver registration failed: %d\n" , ret); +return ret; } -static int __exit gpmi_nand_remove(struct platform_device *pdev) +static int __devexit gpmi_nand_remove(struct platform_device *pdev) {struct gpmi_nand_data *this =platform_get_drvdata (pdev);@@ -1678,29 +1682,10 @@ static struct platform_driver gpmi_nand_driver = { .of_match_table = gpmi_nand_id_table, }, .probe = gpmi_nand_probe, - .remove = __exit_p(gpmi_nand_remove), + .remove = __devexit_p(gpmi_nand_remove), .id_table = gpmi_ids, }; - -static int __init gpmi_nand_init (void ) -{ -int err; - - err =platform_driver_register (&gpmi_nand_driver); -if (err ==0 ) -pr_info ("driver registered.\n" ); -else -pr_err ("driver registration failed.\n" ); -return err; -} - -static void __exit gpmi_nand_exit(void)
drivers/mtd/nand/gpmi-nand/gpmi-nand.c static struct platform_driver gpmi_nand_driver = { · line 1691
Quoted 10 lines
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +1
-6-{ -platform_driver_unregister (&gpmi_nand_driver); -} - -module_init (gpmi_nand_init); -module_exit (gpmi_nand_exit); +module_platform_driver (gpmi_nand_driver);MODULE_AUTHOR ("Freescale Semiconductor, Inc." );MODULE_DESCRIPTION ("i.MX GPMI NAND Flash Controller Driver" );
Best regards,
Marek Vasut
Fabio Estevam
reviewerHi Marek,
Quoted 8 lines · Marek Vasut
Dear Fabio Estevam,
Quoted 3 lines
From: Fabio Estevam <[email protected]>
Using
module_platform_driver()makes the code smaller and cleaner.You did not document the
dev_info()etc. addition, dunno if it's important or not.
It is not an addition. I just moved "pr_info("driver registered.\n")"
from gpmi_nand_init, (which is removed by this patch) to the probe
function.
Regards,
Fabio Estevam
Dear Fabio Estevam,
Quoted 7 lines
Hi Marek,
Quoted 4 lines · Marek Vasut
Dear Fabio Estevam,
Quoted 2 lines
From: Fabio Estevam <[email protected]>
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Using
module_platform_driver()makes the code smaller and cleaner.You did not document the
dev_info()etc. addition, dunno if it's important or not.It is not an addition. I just moved "
pr_info("driver registered.\n")"
fromgpmi_nand_init, (which is removed by this patch) to the probe
function.
Ah, just noticed. I'd say drop it completely then, there's now value in this print (or make it pr_debug() ). Besides, the init call was called only once if compiled in / every time if built as a module. The probe call is done per GPMI nand driver instance.
Quoted 3 lines
Regards,
Fabio Estevam
Best regards,
Marek Vasut
Fabio Estevam
reviewerQuoted 2 lines · Marek Vasut
Ah, just noticed. I'd say drop it completely then, there's now value in this print (or make it
pr_debug()). Besides, the init call was called only once if
I think we can keep this info. It does not hurt and this is how the current driver does.
Quoted 2 lines
compiled in / every time if built as a module. The probe call is done per GPMI nand driver instance.
,which is fine too.
Regards,
Fabio Estevam
Fabio Estevam
reviewerRe: [PATCH 2/2] mtd: mxc_nand: Convert to platform driver
In reply to Fabio EstevamHi Artem,
Quoted 6 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
Using
module_platform_driver()makes the code smaller and cleaner.Signed-off-by Fabio Estevam <[email protected]>---
Does this series look fine?
Thanks,
Fabio Estevam
Fabio Estevam
reviewerHi Artem.
Quoted 7 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
Using
module_platform_driver()makes the code smaller and cleaner.Signed-off-by Fabio Estevam <[email protected]>---
This patch depends on: "mtd: gpmi-nand: Improve logging style"
Any comments, please?
Regards,
Fabio Estevam
Marek Vasut
Reviewed-byDear Fabio Estevam,
Quoted 5 lines
Hi Artem.
Quoted 2 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
Quoted 7 lines
Quoted 5 lines
Using
module_platform_driver()makes the code smaller and cleaner.Signed-off-by Fabio Estevam <[email protected]>---
This patch depends on: "mtd: gpmi-nand: Improve logging style"Any comments, please?
WFM
Quoted 3 lines
Regards,
Fabio Estevam
Best regards,
Marek Vasut
Quoted 5 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
Using
module_platform_driver()makes the code smaller and cleaner.Signed-off-by Fabio Estevam <[email protected]>
Pushed both to l2-mtd.git, thanks!
Signature · 2 lines
Best Regards, Artem Bityutskiy