Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

macintosh/adb-iop: Use big-endian autopoll mask

As usual, the available documentation is inadequate and leaves endianness
unspecified for message data. However, testing shows that this patch does
improve correctness. The mistake should have been detected earlier but it
was obscured by other bugs. In testing, this patch reinstated pre-v5.9
behaviour. The old driver bugs remain and ADB input devices may stop
working. But that appears to be unrelated.

Cc: Joshua Thompson <funaho@jurai.org>
Fixes: c66da95a39ec ("macintosh/adb-iop: Implement SRQ autopolling")
Tested-by: Stan Johnson <userm57@yahoo.com>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Link: https://lore.kernel.org/r/20210125074524.3027452-1-geert@linux-m68k.org

authored by

Finn Thain and committed by
Geert Uytterhoeven
c396dd2e ab5cbfc2

+3 -3
+3 -3
drivers/macintosh/adb-iop.c
··· 19 19 #include <asm/macints.h> 20 20 #include <asm/mac_iop.h> 21 21 #include <asm/adb_iop.h> 22 + #include <asm/unaligned.h> 22 23 23 24 #include <linux/adb.h> 24 25 ··· 250 249 { 251 250 struct adb_iopmsg *amsg = (struct adb_iopmsg *)msg->message; 252 251 253 - autopoll_devs = (amsg->data[1] << 8) | amsg->data[0]; 252 + autopoll_devs = get_unaligned_be16(amsg->data); 254 253 if (autopoll_devs & (1 << autopoll_addr)) 255 254 return; 256 255 autopoll_addr = autopoll_devs ? (ffs(autopoll_devs) - 1) : 0; ··· 267 266 amsg.flags = ADB_IOP_SET_AUTOPOLL | (mask ? ADB_IOP_AUTOPOLL : 0); 268 267 amsg.count = 2; 269 268 amsg.cmd = 0; 270 - amsg.data[0] = mask & 0xFF; 271 - amsg.data[1] = (mask >> 8) & 0xFF; 269 + put_unaligned_be16(mask, amsg.data); 272 270 273 271 iop_send_message(ADB_IOP, ADB_CHAN, NULL, sizeof(amsg), (__u8 *)&amsg, 274 272 adb_iop_set_ap_complete);