driverdev-devel.linuxdriverproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Abbott <abbotti@mev.co.uk>
To: devel@driverdev.osuosl.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Ian Abbott <abbotti@mev.co.uk>
Subject: [PATCH 13/14] staging: comedi: ni_65xx: Use 16-bit 0 for interrupt data
Date: Tue, 23 Feb 2021 14:30:54 +0000	[thread overview]
Message-ID: <20210223143055.257402-14-abbotti@mev.co.uk> (raw)
In-Reply-To: <20210223143055.257402-1-abbotti@mev.co.uk>

The ni_65xx driver has an "interrupt" subdevice that supports Comedi
asynchronous commands, placing a value in the Comedi buffer for each
interrupt.  The subdevice uses Comedi's 16-bit sample format but the
interrupt handler is calling `comedi_buf_write_samples()` with the
address of a 32-bit integer `&s->state`.  On bigendian machines, this
will copy 2 bytes from the wrong end of the 32-bit integer.  This isn't
really a problem since `s->state` will always be 0 for this subdevice,
but clean it up by using a 16-bit variable initialized to 0 to pass the
value.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
---
 drivers/staging/comedi/drivers/ni_65xx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/staging/comedi/drivers/ni_65xx.c
index eb3f9f7109da..7cd8497420f2 100644
--- a/drivers/staging/comedi/drivers/ni_65xx.c
+++ b/drivers/staging/comedi/drivers/ni_65xx.c
@@ -472,6 +472,7 @@ static irqreturn_t ni_65xx_interrupt(int irq, void *d)
 	struct comedi_device *dev = d;
 	struct comedi_subdevice *s = dev->read_subdev;
 	unsigned int status;
+	unsigned short val = 0;
 
 	status = readb(dev->mmio + NI_65XX_STATUS_REG);
 	if ((status & NI_65XX_STATUS_INT) == 0)
@@ -482,7 +483,7 @@ static irqreturn_t ni_65xx_interrupt(int irq, void *d)
 	writeb(NI_65XX_CLR_EDGE_INT | NI_65XX_CLR_OVERFLOW_INT,
 	       dev->mmio + NI_65XX_CLR_REG);
 
-	comedi_buf_write_samples(s, &s->state, 1);
+	comedi_buf_write_samples(s, &val, 1);
 	comedi_handle_events(dev, s);
 
 	return IRQ_HANDLED;
-- 
2.30.0

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

  parent reply	other threads:[~2021-02-23 14:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-23 14:30 [PATCH 00/14] staging: comedi: Fix some command data endian problems Ian Abbott
2021-02-23 14:30 ` [PATCH 01/14] staging: comedi: addi_apci_1032: Fix endian problem for COS sample Ian Abbott
2021-02-23 14:30 ` [PATCH 02/14] staging: comedi: addi_apci_1500: Fix endian problem for command sample Ian Abbott
2021-02-23 14:30 ` [PATCH 03/14] staging: comedi: adv_pci1710: Fix endian problem for AI command data Ian Abbott
2021-02-23 14:30 ` [PATCH 04/14] staging: comedi: das6402: " Ian Abbott
2021-02-23 14:30 ` [PATCH 05/14] staging: comedi: das800: " Ian Abbott
2021-02-23 14:30 ` [PATCH 06/14] staging: comedi: dmm32at: " Ian Abbott
2021-02-23 14:30 ` [PATCH 07/14] staging: comedi: me4000: " Ian Abbott
2021-02-23 14:30 ` [PATCH 08/14] staging: comedi: pcl711: " Ian Abbott
2021-02-23 14:30 ` [PATCH 09/14] staging: comedi: pcl818: " Ian Abbott
2021-02-23 14:30 ` [PATCH 10/14] staging: comedi: amplc_pc236_common: Use 16-bit 0 for interrupt data Ian Abbott
2021-02-23 14:30 ` [PATCH 11/14] staging: comedi: comedi_parport: " Ian Abbott
2021-02-23 14:30 ` [PATCH 12/14] staging: comedi: ni_6527: " Ian Abbott
2021-02-23 14:30 ` Ian Abbott [this message]
2021-02-23 14:30 ` [PATCH 14/14] staging: comedi: pcl726: " Ian Abbott

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210223143055.257402-14-abbotti@mev.co.uk \
    --to=abbotti@mev.co.uk \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).