Commit a752fbb4 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Linus Walleij

gpio: intel-mid: Move hardware initialization to callback

The driver wants to initialize related registers before IRQ chip will be added.
That's why move it to a corresponding callback. It also fixes the NULL pointer
dereference.

Fixes: 8069e69a ("gpio: intel-mid: Pass irqchip when adding gpiochip")
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 9411e3aa
...@@ -293,8 +293,9 @@ static void intel_mid_irq_handler(struct irq_desc *desc) ...@@ -293,8 +293,9 @@ static void intel_mid_irq_handler(struct irq_desc *desc)
chip->irq_eoi(data); chip->irq_eoi(data);
} }
static void intel_mid_irq_init_hw(struct intel_mid_gpio *priv) static int intel_mid_irq_init_hw(struct gpio_chip *chip)
{ {
struct intel_mid_gpio *priv = gpiochip_get_data(chip);
void __iomem *reg; void __iomem *reg;
unsigned base; unsigned base;
...@@ -309,6 +310,8 @@ static void intel_mid_irq_init_hw(struct intel_mid_gpio *priv) ...@@ -309,6 +310,8 @@ static void intel_mid_irq_init_hw(struct intel_mid_gpio *priv)
reg = gpio_reg(&priv->chip, base, GEDR); reg = gpio_reg(&priv->chip, base, GEDR);
writel(~0, reg); writel(~0, reg);
} }
return 0;
} }
static int __maybe_unused intel_gpio_runtime_idle(struct device *dev) static int __maybe_unused intel_gpio_runtime_idle(struct device *dev)
...@@ -372,6 +375,7 @@ static int intel_gpio_probe(struct pci_dev *pdev, ...@@ -372,6 +375,7 @@ static int intel_gpio_probe(struct pci_dev *pdev,
girq = &priv->chip.irq; girq = &priv->chip.irq;
girq->chip = &intel_mid_irqchip; girq->chip = &intel_mid_irqchip;
girq->init_hw = intel_mid_irq_init_hw;
girq->parent_handler = intel_mid_irq_handler; girq->parent_handler = intel_mid_irq_handler;
girq->num_parents = 1; girq->num_parents = 1;
girq->parents = devm_kcalloc(&pdev->dev, girq->num_parents, girq->parents = devm_kcalloc(&pdev->dev, girq->num_parents,
...@@ -384,9 +388,8 @@ static int intel_gpio_probe(struct pci_dev *pdev, ...@@ -384,9 +388,8 @@ static int intel_gpio_probe(struct pci_dev *pdev,
girq->default_type = IRQ_TYPE_NONE; girq->default_type = IRQ_TYPE_NONE;
girq->handler = handle_simple_irq; girq->handler = handle_simple_irq;
intel_mid_irq_init_hw(priv);
pci_set_drvdata(pdev, priv); pci_set_drvdata(pdev, priv);
retval = devm_gpiochip_add_data(&pdev->dev, &priv->chip, priv); retval = devm_gpiochip_add_data(&pdev->dev, &priv->chip, priv);
if (retval) { if (retval) {
dev_err(&pdev->dev, "gpiochip_add error %d\n", retval); dev_err(&pdev->dev, "gpiochip_add error %d\n", retval);
......
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