linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/3] mtd: rawnand: meson: remove unnecessary condition in meson_nfc_select_chip()
@ 2019-02-01  8:30 Dan Carpenter
  2019-02-02  3:01 ` Liang Yang
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2019-02-01  8:30 UTC (permalink / raw)
  To: Liang Yang
  Cc: Boris Brezillon, Richard Weinberger, kernel-janitors,
	Marek Vasut, linux-mtd, Kevin Hilman, Miquel Raynal,
	linux-amlogic, Brian Norris, David Woodhouse

If chip is negative then we return at the very start of the function.
Removing the check lets us pull everything in one indent level.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/mtd/nand/raw/meson_nand.c | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c
index 0d93d0b9c1af..105d12103ca6 100644
--- a/drivers/mtd/nand/raw/meson_nand.c
+++ b/drivers/mtd/nand/raw/meson_nand.c
@@ -234,23 +234,19 @@ static void meson_nfc_select_chip(struct nand_chip *nand, int chip)
 	nfc->timing.tadl = meson_chip->tadl;
 	nfc->timing.tbers_max = meson_chip->tbers_max;
 
-	if (chip >= 0) {
-		if (nfc->clk_rate != meson_chip->clk_rate) {
-			ret = clk_set_rate(nfc->device_clk,
-					   meson_chip->clk_rate);
-			if (ret) {
-				dev_err(nfc->dev, "failed to set clock rate\n");
-				return;
-			}
-			nfc->clk_rate = meson_chip->clk_rate;
-		}
-		if (nfc->bus_timing != meson_chip->bus_timing) {
-			value = (NFC_CLK_CYCLE - 1)
-				| (meson_chip->bus_timing << 5);
-			writel(value, nfc->reg_base + NFC_REG_CFG);
-			writel((1 << 31), nfc->reg_base + NFC_REG_CMD);
-			nfc->bus_timing =  meson_chip->bus_timing;
+	if (nfc->clk_rate != meson_chip->clk_rate) {
+		ret = clk_set_rate(nfc->device_clk, meson_chip->clk_rate);
+		if (ret) {
+			dev_err(nfc->dev, "failed to set clock rate\n");
+			return;
 		}
+		nfc->clk_rate = meson_chip->clk_rate;
+	}
+	if (nfc->bus_timing != meson_chip->bus_timing) {
+		value = (NFC_CLK_CYCLE - 1) | (meson_chip->bus_timing << 5);
+		writel(value, nfc->reg_base + NFC_REG_CFG);
+		writel((1 << 31), nfc->reg_base + NFC_REG_CMD);
+		nfc->bus_timing =  meson_chip->bus_timing;
 	}
 }
 
-- 
2.17.1


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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 3/3] mtd: rawnand: meson: remove unnecessary condition in meson_nfc_select_chip()
  2019-02-01  8:30 [PATCH 3/3] mtd: rawnand: meson: remove unnecessary condition in meson_nfc_select_chip() Dan Carpenter
@ 2019-02-02  3:01 ` Liang Yang
  0 siblings, 0 replies; 2+ messages in thread
From: Liang Yang @ 2019-02-02  3:01 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Boris Brezillon, Richard Weinberger, kernel-janitors,
	Marek Vasut, linux-mtd, Kevin Hilman, Miquel Raynal,
	linux-amlogic, Brian Norris, David Woodhouse


On 2019/2/1 16:30, Dan Carpenter wrote:
> If chip is negative then we return at the very start of the function.
> Removing the check lets us pull everything in one indent level.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>   drivers/mtd/nand/raw/meson_nand.c | 28 ++++++++++++----------------
>   1 file changed, 12 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c
> index 0d93d0b9c1af..105d12103ca6 100644
> --- a/drivers/mtd/nand/raw/meson_nand.c
> +++ b/drivers/mtd/nand/raw/meson_nand.c
> @@ -234,23 +234,19 @@ static void meson_nfc_select_chip(struct nand_chip *nand, int chip)
>   	nfc->timing.tadl = meson_chip->tadl;
>   	nfc->timing.tbers_max = meson_chip->tbers_max;
>   
> -	if (chip >= 0) {
> -		if (nfc->clk_rate != meson_chip->clk_rate) {
> -			ret = clk_set_rate(nfc->device_clk,
> -					   meson_chip->clk_rate);
> -			if (ret) {
> -				dev_err(nfc->dev, "failed to set clock rate\n");
> -				return;
> -			}
> -			nfc->clk_rate = meson_chip->clk_rate;
> -		}
> -		if (nfc->bus_timing != meson_chip->bus_timing) {
> -			value = (NFC_CLK_CYCLE - 1)
> -				| (meson_chip->bus_timing << 5);
> -			writel(value, nfc->reg_base + NFC_REG_CFG);
> -			writel((1 << 31), nfc->reg_base + NFC_REG_CMD);
> -			nfc->bus_timing =  meson_chip->bus_timing;
> +	if (nfc->clk_rate != meson_chip->clk_rate) {
> +		ret = clk_set_rate(nfc->device_clk, meson_chip->clk_rate);
> +		if (ret) {
> +			dev_err(nfc->dev, "failed to set clock rate\n");
> +			return;
>   		}
> +		nfc->clk_rate = meson_chip->clk_rate;
> +	}
> +	if (nfc->bus_timing != meson_chip->bus_timing) {
> +		value = (NFC_CLK_CYCLE - 1) | (meson_chip->bus_timing << 5);
> +		writel(value, nfc->reg_base + NFC_REG_CFG);
> +		writel((1 << 31), nfc->reg_base + NFC_REG_CMD);
> +		nfc->bus_timing =  meson_chip->bus_timing;
>   	}

Indeed, we need not check chip >= 0 again. Thank you.

Acked-by: Liang Yang <liang.yang@amlogic.com>

>   }
>   
> 

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-02-02  3:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-01  8:30 [PATCH 3/3] mtd: rawnand: meson: remove unnecessary condition in meson_nfc_select_chip() Dan Carpenter
2019-02-02  3:01 ` Liang Yang

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).