public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: "Lothar Waßmann" <LW@KARO-electronics.de>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Bayi Cheng <bayi.cheng@mediatek.com>,
	Mark Rutland <mark.rutland@arm.com>,
	devicetree@vger.kernel.org, Pawel Moll <pawel.moll@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	linux-kernel@vger.kernel.org, Daniel Kurtz <djkurtz@chromium.org>,
	Rob Herring <robh+dt@kernel.org>,
	linux-mediatek@lists.infradead.org,
	Kumar Gala <galak@codeaurora.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	linux-mtd@lists.infradead.org,
	Brian Norris <computersforpeace@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 2/3] mtd: mtk-nor: mtk serial flash controller driver
Date: Wed, 9 Sep 2015 15:00:50 +0200	[thread overview]
Message-ID: <20150909150050.44d2b197@ipc1.ka-ro> (raw)
In-Reply-To: <20150909063701.GD18700@pengutronix.de>

Hi,

> > +	writeb(len, mt8173_nor->base + MTK_NOR_CNT_REG);
> > +	return mt8173_nor_execute_cmd(mt8173_nor, MTK_NOR_PRG_CMD);
> > +}
> > +
> > +static int mt8173_nor_get_para(struct mt8173_nor *mt8173_nor, u8 *buf, int len)
> > +{
> > +	if (len > 1) {
> > +		/* read JEDEC ID need 4 bytes commands */
> > +		mt8173_nor_set_cmd(mt8173_nor, 0, 32, SPINOR_OP_RDID);
> > +		buf[2] = readb(mt8173_nor->base + MTK_NOR_SHREG0_REG);
> > +		buf[1] = readb(mt8173_nor->base + MTK_NOR_SHREG1_REG);
> > +		buf[0] = readb(mt8173_nor->base + MTK_NOR_SHREG2_REG);
> > +	} else {
> > +		if (mt8173_nor_execute_cmd(mt8173_nor, MTK_NOR_RDSR_CMD)) {
> > +			dev_err(mt8173_nor->dev, "read status failed!\n");
> > +			return -EINVAL;
> > +		}
> > +		*buf = readb(mt8173_nor->base + MTK_NOR_RDSR_REG);
> > +	}
> > +	return 0;
> > +}
> > +
> > +/* cmd1 sent to nor flash, cmd2 write to nor controller */
> > +static int mt8173_nor_set_para(struct mt8173_nor *mt8173_nor, int cmd1,
> > +			       int cmd2)
> > +{
> > +	if (mt8173_nor_set_cmd(mt8173_nor, 0, 8, SPINOR_OP_WREN)) {
> > +		dev_err(mt8173_nor->dev,
> > +			"write enable failed in write protect!\n");
> > +		return -EINVAL;
> > +	}
> > +	writeb(cmd1, mt8173_nor->base + MTK_NOR_PRGDATA5_REG);
> > +	writeb(8, mt8173_nor->base + MTK_NOR_CNT_REG);
> > +	if (mt8173_nor_execute_cmd(mt8173_nor, cmd2)) {
> > +		dev_err(mt8173_nor->dev, "execute cmd failed!\n");
> 
> mt8173_nor_execute_cmd() will already have printed an error message.
> 
And mt8173_nor_execute_cmd()/mt8173_nor_set_cmd() returned an error
code which should be promoted to the caller rather than
inventing a new one.
The same for other instances of this code fragment.


Lothar Waßmann

  reply	other threads:[~2015-09-09 13:00 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-08  9:49 [PATCH 0/3] Mediatek SPI-NOR flash driver Bayi Cheng
2015-09-08  9:49 ` [PATCH 1/3] doc: dt: add documentation for Mediatek spi-nor controller Bayi Cheng
2015-09-08 11:34   ` Jagan Teki
2015-09-15  6:49     ` bayi.cheng
2015-09-09  5:47   ` Sascha Hauer
2015-09-15  6:39     ` bayi.cheng
2015-09-11 21:47   ` Brian Norris
2015-09-11 21:49   ` Brian Norris
2015-09-15  6:53     ` bayi.cheng
2015-09-08  9:49 ` [PATCH 2/3] mtd: mtk-nor: mtk serial flash controller driver Bayi Cheng
2015-09-09  6:37   ` Sascha Hauer
2015-09-09 13:00     ` Lothar Waßmann [this message]
2015-09-15 16:37       ` bayi.cheng
2015-09-15 16:23     ` bayi.cheng
2015-09-08  9:49 ` [PATCH 3/3] arm64: dts: mt8173: Add nor flash node Bayi Cheng
2015-09-08 11:53   ` Jagan Teki
2015-09-08 15:18     ` Ezequiel Garcia
2015-09-08 23:46       ` Rob Herring
2015-09-11  9:51         ` bayi.cheng
2015-09-11 21:56           ` Brian Norris
2015-09-11  9:49       ` bayi.cheng
2015-09-11  9:47     ` bayi.cheng

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=20150909150050.44d2b197@ipc1.ka-ro \
    --to=lw@karo-electronics.de \
    --cc=bayi.cheng@mediatek.com \
    --cc=computersforpeace@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=djkurtz@chromium.org \
    --cc=dwmw2@infradead.org \
    --cc=galak@codeaurora.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=matthias.bgg@gmail.com \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=s.hauer@pengutronix.de \
    /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