All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jagan Teki <jagannadh.teki@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] sf: Fix to compute proper sector_size
Date: Wed, 22 Apr 2015 18:34:38 +0530	[thread overview]
Message-ID: <CAD6G_RSTCHR6WdTP882z3SZ-Xxfrep=_Qg=07rZsQ_eQQi9zMQ@mail.gmail.com> (raw)
In-Reply-To: <1429696794-8686-1-git-send-email-jagannadh.teki@gmail.com>

Some catches on this!

On 22 April 2015 at 15:29, Jagannadha Sutradharudu Teki
<jagannadh.teki@gmail.com> wrote:
> Upto now flash sector_size is assigned from params which isn't
> necessarily a sector size from vendor, so based on the SECT_*
> flags from flash_params the erase_size will compute and it will
> become the sector_size finally.
>
> Signed-off-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
> Reported-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>  drivers/mtd/spi/sf_internal.h |  3 ++-
>  drivers/mtd/spi/sf_probe.c    | 10 +++++++---
>  2 files changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h
> index d273d30..6c73992 100644
> --- a/drivers/mtd/spi/sf_internal.h
> +++ b/drivers/mtd/spi/sf_internal.h
> @@ -123,7 +123,8 @@ int sst_write_bp(struct spi_flash *flash, u32 offset, size_t len,
>   * @name:              Device name ([MANUFLETTER][DEVTYPE][DENSITY][EXTRAINFO])
>   * @jedec:             Device jedec ID (0x[1byte_manuf_id][2byte_dev_id])
>   * @ext_jedec:         Device ext_jedec ID
> - * @sector_size:       Sector size of this device
> + * @sector_size:       Isn't necessarily a sector size from vendor, the size here
> + *                     is what works with Sector erase (64KB)
>   * @nr_sectors:                No.of sectors on this device
>   * @e_rd_cmd:          Enum list for read commands
>   * @flags:             Important param, for flash specific behaviour
> diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
> index d19138d..68ec583 100644
> --- a/drivers/mtd/spi/sf_probe.c
> +++ b/drivers/mtd/spi/sf_probe.c
> @@ -165,8 +165,9 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,
>                 flash->page_size = 256;
>         }
>         flash->page_size <<= flash->shift;
> -       flash->sector_size = params->sector_size << flash->shift;
> -       flash->size = flash->sector_size * params->nr_sectors << flash->shift;
> +       params->nr_sectors <<= flash->shift;
> +       params->sector_size <<= flash->shift;

These are read-only object.

> +       flash->size = params->sector_size * params->nr_sectors;
>  #ifdef CONFIG_SF_DUAL_FLASH
>         if (flash->dual_flash & SF_DUAL_STACKED_FLASH)
>                 flash->size <<= 1;
> @@ -181,9 +182,12 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,
>                 flash->erase_size = 32768 << flash->shift;
>         } else {
>                 flash->erase_cmd = CMD_ERASE_64K;
> -               flash->erase_size = flash->sector_size;
> +               flash->erase_size = info->sector_size;

Typo it should params->

>         }
>
> +       /* Now erase size becomes valid sector size */
> +       flash->sector_size = flash->erase_size;
> +
>         /* Look for the fastest read cmd */
>         cmd = fls(params->e_rd_cmd & flash->spi->op_mode_rx);
>         if (cmd) {
> --
> 1.9.1
>

Will update on next version.

thanks!
-- 
Jagan.

      reply	other threads:[~2015-04-22 13:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-22  9:59 [U-Boot] sf: Fix to compute proper sector_size Jagannadha Sutradharudu Teki
2015-04-22 13:04 ` Jagan Teki [this message]

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='CAD6G_RSTCHR6WdTP882z3SZ-Xxfrep=_Qg=07rZsQ_eQQi9zMQ@mail.gmail.com' \
    --to=jagannadh.teki@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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.