<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Linus Walleij <<a href="mailto:linus.walleij@linaro.org">linus.walleij@linaro.org</a>> 于2023年2月16日周四 17:41写道:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Convert the driver to immutable irq-chip with a bit of<br>
intuition.<br>
<br>
Cc: Marc Zyngier <<a href="mailto:maz@kernel.org" target="_blank">maz@kernel.org</a>><br>
Signed-off-by: Linus Walleij <<a href="mailto:linus.walleij@linaro.org" target="_blank">linus.walleij@linaro.org</a>><br>
---<br>
drivers/gpio/gpio-eic-sprd.c | 33 ++++++++++++++++++++++++---------<br>
1 file changed, 24 insertions(+), 9 deletions(-)<br>
<br>
diff --git a/drivers/gpio/gpio-eic-sprd.c b/drivers/gpio/gpio-eic-sprd.c<br>
index 8d722e026e9c..695d74ba55f0 100644<br>
--- a/drivers/gpio/gpio-eic-sprd.c<br>
+++ b/drivers/gpio/gpio-eic-sprd.c<br></blockquote><div>Hi LInus: </div><div>this file which convert to immutable changes had included in the patchset[1] early.</div><div>Thank you for your commit anyway.</div><div>[1] <a href="https://lore.kernel.org/all/CAMRc=MeCCT09umHQ+T6Z6OXMedBh3UXzmQ=1PCyo1zEMr34TCw@mail.gmail.com/">https://lore.kernel.org/all/CAMRc=MeCCT09umHQ+T6Z6OXMedBh3UXzmQ=1PCyo1zEMr34TCw@mail.gmail.com/</a></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
@@ -11,6 +11,7 @@<br>
#include <linux/module.h><br>
#include <linux/of_device.h><br>
#include <linux/platform_device.h><br>
+#include <linux/seq_file.h><br>
#include <linux/spinlock.h><br>
<br>
/* EIC registers definition */<br>
@@ -91,7 +92,7 @@ enum sprd_eic_type {<br>
<br>
struct sprd_eic {<br>
struct gpio_chip chip;<br>
- struct irq_chip intc;<br>
+ struct device *dev;<br>
void __iomem *base[SPRD_EIC_MAX_BANK];<br>
enum sprd_eic_type type;<br>
spinlock_t lock;<br>
@@ -255,6 +256,7 @@ static void sprd_eic_irq_mask(struct irq_data *data)<br>
default:<br>
dev_err(chip->parent, "Unsupported EIC type.\n");<br>
}<br>
+ gpiochip_disable_irq(chip, irqd_to_hwirq(data));<br>
}<br>
<br>
static void sprd_eic_irq_unmask(struct irq_data *data)<br>
@@ -263,6 +265,7 @@ static void sprd_eic_irq_unmask(struct irq_data *data)<br>
struct sprd_eic *sprd_eic = gpiochip_get_data(chip);<br>
u32 offset = irqd_to_hwirq(data);<br>
<br>
+ gpiochip_enable_irq(chip, irqd_to_hwirq(data));<br>
switch (sprd_eic->type) {<br>
case SPRD_EIC_DEBOUNCE:<br>
sprd_eic_update(chip, offset, SPRD_EIC_DBNC_IE, 1);<br>
@@ -564,6 +567,24 @@ static void sprd_eic_irq_handler(struct irq_desc *desc)<br>
chained_irq_exit(ic, desc);<br>
}<br>
<br>
+static void sprd_eic_irq_print_chip(struct irq_data *data, struct seq_file *p)<br>
+{<br>
+ struct gpio_chip *chip = irq_data_get_irq_chip_data(data);<br>
+ struct sprd_eic *sprd_eic = gpiochip_get_data(chip);<br>
+<br>
+ seq_printf(p, dev_name(sprd_eic->dev));<br>
+}<br>
+<br>
+static const struct irq_chip sprd_eic_irq_chip = {<br>
+ .irq_ack = sprd_eic_irq_ack,<br>
+ .irq_mask = sprd_eic_irq_mask,<br>
+ .irq_unmask = sprd_eic_irq_unmask,<br>
+ .irq_set_type = sprd_eic_irq_set_type,<br>
+ .irq_print_chip = sprd_eic_irq_print_chip,<br>
+ .flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_IMMUTABLE,<br>
+ GPIOCHIP_IRQ_RESOURCE_HELPERS,<br>
+};<br>
+<br>
static int sprd_eic_probe(struct platform_device *pdev)<br>
{<br>
const struct sprd_eic_variant_data *pdata;<br>
@@ -584,6 +605,7 @@ static int sprd_eic_probe(struct platform_device *pdev)<br>
<br>
spin_lock_init(&sprd_eic->lock);<br>
sprd_eic->type = pdata->type;<br>
+ sprd_eic->dev = &pdev->dev;<br>
<br>
sprd_eic->irq = platform_get_irq(pdev, 0);<br>
if (sprd_eic->irq < 0)<br>
@@ -626,15 +648,8 @@ static int sprd_eic_probe(struct platform_device *pdev)<br>
break;<br>
}<br>
<br>
- sprd_eic-><a href="http://intc.name" rel="noreferrer" target="_blank">intc.name</a> = dev_name(&pdev->dev);<br>
- sprd_eic->intc.irq_ack = sprd_eic_irq_ack;<br>
- sprd_eic->intc.irq_mask = sprd_eic_irq_mask;<br>
- sprd_eic->intc.irq_unmask = sprd_eic_irq_unmask;<br>
- sprd_eic->intc.irq_set_type = sprd_eic_irq_set_type;<br>
- sprd_eic->intc.flags = IRQCHIP_SKIP_SET_WAKE;<br>
-<br>
irq = &sprd_eic->chip.irq;<br>
- irq->chip = &sprd_eic->intc;<br>
+ gpio_irq_chip_set_chip(irq, &sprd_eic_irq_chip);<br>
irq->handler = handle_bad_irq;<br>
irq->default_type = IRQ_TYPE_NONE;<br>
irq->parent_handler = sprd_eic_irq_handler;<br>
<br>
-- <br>
2.34.1<br>
<br>
</blockquote></div></div>