media: hantro: add fallback handling for single irq/clk
Currently the driver expects that each irq/clk will have a name specified. A valid point was raised by the DT maintainers - when there is a single interrupt line or clock - the names are not needed. Keep the names within the drivers themselves, but don't use them when only a single entry exists. Instead use: - num_clk == 1 - devm_clk_get(..., NULL) - num_irq == 1 - platform_get_irq(..., 0) Suggested-by: Ezequiel Garcia <ezequiel@collabora.com> Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
parent
bbc42ab0da
commit
18d6c8b7b4
@ -763,12 +763,23 @@ static int hantro_probe(struct platform_device *pdev)
|
||||
if (!vpu->clocks)
|
||||
return -ENOMEM;
|
||||
|
||||
for (i = 0; i < vpu->variant->num_clocks; i++)
|
||||
vpu->clocks[i].id = vpu->variant->clk_names[i];
|
||||
ret = devm_clk_bulk_get(&pdev->dev, vpu->variant->num_clocks,
|
||||
vpu->clocks);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (vpu->variant->num_clocks > 1) {
|
||||
for (i = 0; i < vpu->variant->num_clocks; i++)
|
||||
vpu->clocks[i].id = vpu->variant->clk_names[i];
|
||||
|
||||
ret = devm_clk_bulk_get(&pdev->dev, vpu->variant->num_clocks,
|
||||
vpu->clocks);
|
||||
if (ret)
|
||||
return ret;
|
||||
} else {
|
||||
/*
|
||||
* If the driver has a single clk, chances are there will be no
|
||||
* actual name in the DT bindings.
|
||||
*/
|
||||
vpu->clocks[0].clk = devm_clk_get(&pdev->dev, NULL);
|
||||
if (IS_ERR(vpu->clocks))
|
||||
return PTR_ERR(vpu->clocks);
|
||||
}
|
||||
|
||||
num_bases = vpu->variant->num_regs ?: 1;
|
||||
vpu->reg_bases = devm_kcalloc(&pdev->dev, num_bases,
|
||||
@ -796,13 +807,23 @@ static int hantro_probe(struct platform_device *pdev)
|
||||
vb2_dma_contig_set_max_seg_size(&pdev->dev, DMA_BIT_MASK(32));
|
||||
|
||||
for (i = 0; i < vpu->variant->num_irqs; i++) {
|
||||
const char *irq_name = vpu->variant->irqs[i].name;
|
||||
const char *irq_name;
|
||||
int irq;
|
||||
|
||||
if (!vpu->variant->irqs[i].handler)
|
||||
continue;
|
||||
|
||||
irq = platform_get_irq_byname(vpu->pdev, irq_name);
|
||||
if (vpu->variant->num_clocks > 1) {
|
||||
irq_name = vpu->variant->irqs[i].name;
|
||||
irq = platform_get_irq_byname(vpu->pdev, irq_name);
|
||||
} else {
|
||||
/*
|
||||
* If the driver has a single IRQ, chances are there
|
||||
* will be no actual name in the DT bindings.
|
||||
*/
|
||||
irq_name = "default";
|
||||
irq = platform_get_irq(vpu->pdev, 0);
|
||||
}
|
||||
if (irq <= 0)
|
||||
return -ENXIO;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user