[PATCH/RFC] remove len/ooblen confusion in MTD/NAND code: respin

Artem Bityutskiy dedekind at infradead.org
Fri Nov 3 04:16:17 EST 2006


On Thu, 2006-11-02 at 10:06 +0300, Vitaly Wool wrote:
> Hello folks,

snip

> ===================================================================
> --- linux-2.6.orig/drivers/mtd/mtdconcat.c
> +++ linux-2.6/drivers/mtd/mtdconcat.c
> @@ -278,14 +278,14 @@ concat_read_oob(struct mtd_info *mtd, lo
>  				return err;
>  		}
>  
> -		devops.len = ops->len - ops->retlen;
> -		if (!devops.len)
> +		devops.ooblen = ops->ooblen - ops->retlen;
> +		if (!devops.ooblen)
>  			return ret;

May you please explain this code. If ops->databuf != NULL,
mtd->read_oob() stores the number of read _data_ bytes. Then we
substract number of _data_ bytes from number of _OOB_ bytes
(devops.ooblen)? Looks confusing.

'struct mtd_oob_ops' is still a bit confusing. This is how it looks
after your patch:


/**
 * struct mtd_oob_ops - oob operation operands
 * @mode:       operation mode
 *
 * @len:        number of data bytes to write/read
 *
 * @retlen:     number of bytes written/read. When a data buffer is
given
 *              (datbuf != NULL) this is the number of data bytes. When
 *              no data buffer is available this is the number of oob
bytes.
 *
 * @ooblen:     number of oob bytes to write/read
 * @ooboffs:    offset of oob data in the oob area (only relevant when
 *              mode = MTD_OOB_PLACE)
 * @datbuf:     data buffer - if NULL only oob data are read/written
 * @oobbuf:     oob data buffer
 */

struct mtd_oob_ops {
        mtd_oob_mode_t  mode;
        size_t          len;
        size_t          retlen;
        size_t          ooblen;
        uint32_t        ooboffs;
        uint8_t         *datbuf;
        uint8_t         *oobbuf;
};

The fact that retlen depends on whether datbuf is NULL is not nice. I
would prefer go further and make it like this:

/**
 * struct mtd_oob_ops - OOB operation operands
 * @mode:       operation mode
 * @len:        number of data bytes to write/read
 * @ooblen:     number of OOB bytes to write/read
 * @retlen:     number of data bytes written/read
 * @oobretlen:  number of OOB bytes written/read
 * @ooboffs:    offset of OOB data in the OOB area (only relevant when
 *              mode = MTD_OOB_PLACE)
 * @datbuf:     data buffer - if NULL only OOB data are read/written
 * @oobbuf:     OOB data buffer - cnnot not be NULL
 */
struct mtd_oob_ops {
        mtd_oob_mode_t  mode;
        size_t          len;
        size_t          ooblen;
        size_t          retlen;
        size_t          oobretlen;
        uint32_t        ooboffs;
        uint8_t         *datbuf;
        uint8_t         *oobbuf;
};

If we say "A" why not to say "B"?

Comments?

-- 
Best regards,
Artem Bityutskiy (Битюцкий Артём)





More information about the linux-mtd mailing list