Skip to content

Commit aab799e

Browse files
prabhakarladwsakernel
authored andcommitted
i2c: sh_mobile: Use platform_get_irq_optional() to get the interrupt
platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static allocation of IRQ resources in DT core code, this causes an issue when using hierarchical interrupt domains using "interrupts" property in the node as this bypasses the hierarchical setup and messes up the irq chaining. In preparation for removal of static setup of IRQ resource from DT core code use platform_get_irq_optional() for DT users only. Signed-off-by: Lad Prabhakar <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Reviewed-by: Wolfram Sang <[email protected]> Tested-by: Wolfram Sang <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent c3b2f91 commit aab799e

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

drivers/i2c/busses/i2c-sh_mobile.c

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -830,20 +830,38 @@ static void sh_mobile_i2c_release_dma(struct sh_mobile_i2c_data *pd)
830830

831831
static int sh_mobile_i2c_hook_irqs(struct platform_device *dev, struct sh_mobile_i2c_data *pd)
832832
{
833-
struct resource *res;
834-
resource_size_t n;
833+
struct device_node *np = dev_of_node(&dev->dev);
835834
int k = 0, ret;
836835

837-
while ((res = platform_get_resource(dev, IORESOURCE_IRQ, k))) {
838-
for (n = res->start; n <= res->end; n++) {
839-
ret = devm_request_irq(&dev->dev, n, sh_mobile_i2c_isr,
840-
0, dev_name(&dev->dev), pd);
836+
if (np) {
837+
int irq;
838+
839+
while ((irq = platform_get_irq_optional(dev, k)) != -ENXIO) {
840+
if (irq < 0)
841+
return irq;
842+
ret = devm_request_irq(&dev->dev, irq, sh_mobile_i2c_isr,
843+
0, dev_name(&dev->dev), pd);
841844
if (ret) {
842-
dev_err(&dev->dev, "cannot request IRQ %pa\n", &n);
845+
dev_err(&dev->dev, "cannot request IRQ %d\n", irq);
843846
return ret;
844847
}
848+
k++;
849+
};
850+
} else {
851+
struct resource *res;
852+
resource_size_t n;
853+
854+
while ((res = platform_get_resource(dev, IORESOURCE_IRQ, k))) {
855+
for (n = res->start; n <= res->end; n++) {
856+
ret = devm_request_irq(&dev->dev, n, sh_mobile_i2c_isr,
857+
0, dev_name(&dev->dev), pd);
858+
if (ret) {
859+
dev_err(&dev->dev, "cannot request IRQ %pa\n", &n);
860+
return ret;
861+
}
862+
}
863+
k++;
845864
}
846-
k++;
847865
}
848866

849867
return k > 0 ? 0 : -ENOENT;

0 commit comments

Comments
 (0)