Skip to content

Commit b03a877

Browse files
committed
dcd/musb: fix unaligned cast
Signed-off-by: HiFiPhile <admin@hifiphile.com>
1 parent 71ed9d1 commit b03a877

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/portable/mentor/musb/dcd_musb.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@
3232
#define MUSB_DEBUG 2
3333
#define MUSB_REGS(rhport) ((musb_regs_t*) MUSB_BASES[rhport])
3434

35-
#if __GNUC__ > 8 && defined(__ARM_FEATURE_UNALIGNED)
36-
/* GCC warns that an address may be unaligned, even though
37-
* the target CPU has the capability for unaligned memory access. */
38-
_Pragma("GCC diagnostic ignored \"-Waddress-of-packed-member\"");
39-
#endif
40-
4135
#include "musb_type.h"
4236
#include "device/dcd.h"
4337

@@ -73,7 +67,10 @@ typedef struct TU_ATTR_PACKED
7367

7468
typedef struct
7569
{
76-
tusb_control_request_t setup_packet;
70+
union {
71+
tusb_control_request_t setup_packet;
72+
uint32_t setup_buffer[2];
73+
};
7774
uint16_t remaining_ctrl; /* The number of bytes remaining in data stage of control transfer. */
7875
int8_t status_out;
7976
pipe_state_t pipe0;
@@ -174,9 +171,8 @@ static void process_setup_packet(uint8_t rhport) {
174171
musb_regs_t* musb_regs = MUSB_REGS(rhport);
175172

176173
// Read setup packet
177-
uint32_t *p = (void*)&_dcd.setup_packet;
178-
p[0] = musb_regs->fifo[0];
179-
p[1] = musb_regs->fifo[0];
174+
_dcd.setup_buffer[0] = musb_regs->fifo[0];
175+
_dcd.setup_buffer[1] = musb_regs->fifo[0];
180176

181177
_dcd.pipe0.buf = NULL;
182178
_dcd.pipe0.length = 0;

0 commit comments

Comments
 (0)