OneNAND: handle byte access on BufferRAM

Jörn Engel joern at wohnheim.fh-wedel.de
Fri May 12 13:30:48 EDT 2006


On Fri, 12 May 2006 16:59:03 +0100, Linux-MTD Mailing List wrote:
> 
> @@ -373,6 +373,17 @@ static int onenand_read_bufferram(struct
>  
>  	bufferram += onenand_bufferram_offset(mtd, area);
>  
> +	if (ONENAND_CHECK_BYTE_ACCESS(count)) {
> +		unsigned short word;
> +
> +		/* Align with word(16-bit) size */
> +		count--;
> +
> +		/* Read word and save byte */
> +		word = this->read_word(bufferram + offset + count);
> +		buffer[count] = (word & 0xff);
> +	}
> +
>  	memcpy(buffer, bufferram + offset, count);
>  
>  	return 0;
> @@ -400,6 +411,17 @@ static int onenand_sync_read_bufferram(s
>  
>  	this->mmcontrol(mtd, ONENAND_SYS_CFG1_SYNC_READ);
>  
> +	if (ONENAND_CHECK_BYTE_ACCESS(count)) {
> +		unsigned short word;
> +
> +		/* Align with word(16-bit) size */
> +		count--;
> +
> +		/* Read word and save byte */
> +		word = this->read_word(bufferram + offset + count);
> +		buffer[count] = (word & 0xff);
> +	}
> +
>  	memcpy(buffer, bufferram + offset, count);
>  
>  	this->mmcontrol(mtd, 0);

Duplicated code

> +/* Check byte access in OneNAND */
> +#define ONENAND_CHECK_BYTE_ACCESS(addr)		(addr & 0x1)

ONENAND_IS_BYTE_ACCESS ?

Also, this looks as if you check for unaligned access at the end of
the buffer, but not at the beginning.  Am I missing something or are
you?

Jörn

-- 
"[One] doesn't need to know [...] how to cause a headache in order
to take an aspirin."
-- Scott Culp, Manager of the Microsoft Security Response Center, 2001




More information about the linux-mtd mailing list