Skip to content

Commit 8e461e1

Browse files
Alex Elderkuba-moo
authored andcommitted
net: ipa: introduce ipa_interrupt_enable()
Create new function ipa_interrupt_enable() to encapsulate enabling one of the IPA interrupt types. Introduce ipa_interrupt_disable() to reverse that operation. Add a helper function to factor out the common register update used by both. Use these in ipa_interrupt_add() and ipa_interrupt_remove(). Signed-off-by: Alex Elder <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent e5709b7 commit 8e461e1

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

drivers/net/ipa/ipa_interrupt.c

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,29 @@ static irqreturn_t ipa_isr_thread(int irq, void *dev_id)
127127
return IRQ_HANDLED;
128128
}
129129

130+
static void ipa_interrupt_enabled_update(struct ipa *ipa)
131+
{
132+
const struct ipa_reg *reg = ipa_reg(ipa, IPA_IRQ_EN);
133+
134+
iowrite32(ipa->interrupt->enabled, ipa->reg_virt + ipa_reg_offset(reg));
135+
}
136+
137+
/* Enable an IPA interrupt type */
138+
static void ipa_interrupt_enable(struct ipa *ipa, enum ipa_irq_id ipa_irq)
139+
{
140+
/* Update the IPA interrupt mask to enable it */
141+
ipa->interrupt->enabled |= BIT(ipa_irq);
142+
ipa_interrupt_enabled_update(ipa);
143+
}
144+
145+
/* Disable an IPA interrupt type */
146+
static void ipa_interrupt_disable(struct ipa *ipa, enum ipa_irq_id ipa_irq)
147+
{
148+
/* Update the IPA interrupt mask to disable it */
149+
ipa->interrupt->enabled &= ~BIT(ipa_irq);
150+
ipa_interrupt_enabled_update(ipa);
151+
}
152+
130153
/* Common function used to enable/disable TX_SUSPEND for an endpoint */
131154
static void ipa_interrupt_suspend_control(struct ipa_interrupt *interrupt,
132155
u32 endpoint_id, bool enable)
@@ -204,36 +227,22 @@ void ipa_interrupt_simulate_suspend(struct ipa_interrupt *interrupt)
204227
void ipa_interrupt_add(struct ipa_interrupt *interrupt,
205228
enum ipa_irq_id ipa_irq, ipa_irq_handler_t handler)
206229
{
207-
struct ipa *ipa = interrupt->ipa;
208-
const struct ipa_reg *reg;
209-
210230
if (WARN_ON(ipa_irq >= IPA_IRQ_COUNT))
211231
return;
212232

213233
interrupt->handler[ipa_irq] = handler;
214234

215-
/* Update the IPA interrupt mask to enable it */
216-
interrupt->enabled |= BIT(ipa_irq);
217-
218-
reg = ipa_reg(ipa, IPA_IRQ_EN);
219-
iowrite32(interrupt->enabled, ipa->reg_virt + ipa_reg_offset(reg));
235+
ipa_interrupt_enable(interrupt->ipa, ipa_irq);
220236
}
221237

222238
/* Remove the handler for an IPA interrupt type */
223239
void
224240
ipa_interrupt_remove(struct ipa_interrupt *interrupt, enum ipa_irq_id ipa_irq)
225241
{
226-
struct ipa *ipa = interrupt->ipa;
227-
const struct ipa_reg *reg;
228-
229242
if (WARN_ON(ipa_irq >= IPA_IRQ_COUNT))
230243
return;
231244

232-
/* Update the IPA interrupt mask to disable it */
233-
interrupt->enabled &= ~BIT(ipa_irq);
234-
235-
reg = ipa_reg(ipa, IPA_IRQ_EN);
236-
iowrite32(interrupt->enabled, ipa->reg_virt + ipa_reg_offset(reg));
245+
ipa_interrupt_disable(interrupt->ipa, ipa_irq);
237246

238247
interrupt->handler[ipa_irq] = NULL;
239248
}

0 commit comments

Comments
 (0)