Commit 4c2b54f7 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Linus Walleij

gpio: dwapb: Split out dwapb_get_irq() helper

Split out dwapb_get_irq() helper for better readability and maintenance.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: default avatarSerge Semin <fancer.lancer@gmail.com>
Reviewed-by: default avatarSerge Semin <fancer.lancer@gmail.com>
Link: https://lore.kernel.org/r/20200415141534.31240-13-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent c59042ed
...@@ -528,14 +528,38 @@ static void dwapb_gpio_unregister(struct dwapb_gpio *gpio) ...@@ -528,14 +528,38 @@ static void dwapb_gpio_unregister(struct dwapb_gpio *gpio)
gpiochip_remove(&gpio->ports[m].gc); gpiochip_remove(&gpio->ports[m].gc);
} }
static struct dwapb_platform_data * static void dwapb_get_irq(struct device *dev, struct fwnode_handle *fwnode,
dwapb_gpio_get_pdata(struct device *dev) struct dwapb_port_property *pp)
{
struct device_node *np = NULL;
int j;
if (fwnode_property_read_bool(fwnode, "interrupt-controller"))
np = to_of_node(fwnode);
for (j = 0; j < pp->ngpio; j++) {
pp->irq[j] = -ENXIO;
if (np)
pp->irq[j] = of_irq_get(np, j);
else if (has_acpi_companion(dev))
pp->irq[j] = platform_get_irq(to_platform_device(dev), j);
if (pp->irq[j] >= 0)
pp->has_irq = true;
}
if (!pp->has_irq)
dev_warn(dev, "no irq for port%d\n", pp->idx);
}
static struct dwapb_platform_data *dwapb_gpio_get_pdata(struct device *dev)
{ {
struct fwnode_handle *fwnode; struct fwnode_handle *fwnode;
struct dwapb_platform_data *pdata; struct dwapb_platform_data *pdata;
struct dwapb_port_property *pp; struct dwapb_port_property *pp;
int nports; int nports;
int i, j; int i;
nports = device_get_child_node_count(dev); nports = device_get_child_node_count(dev);
if (nports == 0) if (nports == 0)
...@@ -553,8 +577,6 @@ dwapb_gpio_get_pdata(struct device *dev) ...@@ -553,8 +577,6 @@ dwapb_gpio_get_pdata(struct device *dev)
i = 0; i = 0;
device_for_each_child_node(dev, fwnode) { device_for_each_child_node(dev, fwnode) {
struct device_node *np = NULL;
pp = &pdata->properties[i++]; pp = &pdata->properties[i++];
pp->fwnode = fwnode; pp->fwnode = fwnode;
...@@ -581,28 +603,8 @@ dwapb_gpio_get_pdata(struct device *dev) ...@@ -581,28 +603,8 @@ dwapb_gpio_get_pdata(struct device *dev)
* Only port A can provide interrupts in all configurations of * Only port A can provide interrupts in all configurations of
* the IP. * the IP.
*/ */
if (pp->idx != 0) if (pp->idx == 0)
continue; dwapb_get_irq(dev, fwnode, pp);
if (dev->of_node && fwnode_property_read_bool(fwnode,
"interrupt-controller")) {
np = to_of_node(fwnode);
}
for (j = 0; j < pp->ngpio; j++) {
pp->irq[j] = -ENXIO;
if (np)
pp->irq[j] = of_irq_get(np, j);
else if (has_acpi_companion(dev))
pp->irq[j] = platform_get_irq(to_platform_device(dev), j);
if (pp->irq[j] >= 0)
pp->has_irq = true;
}
if (!pp->has_irq)
dev_warn(dev, "no irq for port%d\n", pp->idx);
} }
return pdata; return pdata;
......
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