public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Yang Yingliang <yangyingliang@huawei.com>,
	Boris Brezillon <bbrezillon@kernel.org>,
	Arvind Yadav <arvind.yadav.cs@gmail.com>,
	Lee Jones <lee.jones@linaro.org>,
	Brian Norris <computersforpeace@gmail.com>,
	linux-mtd@lists.infradead.org, kernel@pengutronix.de
Subject: Re: [PATCH 4/4] mtd: st_spi_fsm: Simplify error checking in .probe() a bit
Date: Tue, 7 Jun 2022 17:32:44 +0200	[thread overview]
Message-ID: <20220607173244.7c1cdd16@xps-13> (raw)
In-Reply-To: <20220607152458.232847-5-u.kleine-koenig@pengutronix.de>

Hi Uwe,

u.kleine-koenig@pengutronix.de wrote on Tue,  7 Jun 2022 17:24:58 +0200:

> Instead of ending each if branch with the same check, do it once
> unconditionally after the if block.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
> Not entirely sure this is an objective improvement, but I like it better
> this way.
> 
> It could be shorted one step further by doing
> 
> 	ret = (info->config ?: stfsm_prepare_rwe_seqs_default)(fsm);
> 	if (ret)
> 		goto err_clk_unprepare;
> 
> but IMHO readability suffers here.

Clearly, yes, I think you opted-out for the right optimization in the
end.

> 
>  drivers/mtd/devices/st_spi_fsm.c | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c
> index 9f6d4dd8bade..54861d889c30 100644
> --- a/drivers/mtd/devices/st_spi_fsm.c
> +++ b/drivers/mtd/devices/st_spi_fsm.c
> @@ -2084,15 +2084,12 @@ static int stfsm_probe(struct platform_device *pdev)
>  	 * Configure READ/WRITE/ERASE sequences according to platform and
>  	 * device flags.
>  	 */
> -	if (info->config) {
> +	if (info->config)
>  		ret = info->config(fsm);
> -		if (ret)
> -			goto err_clk_unprepare;
> -	} else {
> +	else
>  		ret = stfsm_prepare_rwe_seqs_default(fsm);
> -		if (ret)
> -			goto err_clk_unprepare;
> -	}
> +	if (ret)
> +		goto err_clk_unprepare;
>  
>  	fsm->mtd.name		= info->name;
>  	fsm->mtd.dev.parent	= &pdev->dev;


Thanks,
Miquèl

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2022-06-07 15:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-07 15:24 [PATCH 0/4] mtd: st_spi_fsm: Some fixes and improvements Uwe Kleine-König
2022-06-07 15:24 ` [PATCH 1/4] mtd: st_spi_fsm: Add a clk_disable_unprepare() in .probe()'s error path Uwe Kleine-König
2022-06-09 13:09   ` Miquel Raynal
2022-06-07 15:24 ` [PATCH 2/4] mtd: st_spi_fsm: Warn about failure to unregister mtd device Uwe Kleine-König
2022-06-09 13:08   ` Miquel Raynal
2022-06-07 15:24 ` [PATCH 3/4] mtd: st_spi_fsm: Disable clock only after device was unregistered Uwe Kleine-König
2022-06-09 13:08   ` Miquel Raynal
2022-06-07 15:24 ` [PATCH 4/4] mtd: st_spi_fsm: Simplify error checking in .probe() a bit Uwe Kleine-König
2022-06-07 15:32   ` Miquel Raynal [this message]
2022-06-09 13:08   ` Miquel Raynal

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=20220607173244.7c1cdd16@xps-13 \
    --to=miquel.raynal@bootlin.com \
    --cc=arvind.yadav.cs@gmail.com \
    --cc=bbrezillon@kernel.org \
    --cc=computersforpeace@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=lee.jones@linaro.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=vigneshr@ti.com \
    --cc=yangyingliang@huawei.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