2017-12-01 08:52:45

by Cyrille Pitchen

[permalink] [raw]
Subject: Re: [PATCH 1/2] mtd: spi-nor: add a API to restore the addressing mode

Hi Hou,

Le 24/11/2017 à 11:08, Zhiqiang Hou a écrit :
> From: Hou Zhiqiang <[email protected]>
>
> It's better to restore the addressing mode of the SPI flash
> whenever remove the driver or reboot the system.
>
> Signed-off-by: Hou Zhiqiang <[email protected]>
> ---
> drivers/mtd/spi-nor/spi-nor.c | 8 ++++++++
> include/linux/mtd/spi-nor.h | 1 +
> 2 files changed, 9 insertions(+)
>
> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
> index bc266f70a15b..801cbe99b059 100644
> --- a/drivers/mtd/spi-nor/spi-nor.c
> +++ b/drivers/mtd/spi-nor/spi-nor.c
> @@ -2713,6 +2713,14 @@ static void spi_nor_resume(struct mtd_info *mtd)
> dev_err(dev, "resume() failed\n");
> }
>
> +void spi_nor_restore_addr_mode(struct spi_nor *nor)
> +{
> + if ((nor->addr_width == 4) &&
> + (JEDEC_MFR(nor->info) != SNOR_MFR_SPANSION) &&
> + !(nor->info->flags & SPI_NOR_4B_OPCODES))
> + set_4byte(nor, nor->info, 0);
> +}
+ EXPORT_SYMBOL_GPL(spi_nor_restore_addr_mode);

Like for spi_nor_scan(), you would need to export the symbol for modules.

> +
> int spi_nor_scan(struct spi_nor *nor, const char *name,
> const struct spi_nor_hwcaps *hwcaps)
> {
> diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
> index d0c66a0975cf..fe9357da2049 100644
> --- a/include/linux/mtd/spi-nor.h
> +++ b/include/linux/mtd/spi-nor.h
> @@ -398,5 +398,6 @@ struct spi_nor_hwcaps {
> */
> int spi_nor_scan(struct spi_nor *nor, const char *name,
> const struct spi_nor_hwcaps *hwcaps);
> +void spi_nor_restore_addr_mode(struct spi_nor *nor);
>
Please add the relevant kernel doc.

Best regards,

Cyrille

> #endif
>


2017-12-01 10:06:28

by Zhiqiang Hou

[permalink] [raw]
Subject: RE: [PATCH 1/2] mtd: spi-nor: add a API to restore the addressing mode

Hi Cyrille,

Thanks a lot for your comments!

> -----Original Message-----
> From: Cyrille Pitchen [mailto:[email protected]]
> Sent: 2017年12月1日 16:53
> To: Z.q. Hou <[email protected]>; [email protected];
> [email protected]; [email protected];
> [email protected]; [email protected];
> [email protected]; [email protected]
> Subject: Re: [PATCH 1/2] mtd: spi-nor: add a API to restore the addressing
> mode
>
> Hi Hou,
>
> Le 24/11/2017 à 11:08, Zhiqiang Hou a écrit :
> > From: Hou Zhiqiang <[email protected]>
> >
> > It's better to restore the addressing mode of the SPI flash whenever
> > remove the driver or reboot the system.
> >
> > Signed-off-by: Hou Zhiqiang <[email protected]>
> > ---
> > drivers/mtd/spi-nor/spi-nor.c | 8 ++++++++
> > include/linux/mtd/spi-nor.h | 1 +
> > 2 files changed, 9 insertions(+)
> >
> > diff --git a/drivers/mtd/spi-nor/spi-nor.c
> > b/drivers/mtd/spi-nor/spi-nor.c index bc266f70a15b..801cbe99b059
> > 100644
> > --- a/drivers/mtd/spi-nor/spi-nor.c
> > +++ b/drivers/mtd/spi-nor/spi-nor.c
> > @@ -2713,6 +2713,14 @@ static void spi_nor_resume(struct mtd_info
> *mtd)
> > dev_err(dev, "resume() failed\n");
> > }
> >
> > +void spi_nor_restore_addr_mode(struct spi_nor *nor) {
> > + if ((nor->addr_width == 4) &&
> > + (JEDEC_MFR(nor->info) != SNOR_MFR_SPANSION) &&
> > + !(nor->info->flags & SPI_NOR_4B_OPCODES))
> > + set_4byte(nor, nor->info, 0);
> > +}
> + EXPORT_SYMBOL_GPL(spi_nor_restore_addr_mode);
>
> Like for spi_nor_scan(), you would need to export the symbol for modules.

Yes, I will add this in next version.

>
> > +
> > int spi_nor_scan(struct spi_nor *nor, const char *name,
> > const struct spi_nor_hwcaps *hwcaps) { diff --git
> > a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index
> > d0c66a0975cf..fe9357da2049 100644
> > --- a/include/linux/mtd/spi-nor.h
> > +++ b/include/linux/mtd/spi-nor.h
> > @@ -398,5 +398,6 @@ struct spi_nor_hwcaps {
> > */
> > int spi_nor_scan(struct spi_nor *nor, const char *name,
> > const struct spi_nor_hwcaps *hwcaps);
> > +void spi_nor_restore_addr_mode(struct spi_nor *nor);
> >
> Please add the relevant kernel doc.

Yes, will add comments for this API in next version.

>
> Best regards,
>
> Cyrille
>
> > #endif
> >

Thanks,
Zhiqiang