[PATCH] Simplify write buffer size calculation by using mtd->writebufsize.
Artem Bityutskiy
dedekind1 at gmail.com
Fri Feb 11 10:55:07 EST 2011
On Fri, 2011-02-11 at 16:53 +0100, Guillaume LECERF wrote:
> This patch applies on top of "[PATCH 2/2] mtd: cfi: fix writebufsize initialization" by Anatolij Gustschin <agust at denx.de>.
>
>
> Signed-off-by: Guillaume LECERF <glecerf at gmail.com>
> ---
> drivers/mtd/chips/cfi_cmdset_0001.c | 13 ++++++-------
> drivers/mtd/chips/cfi_cmdset_0002.c | 3 +--
> drivers/mtd/chips/cfi_cmdset_0020.c | 16 ++++++++--------
> 3 files changed, 15 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
> index 178f87b..7d6a752 100644
> --- a/drivers/mtd/chips/cfi_cmdset_0001.c
> +++ b/drivers/mtd/chips/cfi_cmdset_0001.c
> @@ -1643,23 +1643,23 @@ static int cfi_intelext_write_words (struct mtd_info *mtd, loff_t to , size_t le
> }
>
>
> -static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
> +static int __xipram do_write_buffer(struct mtd_info *mtd, struct flchip *chip,
> unsigned long adr, const struct kvec **pvec,
> unsigned long *pvec_seek, int len)
> {
> + struct map_info *map = mtd->priv;
> struct cfi_private *cfi = map->fldrv_priv;
> map_word status, write_cmd, datum;
> unsigned long cmd_adr;
> - int ret, wbufsize, word_gap, words;
> + int ret, word_gap, words;
> const struct kvec *vec;
> unsigned long vec_seek;
> unsigned long initial_adr;
> int initial_len = len;
>
> - wbufsize = cfi_interleave(cfi) << cfi->cfiq->MaxBufWriteSize;
> adr += chip->start;
> initial_adr = adr;
> - cmd_adr = adr & ~(wbufsize-1);
> + cmd_adr = adr & ~(mtd->writebufsize - 1);
It feels like bad layering when drivers use fields like
'mtd->writesize'. I know we do this all over the place, but I think
drivers should not really rely on the contents of the "mtd->" object and
has all the needed data in private objects.
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
More information about the linux-mtd
mailing list