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 28/28] staging: comedi: amplc_pci230: simplify interrupt enable handling Date: Mon, 1 Sep 2014 12:04:00 +0100 [thread overview] Message-ID: <1409569440-10979-29-git-send-email-abbotti@mev.co.uk> (raw) In-Reply-To: <1409569440-10979-1-git-send-email-abbotti@mev.co.uk> `struct pci230_private` has two members to manage the enabled interrupt sources. `int_en` is the interrupt sources we want to be enabled and `ier` is a shadow of the write-only interrupt enable register. They have the same value most of the time. They differ in the interrupt handler (`pci230_interrupt()`) itself when it temporarily clears bits in the interrupt enable register and the `ier` member in order to unlatch them in hardware, but leaves the `int_en` member alone. They also differ in `pci230_ai_stop()` and `pci230_ao_stop()` which clear bits in the `int_en` member and wait for the interrupt handler to finish before copying the value to the `ier` member and the interrupt enable register. Simplify the handling a bit, by making the `ier` member take on the role of the `int_en` member, and allowing the value to differ from the interrupt enable register while the interrupt handler is running. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> --- drivers/staging/comedi/drivers/amplc_pci230.c | 32 +++++++++------------------ 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index 7748e17..66e7a47 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -499,8 +499,7 @@ struct pci230_private { unsigned short daccon; /* DACCON register value */ unsigned short adcfifothresh; /* ADC FIFO threshold (PCI230+/260+) */ unsigned short adcg; /* ADCG register value */ - unsigned char int_en; /* Interrupt enable bits */ - unsigned char ier; /* Copy of interrupt enable register */ + unsigned char ier; /* Interrupt enable bits */ unsigned char res_owned[NUM_OWNERS]; /* Owned resources */ bool intr_running:1; /* Flag set in interrupt routine */ bool ai_bipolar:1; /* Flag AI range is bipolar */ @@ -1049,15 +1048,12 @@ static void pci230_ao_stop(struct comedi_device *dev, * unless we are called from the interrupt routine. */ spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); - devpriv->int_en &= ~intsrc; + devpriv->ier &= ~intsrc; while (devpriv->intr_running && devpriv->intr_cpuid != THISCPU) { spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); } - if (devpriv->ier != devpriv->int_en) { - devpriv->ier = devpriv->int_en; - outb(devpriv->ier, dev->iobase + PCI230_INT_SCE); - } + outb(devpriv->ier, dev->iobase + PCI230_INT_SCE); spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); if (devpriv->hwver >= 2) { /* @@ -1311,7 +1307,6 @@ static void pci230_ao_start(struct comedi_device *dev, /* Not using DAC FIFO. */ /* Enable CT1 timer interrupt. */ spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); - devpriv->int_en |= PCI230_INT_ZCLK_CT1; devpriv->ier |= PCI230_INT_ZCLK_CT1; outb(devpriv->ier, dev->iobase + PCI230_INT_SCE); spin_unlock_irqrestore(&devpriv->isr_spinlock, @@ -1327,7 +1322,6 @@ static void pci230_ao_start(struct comedi_device *dev, if (devpriv->hwver >= 2) { /* Using DAC FIFO. Enable DAC FIFO interrupt. */ spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); - devpriv->int_en |= PCI230P2_INT_DAC; devpriv->ier |= PCI230P2_INT_DAC; outb(devpriv->ier, dev->iobase + PCI230_INT_SCE); spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); @@ -1892,15 +1886,12 @@ static void pci230_ai_stop(struct comedi_device *dev, * Disable ADC interrupt and wait for interrupt routine to finish * running unless we are called from the interrupt routine. */ - devpriv->int_en &= ~PCI230_INT_ADC; + devpriv->ier &= ~PCI230_INT_ADC; while (devpriv->intr_running && devpriv->intr_cpuid != THISCPU) { spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); } - if (devpriv->ier != devpriv->int_en) { - devpriv->ier = devpriv->int_en; - outb(devpriv->ier, dev->iobase + PCI230_INT_SCE); - } + outb(devpriv->ier, dev->iobase + PCI230_INT_SCE); spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); /* * Reset FIFO, disable FIFO and set start conversion source to none. @@ -1935,7 +1926,6 @@ static void pci230_ai_start(struct comedi_device *dev, /* Enable ADC FIFO trigger level interrupt. */ spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); - devpriv->int_en |= PCI230_INT_ADC; devpriv->ier |= PCI230_INT_ADC; outb(devpriv->ier, dev->iobase + PCI230_INT_SCE); spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); @@ -2379,7 +2369,7 @@ static int pci230_ai_cancel(struct comedi_device *dev, /* Interrupt handler */ static irqreturn_t pci230_interrupt(int irq, void *d) { - unsigned char status_int, valid_status_int; + unsigned char status_int, valid_status_int, temp_ier; struct comedi_device *dev = (struct comedi_device *)d; struct pci230_private *devpriv = dev->private; struct comedi_subdevice *s; @@ -2392,14 +2382,14 @@ static irqreturn_t pci230_interrupt(int irq, void *d) return IRQ_NONE; spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); - valid_status_int = devpriv->int_en & status_int; + valid_status_int = devpriv->ier & status_int; /* * Disable triggered interrupts. * (Only those interrupts that need re-enabling, are, later in the * handler). */ - devpriv->ier = devpriv->int_en & ~status_int; - outb(devpriv->ier, dev->iobase + PCI230_INT_SCE); + temp_ier = devpriv->ier & ~status_int; + outb(temp_ier, dev->iobase + PCI230_INT_SCE); devpriv->intr_running = true; devpriv->intr_cpuid = THISCPU; spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); @@ -2432,10 +2422,8 @@ static irqreturn_t pci230_interrupt(int irq, void *d) /* Reenable interrupts. */ spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); - if (devpriv->ier != devpriv->int_en) { - devpriv->ier = devpriv->int_en; + if (devpriv->ier != temp_ier) outb(devpriv->ier, dev->iobase + PCI230_INT_SCE); - } devpriv->intr_running = false; spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); -- 2.0.4
WARNING: multiple messages have this Message-ID (diff)
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>, linux-kernel@vger.kernel.org Subject: [PATCH 28/28] staging: comedi: amplc_pci230: simplify interrupt enable handling Date: Mon, 1 Sep 2014 12:04:00 +0100 [thread overview] Message-ID: <1409569440-10979-29-git-send-email-abbotti@mev.co.uk> (raw) In-Reply-To: <1409569440-10979-1-git-send-email-abbotti@mev.co.uk> `struct pci230_private` has two members to manage the enabled interrupt sources. `int_en` is the interrupt sources we want to be enabled and `ier` is a shadow of the write-only interrupt enable register. They have the same value most of the time. They differ in the interrupt handler (`pci230_interrupt()`) itself when it temporarily clears bits in the interrupt enable register and the `ier` member in order to unlatch them in hardware, but leaves the `int_en` member alone. They also differ in `pci230_ai_stop()` and `pci230_ao_stop()` which clear bits in the `int_en` member and wait for the interrupt handler to finish before copying the value to the `ier` member and the interrupt enable register. Simplify the handling a bit, by making the `ier` member take on the role of the `int_en` member, and allowing the value to differ from the interrupt enable register while the interrupt handler is running. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> --- drivers/staging/comedi/drivers/amplc_pci230.c | 32 +++++++++------------------ 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index 7748e17..66e7a47 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -499,8 +499,7 @@ struct pci230_private { unsigned short daccon; /* DACCON register value */ unsigned short adcfifothresh; /* ADC FIFO threshold (PCI230+/260+) */ unsigned short adcg; /* ADCG register value */ - unsigned char int_en; /* Interrupt enable bits */ - unsigned char ier; /* Copy of interrupt enable register */ + unsigned char ier; /* Interrupt enable bits */ unsigned char res_owned[NUM_OWNERS]; /* Owned resources */ bool intr_running:1; /* Flag set in interrupt routine */ bool ai_bipolar:1; /* Flag AI range is bipolar */ @@ -1049,15 +1048,12 @@ static void pci230_ao_stop(struct comedi_device *dev, * unless we are called from the interrupt routine. */ spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); - devpriv->int_en &= ~intsrc; + devpriv->ier &= ~intsrc; while (devpriv->intr_running && devpriv->intr_cpuid != THISCPU) { spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); } - if (devpriv->ier != devpriv->int_en) { - devpriv->ier = devpriv->int_en; - outb(devpriv->ier, dev->iobase + PCI230_INT_SCE); - } + outb(devpriv->ier, dev->iobase + PCI230_INT_SCE); spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); if (devpriv->hwver >= 2) { /* @@ -1311,7 +1307,6 @@ static void pci230_ao_start(struct comedi_device *dev, /* Not using DAC FIFO. */ /* Enable CT1 timer interrupt. */ spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); - devpriv->int_en |= PCI230_INT_ZCLK_CT1; devpriv->ier |= PCI230_INT_ZCLK_CT1; outb(devpriv->ier, dev->iobase + PCI230_INT_SCE); spin_unlock_irqrestore(&devpriv->isr_spinlock, @@ -1327,7 +1322,6 @@ static void pci230_ao_start(struct comedi_device *dev, if (devpriv->hwver >= 2) { /* Using DAC FIFO. Enable DAC FIFO interrupt. */ spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); - devpriv->int_en |= PCI230P2_INT_DAC; devpriv->ier |= PCI230P2_INT_DAC; outb(devpriv->ier, dev->iobase + PCI230_INT_SCE); spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); @@ -1892,15 +1886,12 @@ static void pci230_ai_stop(struct comedi_device *dev, * Disable ADC interrupt and wait for interrupt routine to finish * running unless we are called from the interrupt routine. */ - devpriv->int_en &= ~PCI230_INT_ADC; + devpriv->ier &= ~PCI230_INT_ADC; while (devpriv->intr_running && devpriv->intr_cpuid != THISCPU) { spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); } - if (devpriv->ier != devpriv->int_en) { - devpriv->ier = devpriv->int_en; - outb(devpriv->ier, dev->iobase + PCI230_INT_SCE); - } + outb(devpriv->ier, dev->iobase + PCI230_INT_SCE); spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); /* * Reset FIFO, disable FIFO and set start conversion source to none. @@ -1935,7 +1926,6 @@ static void pci230_ai_start(struct comedi_device *dev, /* Enable ADC FIFO trigger level interrupt. */ spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); - devpriv->int_en |= PCI230_INT_ADC; devpriv->ier |= PCI230_INT_ADC; outb(devpriv->ier, dev->iobase + PCI230_INT_SCE); spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); @@ -2379,7 +2369,7 @@ static int pci230_ai_cancel(struct comedi_device *dev, /* Interrupt handler */ static irqreturn_t pci230_interrupt(int irq, void *d) { - unsigned char status_int, valid_status_int; + unsigned char status_int, valid_status_int, temp_ier; struct comedi_device *dev = (struct comedi_device *)d; struct pci230_private *devpriv = dev->private; struct comedi_subdevice *s; @@ -2392,14 +2382,14 @@ static irqreturn_t pci230_interrupt(int irq, void *d) return IRQ_NONE; spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); - valid_status_int = devpriv->int_en & status_int; + valid_status_int = devpriv->ier & status_int; /* * Disable triggered interrupts. * (Only those interrupts that need re-enabling, are, later in the * handler). */ - devpriv->ier = devpriv->int_en & ~status_int; - outb(devpriv->ier, dev->iobase + PCI230_INT_SCE); + temp_ier = devpriv->ier & ~status_int; + outb(temp_ier, dev->iobase + PCI230_INT_SCE); devpriv->intr_running = true; devpriv->intr_cpuid = THISCPU; spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); @@ -2432,10 +2422,8 @@ static irqreturn_t pci230_interrupt(int irq, void *d) /* Reenable interrupts. */ spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); - if (devpriv->ier != devpriv->int_en) { - devpriv->ier = devpriv->int_en; + if (devpriv->ier != temp_ier) outb(devpriv->ier, dev->iobase + PCI230_INT_SCE); - } devpriv->intr_running = false; spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); -- 2.0.4 _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
next prev parent reply other threads:[~2014-09-01 11:05 UTC|newest] Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-09-01 11:03 [PATCH 00/28] staging: comedi: more clean-up and remove legacy attach Ian Abbott 2014-09-01 11:03 ` Ian Abbott 2014-09-01 11:03 ` [PATCH 01/28] staging: comedi: amplc_pci230: update MODULE_DESCRIPTION() Ian Abbott 2014-09-01 11:03 ` Ian Abbott 2014-09-01 11:03 ` [PATCH 02/28] staging: comedi: amplc_pci230: don't use multiple blank lines Ian Abbott 2014-09-01 11:03 ` Ian Abbott 2014-09-01 11:03 ` [PATCH 03/28] staging: comedi: amplc_pci230: remove some unnecessary parentheses Ian Abbott 2014-09-01 11:03 ` Ian Abbott 2014-09-01 11:03 ` [PATCH 04/28] staging: comedi: amplc_pci230: collapse some 'else { if' chains Ian Abbott 2014-09-01 11:03 ` Ian Abbott 2014-09-01 11:03 ` [PATCH 05/28] staging: comedi: amplc_pci230: remove "legacy" attach mechanism Ian Abbott 2014-09-01 11:03 ` Ian Abbott 2014-09-01 11:03 ` [PATCH 06/28] staging: comedi: amplc_pci230: no need to manipulate PCI ref count Ian Abbott 2014-09-01 11:03 ` Ian Abbott 2014-09-01 11:03 ` [PATCH 07/28] staging: comedi: amplc_pci230: set detach handler to comedi_pci_detach() Ian Abbott 2014-09-01 11:03 ` Ian Abbott 2014-09-01 11:03 ` [PATCH 08/28] staging: comedi: amplc_pci230: absorb pci230_attach_common() Ian Abbott 2014-09-01 11:03 ` Ian Abbott 2014-09-01 11:03 ` [PATCH 09/28] staging: comedi: amplc_pci230: no need to comedi_set_hw_dev() here Ian Abbott 2014-09-01 11:03 ` Ian Abbott 2014-09-01 11:03 ` [PATCH 10/28] staging: comedi: amplc_pci230: absorb pci230_alloc_private() Ian Abbott 2014-09-01 11:03 ` Ian Abbott 2014-09-01 11:03 ` [PATCH 11/28] staging: comedi: amplc_pci230: remove ai_chans member Ian Abbott 2014-09-01 11:03 ` Ian Abbott 2014-09-01 11:03 ` [PATCH 12/28] staging: comedi: amplc_pci230: remove ao_chans member Ian Abbott 2014-09-01 11:03 ` Ian Abbott 2014-09-01 11:03 ` [PATCH 13/28] staging: comedi: amplc_pci230: shrink struct pci230_board Ian Abbott 2014-09-01 11:03 ` Ian Abbott 2014-09-01 11:03 ` [PATCH 14/28] staging: comedi: amplc_pci230: simplify pci230_ao_mangle_datum() Ian Abbott 2014-09-01 11:03 ` Ian Abbott 2014-09-01 11:03 ` [PATCH 15/28] staging: comedi: amplc_pci230: simplify pci230_ai_read() Ian Abbott 2014-09-01 11:03 ` Ian Abbott 2014-09-01 11:03 ` [PATCH 16/28] staging: comedi: amplc_pci230: remove 'inline' Ian Abbott 2014-09-01 11:03 ` Ian Abbott 2014-09-01 11:03 ` [PATCH 17/28] staging: comedi: amplc_pci230: rename pci230_ai_rinsn() Ian Abbott 2014-09-01 11:03 ` Ian Abbott 2014-09-01 11:03 ` [PATCH 18/28] staging: comedi: amplc_pci230: add `pci230_` prefix to functions Ian Abbott 2014-09-01 11:03 ` Ian Abbott 2014-09-01 11:03 ` [PATCH 19/28] staging: comedi: amplc_pci230: use comedi_range_is_bipolar() Ian Abbott 2014-09-01 11:03 ` Ian Abbott 2014-09-01 11:03 ` [PATCH 20/28] staging: comedi: amplc_pci230: make `intr_running` a bitfield Ian Abbott 2014-09-01 11:03 ` Ian Abbott 2014-09-01 11:03 ` [PATCH 21/28] staging: comedi: amplc_pci230: replace `state` member with bitfields Ian Abbott 2014-09-01 11:03 ` Ian Abbott 2014-09-01 11:03 ` [PATCH 22/28] staging: comedi: amplc_pci230: rewrite shared resource handling Ian Abbott 2014-09-01 11:03 ` Ian Abbott 2014-09-01 11:03 ` [PATCH 23/28] staging: comedi: amplc_pci230: reduce indentation in pci230_ao_inttrig_scan_begin() Ian Abbott 2014-09-01 11:03 ` Ian Abbott 2014-09-01 11:03 ` [PATCH 24/28] staging: comedi: amplc_pci230: reduce indentation in pci230_ao_start() Ian Abbott 2014-09-01 11:03 ` Ian Abbott 2014-09-01 11:03 ` [PATCH 25/28] staging: comedi: amplc_pci230: reduce indentation in pci230_ai_inttrig_convert() Ian Abbott 2014-09-01 11:03 ` Ian Abbott 2014-09-01 11:03 ` [PATCH 26/28] staging: comedi: amplc_pci230: reduce indentation in pci230_ai_start() Ian Abbott 2014-09-01 11:03 ` Ian Abbott 2014-09-01 11:03 ` [PATCH 27/28] staging: comedi: amplc_pci230: change pci230_handle_ao_fifo() return type Ian Abbott 2014-09-01 11:03 ` Ian Abbott 2014-09-01 11:04 ` Ian Abbott [this message] 2014-09-01 11:04 ` [PATCH 28/28] staging: comedi: amplc_pci230: simplify interrupt enable handling Ian Abbott 2014-09-02 17:43 ` [PATCH 00/28] staging: comedi: more clean-up and remove legacy attach Hartley Sweeten 2014-09-02 17:43 ` Hartley Sweeten
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=1409569440-10979-29-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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.