From: Alexander Sverdlin <alexander.sverdlin@gmail.com>
To: SF Markus Elfring <elfring@users.sourceforge.net>,
linux-cris-kernel@axis.com,
Jesper Nilsson <jesper.nilsson@axis.com>,
Mikael Starvik <starvik@axis.com>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 5/5] cris: nand: Split a condition check in crisv32_nand_flash_probe()
Date: Wed, 4 Oct 2017 22:26:45 +0200 [thread overview]
Message-ID: <4aa6e2f1-2324-6740-021a-24ee8cd63104@gmail.com> (raw)
In-Reply-To: <290ad3d7-eb40-5c60-068f-3835063babc2@users.sourceforge.net>
Hello Markus,
On 04/10/17 20:50, SF Markus Elfring wrote:
> * Split a condition check for failed calls of the function "ioremap"
> so that the return value in the variable "write_cs" will also be
> immediately checked.
>
> * Adjust jump targets according to the Linux coding style convention.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> arch/cris/arch-v32/drivers/mach-fs/nandflash.c | 17 +++++++++++------
> 1 file changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/arch/cris/arch-v32/drivers/mach-fs/nandflash.c b/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
> index 2b53f0c615ea..564218a12213 100644
> --- a/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
> +++ b/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
> @@ -113,13 +113,17 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
> return NULL;
>
> read_cs = ioremap(MEM_CSP0_START | MEM_NON_CACHEABLE, 8192);
> - write_cs = ioremap(MEM_CSP1_START | MEM_NON_CACHEABLE, 8192);
> -
> - if (!read_cs || !write_cs) {
> + if (!read_cs) {
> printk(KERN_ERR "CRISv32 NAND ioremap failed\n");
> goto out_mtd;
> }
>
> + write_cs = ioremap(MEM_CSP1_START | MEM_NON_CACHEABLE, 8192);
> + if (!write_cs) {
> + printk(KERN_ERR "CRISv32 NAND ioremap failed\n");
> + goto unmap_read;
> + }
> +
Instead of duplicating the error message I'd rather put an "if" in the
iounmap() path.
> /* Get pointer to private data */
> this = &wrapper->chip;
> crisv32_mtd = nand_to_mtd(this);
> @@ -149,13 +153,14 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
>
> /* Scan to find existence of the device */
> if (nand_scan(crisv32_mtd, 1))
> - goto out_ior;
> + goto unmap_io;
>
> return crisv32_mtd;
>
> -out_ior:
> - iounmap((void *)read_cs);
> +unmap_io:
> iounmap((void *)write_cs);
> +unmap_read:
> + iounmap((void *)read_cs);
I believe, (void *) casting is wrong, it does nothing than
removing __iomem qualifier.
I'd rather write
if (read_cs)
iounmap(read_cs);
if (write_cs)
iounmap(write_cs);
> out_mtd:
> kfree(wrapper);
next prev parent reply other threads:[~2017-10-04 20:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-04 18:43 [PATCH 0/5] CRIS v32: Adjustments for crisv32_nand_flash_probe() SF Markus Elfring
2017-10-04 18:45 ` [PATCH 1/5] cris: nand: Delete an error message for a failed memory allocation in crisv32_nand_flash_probe() SF Markus Elfring
2017-10-04 19:44 ` Alexander Sverdlin
2017-10-04 19:55 ` SF Markus Elfring
2017-10-04 20:12 ` [PATCH 1/5] " Julia Lawall
2017-10-04 20:16 ` Alexander Sverdlin
2017-10-04 18:46 ` [PATCH 2/5] cris: nand: Improve a size determination " SF Markus Elfring
2017-10-04 18:47 ` [PATCH 3/5] cris: nand: Delete a jump target " SF Markus Elfring
2017-10-04 18:48 ` [PATCH 4/5] cris: nand: Delete an unnecessary local variable " SF Markus Elfring
2017-10-04 20:17 ` Alexander Sverdlin
2017-10-04 18:50 ` [PATCH 5/5] cris: nand: Split a condition check " SF Markus Elfring
2017-10-04 20:26 ` Alexander Sverdlin [this message]
2017-10-05 15:31 ` [PATCH 0/5] CRIS v32: Adjustments for crisv32_nand_flash_probe() Gregory CLEMENT
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4aa6e2f1-2324-6740-021a-24ee8cd63104@gmail.com \
--to=alexander.sverdlin@gmail.com \
--cc=elfring@users.sourceforge.net \
--cc=jesper.nilsson@axis.com \
--cc=linux-cris-kernel@axis.com \
--cc=linux-kernel@vger.kernel.org \
--cc=starvik@axis.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox