Date: Fri, 15 Nov 2013 10:04:31 -0700 From: Ian Lepore <ian@FreeBSD.org> To: kristof@sigsegv.be Cc: Grzegorz Bernacki <gber@FreeBSD.org>, freebsd-embedded@FreeBSD.org Subject: Re: [PATCH 4/5] Unpack (align) and decode (endian) the values in the onfi_params struct. Message-ID: <1384535071.31172.381.camel@revolution.hippie.lan> In-Reply-To: <1384381960-98851-5-git-send-email-kristof@sigsegv.be> References: <1383782353.31172.183.camel@revolution.hippie.lan> <1384381960-98851-1-git-send-email-kristof@sigsegv.be> <1384381960-98851-5-git-send-email-kristof@sigsegv.be>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 2013-11-13 at 23:32 +0100, kristof@sigsegv.be wrote: > From: Kristof Provost <kristof@sigsegv.be> > > ONFI parameters are little-endian, hence we must take care to convert them to > native endianness. We must also pay attention to unalligned accesses. > > Copy the interesting parameters to a new struct so the rest of the code can > forget about these problems. > --- > sys/dev/nand/nand.c | 2 +- > sys/dev/nand/nand.h | 16 +++++++++++++- > sys/dev/nand/nand_generic.c | 51 +++++++++++++++++++++++++++---------------- > 3 files changed, 48 insertions(+), 21 deletions(-) > > diff --git a/sys/dev/nand/nand.c b/sys/dev/nand/nand.c > index f46d0f0..902ff79 100644 > --- a/sys/dev/nand/nand.c > +++ b/sys/dev/nand/nand.c > @@ -115,7 +115,7 @@ nand_init(struct nand_softc *nand, device_t dev, int ecc_mode, > } > > void > -nand_onfi_set_params(struct nand_chip *chip, struct onfi_params *params) > +nand_onfi_set_params(struct nand_chip *chip, struct onfi_chip_params *params) > { > struct chip_geom *cg; > > diff --git a/sys/dev/nand/nand.h b/sys/dev/nand/nand.h > index d9bfad7..4fbe75c 100644 > --- a/sys/dev/nand/nand.h > +++ b/sys/dev/nand/nand.h > @@ -235,6 +235,20 @@ struct onfi_params { > }__attribute__((packed)); > CTASSERT(sizeof(struct onfi_params) == 256); > > +struct onfi_chip_params { > + uint8_t luns; > + uint32_t blocks_per_lun; > + uint32_t pages_per_block; > + uint32_t bytes_per_page; > + uint32_t spare_bytes_per_page; > + uint16_t t_bers; > + uint16_t t_prog; > + uint16_t t_r; > + uint16_t t_ccs; > + uint16_t features; > + uint8_t address_cycles; > +}; Sorry for the delay on this, I finally got around to looking at these today. The only comment I have on the 5 patches is that if the 'luns' field of the new onfi_chip_params struct were moved to the end, the struct would be ideally packed with no unused padding on architectures where alignment counts. -- Ian
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1384535071.31172.381.camel>