linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/24] Staging: ipack/bridges/tpci200: add helpers for writing control regs.
@ 2012-09-12 12:55 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
                   ` (22 more replies)
  0 siblings, 23 replies; 30+ messages in thread
From: Samuel Iglesias Gonsalvez @ 2012-09-12 12:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: devel, linux-kernel, industrypack-devel, Jens Taprogge,
	Samuel Iglesias Gonsalvez

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

Convert tpci200_set_clockrate and tpci200_interrupt.

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

diff --git a/drivers/staging/ipack/bridges/tpci200.c b/drivers/staging/ipack/bridges/tpci200.c
index 9d886b7..2560519 100644
--- a/drivers/staging/ipack/bridges/tpci200.c
+++ b/drivers/staging/ipack/bridges/tpci200.c
@@ -53,6 +53,32 @@ static struct tpci200_board *check_slot(struct ipack_device *dev)
 	return tpci200;
 }
 
+static void __tpci200_clear_mask(__le16 __iomem *addr, u16 mask)
+{
+	iowrite16(ioread16(addr) & (~mask), addr);
+}
+
+static void tpci200_clear_mask(struct tpci200_board *tpci200,
+			       __le16 __iomem *addr, u16 mask)
+{
+	mutex_lock(&tpci200->mutex);
+	__tpci200_clear_mask(addr, mask);
+	mutex_unlock(&tpci200->mutex);
+}
+
+static void __tpci200_set_mask(__le16 __iomem *addr, u16 mask)
+{
+	iowrite16(ioread16(addr) | mask, addr);
+}
+
+static void tpci200_set_mask(struct tpci200_board *tpci200,
+			     __le16 __iomem *addr, u16 mask)
+{
+	mutex_lock(&tpci200->mutex);
+	__tpci200_set_mask(addr, mask);
+	mutex_unlock(&tpci200->mutex);
+}
+
 static void tpci200_unregister(struct tpci200_board *tpci200)
 {
 	int i;
@@ -86,7 +112,7 @@ static irqreturn_t tpci200_interrupt(int irq, void *dev_id)
 {
 	struct tpci200_board *tpci200 = (struct tpci200_board *) dev_id;
 	int i;
-	unsigned short status_reg, reg_value;
+	unsigned short status_reg;
 	unsigned short unhandled_ints = 0;
 	irqreturn_t ret = IRQ_NONE;
 	struct slot_irq *slot_irq;
@@ -124,12 +150,9 @@ static irqreturn_t tpci200_interrupt(int irq, void *dev_id)
 				dev_info(&slot_irq->holder->dev,
 					 "No registered ISR for slot [%d:%d]!. IRQ will be disabled.\n",
 					 tpci200->number, i);
-				reg_value = readw(
-					&tpci200->info->interface_regs->control[i]);
-				reg_value &=
-					~(TPCI200_INT0_EN | TPCI200_INT1_EN);
-				writew(reg_value,
-				       &tpci200->info->interface_regs->control[i]);
+				__tpci200_clear_mask(
+					&tpci200->info->interface_regs->control[i],
+					TPCI200_INT0_EN | TPCI200_INT1_EN);
 			}
 		}
 	}
@@ -518,30 +541,22 @@ static int tpci200_set_clockrate(struct ipack_device *dev, int mherz)
 {
 	struct tpci200_board *tpci200 = check_slot(dev);
 	u16 __iomem *addr;
-	u16 reg;
 
 	if (!tpci200)
 		return -ENODEV;
 
 	addr = &tpci200->info->interface_regs->control[dev->slot];
 
-	/* Ensure the control register is not changed by another task after we
-	 * have read it. */
-	mutex_lock(&tpci200->mutex);
-	reg = ioread16(addr);
 	switch (mherz) {
 	case 8:
-		reg &= ~(TPCI200_CLK32);
+		tpci200_clear_mask(tpci200, addr, TPCI200_CLK32);
 		break;
 	case 32:
-		reg |= TPCI200_CLK32;
+		tpci200_set_mask(tpci200, addr, TPCI200_CLK32);
 		break;
 	default:
-		mutex_unlock(&tpci200->mutex);
 		return -EINVAL;
 	}
-	iowrite16(reg, addr);
-	mutex_unlock(&tpci200->mutex);
 	return 0;
 }
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2012-09-14  0:26 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 15/24] Staging: ipack/bridges/tpci200: move tpci200_free_irq() and tpci200_request_irq() Samuel Iglesias Gonsalvez
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

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).