Message ID | 20181129141026.24892-4-boris.brezillon@bootlin.com |
---|---|
State | Superseded |
Headers | show |
Series | mtd: spi-nor: Random cleanups | expand |
On 29/11/2018 15:10, Boris Brezillon wrote: > info can be extracted from nor->info, no need to pass it as an > argument. > > Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Reviewed-by: Aleaxander Sverdlin <alexander.sverdlin@nokia.com> > --- > Changes in v2: > - None > --- > drivers/mtd/spi-nor/spi-nor.c | 11 +++++------ > 1 file changed, 5 insertions(+), 6 deletions(-) > > diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c > index e1eaabf98d08..6da50684f303 100644 > --- a/drivers/mtd/spi-nor/spi-nor.c > +++ b/drivers/mtd/spi-nor/spi-nor.c > @@ -274,14 +274,13 @@ static void spi_nor_set_4byte_opcodes(struct spi_nor *nor, > } > > /* Enable/disable 4-byte addressing mode. */ > -static int set_4byte(struct spi_nor *nor, const struct flash_info *info, > - int enable) > +static int set_4byte(struct spi_nor *nor, int enable) > { > int status; > bool need_wren = false; > u8 cmd; > > - switch (JEDEC_MFR(info)) { > + switch (JEDEC_MFR(nor->info)) { > case SNOR_MFR_ST: > case SNOR_MFR_MICRON: > /* Some Micron need WREN command; all will accept it */ > @@ -298,7 +297,7 @@ static int set_4byte(struct spi_nor *nor, const struct flash_info *info, > write_disable(nor); > > if (!status && !enable && > - JEDEC_MFR(info) == SNOR_MFR_WINBOND) { > + JEDEC_MFR(nor->info) == SNOR_MFR_WINBOND) { > /* > * On Winbond W25Q256FV, leaving 4byte mode causes > * the Extended Address Register to be set to 1, so all > @@ -3574,7 +3573,7 @@ static int spi_nor_init(struct spi_nor *nor) > */ > WARN_ONCE(nor->flags & SNOR_F_BROKEN_RESET, > "enabling reset hack; may not recover from unexpected reboots\n"); > - set_4byte(nor, nor->info, 1); > + set_4byte(nor, 1); > } > > return 0; > @@ -3600,7 +3599,7 @@ void spi_nor_restore(struct spi_nor *nor) > (JEDEC_MFR(nor->info) != SNOR_MFR_SPANSION) && > !(nor->info->flags & SPI_NOR_4B_OPCODES) && > (nor->flags & SNOR_F_BROKEN_RESET)) > - set_4byte(nor, nor->info, 0); > + set_4byte(nor, 0); > } > EXPORT_SYMBOL_GPL(spi_nor_restore);
On 11/29/2018 04:10 PM, Boris Brezillon wrote: > info can be extracted from nor->info, no need to pass it as an > argument. Nice! If you move the assignment nor->info = info; earlier in spi_nor_scan(), you'll be able to spare more functions to pass info as argument. Cheers, ta
On Tue, 4 Dec 2018 19:35:15 +0000 <Tudor.Ambarus@microchip.com> wrote: > On 11/29/2018 04:10 PM, Boris Brezillon wrote: > > info can be extracted from nor->info, no need to pass it as an > > argument. > > Nice! If you move the assignment nor->info = info; earlier in spi_nor_scan(), > you'll be able to spare more functions to pass info as argument. You mean like in patch 6? ;)
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index e1eaabf98d08..6da50684f303 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -274,14 +274,13 @@ static void spi_nor_set_4byte_opcodes(struct spi_nor *nor, } /* Enable/disable 4-byte addressing mode. */ -static int set_4byte(struct spi_nor *nor, const struct flash_info *info, - int enable) +static int set_4byte(struct spi_nor *nor, int enable) { int status; bool need_wren = false; u8 cmd; - switch (JEDEC_MFR(info)) { + switch (JEDEC_MFR(nor->info)) { case SNOR_MFR_ST: case SNOR_MFR_MICRON: /* Some Micron need WREN command; all will accept it */ @@ -298,7 +297,7 @@ static int set_4byte(struct spi_nor *nor, const struct flash_info *info, write_disable(nor); if (!status && !enable && - JEDEC_MFR(info) == SNOR_MFR_WINBOND) { + JEDEC_MFR(nor->info) == SNOR_MFR_WINBOND) { /* * On Winbond W25Q256FV, leaving 4byte mode causes * the Extended Address Register to be set to 1, so all @@ -3574,7 +3573,7 @@ static int spi_nor_init(struct spi_nor *nor) */ WARN_ONCE(nor->flags & SNOR_F_BROKEN_RESET, "enabling reset hack; may not recover from unexpected reboots\n"); - set_4byte(nor, nor->info, 1); + set_4byte(nor, 1); } return 0; @@ -3600,7 +3599,7 @@ void spi_nor_restore(struct spi_nor *nor) (JEDEC_MFR(nor->info) != SNOR_MFR_SPANSION) && !(nor->info->flags & SPI_NOR_4B_OPCODES) && (nor->flags & SNOR_F_BROKEN_RESET)) - set_4byte(nor, nor->info, 0); + set_4byte(nor, 0); } EXPORT_SYMBOL_GPL(spi_nor_restore);
info can be extracted from nor->info, no need to pass it as an argument. Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> --- Changes in v2: - None --- drivers/mtd/spi-nor/spi-nor.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)