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 4/7] staging: comedi: amplc_pc236: combine interrupt enable/disable functions
Date: Mon, 28 Jul 2014 13:09:32 +0100 [thread overview]
Message-ID: <1406549375-1864-5-git-send-email-abbotti@mev.co.uk> (raw)
In-Reply-To: <1406549375-1864-1-git-send-email-abbotti@mev.co.uk>
`pc236_intr_enable()` and `pc236_intr_disable()` are very similar.
Combine them into a single function `pc236_intr_update()` with a
parameter to indicate whether interrupts are being enabled or disabled.
Change type type of the `enable_irq` member of the private data to
`bool` to match the parameter.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
---
drivers/staging/comedi/drivers/amplc_pc236.c | 37 ++++++----------------------
1 file changed, 7 insertions(+), 30 deletions(-)
diff --git a/drivers/staging/comedi/drivers/amplc_pc236.c b/drivers/staging/comedi/drivers/amplc_pc236.c
index 7b78d57..c69aa2d 100644
--- a/drivers/staging/comedi/drivers/amplc_pc236.c
+++ b/drivers/staging/comedi/drivers/amplc_pc236.c
@@ -87,7 +87,7 @@ struct pc236_board {
struct pc236_private {
unsigned long lcr_iobase; /* PLX PCI9052 config registers in PCIBAR1 */
- int enable_irq;
+ bool enable_irq;
};
/* test if ISA supported and this is an ISA board */
@@ -102,39 +102,16 @@ static inline bool is_pci_board(const struct pc236_board *board)
return DO_PCI && board->bustype == pci_bustype;
}
-/*
- * This function is called to mark the interrupt as disabled (no command
- * configured on subdevice 1) and to physically disable the interrupt
- * (not possible on the PC36AT, except by removing the IRQ jumper!).
- */
-static void pc236_intr_disable(struct comedi_device *dev)
-{
- const struct pc236_board *thisboard = comedi_board(dev);
- struct pc236_private *devpriv = dev->private;
- unsigned long flags;
-
- spin_lock_irqsave(&dev->spinlock, flags);
- devpriv->enable_irq = 0;
- if (thisboard->intr_update_cb)
- thisboard->intr_update_cb(dev, false);
- spin_unlock_irqrestore(&dev->spinlock, flags);
-}
-
-/*
- * This function is called to mark the interrupt as enabled (a command
- * configured on subdevice 1) and to physically enable the interrupt
- * (not possible on the PC36AT, except by (re)connecting the IRQ jumper!).
- */
-static void pc236_intr_enable(struct comedi_device *dev)
+static void pc236_intr_update(struct comedi_device *dev, bool enable)
{
const struct pc236_board *thisboard = comedi_board(dev);
struct pc236_private *devpriv = dev->private;
unsigned long flags;
spin_lock_irqsave(&dev->spinlock, flags);
- devpriv->enable_irq = 1;
+ devpriv->enable_irq = enable;
if (thisboard->intr_update_cb)
- thisboard->intr_update_cb(dev, true);
+ thisboard->intr_update_cb(dev, enable);
spin_unlock_irqrestore(&dev->spinlock, flags);
}
@@ -235,7 +212,7 @@ static int pc236_intr_cmdtest(struct comedi_device *dev,
*/
static int pc236_intr_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
- pc236_intr_enable(dev);
+ pc236_intr_update(dev, true);
return 0;
}
@@ -246,7 +223,7 @@ static int pc236_intr_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
static int pc236_intr_cancel(struct comedi_device *dev,
struct comedi_subdevice *s)
{
- pc236_intr_disable(dev);
+ pc236_intr_update(dev, false);
return 0;
}
@@ -291,7 +268,7 @@ static int pc236_common_attach(struct comedi_device *dev, unsigned long iobase,
s = &dev->subdevices[1];
dev->read_subdev = s;
s->type = COMEDI_SUBD_UNUSED;
- pc236_intr_disable(dev);
+ pc236_intr_update(dev, false);
if (irq) {
if (request_irq(irq, pc236_interrupt, req_irq_flags,
dev->board_name, dev) >= 0) {
--
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 ` Ian Abbott [this message]
2014-07-28 12:09 ` [PATCH 5/7] staging: comedi: amplc_pc236: add callback to check and clear interrupt Ian Abbott
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-5-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®