media: hantro: Fix check for single irq
Subsystems (3)
PATCH 1/1 media: hantro: Fix check for single irq
Some cores use only one interrupt and in such case interrupt name in DT is not needed. Driver supposedly accounted that, but due to the wrong field check it never worked. Fix that.
--- drivers/staging/media/hantro/hantro_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/hantro/hantro_drv.c +1 -1
@@ -919,7 +919,7 @@ static int hantro_probe(struct platform_device *pdev)if (!vpu->variant->irqs[i].handler)continue ; -if (vpu->variant->num_clocks >1 ) { +if (vpu->variant->num_irqs >1 ) { irq_name = vpu->variant->irqs[i].name; irq =platform_get_irq_byname (vpu->pdev, irq_name); }else {
Signature · 1 line
2.32.0
Hi Jernej,
Quoted 17 lines · Jernej Skrabec
Some cores use only one interrupt and in such case interrupt name in DT is not needed. Driver supposedly accounted that, but due to the wrong field check it never worked. Fix that.
Fixes 18d6c8b7b4c9 ("media: hantro: add fallback handling for single irq/clk")Signed-off-by Jernej Skrabec <[email protected]>---
drivers/staging/media/hantro/hantro_drv.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/media/hantro/hantro_drv.c +0
-0@@ -919,7 +919,7 @@ static int hantro_probe(struct platform_device *pdev) if (!vpu->variant->irqs[i].handler) continue;
Quoted 3 lines
- if (vpu->variant->num_clocks> 1) { + if (vpu->variant->num_irqs> 1) {
Oops, thanks for spotting this.
How about this instead?
drivers/staging/media/hantro/hantro_drv.c +6 -7
@@ -918,16 +918,15 @@ static int hantro_probe(struct platform_device *pdev)if (!vpu->variant->irqs[i].handler)continue ; -if (vpu->variant->num_clocks >1 ) { - irq_name = vpu->variant->irqs[i].name; - irq =platform_get_irq_byname (vpu->pdev, irq_name); - }else { + irq_name = vpu->variant->irqs[i].name; + irq =platform_get_irq_byname (vpu->pdev, irq_name); +if (irq <=0 ) {/* -* If the driver has a single IRQ, chances are there -* will be no actual name in the DT bindings. +* Missing interrupt-names property in device tree, +* looking up interrupts by index. */ irq_name ="default" ; - irq =platform_get_irq (vpu->pdev,0 ); + irq =platform_get_irq (vpu->pdev, i); }if (irq <=0 )return -ENXIO ;
Signature · 2 lines
Kindly, Ezequiel
Dne petek, 06. avgust 2021 ob 00:03:36 CEST je Ezequiel Garcia napisal(a):
Quoted 22 lines
Hi Jernej,
Quoted 19 lines · Jernej Skrabec
Some cores use only one interrupt and in such case interrupt name in DT is not needed. Driver supposedly accounted that, but due to the wrong field check it never worked. Fix that.
Fixes 18d6c8b7b4c9 ("media: hantro: add fallback handling for singleirq/clk") Signed-off-by: Jernej Skrabec <[email protected]>
--- drivers/staging/media/hantro/hantro_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/staging/media/hantro/hantro_drv.cindex8a2edd67f2c6..20e508158871100644drivers/staging/media/hantro/hantro_drv.c +0
-0@@ -919,7 +919,7 @@ static int hantro_probe(struct platform_device *pdev)if (!vpu->variant->irqs[i].handler)continue ;
Quoted 6 lines
drivers/staging/media/hantro/hantro_drv.c static int hantro_probe(struct platform_device *pdev) · line 922
Quoted 2 lines
drivers/staging/media/hantro/hantro_drv.c +1
-1-if (vpu->variant->num_clocks >1 ) { +if (vpu->variant->num_irqs >1 ) {Oops, thanks for spotting this.
How about this instead?
No, original solution is more robust. With solution below, you're assuming that irq order in driver array is same as in DT. That doesn't matter if there is only one name or if names match. However, if there is a typo, either in DT node or in driver, driver will still happily assign clock based on index and that might not be correct one. Even if it works out, you can easily miss that you have a typo. Driver doesn't tell you which irq is used, if it is successfully acquired.
Best regards,
Jernej
Quoted 29 lines
(quoted diff) +0
-0
b/drivers/staging/media/hantro/hantro_drv.cindex31d8449ca1d2..af7054b04155100644drivers/staging/media/hantro/hantro_drv.c +4
-7@@ -918,16 +918,15 @@ static int hantro_probe(struct platform_device *pdev)if (!vpu->variant->irqs[i].handler)continue ; -if (vpu->variant->num_clocks >1 ) { - irq_name = vpu->variant->irqs[i].name; - irq =platform_get_irq_byname (vpu->pdev, irq_name); - }else { + irq_name = vpu->variant->irqs[i].name; + irq =platform_get_irq_byname (vpu->pdev, irq_name); +if (irq <=0 ) {/* -* If the driver has a single IRQ, chances are there -* will be no actual name in the DT bindings. + * Missing interrupt-names property in device tree, + * looking up interrupts by index. */ irq_name ="default" ; - irq =platform_get_irq (vpu->pdev,0 ); + irq =platform_get_irq (vpu->pdev, i); }if (irq <=0 )return -ENXIO ;
Ezequiel Garcia
Reviewed-byQuoted 30 lines · Jernej Škrabec
Dne petek, 06. avgust 2021 ob 00:03:36 CEST je Ezequiel Garcia napisal(a):
Quoted 27 lines
Hi Jernej,
Quoted 18 lines · Jernej Skrabec
Some cores use only one interrupt and in such case interrupt name in DT is not needed. Driver supposedly accounted that, but due to the wrong field check it never worked. Fix that.
Fixes 18d6c8b7b4c9 ("media: hantro: add fallback handling for singleirq/clk") Signed-off-by: Jernej Skrabec <[email protected]>
---
drivers/staging/media/hantro/hantro_drv.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/staging/media/hantro/hantro_drv.cindex8a2edd67f2c6..20e508158871100644drivers/staging/media/hantro/hantro_drv.c +0
-0@@ -919,7 +919,7 @@ static int hantro_probe(struct platform_device *pdev) if (!vpu->variant->irqs[i].handler) continue;Quoted 3 lines
- if (vpu->variant->num_clocks> 1) { + if (vpu->variant->num_irqs> 1) {Oops, thanks for spotting this.
Quoted 1 line
How about this instead?
Quoted 8 lines
No, original solution is more robust. With solution below, you're assuming that irq order in driver array is same as in DT. That doesn't matter if there is only one name or if names match. However, if there is a typo, either in DT node or in driver, driver will still happily assign clock based on index and that might not be correct one. Even if it works out, you can easily miss that you have a typo. Driver doesn't tell you which irq is used, if it is successfully acquired.
I find it odd to iterate up to num_irqs but then
have a case for num_irqs == 1, and callplatform_get_irq(vpu->pdev, 0).
But OTOH, your fix is correct and it's a oneliner.
Thanks,
Ezequiel
Dne petek, 06. avgust 2021 ob 16:13:46 CEST je Ezequiel Garcia napisal(a):
Quoted 41 lines · Jernej Škrabec
Quoted 32 lines
Dne petek, 06. avgust 2021 ob 00:03:36 CEST je Ezequiel Garcia napisal(a):
Quoted 24 lines
Hi Jernej,
Quoted 21 lines · Jernej Skrabec
Some cores use only one interrupt and in such case interrupt name in DT
is not needed. Driver supposedly accounted that, but due to the wrong field check it never worked. Fix that.Fixes 18d6c8b7b4c9 ("media: hantro: add fallback handling for singleirq/clk") Signed-off-by: Jernej Skrabec <[email protected]>
--- drivers/staging/media/hantro/hantro_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/staging/media/hantro/hantro_drv.cindex8a2edd67f2c6..20e508158871100644drivers/staging/media/hantro/hantro_drv.c +0
-0@@ -919,7 +919,7 @@ static int hantro_probe(struct platform_device *pdev)if (!vpu->variant->irqs[i].handler)continue ;Quoted 6 lines
drivers/staging/media/hantro/hantro_drv.c static int hantro_probe(struct platform_device · line 923
Quoted 2 lines
drivers/staging/media/hantro/hantro_drv.c +1
-1-if (vpu->variant->num_clocks >1 ) { +if (vpu->variant->num_irqs >1 ) {Oops, thanks for spotting this.
How about this instead?
Quoted 7 lines
No, original solution is more robust. With solution below, you're assuming that irq order in driver array is same as in DT. That doesn't matter if there is only one name or if names match. However, if there is a typo, either in DT node or in driver, driver will still happily assign clock based on index and that might not be correct one. Even if it works out, you can easily miss that you have a typo. Driver doesn't tell you which irq is used, if it is successfully acquired.
Quoted 3 lines
I find it odd to iterate up to
num_irqsbut then
have a case fornum_irqs== 1, and callplatform_get_irq(vpu->pdev, 0).
True, it was also strange for me at first, but then it's robust and simple. Because of that, I just fixed obvious issue.
Quoted 5 lines
But OTOH, your fix is correct and it's a oneliner.
Reviewed-by Ezequiel Garcia <[email protected]>
Thanks!
Best regards,
Jernej
Quoted 2 lines
Thanks,
Ezequiel
Quoted 6 lines · Jernej Skrabec
Some cores use only one interrupt and in such case interrupt name in DT is not needed. Driver supposedly accounted that, but due to the wrong field check it never worked. Fix that.
Fixes 18d6c8b7b4c9 ("media: hantro: add fallback handling for single irq/clk")Signed-off-by Jernej Skrabec <[email protected]>
D'oh thanks for catching that. This commit is:
-Emil