[PATCH 4/5] Unpack (align) and decode (endian) the values in the onfi_params struct.

Ian Lepore ian at FreeBSD.org
Fri Nov 15 17:04:42 UTC 2013


On Wed, 2013-11-13 at 23:32 +0100, kristof at sigsegv.be wrote:
> From: Kristof Provost <kristof at 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






More information about the freebsd-embedded mailing list