[PATCH 1/2] mtd: spi-nor: provide default erase_sector implementation
Brian Norris
computersforpeace at gmail.com
Fri Oct 30 14:05:33 PDT 2015
On Thu, Oct 29, 2015 at 06:24:20PM -0700, Brian Norris wrote:
> Some spi-nor drivers perform sector erase by duplicating their
> write_reg() command. Let's not require that the driver fill this out,
> and provide a default instead.
>
> Signed-off-by: Brian Norris <computersforpeace at gmail.com>
> ---
> drivers/mtd/spi-nor/spi-nor.c | 30 ++++++++++++++++++++++++++----
> include/linux/mtd/spi-nor.h | 3 ++-
> 2 files changed, 28 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
> index 49883905a434..58a435372be7 100644
> --- a/drivers/mtd/spi-nor/spi-nor.c
> +++ b/drivers/mtd/spi-nor/spi-nor.c
> @@ -313,6 +313,29 @@ static void spi_nor_unlock_and_unprep(struct spi_nor *nor, enum spi_nor_ops ops)
> }
>
> /*
> + * Initiate the erasure of a single sector
> + */
> +static int spi_nor_erase_sector(struct spi_nor *nor, u32 addr)
> +{
> + u8 buf[nor->addr_width];
Hmm, I see some warnings about variable length arrays here. Probably
better to just set a MAX macro with the value of 4, since the extra byte
really doesn't matter that much.
I'll send v2.
Brian
More information about the linux-mtd
mailing list