Linux-Amlogic Archive on lore.kernel.org
 help / 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-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[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-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

end of thread, back to index

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

Linux-Amlogic Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-amlogic/0 linux-amlogic/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-amlogic linux-amlogic/ https://lore.kernel.org/linux-amlogic \
		linux-amlogic@lists.infradead.org linux-amlogic@archiver.kernel.org
	public-inbox-index linux-amlogic


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-amlogic


AGPL code for this site: git clone https://public-inbox.org/ public-inbox