[PATCH] [MTD] Make ecclayout static const

Adrian Hunter ext-adrian.hunter at nokia.com
Mon Feb 19 08:08:17 EST 2007


ext Kyungmin Park wrote:
> @@ -827,13 +829,15 @@ static int onenand_transfer_auto_oob(struct mtd_info
> *mtd, uint8_t *buf, int col
>  				int thislen)
>  {
>  	struct onenand_chip *this = mtd->priv;
>  	struct nand_oobfree *free;
>  	int readcol = column;
>  	int readend = column + thislen;
>  	int lastgap = 0;
>  	uint8_t *oob_buf = this->page_buf + mtd->writesize;
> +	int i;
>  
> -	for (free = this->ecclayout->oobfree; free->length; ++free) {
> +	free = this->ecclayout->oobfree;
> +	for (i = 0; i < ARRAY_SIZE(this->ecclayout->oobfree); i++, free++) {
>  		if (readcol >= lastgap)
>  			readcol += free->offset - lastgap;
>  		if (readend >= lastgap)
> @@ -841,7 +845,8 @@ static int onenand_transfer_auto_oob(struct mtd_info
> *mtd, uint8_t *buf, int col
>  		lastgap = free->offset + free->length;
>  	}
>  	this->read_bufferram(mtd, ONENAND_SPARERAM, oob_buf, 0, mtd-
>> oobsize);
> -	for (free = this->ecclayout->oobfree; free->length; ++free) {
> +	free = this->ecclayout->oobfree;
> +	for (i = 0; i < ARRAY_SIZE(this->ecclayout->oobfree); i++, free++) {
>  		int free_end = free->offset + free->length;
>  		if (free->offset < readend && free_end > readcol) {
>  			int st = max_t(int,free->offset,readcol);
> @@ -1270,19 +1277,22 @@ static int onenand_fill_auto_oob(struct mtd_info
> *mtd, u_char *oob_buf,
>  				  const u_char *buf, int column, int
> thislen)
>  {
>  	struct onenand_chip *this = mtd->priv;
>  	struct nand_oobfree *free;
>  	int writecol = column;
>  	int writeend = column + thislen;
>  	int lastgap = 0;
> +	int i;
>  
> -	for (free = this->ecclayout->oobfree; free->length; ++free) {
> +	free = this->ecclayout->oobfree;
> +	for (i = 0; i < ARRAY_SIZE(this->ecclayout->oobfree); i++, free++) {
>  		if (writecol >= lastgap)
>  			writecol += free->offset - lastgap;
>  		if (writeend >= lastgap)
>  			writeend += free->offset - lastgap;
>  		lastgap = free->offset + free->length;
>  	}
> -	for (free = this->ecclayout->oobfree; free->length; ++free) {
> +	free = this->ecclayout->oobfree;
> +	for (i = 0; i < ARRAY_SIZE(this->ecclayout->oobfree); i++, free++) {
>  		int free_end = free->offset + free->length;
>  		if (free->offset < writeend && free_end > writecol) {
>  			int st = max_t(int,free->offset,writecol);

Isn't this still needed?

Note you could use MTD_MAX_OOBFREE_ENTRIES instead of ARRAY_SIZE





More information about the linux-mtd mailing list