linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	industrypack-devel@lists.sourceforge.net,
	Jens Taprogge <jens.taprogge@taprogge.org>,
	Samuel Iglesias Gonsalvez <siglesias@igalia.com>
Subject: [PATCH 15/24] Staging: ipack/bridges/tpci200: move tpci200_free_irq() and tpci200_request_irq()
Date: Wed, 12 Sep 2012 14:55:37 +0200	[thread overview]
Message-ID: <1347454546-23236-15-git-send-email-siglesias@igalia.com> (raw)
In-Reply-To: <1347454546-23236-1-git-send-email-siglesias@igalia.com>

From: Jens Taprogge <jens.taprogge@taprogge.org>

Now, all the interrupt related functions are next to each other.

Signed-off-by: Jens Taprogge <jens.taprogge@taprogge.org>
Signed-off-by: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
---
 drivers/staging/ipack/bridges/tpci200.c |  154 +++++++++++++++----------------
 1 file changed, 77 insertions(+), 77 deletions(-)

diff --git a/drivers/staging/ipack/bridges/tpci200.c b/drivers/staging/ipack/bridges/tpci200.c
index c7ec342..b0d2205 100644
--- a/drivers/staging/ipack/bridges/tpci200.c
+++ b/drivers/staging/ipack/bridges/tpci200.c
@@ -165,6 +165,83 @@ static irqreturn_t tpci200_interrupt(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
+static int tpci200_free_irq(struct ipack_device *dev)
+{
+	struct slot_irq *slot_irq;
+	struct tpci200_board *tpci200;
+
+	tpci200 = check_slot(dev);
+	if (tpci200 == NULL)
+		return -EINVAL;
+
+	if (mutex_lock_interruptible(&tpci200->mutex))
+		return -ERESTARTSYS;
+
+	if (tpci200->slots[dev->slot].irq == NULL) {
+		mutex_unlock(&tpci200->mutex);
+		return -EINVAL;
+	}
+
+	tpci200_disable_irq(tpci200, dev->slot);
+	slot_irq = tpci200->slots[dev->slot].irq;
+	/* uninstall handler */
+	RCU_INIT_POINTER(tpci200->slots[dev->slot].irq, NULL);
+	synchronize_rcu();
+	kfree(slot_irq);
+	mutex_unlock(&tpci200->mutex);
+	return 0;
+}
+
+static int tpci200_request_irq(struct ipack_device *dev, int vector,
+			       int (*handler)(void *), void *arg)
+{
+	int res = 0;
+	struct slot_irq *slot_irq;
+	struct tpci200_board *tpci200;
+
+	tpci200 = check_slot(dev);
+	if (tpci200 == NULL)
+		return -EINVAL;
+
+	if (mutex_lock_interruptible(&tpci200->mutex))
+		return -ERESTARTSYS;
+
+	if (tpci200->slots[dev->slot].irq != NULL) {
+		dev_err(&dev->dev,
+			"Slot [%d:%d] IRQ already registered !\n", dev->bus_nr,
+			dev->slot);
+		res = -EINVAL;
+		goto out_unlock;
+	}
+
+	slot_irq = kzalloc(sizeof(struct slot_irq), GFP_KERNEL);
+	if (slot_irq == NULL) {
+		dev_err(&dev->dev,
+			"Slot [%d:%d] unable to allocate memory for IRQ !\n",
+			dev->bus_nr, dev->slot);
+		res = -ENOMEM;
+		goto out_unlock;
+	}
+
+	/*
+	 * WARNING: Setup Interrupt Vector in the IndustryPack device
+	 * before an IRQ request.
+	 * Read the User Manual of your IndustryPack device to know
+	 * where to write the vector in memory.
+	 */
+	slot_irq->vector = vector;
+	slot_irq->handler = handler;
+	slot_irq->arg = arg;
+	slot_irq->holder = dev;
+
+	rcu_assign_pointer(tpci200->slots[dev->slot].irq, slot_irq);
+	tpci200_enable_irq(tpci200, dev->slot);
+
+out_unlock:
+	mutex_unlock(&tpci200->mutex);
+	return res;
+}
+
 static int tpci200_register(struct tpci200_board *tpci200)
 {
 	int i;
@@ -283,33 +360,6 @@ out_disable_pci:
 	return res;
 }
 
-static int tpci200_free_irq(struct ipack_device *dev)
-{
-	struct slot_irq *slot_irq;
-	struct tpci200_board *tpci200;
-
-	tpci200 = check_slot(dev);
-	if (tpci200 == NULL)
-		return -EINVAL;
-
-	if (mutex_lock_interruptible(&tpci200->mutex))
-		return -ERESTARTSYS;
-
-	if (tpci200->slots[dev->slot].irq == NULL) {
-		mutex_unlock(&tpci200->mutex);
-		return -EINVAL;
-	}
-
-	tpci200_disable_irq(tpci200, dev->slot);
-	slot_irq = tpci200->slots[dev->slot].irq;
-	/* uninstall handler */
-	RCU_INIT_POINTER(tpci200->slots[dev->slot].irq, NULL);
-	synchronize_rcu();
-	kfree(slot_irq);
-	mutex_unlock(&tpci200->mutex);
-	return 0;
-}
-
 static int tpci200_slot_unmap_space(struct ipack_device *dev, int space)
 {
 	struct ipack_addr_space *virt_addr_space;
@@ -448,56 +498,6 @@ out_unlock:
 	return res;
 }
 
-static int tpci200_request_irq(struct ipack_device *dev, int vector,
-			       int (*handler)(void *), void *arg)
-{
-	int res = 0;
-	struct slot_irq *slot_irq;
-	struct tpci200_board *tpci200;
-
-	tpci200 = check_slot(dev);
-	if (tpci200 == NULL)
-		return -EINVAL;
-
-	if (mutex_lock_interruptible(&tpci200->mutex))
-		return -ERESTARTSYS;
-
-	if (tpci200->slots[dev->slot].irq != NULL) {
-		dev_err(&dev->dev,
-			"Slot [%d:%d] IRQ already registered !\n", dev->bus_nr,
-			dev->slot);
-		res = -EINVAL;
-		goto out_unlock;
-	}
-
-	slot_irq = kzalloc(sizeof(struct slot_irq), GFP_KERNEL);
-	if (slot_irq == NULL) {
-		dev_err(&dev->dev,
-			"Slot [%d:%d] unable to allocate memory for IRQ !\n",
-			dev->bus_nr, dev->slot);
-		res = -ENOMEM;
-		goto out_unlock;
-	}
-
-	/*
-	 * WARNING: Setup Interrupt Vector in the IndustryPack device
-	 * before an IRQ request.
-	 * Read the User Manual of your IndustryPack device to know
-	 * where to write the vector in memory.
-	 */
-	slot_irq->vector = vector;
-	slot_irq->handler = handler;
-	slot_irq->arg = arg;
-	slot_irq->holder = dev;
-
-	rcu_assign_pointer(tpci200->slots[dev->slot].irq, slot_irq);
-	tpci200_enable_irq(tpci200, dev->slot);
-
-out_unlock:
-	mutex_unlock(&tpci200->mutex);
-	return res;
-}
-
 static int tpci200_get_clockrate(struct ipack_device *dev)
 {
 	struct tpci200_board *tpci200 = check_slot(dev);
-- 
1.7.10.4


  parent reply	other threads:[~2012-09-12 12:55 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-12 12:55 [PATCH 01/24] Staging: ipack/bridges/tpci200: add helpers for writing control regs Samuel Iglesias Gonsalvez
2012-09-12 12:55 ` [PATCH 02/24] Staging: ipack/bridges/tpci200: Remove side effects of tpci200_{request,free}_irq Samuel Iglesias Gonsalvez
2012-09-12 12:55 ` [PATCH 03/24] Staging: ipack/bridges/tpci200: Clean up interrupt handler Samuel Iglesias Gonsalvez
2012-09-12 12:55 ` [PATCH 04/24] Staging: ipack/devices/ipoctal: split ipoctal_channel from ipoctal Samuel Iglesias Gonsalvez
2012-09-12 12:55 ` [PATCH 05/24] Staging: ipack/devices/ipoctal: Directly use ioread/iowrite function Samuel Iglesias Gonsalvez
2012-09-12 12:55 ` [PATCH 06/24] Staging: ipack/devices/ipoctal: put ipoctal_channel into tty->driver_data Samuel Iglesias Gonsalvez
2012-09-12 12:55 ` [PATCH 07/24] Staging: ipack/devices/ipoctal: Store isr masks in ipoctal_channel Samuel Iglesias Gonsalvez
2012-09-13 17:43   ` Dan Carpenter
2012-09-13 17:49     ` Dan Carpenter
2012-09-13 18:19       ` Joe Perches
2012-09-13 18:43         ` Jens Taprogge
2012-09-13 19:17           ` Dan Carpenter
2012-09-14  0:25             ` Joe Perches
2012-09-12 12:55 ` [PATCH 08/24] Staging: ipack/devices/ipoctal: Split interrupt service routine Samuel Iglesias Gonsalvez
2012-09-12 12:55 ` [PATCH 09/24] Staging: ipack/devices/ipoctal: remove superfluous function Samuel Iglesias Gonsalvez
2012-09-12 12:55 ` [PATCH 10/24] Staging: ipack/bridges/tpci200: RCU protect slot_irq pointers Samuel Iglesias Gonsalvez
2012-09-12 12:55 ` [PATCH 11/24] Staging: ipack/bridges/tpci200: Protect device registers with spinlock Samuel Iglesias Gonsalvez
2012-09-12 12:55 ` [PATCH 12/24] Staging: ipack/bridges/tpci200: Clean up interrupt handling Samuel Iglesias Gonsalvez
2012-09-12 12:55 ` [PATCH 13/24] Staging: ipack/bridges/tpci200: Cleanup in tpci200_slot_irq() and tpci200_interrupt() Samuel Iglesias Gonsalvez
2012-09-12 12:55 ` [PATCH 14/24] Staging: ipack/bridges/tpci200: More cleanups Samuel Iglesias Gonsalvez
2012-09-12 12:55 ` Samuel Iglesias Gonsalvez [this message]
2012-09-12 12:55 ` [PATCH 16/24] Staging: ipack: Let interrupts return irqreturn_t Samuel Iglesias Gonsalvez
2012-09-12 12:55 ` [PATCH 17/24] Staging: ipack/devices/ipoctal: Clean up device removal Samuel Iglesias Gonsalvez
2012-09-12 12:55 ` [PATCH 18/24] Staging: ipack/devices/ipoctal: Check tty_register_device return value Samuel Iglesias Gonsalvez
2012-09-12 12:55 ` [PATCH 19/24] Staging: ipack/devices/ipoctal: Use KBUILD_MODNAME instead of hardcoded string Samuel Iglesias Gonsalvez
2012-09-12 12:55 ` [PATCH 20/24] Staging: ipack/devices/ipoctal: Get rid of ipoctal_list Samuel Iglesias Gonsalvez
2012-09-12 12:55 ` [PATCH 21/24] Staging: ipack/devices/ipoctal: read more than one character from RX FIFO Samuel Iglesias Gonsalvez
2012-09-12 12:55 ` [PATCH 22/24] Staging: ipack: update TODO file Samuel Iglesias Gonsalvez
2012-09-12 12:55 ` [PATCH 23/24] Staging: ipack/devices/ipoctal: Unmap memory on device removal Samuel Iglesias Gonsalvez
2012-09-12 12:55 ` [PATCH 24/24] staging: ipack/bridges/tpci200: Use endianess-aware types where applicable Samuel Iglesias Gonsalvez

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=1347454546-23236-15-git-send-email-siglesias@igalia.com \
    --to=siglesias@igalia.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=industrypack-devel@lists.sourceforge.net \
    --cc=jens.taprogge@taprogge.org \
    --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;
as well as URLs for NNTP newsgroup(s).