public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@bootlin.com>
To: <Tudor.Ambarus@microchip.com>
Cc: <marek.vasut@gmail.com>, <dwmw2@infradead.org>,
	<computersforpeace@gmail.com>, <richard@nod.at>,
	<linux-mtd@lists.infradead.org>
Subject: Re: [PATCH v2 6/6] mtd: spi-nor: Move the nor->info assignment earlier in the scan func
Date: Wed, 5 Dec 2018 09:11:27 +0100	[thread overview]
Message-ID: <20181205091127.1c91eef6@bbrezillon> (raw)
In-Reply-To: <7376425b-fae3-2bce-4375-2c2c50c9e741@microchip.com>

On Tue, 4 Dec 2018 20:21:36 +0000
<Tudor.Ambarus@microchip.com> wrote:

> On 11/29/2018 04:10 PM, Boris Brezillon wrote:
> > Some functions called from spi_nor_scan() need a flash_info object.
> > Let's assign nor->info early on to avoid passing info as an extra
> > argument to each of these sub-functions.  
> 
> Why not to squash it with patch 3?

Makes sense. I'll squash this patch in patch 3 and reword the commit
message accordingly.

> 
> > 
> > Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
> > ---
> > Changes in v2:
> > - New patch
> > ---
> >  drivers/mtd/spi-nor/spi-nor.c | 24 ++++++++++++++----------
> >  1 file changed, 14 insertions(+), 10 deletions(-)
> > 
> > diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
> > index d2b09f52b1fb..c1d9c2e50bee 100644
> > --- a/drivers/mtd/spi-nor/spi-nor.c
> > +++ b/drivers/mtd/spi-nor/spi-nor.c
> > @@ -238,9 +238,10 @@ static u8 spi_nor_convert_3to4_erase(u8 opcode)
> >  				      ARRAY_SIZE(spi_nor_3to4_erase));
> >  }
> >  
> > -static void spi_nor_set_4byte_opcodes(struct spi_nor *nor,
> > -				      const struct flash_info *info)
> > +static void spi_nor_set_4byte_opcodes(struct spi_nor *nor)
> >  {
> > +	const struct flash_info *info = nor->info;
> > +
> >  	/* Do some manufacturer fixups first */
> >  	switch (JEDEC_MFR(info)) {
> >  	case SNOR_MFR_SPANSION:
> > @@ -2023,8 +2024,9 @@ static int spi_nor_check(struct spi_nor *nor)
> >  	return 0;
> >  }
> >  
> > -static int s3an_nor_scan(const struct flash_info *info, struct spi_nor *nor)
> > +static int s3an_nor_scan(struct spi_nor *nor)
> >  {
> > +	const struct flash_info *info = nor->info;  
> 
> info is used in this function just to get info->n_sectors. We can dereference
> n_sectors directly.

Sure.

> 
> >  	int ret;
> >  	u8 val;
> >  
> > @@ -3204,10 +3206,10 @@ static int spi_nor_parse_sfdp(struct spi_nor *nor,
> >  }
> >  
> >  static int spi_nor_init_params(struct spi_nor *nor,
> > -			       const struct flash_info *info,
> >  			       struct spi_nor_flash_parameter *params)
> >  {
> >  	struct spi_nor_erase_map *map = &nor->erase_map;
> > +	const struct flash_info *info = nor->info;
> >  	u8 i, erase_mask;
> >  
> >  	/* Set legacy flash parameters as default. */
> > @@ -3472,10 +3474,11 @@ static int spi_nor_select_erase(struct spi_nor *nor, u32 wanted_size)
> >  	return 0;
> >  }
> >  
> > -static int spi_nor_setup(struct spi_nor *nor, const struct flash_info *info,
> > +static int spi_nor_setup(struct spi_nor *nor,
> >  			 const struct spi_nor_flash_parameter *params,
> >  			 const struct spi_nor_hwcaps *hwcaps)
> >  {
> > +	const struct flash_info *info = nor->info;  
> 
> info is used in this function just to pass the info->sector_size to
> spi_nor_select_erase(). We can dereference sector_size directly,  without even
> declaring a local variable.

Ditto.

Thanks for the review.

Boris

      reply	other threads:[~2018-12-05  8:11 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-29 14:10 [PATCH v2 0/6] mtd: spi-nor: Random cleanups Boris Brezillon
2018-11-29 14:10 ` [PATCH v2 1/6] mtd: spi-nor: Drop inline on all internal helpers Boris Brezillon
2018-11-29 16:16   ` Sverdlin, Alexander (Nokia - DE/Ulm)
2018-12-04 17:01   ` Tudor.Ambarus
2018-11-29 14:10 ` [PATCH v2 2/6] mtd: spi-nor: Avoid forward declaration of internal functions Boris Brezillon
2018-12-04 19:09   ` Tudor.Ambarus
2018-12-05  8:09     ` Boris Brezillon
2018-12-05  8:40       ` Tudor.Ambarus
2018-11-29 14:10 ` [PATCH v2 3/6] mtd: spi-nor: Stop passing info to set_4byte() Boris Brezillon
2018-11-29 16:23   ` Sverdlin, Alexander (Nokia - DE/Ulm)
2018-12-04 19:35   ` Tudor.Ambarus
2018-12-04 19:37     ` Boris Brezillon
2018-11-29 14:10 ` [PATCH v2 4/6] mtd: spi-nor: Make the enable argument passed to set_byte() a bool Boris Brezillon
2018-12-04 19:38   ` Tudor.Ambarus
2018-11-29 14:10 ` [PATCH v2 5/6] mtd: spi-nor: Add an SPDX tag to spi-nor.c Boris Brezillon
2018-11-29 16:29   ` Sverdlin, Alexander (Nokia - DE/Ulm)
2018-12-04 19:45   ` Tudor.Ambarus
2018-12-05  8:09     ` Boris Brezillon
2018-11-29 14:10 ` [PATCH v2 6/6] mtd: spi-nor: Move the nor->info assignment earlier in the scan func Boris Brezillon
2018-11-29 16:35   ` Sverdlin, Alexander (Nokia - DE/Ulm)
2018-12-04 20:24     ` Tudor.Ambarus
2018-12-04 20:21   ` Tudor.Ambarus
2018-12-05  8:11     ` Boris Brezillon [this message]

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=20181205091127.1c91eef6@bbrezillon \
    --to=boris.brezillon@bootlin.com \
    --cc=Tudor.Ambarus@microchip.com \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=richard@nod.at \
    /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