diff mbox series

[v13,12/15] mtd: spi-nor: core: disable Octal DTR mode on suspend.

Message ID 20200916124418.833-13-p.yadav@ti.com
State Changes Requested
Delegated to: Vignesh R
Headers show
Series mtd: spi-nor: add xSPI Octal DTR support | expand

Commit Message

Pratyush Yadav Sept. 16, 2020, 12:44 p.m. UTC
On resume, the init procedure will be run that will re-enable it.

Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
---
 drivers/mtd/spi-nor/core.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Comments

Tudor Ambarus Sept. 30, 2020, 7:40 a.m. UTC | #1
On 9/16/20 3:44 PM, Pratyush Yadav wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> On resume, the init procedure will be run that will re-enable it.
> 
> Signed-off-by: Pratyush Yadav <p.yadav@ti.com>

> ---
>  drivers/mtd/spi-nor/core.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
> index 853dfa02f0de..d5c92c9c7307 100644
> --- a/drivers/mtd/spi-nor/core.c
> +++ b/drivers/mtd/spi-nor/core.c
> @@ -3212,6 +3212,23 @@ static void spi_nor_soft_reset(struct spi_nor *nor)
>         usleep_range(SPI_NOR_SRST_SLEEP_MIN, SPI_NOR_SRST_SLEEP_MAX);
>  }
> 
> +/* mtd suspend handler */
> +static int spi_nor_suspend(struct mtd_info *mtd)
> +{
> +       struct spi_nor *nor = mtd_to_spi_nor(mtd);
> +       struct device *dev = nor->dev;
> +       int ret;
> +
> +       /* Disable octal DTR mode if we enabled it. */
> +       ret = spi_nor_octal_dtr_enable(nor, false);
> +       if (ret) {
> +               dev_err(dev, "suspend() failed\n");

we can get rid of dev local variable as it is used only once. you can use
nor->dev directly

> +               return ret;
> +       }

and maybe just return ret; directly. spi_nor_octal_dtr_enable() returns 0 on
success.

Looks good.
 
> +
> +       return 0;
> +}
> +
>  /* mtd resume handler */
>  static void spi_nor_resume(struct mtd_info *mtd)
>  {
> @@ -3406,6 +3423,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,
>         mtd->size = nor->params->size;
>         mtd->_erase = spi_nor_erase;
>         mtd->_read = spi_nor_read;
> +       mtd->_suspend = spi_nor_suspend;
>         mtd->_resume = spi_nor_resume;
> 
>         if (nor->params->locking_ops) {
> --
> 2.28.0
>
Pratyush Yadav Sept. 30, 2020, 7:44 a.m. UTC | #2
On 30/09/20 07:40AM, Tudor.Ambarus@microchip.com wrote:
> On 9/16/20 3:44 PM, Pratyush Yadav wrote:
> > EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> > 
> > On resume, the init procedure will be run that will re-enable it.
> > 
> > Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
> 
> > ---
> >  drivers/mtd/spi-nor/core.c | 18 ++++++++++++++++++
> >  1 file changed, 18 insertions(+)
> > 
> > diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
> > index 853dfa02f0de..d5c92c9c7307 100644
> > --- a/drivers/mtd/spi-nor/core.c
> > +++ b/drivers/mtd/spi-nor/core.c
> > @@ -3212,6 +3212,23 @@ static void spi_nor_soft_reset(struct spi_nor *nor)
> >         usleep_range(SPI_NOR_SRST_SLEEP_MIN, SPI_NOR_SRST_SLEEP_MAX);
> >  }
> > 
> > +/* mtd suspend handler */
> > +static int spi_nor_suspend(struct mtd_info *mtd)
> > +{
> > +       struct spi_nor *nor = mtd_to_spi_nor(mtd);
> > +       struct device *dev = nor->dev;
> > +       int ret;
> > +
> > +       /* Disable octal DTR mode if we enabled it. */
> > +       ret = spi_nor_octal_dtr_enable(nor, false);
> > +       if (ret) {
> > +               dev_err(dev, "suspend() failed\n");
> 
> we can get rid of dev local variable as it is used only once. you can use
> nor->dev directly

Ok.
 
> > +               return ret;
> > +       }
> 
> and maybe just return ret; directly. spi_nor_octal_dtr_enable() returns 0 on
> success.

Ok.
 
> Looks good.
>
diff mbox series

Patch

diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 853dfa02f0de..d5c92c9c7307 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -3212,6 +3212,23 @@  static void spi_nor_soft_reset(struct spi_nor *nor)
 	usleep_range(SPI_NOR_SRST_SLEEP_MIN, SPI_NOR_SRST_SLEEP_MAX);
 }
 
+/* mtd suspend handler */
+static int spi_nor_suspend(struct mtd_info *mtd)
+{
+	struct spi_nor *nor = mtd_to_spi_nor(mtd);
+	struct device *dev = nor->dev;
+	int ret;
+
+	/* Disable octal DTR mode if we enabled it. */
+	ret = spi_nor_octal_dtr_enable(nor, false);
+	if (ret) {
+		dev_err(dev, "suspend() failed\n");
+		return ret;
+	}
+
+	return 0;
+}
+
 /* mtd resume handler */
 static void spi_nor_resume(struct mtd_info *mtd)
 {
@@ -3406,6 +3423,7 @@  int spi_nor_scan(struct spi_nor *nor, const char *name,
 	mtd->size = nor->params->size;
 	mtd->_erase = spi_nor_erase;
 	mtd->_read = spi_nor_read;
+	mtd->_suspend = spi_nor_suspend;
 	mtd->_resume = spi_nor_resume;
 
 	if (nor->params->locking_ops) {