From: Ian Abbott <abbotti@mev.co.uk>
To: driverdev-devel@linuxdriverproject.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Ian Abbott <abbotti@mev.co.uk>,
H Hartley Sweeten <hartleys@visionengravers.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 5/7] staging: comedi: amplc_pc236: add callback to check and clear interrupt
Date: Mon, 28 Jul 2014 13:09:33 +0100 [thread overview]
Message-ID: <1406549375-1864-6-git-send-email-abbotti@mev.co.uk> (raw)
In-Reply-To: <1406549375-1864-1-git-send-email-abbotti@mev.co.uk>
Add an optional callback function pointer to the board data to be called
when checking if an interrupt has occurred and to clear it if it has.
Since the callback returns `bool`, change a few other `int` values to
`bool` to match.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
---
drivers/staging/comedi/drivers/amplc_pc236.c | 40 +++++++++++++++++-----------
1 file changed, 24 insertions(+), 16 deletions(-)
diff --git a/drivers/staging/comedi/drivers/amplc_pc236.c b/drivers/staging/comedi/drivers/amplc_pc236.c
index c69aa2d..677911b 100644
--- a/drivers/staging/comedi/drivers/amplc_pc236.c
+++ b/drivers/staging/comedi/drivers/amplc_pc236.c
@@ -83,6 +83,7 @@ struct pc236_board {
const char *name;
enum pc236_bustype bustype;
void (*intr_update_cb)(struct comedi_device *dev, bool enable);
+ bool (*intr_chk_clr_cb)(struct comedi_device *dev);
};
struct pc236_private {
@@ -120,29 +121,21 @@ static void pc236_intr_update(struct comedi_device *dev, bool enable)
* the interrupt has been marked as enabled and was generated by the
* board. If so, the function prepares the hardware for the next
* interrupt.
- * Returns 0 if the interrupt should be ignored.
+ * Returns false if the interrupt should be ignored.
*/
-static int pc236_intr_check(struct comedi_device *dev)
+static bool pc236_intr_check(struct comedi_device *dev)
{
const struct pc236_board *thisboard = comedi_board(dev);
struct pc236_private *devpriv = dev->private;
- int retval = 0;
+ bool retval = false;
unsigned long flags;
- unsigned int intcsr;
spin_lock_irqsave(&dev->spinlock, flags);
if (devpriv->enable_irq) {
- retval = 1;
- if (is_pci_board(thisboard)) {
- intcsr = inl(devpriv->lcr_iobase + PLX9052_INTCSR);
- if (!(intcsr & PLX9052_INTCSR_LI1STAT)) {
- retval = 0;
- } else {
- /* Clear interrupt and keep it enabled. */
- outl(PCI236_INTR_ENABLE,
- devpriv->lcr_iobase + PLX9052_INTCSR);
- }
- }
+ if (thisboard->intr_chk_clr_cb)
+ retval = thisboard->intr_chk_clr_cb(dev);
+ else
+ retval = true;
}
spin_unlock_irqrestore(&dev->spinlock, flags);
@@ -236,7 +229,7 @@ static irqreturn_t pc236_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
struct comedi_subdevice *s = dev->read_subdev;
- int handled;
+ bool handled;
handled = pc236_intr_check(dev);
if (dev->attached && handled) {
@@ -312,13 +305,28 @@ static void pci236_intr_update_cb(struct comedi_device *dev, bool enable)
{
struct pc236_private *devpriv = dev->private;
+ /* this will also clear the "local interrupt 1" latch */
outl(enable ? PCI236_INTR_ENABLE : PCI236_INTR_DISABLE,
devpriv->lcr_iobase + PLX9052_INTCSR);
}
+static bool pci236_intr_chk_clr_cb(struct comedi_device *dev)
+{
+ struct pc236_private *devpriv = dev->private;
+
+ /* check if interrupt occurred */
+ if (!(inl(devpriv->lcr_iobase + PLX9052_INTCSR) &
+ PLX9052_INTCSR_LI1STAT))
+ return false;
+ /* clear the interrupt */
+ pci236_intr_update_cb(dev, devpriv->enable_irq);
+ return true;
+}
+
static const struct pc236_board pc236_pci_board = {
.name = "pci236",
.intr_update_cb = pci236_intr_update_cb,
+ .intr_chk_clr_cb = pci236_intr_chk_clr_cb,
.bustype = pci_bustype,
};
--
2.0.0
next prev parent reply other threads:[~2014-07-28 12:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-28 12:09 [PATCH 0/7] staging: comedi: amplc_pc236: split into separate ISA and PCI drivers Ian Abbott
2014-07-28 12:09 ` [PATCH 1/7] staging: comedi: amplc_pc236: move static board data Ian Abbott
2014-07-28 12:09 ` [PATCH 2/7] staging: comedi: amplc_pc236: don't disable h/w interrupt on detach() Ian Abbott
2014-07-28 12:09 ` [PATCH 3/7] staging: comedi: amplc_pc236: add callback to enable/disable interrupt Ian Abbott
2014-07-28 12:09 ` [PATCH 4/7] staging: comedi: amplc_pc236: combine interrupt enable/disable functions Ian Abbott
2014-07-28 12:09 ` Ian Abbott [this message]
2014-07-28 12:09 ` [PATCH 6/7] staging: comedi: amplc_pc236: split into ISA, PCI and common module Ian Abbott
2014-07-28 12:09 ` [PATCH 7/7] staging: comedi: amplc_pc236, amplc_pci236: get rid of bustype 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=1406549375-1864-6-git-send-email-abbotti@mev.co.uk \
--to=abbotti@mev.co.uk \
--cc=driverdev-devel@linuxdriverproject.org \
--cc=gregkh@linuxfoundation.org \
--cc=hartleys@visionengravers.com \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®