* [PATCH] media: hantro: fix compatible string deprecation warning
@ 2022-05-17 14:35 Martin Kepplinger
2022-05-17 16:46 ` Robin Murphy
0 siblings, 1 reply; 3+ messages in thread
From: Martin Kepplinger @ 2022-05-17 14:35 UTC (permalink / raw)
To: ezequiel, p.zabel, mchehab
Cc: linux-media, linux-rockchip, linux-staging, linux-kernel,
Martin Kepplinger
of_device_is_compatible() in the end uses strlen of the string
for comparison, so in this case, the condition is true even if
the requested string "nxp,imx8mq-vpu-g1" is being used. The first
chars containing "nxp,imx8mq-vpu" are the same.
Fix this by encoding what the comment says.
Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
---
This is more of a bugreport as the solution doesn't look very elegant
to me. I'm happy for advice.
thanks,
martin
drivers/staging/media/hantro/hantro_drv.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/media/hantro/hantro_drv.c b/drivers/staging/media/hantro/hantro_drv.c
index ac232b5f7825..014fab637df0 100644
--- a/drivers/staging/media/hantro/hantro_drv.c
+++ b/drivers/staging/media/hantro/hantro_drv.c
@@ -923,10 +923,11 @@ static int hantro_probe(struct platform_device *pdev)
/*
* Support for nxp,imx8mq-vpu is kept for backwards compatibility
- * but it's deprecated. Please update your DTS file to use
- * nxp,imx8mq-vpu-g1 or nxp,imx8mq-vpu-g2 instead.
+ * but it's deprecated.
*/
- if (of_device_is_compatible(pdev->dev.of_node, "nxp,imx8mq-vpu"))
+ if ((of_device_is_compatible(pdev->dev.of_node, "nxp,imx8mq-vpu")) &&
+ (!of_device_is_compatible(pdev->dev.of_node, "nxp,imx8mq-vpu-g1")) &&
+ (!of_device_is_compatible(pdev->dev.of_node, "nxp,imx8mq-vpu-g2")))
dev_warn(&pdev->dev, "%s compatible is deprecated\n",
match->compatible);
--
2.30.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] media: hantro: fix compatible string deprecation warning
2022-05-17 14:35 [PATCH] media: hantro: fix compatible string deprecation warning Martin Kepplinger
@ 2022-05-17 16:46 ` Robin Murphy
2022-06-09 8:47 ` Hans Verkuil
0 siblings, 1 reply; 3+ messages in thread
From: Robin Murphy @ 2022-05-17 16:46 UTC (permalink / raw)
To: Martin Kepplinger, ezequiel, p.zabel, mchehab
Cc: linux-media, linux-rockchip, linux-staging, linux-kernel
On 2022-05-17 15:35, Martin Kepplinger wrote:
> of_device_is_compatible() in the end uses strlen of the string
> for comparison, so in this case, the condition is true even if
> the requested string "nxp,imx8mq-vpu-g1" is being used. The first
> chars containing "nxp,imx8mq-vpu" are the same.
Have you seen this go wrong in practice? AFAICS, unless you're on SPARC,
which seems somewhat unlikely for an i.MX8 peripheral, of_compat_cmp()
should map to strcasecmp(), which should do the right thing :/
Robin.
> Fix this by encoding what the comment says.
>
> Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
> ---
>
> This is more of a bugreport as the solution doesn't look very elegant
> to me. I'm happy for advice.
>
> thanks,
> martin
>
>
> drivers/staging/media/hantro/hantro_drv.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/media/hantro/hantro_drv.c b/drivers/staging/media/hantro/hantro_drv.c
> index ac232b5f7825..014fab637df0 100644
> --- a/drivers/staging/media/hantro/hantro_drv.c
> +++ b/drivers/staging/media/hantro/hantro_drv.c
> @@ -923,10 +923,11 @@ static int hantro_probe(struct platform_device *pdev)
>
> /*
> * Support for nxp,imx8mq-vpu is kept for backwards compatibility
> - * but it's deprecated. Please update your DTS file to use
> - * nxp,imx8mq-vpu-g1 or nxp,imx8mq-vpu-g2 instead.
> + * but it's deprecated.
> */
> - if (of_device_is_compatible(pdev->dev.of_node, "nxp,imx8mq-vpu"))
> + if ((of_device_is_compatible(pdev->dev.of_node, "nxp,imx8mq-vpu")) &&
> + (!of_device_is_compatible(pdev->dev.of_node, "nxp,imx8mq-vpu-g1")) &&
> + (!of_device_is_compatible(pdev->dev.of_node, "nxp,imx8mq-vpu-g2")))
> dev_warn(&pdev->dev, "%s compatible is deprecated\n",
> match->compatible);
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] media: hantro: fix compatible string deprecation warning
2022-05-17 16:46 ` Robin Murphy
@ 2022-06-09 8:47 ` Hans Verkuil
0 siblings, 0 replies; 3+ messages in thread
From: Hans Verkuil @ 2022-06-09 8:47 UTC (permalink / raw)
To: Robin Murphy, Martin Kepplinger, ezequiel, p.zabel, mchehab
Cc: linux-media, linux-rockchip, linux-staging, linux-kernel
Hi Martin,
On 5/17/22 18:46, Robin Murphy wrote:
> On 2022-05-17 15:35, Martin Kepplinger wrote:
>> of_device_is_compatible() in the end uses strlen of the string
>> for comparison, so in this case, the condition is true even if
>> the requested string "nxp,imx8mq-vpu-g1" is being used. The first
>> chars containing "nxp,imx8mq-vpu" are the same.
>
> Have you seen this go wrong in practice? AFAICS, unless you're on SPARC, which seems somewhat unlikely for an i.MX8 peripheral, of_compat_cmp() should map to strcasecmp(), which should do the right thing :/
Robin is correct, the existing code is fine for all but SPARC, which
won't be using this driver.
I'm rejecting this patch.
Regards,
Hans
>
> Robin.
>
>> Fix this by encoding what the comment says.
>>
>> Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
>> ---
>>
>> This is more of a bugreport as the solution doesn't look very elegant
>> to me. I'm happy for advice.
>>
>> thanks,
>> martin
>>
>>
>> drivers/staging/media/hantro/hantro_drv.c | 7 ++++---
>> 1 file changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/staging/media/hantro/hantro_drv.c b/drivers/staging/media/hantro/hantro_drv.c
>> index ac232b5f7825..014fab637df0 100644
>> --- a/drivers/staging/media/hantro/hantro_drv.c
>> +++ b/drivers/staging/media/hantro/hantro_drv.c
>> @@ -923,10 +923,11 @@ static int hantro_probe(struct platform_device *pdev)
>> /*
>> * Support for nxp,imx8mq-vpu is kept for backwards compatibility
>> - * but it's deprecated. Please update your DTS file to use
>> - * nxp,imx8mq-vpu-g1 or nxp,imx8mq-vpu-g2 instead.
>> + * but it's deprecated.
>> */
>> - if (of_device_is_compatible(pdev->dev.of_node, "nxp,imx8mq-vpu"))
>> + if ((of_device_is_compatible(pdev->dev.of_node, "nxp,imx8mq-vpu")) &&
>> + (!of_device_is_compatible(pdev->dev.of_node, "nxp,imx8mq-vpu-g1")) &&
>> + (!of_device_is_compatible(pdev->dev.of_node, "nxp,imx8mq-vpu-g2")))
>> dev_warn(&pdev->dev, "%s compatible is deprecated\n",
>> match->compatible);
>>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-06-09 8:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-17 14:35 [PATCH] media: hantro: fix compatible string deprecation warning Martin Kepplinger
2022-05-17 16:46 ` Robin Murphy
2022-06-09 8:47 ` Hans Verkuil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).