public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: <Tudor.Ambarus@microchip.com>
To: <vigneshr@ti.com>, <miquel.raynal@bootlin.com>, <richard@nod.at>
Cc: <marek.vasut@gmail.com>, <bbrezillon@kernel.org>,
	<linux-kernel@vger.kernel.org>, <linux-mtd@lists.infradead.org>,
	<tmaimon77@gmail.com>
Subject: Re: [PATCH v5 3/3] mtd: spi-nor: Rework hwcaps selection for the spi-mem case
Date: Wed, 7 Aug 2019 05:48:13 +0000	[thread overview]
Message-ID: <ae26ad74-3506-6074-8024-2ff9bc1003aa@microchip.com> (raw)
In-Reply-To: <20190806051041.3636-4-vigneshr@ti.com>



On 08/06/2019 08:10 AM, Vignesh Raghavendra wrote:
> +static int spi_nor_spimem_check_op(struct spi_nor *nor,
> +				   struct spi_mem_op *op)
> +{
> +	/*
> +	 * First test with 4 address bytes. The opcode itself might
> +	 * be a 3B addressing opcode but we don't care, because
> +	 * SPI controller implementation should not check the opcode,
> +	 * but just the sequence.
> +	 */
> +	op->addr.nbytes = 4;
> +	if (!spi_mem_supports_op(nor->spimem, op)) {
> +		/* If flash size <16MB, 3 address bytes are sufficient */
> +		if (nor->mtd.size <= SZ_16M) {
> +			op->addr.nbytes = 3;
> +			if (!spi_mem_supports_op(nor->spimem, op))
> +				return -ENOTSUPP;
> +			return 0;
> +		}
> +		return -ENOTSUPP;
> +	}
> +
> +	return 0;
> +}

We can get rid of a level of indentation by writing it as:

static int spi_nor_spimem_check_op(struct spi_nor *nor,
                                   struct spi_mem_op *op)
{
        op->addr.nbytes = 4;
        if (!spi_mem_supports_op(nor->spimem, op)) {
                if (nor->mtd.size > SZ_16M)
			return -ENOTSUPP;

                /* If flash size <16MB, 3 address bytes are sufficient */
		op->addr.nbytes = 3;
		if (!spi_mem_supports_op(nor->spimem, op))
			return -ENOTSUPP;
        }

        return 0;
}

I'll do this by myself when applying, no need to resubmit.

Thanks, Vignesh!
ta

  reply	other threads:[~2019-08-07  5:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-06  5:10 [PATCH v5 0/3] Merge m25p80 into spi-nor Vignesh Raghavendra
2019-08-06  5:10 ` [PATCH v5 1/3] mtd: spi-nor: always use bounce buffer for register read/writes Vignesh Raghavendra
2019-08-06  5:10 ` [PATCH v5 2/3] mtd: spi-nor: Move m25p80 code in spi-nor.c Vignesh Raghavendra
     [not found]   ` <CAP6Zq1h9Xe9ptGxQpjYwoFaS1sTyd-3EsMTAYwp9e70Cm1czLg@mail.gmail.com>
2019-08-08 14:04     ` Boris Brezillon
     [not found]       ` <CAP6Zq1g6Z=o7FnX4UpZ-dq_9Ui-yv9E5OEJGirK49RqFUPoP_g@mail.gmail.com>
2019-08-08 15:19         ` Boris Brezillon
2019-08-09 11:47     ` Vignesh Raghavendra
2019-08-06  5:10 ` [PATCH v5 3/3] mtd: spi-nor: Rework hwcaps selection for the spi-mem case Vignesh Raghavendra
2019-08-07  5:48   ` Tudor.Ambarus [this message]
2019-08-07  5:54 ` [PATCH v5 0/3] Merge m25p80 into spi-nor Tudor.Ambarus
2019-08-12 10:33 ` Tudor.Ambarus

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=ae26ad74-3506-6074-8024-2ff9bc1003aa@microchip.com \
    --to=tudor.ambarus@microchip.com \
    --cc=bbrezillon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=tmaimon77@gmail.com \
    --cc=vigneshr@ti.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