lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f4c6e60a22a4252bcecdfb3a2c957b2a@walle.cc>
Date:   Thu, 01 Sep 2022 09:39:17 +0200
From:   Michael Walle <michael@...le.cc>
To:     Sai Krishna Potthuri <sai.krishna.potthuri@....com>
Cc:     Tudor Ambarus <tudor.ambarus@...rochip.com>,
        Pratyush Yadav <pratyush@...nel.org>,
        Miquel Raynal <miquel.raynal@...tlin.com>,
        Richard Weinberger <richard@....at>,
        Vignesh Raghavendra <vigneshr@...com>,
        Rob Herring <robh+dt@...nel.org>,
        Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
        devicetree@...r.kernel.org, linux-mtd@...ts.infradead.org,
        linux-kernel@...r.kernel.org, saikrishna12468@...il.com,
        git@....com
Subject: Re: [PATCH v2 2/2] mtd: spi-nor: Add support for flash reset

Am 2022-09-01 09:29, schrieb Sai Krishna Potthuri:
> Add support for spi-nor flash reset via GPIO controller by reading the
> reset-gpio property. If there is a valid GPIO specifier then reset will
> be performed by asserting and deasserting the GPIO using gpiod APIs
> otherwise it will not perform any operation.
> 
> Signed-off-by: Sai Krishna Potthuri <sai.krishna.potthuri@....com>

Reviewed-by: Michael Walle <michael@...le.cc>

Just one comment, see below

> ---
>  drivers/mtd/spi-nor/core.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
> index f2c64006f8d7..a78ab9bae2be 100644
> --- a/drivers/mtd/spi-nor/core.c
> +++ b/drivers/mtd/spi-nor/core.c
> @@ -2933,6 +2933,27 @@ static void spi_nor_set_mtd_info(struct spi_nor 
> *nor)
>  	mtd->_put_device = spi_nor_put_device;
>  }
> 
> +static int spi_nor_hw_reset(struct spi_nor *nor)
> +{
> +	struct gpio_desc *reset;
> +
> +	reset = devm_gpiod_get_optional(nor->dev, "reset", GPIOD_OUT_LOW);
> +	if (IS_ERR_OR_NULL(reset))
> +		return PTR_ERR_OR_ZERO(reset);
> +
> +	/*
> +	 * Experimental delay values by looking at different flash device
> +	 * vendors datasheets.
> +	 */
> +	usleep_range(1, 5);

I think this is superfluous, because parts of the kernel
will boot which should take longer than 1us. But I'm
fine with leaving it here.

-michael

> +	gpiod_set_value_cansleep(reset, 1);
> +	usleep_range(100, 150);
> +	gpiod_set_value_cansleep(reset, 0);
> +	usleep_range(1000, 1200);
> +
> +	return 0;
> +}
> +
>  int spi_nor_scan(struct spi_nor *nor, const char *name,
>  		 const struct spi_nor_hwcaps *hwcaps)
>  {
> @@ -2965,6 +2986,10 @@ int spi_nor_scan(struct spi_nor *nor, const char 
> *name,
>  	if (!nor->bouncebuf)
>  		return -ENOMEM;
> 
> +	ret = spi_nor_hw_reset(nor);
> +	if (ret)
> +		return ret;
> +
>  	info = spi_nor_get_flash_info(nor, name);
>  	if (IS_ERR(info))
>  		return PTR_ERR(info);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ