Skip to content

Commit ac0bbf5

Browse files
ian-abbottgregkh
authored andcommitted
staging: comedi: addi_apci_1500: Fix endian problem for command sample
The digital input subdevice supports Comedi asynchronous commands that read interrupt status information. This uses 16-bit Comedi samples (of which only the bottom 8 bits contain status information). However, the interrupt handler is calling `comedi_buf_write_samples()` with the address of a 32-bit variable `unsigned int status`. On a bigendian machine, this will copy 2 bytes from the wrong end of the variable. Fix it by changing the type of the variable to `unsigned short`. Fixes: a8c66b6 ("staging: comedi: addi_apci_1500: rewrite the subdevice support functions") Cc: <[email protected]> #4.0+ Signed-off-by: Ian Abbott <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 25317f4 commit ac0bbf5

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

drivers/staging/comedi/drivers/addi_apci_1500.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ static irqreturn_t apci1500_interrupt(int irq, void *d)
208208
struct comedi_device *dev = d;
209209
struct apci1500_private *devpriv = dev->private;
210210
struct comedi_subdevice *s = dev->read_subdev;
211-
unsigned int status = 0;
211+
unsigned short status = 0;
212212
unsigned int val;
213213

214214
val = inl(devpriv->amcc + AMCC_OP_REG_INTCSR);
@@ -238,14 +238,14 @@ static irqreturn_t apci1500_interrupt(int irq, void *d)
238238
*
239239
* Mask Meaning
240240
* ---------- ------------------------------------------
241-
* 0x00000001 Event 1 has occurred
242-
* 0x00000010 Event 2 has occurred
243-
* 0x00000100 Counter/timer 1 has run down (not implemented)
244-
* 0x00001000 Counter/timer 2 has run down (not implemented)
245-
* 0x00010000 Counter 3 has run down (not implemented)
246-
* 0x00100000 Watchdog has run down (not implemented)
247-
* 0x01000000 Voltage error
248-
* 0x10000000 Short-circuit error
241+
* 0b00000001 Event 1 has occurred
242+
* 0b00000010 Event 2 has occurred
243+
* 0b00000100 Counter/timer 1 has run down (not implemented)
244+
* 0b00001000 Counter/timer 2 has run down (not implemented)
245+
* 0b00010000 Counter 3 has run down (not implemented)
246+
* 0b00100000 Watchdog has run down (not implemented)
247+
* 0b01000000 Voltage error
248+
* 0b10000000 Short-circuit error
249249
*/
250250
comedi_buf_write_samples(s, &status, 1);
251251
comedi_handle_events(dev, s);

0 commit comments

Comments
 (0)