lkml.org 
[lkml]   [2020]   [Jan]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v2] mtd: nand: spi: rework detect procedure for different read id op
Hi!

On Fri, Jan 10, 2020 at 2:59 PM Boris Brezillon
<boris.brezillon@collabora.com> wrote:
> [...]
> > + ret = spinand_read_id_op(spinand, 1, 0, id);
> > + if (ret)
> > + return ret;
> > + ret = spinand_manufacturer_match(spinand,
> > + SPINAND_READID_METHOD_OPCODE_ADDR);
> > + if (!ret)
> > + return 0;
> > +
> > + ret = spinand_read_id_op(spinand, 0, 1, id);
>
> Hm, we should probably do only one of each read_id and iterate over all
> manufacturers/chips each time instead of doing 3 read_ids per
> manufacturer.

This actually do the former instead of the latter. Maybe the function
names are a bit
misleading. spinand_manufacturer_match iterates over all manufacturers
in one call,
and spinand_manufacturer_detect is called once in spinand_detect.
Do you have suggestions on function naming?

> [...]
> > + * SPINAND_READID_METHOD_OPCODE_DUMMY: chip id is returned after
> > + * read_id opcode + 1 dummy byte.
> > + */
> > +struct spinand_devid {
> > + u16 id;
>
> Can we make that field an array of u8?
>
> const u8 *id;
>
> > + u8 len;
> > + enum spinand_readid_method method;
> > +};
> [...]
> >
> > +#define SPINAND_ID(__id, __len, __method) \
> > + { \
> > + .id = __id, \
> > + .len = __len, \
> > + .method = __method, \
> > + }
>
> That one can be turned into
>
> #define SPINAND_ID(__method, ...) \
> { \
> .id = (const u8[]){ __VA_ARGS }, \
> .len = sizeof((u8[]){ __VA_ARGS }), \
> .method = __method, \
> }

Wow. I never thought of this cool trick. I'll give it a try.

Regards,
Chuanhong Guo

\
 
 \ /
  Last update: 2020-01-10 08:34    [W:0.050 / U:10.564 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site