From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gabbasov, Andrew Date: Wed, 8 May 2013 17:38:39 +0000 Subject: [U-Boot] [PATCH] ARM: cfi_flash: Fix unaligned accesses to cfi_qry structure In-Reply-To: <201305081926.01516.marex@denx.de> References: <1367228070-6351-1-git-send-email-andrew_gabbasov@mentor.com>, <201305081926.01516.marex@denx.de> Message-ID: <6C5EA58090A5ED459815C4D04C2B466FD932EEF6@EU-MBX-01.mgc.mentorg.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Marek, > From: Marek Vasut [marex at denx.de] > Sent: Wednesday, May 08, 2013 21:26 > To: u-boot at lists.denx.de > Cc: Gabbasov, Andrew; Tom Rini; Albert Aribaud > Subject: Re: [U-Boot] [PATCH] ARM: cfi_flash: Fix unaligned accesses to cfi_qry structure > > Dear Andrew Gabbasov, > > > Packed structure cfi_qry contains unaligned 16- and 32-bits members, > > accessing which causes problems when cfi_flash driver is compiled with > > -munaligned-access option: flash initialization hangs, probably > > due to data error. > > > > This fix converts 16- and 32-bit members to byte arrays and uses special > > macros to access such fields. It removes possible unaligned accesses > > in cfi_flash driver. > > > > Signed-off-by: Andrew Gabbasov > > It seems OK. I just wonder if the le16_to_cpu you removed can have no impact now > on obscure-endian architectures, that's my only concern. > > Best regards, > Marek Vasut Thank you for your feedback. Using le16_to_cpu macros assumed that the data, read from flash, are always in little-endian order, that is the LSB byte comes first in those 2-bytes unaligned fields. This is exactly how the data is read by new macros. So, it looks like new macros should work on any host endianness. Thanks. Best regards, Andrew