fix big-endian platforms after 6733401935
The NVMe byte-swap routines for big-endian platforms used memcpy() to move the unaligned 64-bit value into a temp register to byte swap it. Instead of introducing a dependency, manually byte-swap the values in place. Point hat: me
This commit is contained in:
parent
a82f07fc2e
commit
e83fdf8bb3
@ -2042,16 +2042,20 @@ static inline void
|
|||||||
nvme_device_self_test_swapbytes(struct nvme_device_self_test_page *s __unused)
|
nvme_device_self_test_swapbytes(struct nvme_device_self_test_page *s __unused)
|
||||||
{
|
{
|
||||||
#if _BYTE_ORDER != _LITTLE_ENDIAN
|
#if _BYTE_ORDER != _LITTLE_ENDIAN
|
||||||
uint64_t failing_lba;
|
uint8_t *tmp;
|
||||||
uint32_t r;
|
uint32_t r, i;
|
||||||
|
uint8_t b;
|
||||||
|
|
||||||
for (r = 0; r < 20; r++) {
|
for (r = 0; r < 20; r++) {
|
||||||
s->result[r].poh = le64toh(s->result[r].poh);
|
s->result[r].poh = le64toh(s->result[r].poh);
|
||||||
s->result[r].nsid = le32toh(s->result[r].nsid);
|
s->result[r].nsid = le32toh(s->result[r].nsid);
|
||||||
/* Unaligned 64-bit loads fail on some architectures */
|
/* Unaligned 64-bit loads fail on some architectures */
|
||||||
memcpy(&failing_lba, s->result[r].failing_lba, sizeof(failing_lba));
|
tmp = s->result[r].failing_lba;
|
||||||
failing_lba = le64toh(failing_lba);
|
for (i = 0; i < 4; i++) {
|
||||||
memcpy(s->result[r].failing_lba, &failing_lba, sizeof(failing_lba));
|
b = tmp[i];
|
||||||
|
tmp[i] = tmp[7-i];
|
||||||
|
tmp[7-i] = b;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user