[PATCH 2/2] mtd: m25p80: restore the addressing mode when stop using the flash

2017-11-24 Thread Zhiqiang Hou
From: Hou Zhiqiang 

Add .shutdown function to restore the addressing mode in reboot
process, and add the same operation to the .remove function.

Signed-off-by: Hou Zhiqiang 
---
 drivers/mtd/devices/m25p80.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index dbe6a1de2bb8..867bd2d5a267 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -307,10 +307,17 @@ static int m25p_remove(struct spi_device *spi)
 {
struct m25p *flash = spi_get_drvdata(spi);
 
+   spi_nor_restore_addr_mode(&flash->spi_nor);
/* Clean up MTD stuff. */
return mtd_device_unregister(&flash->spi_nor.mtd);
 }
 
+static void m25p_shutdown(struct spi_device *spi)
+{
+   struct m25p *flash = spi_get_drvdata(spi);
+
+   spi_nor_restore_addr_mode(&flash->spi_nor);
+}
 /*
  * Do NOT add to this array without reading the following:
  *
@@ -386,6 +393,7 @@ static struct spi_driver m25p80_driver = {
.id_table   = m25p_ids,
.probe  = m25p_probe,
.remove = m25p_remove,
+   .shutdown   = m25p_shutdown,
 
/* REVISIT: many of these chips have deep power-down modes, which
 * should clearly be entered on suspend() to minimize power use.
-- 
2.14.1



Re: [PATCH 2/2] mtd: m25p80: restore the addressing mode when stop using the flash

2017-12-01 Thread Cyrille Pitchen
Hi Hou,

Le 24/11/2017 à 11:08, Zhiqiang Hou a écrit :
> From: Hou Zhiqiang 
> 
> Add .shutdown function to restore the addressing mode in reboot
> process, and add the same operation to the .remove function.
> 
> Signed-off-by: Hou Zhiqiang 
> ---
>  drivers/mtd/devices/m25p80.c | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
> index dbe6a1de2bb8..867bd2d5a267 100644
> --- a/drivers/mtd/devices/m25p80.c
> +++ b/drivers/mtd/devices/m25p80.c
> @@ -307,10 +307,17 @@ static int m25p_remove(struct spi_device *spi)
>  {
>   struct m25p *flash = spi_get_drvdata(spi);
>  
> + spi_nor_restore_addr_mode(&flash->spi_nor);

maybe add a new line here.

Otherwise, this looks good :)

Best regards,

Cyrille

>   /* Clean up MTD stuff. */
>   return mtd_device_unregister(&flash->spi_nor.mtd);
>  }
>  
> +static void m25p_shutdown(struct spi_device *spi)
> +{
> + struct m25p *flash = spi_get_drvdata(spi);
> +
> + spi_nor_restore_addr_mode(&flash->spi_nor);
> +}
>  /*
>   * Do NOT add to this array without reading the following:
>   *
> @@ -386,6 +393,7 @@ static struct spi_driver m25p80_driver = {
>   .id_table   = m25p_ids,
>   .probe  = m25p_probe,
>   .remove = m25p_remove,
> + .shutdown   = m25p_shutdown,
>  
>   /* REVISIT: many of these chips have deep power-down modes, which
>* should clearly be entered on suspend() to minimize power use.
> 



RE: [PATCH 2/2] mtd: m25p80: restore the addressing mode when stop using the flash

2017-12-01 Thread Z.q. Hou
Hi Cyrille,

Thanks for your comments!

> -Original Message-
> From: Cyrille Pitchen [mailto:cyrille.pitc...@wedev4u.fr]
> Sent: 2017年12月1日 16:58
> To: Z.q. Hou ; linux-...@lists.infradead.org;
> linux-kernel@vger.kernel.org; computersforpe...@gmail.com;
> dw...@infradead.org; boris.brezil...@free-electrons.com;
> marek.va...@gmail.com; rich...@nod.at
> Subject: Re: [PATCH 2/2] mtd: m25p80: restore the addressing mode when
> stop using the flash
> 
> Hi Hou,
> 
> Le 24/11/2017 à 11:08, Zhiqiang Hou a écrit :
> > From: Hou Zhiqiang 
> >
> > Add .shutdown function to restore the addressing mode in reboot
> > process, and add the same operation to the .remove function.
> >
> > Signed-off-by: Hou Zhiqiang 
> > ---
> >  drivers/mtd/devices/m25p80.c | 8 
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/drivers/mtd/devices/m25p80.c
> > b/drivers/mtd/devices/m25p80.c index dbe6a1de2bb8..867bd2d5a267
> 100644
> > --- a/drivers/mtd/devices/m25p80.c
> > +++ b/drivers/mtd/devices/m25p80.c
> > @@ -307,10 +307,17 @@ static int m25p_remove(struct spi_device *spi)
> > {
> > struct m25p *flash = spi_get_drvdata(spi);
> >
> > +   spi_nor_restore_addr_mode(&flash->spi_nor);
> 
> maybe add a new line here.
> 
> Otherwise, this looks good :)

Yes, will add in next version, thanks a lot for the suggestion!


Thanks,
Zhiqiang