All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: Brian Norris <computersforpeace@gmail.com>
Cc: linux-mtd@lists.infradead.org
Subject: Re: [PATCH 07/10] mtd: spi-nor: add mtd_is_locked() support
Date: Wed, 2 Sep 2015 11:01:49 +0200	[thread overview]
Message-ID: <201509021101.49731.marex@denx.de> (raw)
In-Reply-To: <1441137435-52862-8-git-send-email-computersforpeace@gmail.com>

On Tuesday, September 01, 2015 at 09:57:12 PM, Brian Norris wrote:
> This enables ioctl(MEMISLOCKED). Status can now be reported in the
> mtdinfo or flash_lock utilities found in mtd-utils.
> 
> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
> ---
>  drivers/mtd/spi-nor/spi-nor.c | 37 ++++++++++++++++++++++++++++++++++++-
>  include/linux/mtd/spi-nor.h   |  3 +++
>  2 files changed, 39 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
> index 62fa1b4ff3c0..c4fb1205f1d3 100644
> --- a/drivers/mtd/spi-nor/spi-nor.c
> +++ b/drivers/mtd/spi-nor/spi-nor.c
> @@ -519,6 +519,24 @@ static int stm_unlock(struct spi_nor *nor, loff_t ofs,
> uint64_t len) return write_sr(nor, status_new);
>  }
> 
> +/*
> + * Check if a region of the flash is (completely) locked. See stm_lock()
> for + * more info.
> + *
> + * Returns 1 if entire region is locked, 0 if any portion is unlocked, and
> + * negative on errors.
> + */
> +static int stm_is_locked(struct spi_nor *nor, loff_t ofs, uint64_t len)
> +{
> +	int status;
> +
> +	status = read_sr(nor);
> +	if (status < 0)
> +		return status;
> +
> +	return stm_is_locked_sr(nor, ofs, len, status);
> +}
> +
>  static int spi_nor_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
>  {
>  	struct spi_nor *nor = mtd_to_spi_nor(mtd);
> @@ -549,6 +567,21 @@ static int spi_nor_unlock(struct mtd_info *mtd, loff_t
> ofs, uint64_t len) return ret;
>  }
> 
> +static int spi_nor_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t
> len) +{
> +	struct spi_nor *nor = mtd_to_spi_nor(mtd);
> +	int ret;
> +
> +	ret = spi_nor_lock_and_prep(nor, SPI_NOR_OPS_UNLOCK);
> +	if (ret)
> +		return ret;
> +
> +	ret = nor->flash_is_locked(nor, ofs, len);

Is nor->flash_is_locked () always available or should you check this here ?

> +
> +	spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_LOCK);
> +	return ret;
> +}
> +
[...]

  reply	other threads:[~2015-09-02  9:02 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-01 19:57 [PATCH 00/10] mtd: spi-nor: cleanups + block protection support updates Brian Norris
2015-09-01 19:57 ` [PATCH 01/10] mtd: spi-nor: make implicit <linux/bitops.h> dependency explicit Brian Norris
2015-09-01 19:57 ` [PATCH 02/10] mtd: spi-nor: make bitfield constants more consistent Brian Norris
2015-09-01 19:57 ` [PATCH 03/10] mtd: spi-nor: add SPI NOR manufacturer IDs Brian Norris
2015-09-24 20:17   ` Jagan Teki
2015-09-28  0:46     ` Brian Norris
2015-09-28  9:12       ` Jagan Teki
2015-09-28 23:13         ` Brian Norris
2015-10-01  8:12           ` Jagan Teki
2015-10-01 18:43             ` Brian Norris
2015-09-01 19:57 ` [PATCH 04/10] mtd: spi-nor: use SNOR_MFR_* instead of CFI_MFR_* Brian Norris
2015-09-01 19:57 ` [PATCH 05/10] mtd: spi-nor: fixup kernel-doc for flash lock/unlock function pointers Brian Norris
2015-09-01 19:57 ` [PATCH 06/10] mtd: spi-nor: refactor block protection functions Brian Norris
2015-09-01 19:57 ` [PATCH 07/10] mtd: spi-nor: add mtd_is_locked() support Brian Norris
2015-09-02  9:01   ` Marek Vasut [this message]
2015-09-02 20:30     ` Brian Norris
2015-09-03  9:43       ` Marek Vasut
2015-09-03 20:29         ` Brian Norris
2015-10-01  9:00   ` Jagan Teki
2015-10-12 16:49     ` Brian Norris
2015-09-01 19:57 ` [PATCH 08/10] mtd: spi-nor: add DUAL_READ for w25q{32,64}dw Brian Norris
2015-09-01 19:57 ` [PATCH 09/10] mtd: spi-nor: support lock/unlock/is_locked for Winbond Brian Norris
2015-09-01 19:57 ` [PATCH 10/10] mtd: spi-nor: disable protection for Winbond flash at startup Brian Norris
2015-10-14  1:29 ` [PATCH 00/10] mtd: spi-nor: cleanups + block protection support updates Brian Norris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201509021101.49731.marex@denx.de \
    --to=marex@denx.de \
    --cc=computersforpeace@gmail.com \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.