* [PATCH] mtd: nand: lpc32xx_slc: Remove unneeded NULL check on 'rc'
@ 2016-11-29 15:28 Fabio Estevam
2016-11-29 17:30 ` Marek Vasut
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Fabio Estevam @ 2016-11-29 15:28 UTC (permalink / raw)
To: boris.brezillon
Cc: marek.vasut, cyrille.pitchen, vz, linux-mtd, Fabio Estevam
devm_ioremap_resource() does a NULL check on the 'rc' argument, so
remove the unneeded manual NULL check.
While at it, place the 'rc' assignment just before
devm_ioremap_resource() to improve readability.
Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
---
drivers/mtd/nand/lpc32xx_slc.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/mtd/nand/lpc32xx_slc.c b/drivers/mtd/nand/lpc32xx_slc.c
index 53bafe2..a0669a3 100644
--- a/drivers/mtd/nand/lpc32xx_slc.c
+++ b/drivers/mtd/nand/lpc32xx_slc.c
@@ -797,22 +797,17 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
struct resource *rc;
int res;
- rc = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (rc == NULL) {
- dev_err(&pdev->dev, "No memory resource found for device\n");
- return -EBUSY;
- }
-
/* Allocate memory for the device structure (and zero it) */
host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL);
if (!host)
return -ENOMEM;
- host->io_base_dma = rc->start;
+ rc = platform_get_resource(pdev, IORESOURCE_MEM, 0);
host->io_base = devm_ioremap_resource(&pdev->dev, rc);
if (IS_ERR(host->io_base))
return PTR_ERR(host->io_base);
+ host->io_base_dma = rc->start;
if (pdev->dev.of_node)
host->ncfg = lpc32xx_parse_dt(&pdev->dev);
if (!host->ncfg) {
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] mtd: nand: lpc32xx_slc: Remove unneeded NULL check on 'rc'
2016-11-29 15:28 [PATCH] mtd: nand: lpc32xx_slc: Remove unneeded NULL check on 'rc' Fabio Estevam
@ 2016-11-29 17:30 ` Marek Vasut
2016-11-29 19:04 ` Fabio Estevam
2016-12-08 1:44 ` Vladimir Zapolskiy
2017-01-03 10:55 ` Boris Brezillon
2 siblings, 1 reply; 5+ messages in thread
From: Marek Vasut @ 2016-11-29 17:30 UTC (permalink / raw)
To: Fabio Estevam, boris.brezillon; +Cc: cyrille.pitchen, vz, linux-mtd
On 11/29/2016 04:28 PM, Fabio Estevam wrote:
> devm_ioremap_resource() does a NULL check on the 'rc' argument, so
> remove the unneeded manual NULL check.
>
> While at it, place the 'rc' assignment just before
> devm_ioremap_resource() to improve readability.
>
> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
> ---
> drivers/mtd/nand/lpc32xx_slc.c | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/mtd/nand/lpc32xx_slc.c b/drivers/mtd/nand/lpc32xx_slc.c
> index 53bafe2..a0669a3 100644
> --- a/drivers/mtd/nand/lpc32xx_slc.c
> +++ b/drivers/mtd/nand/lpc32xx_slc.c
> @@ -797,22 +797,17 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
> struct resource *rc;
> int res;
>
> - rc = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - if (rc == NULL) {
> - dev_err(&pdev->dev, "No memory resource found for device\n");
> - return -EBUSY;
> - }
I can understand the original code where you avoid calling the malloc()
in case of failure, but that looks like microoptimization to me.
Acked-by: Marek Vasut <marek.vasut@gmail.com>
> /* Allocate memory for the device structure (and zero it) */
> host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL);
> if (!host)
> return -ENOMEM;
> - host->io_base_dma = rc->start;
>
> + rc = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> host->io_base = devm_ioremap_resource(&pdev->dev, rc);
> if (IS_ERR(host->io_base))
> return PTR_ERR(host->io_base);
>
> + host->io_base_dma = rc->start;
> if (pdev->dev.of_node)
> host->ncfg = lpc32xx_parse_dt(&pdev->dev);
> if (!host->ncfg) {
>
--
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mtd: nand: lpc32xx_slc: Remove unneeded NULL check on 'rc'
2016-11-29 17:30 ` Marek Vasut
@ 2016-11-29 19:04 ` Fabio Estevam
0 siblings, 0 replies; 5+ messages in thread
From: Fabio Estevam @ 2016-11-29 19:04 UTC (permalink / raw)
To: Marek Vasut
Cc: Fabio Estevam, Boris Brezillon, Cyrille Pitchen,
linux-mtd@lists.infradead.org, Vladimir Zapolskiy
Hi Marek,
On Tue, Nov 29, 2016 at 3:30 PM, Marek Vasut <marek.vasut@gmail.com> wrote:
> I can understand the original code where you avoid calling the malloc()
> in case of failure, but that looks like microoptimization to me.
I did not work on this driver before, so I did not touch the original code.
> Acked-by: Marek Vasut <marek.vasut@gmail.com>
Thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mtd: nand: lpc32xx_slc: Remove unneeded NULL check on 'rc'
2016-11-29 15:28 [PATCH] mtd: nand: lpc32xx_slc: Remove unneeded NULL check on 'rc' Fabio Estevam
2016-11-29 17:30 ` Marek Vasut
@ 2016-12-08 1:44 ` Vladimir Zapolskiy
2017-01-03 10:55 ` Boris Brezillon
2 siblings, 0 replies; 5+ messages in thread
From: Vladimir Zapolskiy @ 2016-12-08 1:44 UTC (permalink / raw)
To: Fabio Estevam, boris.brezillon; +Cc: marek.vasut, cyrille.pitchen, linux-mtd
Hi Fabio,
On 11/29/2016 05:28 PM, Fabio Estevam wrote:
> devm_ioremap_resource() does a NULL check on the 'rc' argument, so
> remove the unneeded manual NULL check.
>
> While at it, place the 'rc' assignment just before
> devm_ioremap_resource() to improve readability.
>
> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
> ---
thank you for the change, it is nice.
Acked-by: Vladimir Zapolskiy <vz@mleia.com>
--
With best wishes,
Vladimir
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mtd: nand: lpc32xx_slc: Remove unneeded NULL check on 'rc'
2016-11-29 15:28 [PATCH] mtd: nand: lpc32xx_slc: Remove unneeded NULL check on 'rc' Fabio Estevam
2016-11-29 17:30 ` Marek Vasut
2016-12-08 1:44 ` Vladimir Zapolskiy
@ 2017-01-03 10:55 ` Boris Brezillon
2 siblings, 0 replies; 5+ messages in thread
From: Boris Brezillon @ 2017-01-03 10:55 UTC (permalink / raw)
To: Fabio Estevam; +Cc: marek.vasut, cyrille.pitchen, vz, linux-mtd
On Tue, 29 Nov 2016 13:28:52 -0200
Fabio Estevam <fabio.estevam@nxp.com> wrote:
> devm_ioremap_resource() does a NULL check on the 'rc' argument, so
> remove the unneeded manual NULL check.
>
> While at it, place the 'rc' assignment just before
> devm_ioremap_resource() to improve readability.
>
Applied.
Thanks,
Boris
> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
> ---
> drivers/mtd/nand/lpc32xx_slc.c | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/mtd/nand/lpc32xx_slc.c b/drivers/mtd/nand/lpc32xx_slc.c
> index 53bafe2..a0669a3 100644
> --- a/drivers/mtd/nand/lpc32xx_slc.c
> +++ b/drivers/mtd/nand/lpc32xx_slc.c
> @@ -797,22 +797,17 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
> struct resource *rc;
> int res;
>
> - rc = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - if (rc == NULL) {
> - dev_err(&pdev->dev, "No memory resource found for device\n");
> - return -EBUSY;
> - }
> -
> /* Allocate memory for the device structure (and zero it) */
> host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL);
> if (!host)
> return -ENOMEM;
> - host->io_base_dma = rc->start;
>
> + rc = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> host->io_base = devm_ioremap_resource(&pdev->dev, rc);
> if (IS_ERR(host->io_base))
> return PTR_ERR(host->io_base);
>
> + host->io_base_dma = rc->start;
> if (pdev->dev.of_node)
> host->ncfg = lpc32xx_parse_dt(&pdev->dev);
> if (!host->ncfg) {
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-01-03 10:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-29 15:28 [PATCH] mtd: nand: lpc32xx_slc: Remove unneeded NULL check on 'rc' Fabio Estevam
2016-11-29 17:30 ` Marek Vasut
2016-11-29 19:04 ` Fabio Estevam
2016-12-08 1:44 ` Vladimir Zapolskiy
2017-01-03 10:55 ` Boris Brezillon
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).