Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpiolib: Use IRQ hardware number getter instead of direct access

IRQ framework provides special type and getter to transform
the Linux IRQ to the hardware pin. Use that type and getter
function instead of direct access.

While at it, amend an indentation in a couple of places.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

authored by

Andy Shevchenko and committed by
Bartosz Golaszewski
db4064cc c122f461

+18 -11
+18 -11
drivers/gpio/gpiolib.c
··· 1218 1218 if (ret) 1219 1219 return ret; 1220 1220 1221 - chip_dbg(gc, "allocate IRQ %d, hwirq %lu\n", irq, hwirq); 1221 + chip_dbg(gc, "allocate IRQ %d, hwirq %lu\n", irq, hwirq); 1222 1222 1223 1223 ret = girq->child_to_parent_hwirq(gc, hwirq, type, 1224 1224 &parent_hwirq, &parent_type); ··· 1386 1386 * gpiochip by assigning the gpiochip as chip data, and using the irqchip 1387 1387 * stored inside the gpiochip. 1388 1388 */ 1389 - int gpiochip_irq_map(struct irq_domain *d, unsigned int irq, 1390 - irq_hw_number_t hwirq) 1389 + int gpiochip_irq_map(struct irq_domain *d, unsigned int irq, irq_hw_number_t hwirq) 1391 1390 { 1392 1391 struct gpio_chip *gc = d->host_data; 1393 1392 int ret = 0; ··· 1462 1463 struct irq_data *data, bool reserve) 1463 1464 { 1464 1465 struct gpio_chip *gc = domain->host_data; 1466 + unsigned int hwirq = irqd_to_hwirq(data); 1465 1467 1466 - return gpiochip_lock_as_irq(gc, data->hwirq); 1468 + return gpiochip_lock_as_irq(gc, hwirq); 1467 1469 } 1468 1470 EXPORT_SYMBOL_GPL(gpiochip_irq_domain_activate); 1469 1471 ··· 1481 1481 struct irq_data *data) 1482 1482 { 1483 1483 struct gpio_chip *gc = domain->host_data; 1484 + unsigned int hwirq = irqd_to_hwirq(data); 1484 1485 1485 - return gpiochip_unlock_as_irq(gc, data->hwirq); 1486 + return gpiochip_unlock_as_irq(gc, hwirq); 1486 1487 } 1487 1488 EXPORT_SYMBOL_GPL(gpiochip_irq_domain_deactivate); 1488 1489 ··· 1523 1522 int gpiochip_irq_reqres(struct irq_data *d) 1524 1523 { 1525 1524 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 1525 + unsigned int hwirq = irqd_to_hwirq(d); 1526 1526 1527 - return gpiochip_reqres_irq(gc, d->hwirq); 1527 + return gpiochip_reqres_irq(gc, hwirq); 1528 1528 } 1529 1529 EXPORT_SYMBOL(gpiochip_irq_reqres); 1530 1530 1531 1531 void gpiochip_irq_relres(struct irq_data *d) 1532 1532 { 1533 1533 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 1534 + unsigned int hwirq = irqd_to_hwirq(d); 1534 1535 1535 - gpiochip_relres_irq(gc, d->hwirq); 1536 + gpiochip_relres_irq(gc, hwirq); 1536 1537 } 1537 1538 EXPORT_SYMBOL(gpiochip_irq_relres); 1538 1539 1539 1540 static void gpiochip_irq_mask(struct irq_data *d) 1540 1541 { 1541 1542 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 1543 + unsigned int hwirq = irqd_to_hwirq(d); 1542 1544 1543 1545 if (gc->irq.irq_mask) 1544 1546 gc->irq.irq_mask(d); 1545 - gpiochip_disable_irq(gc, d->hwirq); 1547 + gpiochip_disable_irq(gc, hwirq); 1546 1548 } 1547 1549 1548 1550 static void gpiochip_irq_unmask(struct irq_data *d) 1549 1551 { 1550 1552 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 1553 + unsigned int hwirq = irqd_to_hwirq(d); 1551 1554 1552 - gpiochip_enable_irq(gc, d->hwirq); 1555 + gpiochip_enable_irq(gc, hwirq); 1553 1556 if (gc->irq.irq_unmask) 1554 1557 gc->irq.irq_unmask(d); 1555 1558 } ··· 1561 1556 static void gpiochip_irq_enable(struct irq_data *d) 1562 1557 { 1563 1558 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 1559 + unsigned int hwirq = irqd_to_hwirq(d); 1564 1560 1565 - gpiochip_enable_irq(gc, d->hwirq); 1561 + gpiochip_enable_irq(gc, hwirq); 1566 1562 gc->irq.irq_enable(d); 1567 1563 } 1568 1564 1569 1565 static void gpiochip_irq_disable(struct irq_data *d) 1570 1566 { 1571 1567 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 1568 + unsigned int hwirq = irqd_to_hwirq(d); 1572 1569 1573 1570 gc->irq.irq_disable(d); 1574 - gpiochip_disable_irq(gc, d->hwirq); 1571 + gpiochip_disable_irq(gc, hwirq); 1575 1572 } 1576 1573 1577 1574 static void gpiochip_set_irq_hooks(struct gpio_chip *gc)