[PATCH v2 2/2] Adding nand lock/unlock routines.

kishore kadiyala kishorek.kadiyala at gmail.com
Mon Feb 8 03:41:24 EST 2010


On Mon, Feb 8, 2010 at 2:09 PM, Vimal Singh <vimal.newwork at gmail.com> wrote:
> From a28c230f3bd8fa765f78c0be91370f146e71f670 Mon Sep 17 00:00:00 2001
> From: Vimal Singh <vimalsingh at ti.com>
> Date: Wed, 3 Feb 2010 14:32:06 +0530
> Subject: [PATCH 2/2] Adding nand lock/unlock routines.
>
> Adding nand lock / unlock routines. At least 'micron' parts
> support this.
>
> Signed-off-by: Vimal Singh <vimalsingh at ti.com>
> ---
>  drivers/mtd/nand/nand_base.c |  164 ++++++++++++++++++++++++++++++++++++++++++
>  include/linux/mtd/nand.h     |   10 +++
>  2 files changed, 174 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index 2dfeb4b..a2dddca 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -864,6 +864,168 @@ static int nand_wait(struct
>  }
>
>  /**
> + * __nand_unlock - [REPLACABLE] unlocks specified locked blockes
> + *
> + * @param mtd - mtd info
> + * @param ofs - offset to start unlock from
> + * @param len - length to unlock
> + * @invert -  when = 0, unlock the range of blocks within the lower and
> + *                      upper boundary address
> + *            whne = 1, unlock the range of blocks outside the boundaries
> + *                      of the lower and upper boundary address
> + *
> + * @return - unlock status
> + */
> +static int __nand_unlock(struct mtd_info *mtd, loff_t ofs,
> +                                       uint64_t len, int invert)
> +{
> +       int ret = 0;
> +       int status, page;
> +       struct nand_chip *chip = mtd->priv;
> +
> +       /* Submit address of first page to unlock */
> +       page = ofs >> chip->page_shift;
> +       chip->cmdfunc(mtd, NAND_CMD_UNLOCK1, -1, page & chip->pagemask);
> +
> +       /* Submit address of last page to unlock */
> +       page = (ofs + len) >> chip->page_shift;
> +       chip->cmdfunc(mtd, NAND_CMD_UNLOCK2, -1,
> +                               (page | invert) & chip->pagemask);
> +
> +       /* Call wait ready function */
> +       status = chip->waitfunc(mtd, chip);
> +       udelay(1000);
> +       /* See if device thinks it succeeded */
> +       if (status & 0x01) {
> +               DEBUG(MTD_DEBUG_LEVEL0, "%s: Error status = 0x%08x\n",
> +                                       __func__, status);
> +               ret = -EIO;
> +       }
> +
> +       return ret;
> +}
> +
> +/**
> + * nand_unlock - [REPLACABLE] unlocks specified locked blockes
> + *
> + * @param mtd - mtd info
> + * @param ofs - offset to start unlock from
> + * @param len - length to unlock
> + *
> + * @return - unlock status
> + */
> +int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
> +{
> +       int ret = 0;
> +       int chipnr;
> +       struct nand_chip *chip = mtd->priv;
> +
> +       DEBUG(MTD_DEBUG_LEVEL3, "%s: start = 0x%012llx, len = %llu\n",
> +                       __func__, (unsigned long long)ofs, len);
> +
> +       if (check_offs_len(mtd, instr->addr, instr->len))
> +               ret = -EINVAL;

This patch breaks the compilation. See below:

drivers/mtd/nand/nand_base.c: In function 'nand_unlock':
drivers/mtd/nand/nand_base.c:926: error: 'instr' undeclared (first use
in this function)
drivers/mtd/nand/nand_base.c:926: error: (Each undeclared identifier
is reported only once
drivers/mtd/nand/nand_base.c:926: error: for each function it appears in.)
drivers/mtd/nand/nand_base.c: In function 'nand_lock':
drivers/mtd/nand/nand_base.c:983: error: 'instr' undeclared (first use
in this function)
make[3]: *** [drivers/mtd/nand/nand_base.o] Error 1

Regards,
Kishore



More information about the linux-mtd mailing list