Skip to content

Commit aaeaef0

Browse files
LoveKarlssonmmahadevan108
authored andcommitted
drivers: flash: Removed a __packed attribute from struct jesd216_bfp
The struct jesd216_bfp was declared as __packed but later in the code the address of a member was given to a non-packed pointer, potentially causing reading of wrong addresses, and causing warnings with the IAR ICCARM compiler. After studying the JEDEC documentation JESD216F.02, section 6.4.2 JEDEC Basic Flash Parameter Header: 2nd DWORD, the struct must be aligned to 4 so __packed is not necessary, just 4 byte alignment. Signed-off-by: Lars-Ove Karlsson <[email protected]>
1 parent a5555ab commit aaeaef0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/flash/jesd216.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ static inline uint32_t jesd216_sfdp_magic(const struct jesd216_sfdp_header *hp)
129129
* the standard. Rather than pre-define layouts to access to all
130130
* potential fields this header provides functions for specific fields
131131
* known to be important, such as density and erase command support.
132+
*
133+
* Must be aligned to a DWORD (32-bit) address according to JESD216F.
132134
*/
133135
struct jesd216_bfp {
134136
uint32_t dw1;
@@ -141,7 +143,7 @@ struct jesd216_bfp {
141143
uint32_t dw8;
142144
uint32_t dw9;
143145
uint32_t dw10[];
144-
} __packed;
146+
} __aligned(4);
145147

146148
/* Provide a few word-specific flags and bitfield ranges for values
147149
* that an application or driver might expect to want to extract.

0 commit comments

Comments
 (0)