diff options
author | Jens Taprogge <jens.taprogge@taprogge.org> | 2012-09-12 08:55:35 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-09-12 12:56:01 -0400 |
commit | ab0deffcb957d1e0bf8c7e1d6373b4e1587b8192 (patch) | |
tree | a94905256d0e7d821473ba5b9ad9fa53f4cbd6d5 | |
parent | 88ff8480d39da6b2961444f0c28b5b0d194d2de6 (diff) |
Staging: ipack/bridges/tpci200: Cleanup in tpci200_slot_irq() and tpci200_interrupt()
Minor cleanup. No functional changes.
Signed-off-by: Jens Taprogge <jens.taprogge@taprogge.org>
Signed-off-by: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/ipack/bridges/tpci200.c | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/drivers/staging/ipack/bridges/tpci200.c b/drivers/staging/ipack/bridges/tpci200.c index 0cbaf3ab53cd..4eaa2aaec24d 100644 --- a/drivers/staging/ipack/bridges/tpci200.c +++ b/drivers/staging/ipack/bridges/tpci200.c | |||
@@ -102,9 +102,13 @@ static void tpci200_unregister(struct tpci200_board *tpci200) | |||
102 | 102 | ||
103 | static irqreturn_t tpci200_slot_irq(struct slot_irq *slot_irq) | 103 | static irqreturn_t tpci200_slot_irq(struct slot_irq *slot_irq) |
104 | { | 104 | { |
105 | irqreturn_t ret = slot_irq->handler(slot_irq->arg); | 105 | irqreturn_t ret; |
106 | 106 | ||
107 | /* Dummy reads */ | 107 | if (!slot_irq) |
108 | return -ENODEV; | ||
109 | ret = slot_irq->handler(slot_irq->arg); | ||
110 | |||
111 | /* Clear the IPack device interrupt */ | ||
108 | readw(slot_irq->holder->io_space.address + 0xC0); | 112 | readw(slot_irq->holder->io_space.address + 0xC0); |
109 | readw(slot_irq->holder->io_space.address + 0xC2); | 113 | readw(slot_irq->holder->io_space.address + 0xC2); |
110 | 114 | ||
@@ -114,37 +118,37 @@ static irqreturn_t tpci200_slot_irq(struct slot_irq *slot_irq) | |||
114 | static irqreturn_t tpci200_interrupt(int irq, void *dev_id) | 118 | static irqreturn_t tpci200_interrupt(int irq, void *dev_id) |
115 | { | 119 | { |
116 | struct tpci200_board *tpci200 = (struct tpci200_board *) dev_id; | 120 | struct tpci200_board *tpci200 = (struct tpci200_board *) dev_id; |
117 | int i; | ||
118 | unsigned short status_reg; | ||
119 | struct slot_irq *slot_irq; | 121 | struct slot_irq *slot_irq; |
122 | irqreturn_t ret; | ||
123 | u16 status_reg; | ||
124 | int i; | ||
120 | 125 | ||
121 | /* Read status register */ | 126 | /* Read status register */ |
122 | status_reg = readw(&tpci200->info->interface_regs->status); | 127 | status_reg = ioread16(&tpci200->info->interface_regs->status); |
123 | |||
124 | if (status_reg & TPCI200_SLOT_INT_MASK) { | ||
125 | /* callback to the IRQ handler for the corresponding slot */ | ||
126 | rcu_read_lock(); | ||
127 | for (i = 0; i < TPCI200_NB_SLOT; i++) { | ||
128 | if (!(status_reg & ((TPCI200_A_INT0 | TPCI200_A_INT1) << (2*i)))) | ||
129 | continue; | ||
130 | slot_irq = rcu_dereference(tpci200->slots[i].irq); | ||
131 | if (slot_irq) { | ||
132 | tpci200_slot_irq(slot_irq); | ||
133 | } else { | ||
134 | dev_info(&tpci200->info->pdev->dev, | ||
135 | "No registered ISR for slot [%d:%d]!. IRQ will be disabled.\n", | ||
136 | tpci200->number, i); | ||
137 | tpci200_clear_mask(tpci200, | ||
138 | &tpci200->info->interface_regs->control[i], | ||
139 | TPCI200_INT0_EN | TPCI200_INT1_EN); | ||
140 | } | ||
141 | } | ||
142 | rcu_read_unlock(); | ||
143 | 128 | ||
144 | return IRQ_HANDLED; | 129 | /* Did we cause the interrupt? */ |
145 | } else { | 130 | if (!(status_reg & TPCI200_SLOT_INT_MASK)) |
146 | return IRQ_NONE; | 131 | return IRQ_NONE; |
132 | |||
133 | /* callback to the IRQ handler for the corresponding slot */ | ||
134 | rcu_read_lock(); | ||
135 | for (i = 0; i < TPCI200_NB_SLOT; i++) { | ||
136 | if (!(status_reg & ((TPCI200_A_INT0 | TPCI200_A_INT1) << (2 * i)))) | ||
137 | continue; | ||
138 | slot_irq = rcu_dereference(tpci200->slots[i].irq); | ||
139 | ret = tpci200_slot_irq(slot_irq); | ||
140 | if (ret == -ENODEV) { | ||
141 | dev_info(&tpci200->info->pdev->dev, | ||
142 | "No registered ISR for slot [%d:%d]!. IRQ will be disabled.\n", | ||
143 | tpci200->number, i); | ||
144 | tpci200_clear_mask(tpci200, | ||
145 | &tpci200->info->interface_regs->control[i], | ||
146 | TPCI200_INT0_EN | TPCI200_INT1_EN); | ||
147 | } | ||
147 | } | 148 | } |
149 | rcu_read_unlock(); | ||
150 | |||
151 | return IRQ_HANDLED; | ||
148 | } | 152 | } |
149 | 153 | ||
150 | static int tpci200_register(struct tpci200_board *tpci200) | 154 | static int tpci200_register(struct tpci200_board *tpci200) |