Commit 325255bc authored by Kiran Gunda's avatar Kiran Gunda Committed by Greg Kroah-Hartman

spmi: pmic-arb: optimize qpnpint_irq_set_type function

Optimize the qpnpint_irq_set_type() by using a local variable
to hold the handler type. Also clean up other variable usage.
Signed-off-by: default avatarKiran Gunda <kgunda@codeaurora.org>
Reviewed-by: default avatarStephen Boyd <sboyd@codeaurora.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f2f31564
...@@ -587,35 +587,35 @@ static void qpnpint_irq_unmask(struct irq_data *d) ...@@ -587,35 +587,35 @@ static void qpnpint_irq_unmask(struct irq_data *d)
static int qpnpint_irq_set_type(struct irq_data *d, unsigned int flow_type) static int qpnpint_irq_set_type(struct irq_data *d, unsigned int flow_type)
{ {
struct spmi_pmic_arb_qpnpint_type type; struct spmi_pmic_arb_qpnpint_type type;
irq_flow_handler_t flow_handler;
u8 irq = hwirq_to_irq(d->hwirq); u8 irq = hwirq_to_irq(d->hwirq);
u8 bit_mask_irq = BIT(irq);
qpnpint_spmi_read(d, QPNPINT_REG_SET_TYPE, &type, sizeof(type)); qpnpint_spmi_read(d, QPNPINT_REG_SET_TYPE, &type, sizeof(type));
if (flow_type & (IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING)) { if (flow_type & (IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING)) {
type.type |= bit_mask_irq; type.type |= BIT(irq);
if (flow_type & IRQF_TRIGGER_RISING) if (flow_type & IRQF_TRIGGER_RISING)
type.polarity_high |= bit_mask_irq; type.polarity_high |= BIT(irq);
if (flow_type & IRQF_TRIGGER_FALLING) if (flow_type & IRQF_TRIGGER_FALLING)
type.polarity_low |= bit_mask_irq; type.polarity_low |= BIT(irq);
flow_handler = handle_edge_irq;
} else { } else {
if ((flow_type & (IRQF_TRIGGER_HIGH)) && if ((flow_type & (IRQF_TRIGGER_HIGH)) &&
(flow_type & (IRQF_TRIGGER_LOW))) (flow_type & (IRQF_TRIGGER_LOW)))
return -EINVAL; return -EINVAL;
type.type &= ~bit_mask_irq; /* level trig */ type.type &= ~BIT(irq); /* level trig */
if (flow_type & IRQF_TRIGGER_HIGH) if (flow_type & IRQF_TRIGGER_HIGH)
type.polarity_high |= bit_mask_irq; type.polarity_high |= BIT(irq);
else else
type.polarity_low |= bit_mask_irq; type.polarity_low |= BIT(irq);
flow_handler = handle_level_irq;
} }
qpnpint_spmi_write(d, QPNPINT_REG_SET_TYPE, &type, sizeof(type)); qpnpint_spmi_write(d, QPNPINT_REG_SET_TYPE, &type, sizeof(type));
irq_set_handler_locked(d, flow_handler);
if (flow_type & IRQ_TYPE_EDGE_BOTH)
irq_set_handler_locked(d, handle_edge_irq);
else
irq_set_handler_locked(d, handle_level_irq);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment