* [PATCH] media: v4l2-common: Always register clock with device-specific name
@ 2026-03-27 17:52 Paul Cercueil
2026-03-27 18:06 ` Laurent Pinchart
0 siblings, 1 reply; 3+ messages in thread
From: Paul Cercueil @ 2026-03-27 17:52 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Mehdi Djait, Laurent Pinchart, linux-media, linux-kernel,
Paul Cercueil
If we need to register a dummy fixed-frequency clock, always register it
using a device-specific name.
This supports the use case where a system has two of the same sensor,
meaning two instances of the same driver, which previously both tried
(and failed) to create a clock with the same name.
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
drivers/media/v4l2-core/v4l2-common.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
index 554c591e1113..5f3295c3122a 100644
--- a/drivers/media/v4l2-core/v4l2-common.c
+++ b/drivers/media/v4l2-core/v4l2-common.c
@@ -792,14 +792,11 @@ struct clk *__devm_v4l2_sensor_clk_get(struct device *dev, const char *id,
if (ret)
return ERR_PTR(ret == -EINVAL ? -EPROBE_DEFER : ret);
- if (!id) {
- clk_id = kasprintf(GFP_KERNEL, "clk-%s", dev_name(dev));
- if (!clk_id)
- return ERR_PTR(-ENOMEM);
- id = clk_id;
- }
+ clk_id = kasprintf(GFP_KERNEL, "clk-%s", dev_name(dev));
+ if (!clk_id)
+ return ERR_PTR(-ENOMEM);
- clk_hw = devm_clk_hw_register_fixed_rate(dev, id, NULL, 0, rate);
+ clk_hw = devm_clk_hw_register_fixed_rate(dev, clk_id, NULL, 0, rate);
if (IS_ERR(clk_hw))
return ERR_CAST(clk_hw);
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] media: v4l2-common: Always register clock with device-specific name
2026-03-27 17:52 [PATCH] media: v4l2-common: Always register clock with device-specific name Paul Cercueil
@ 2026-03-27 18:06 ` Laurent Pinchart
2026-03-27 19:52 ` Paul Cercueil
0 siblings, 1 reply; 3+ messages in thread
From: Laurent Pinchart @ 2026-03-27 18:06 UTC (permalink / raw)
To: Paul Cercueil
Cc: Mauro Carvalho Chehab, Mehdi Djait, linux-media, linux-kernel
On Fri, Mar 27, 2026 at 06:52:12PM +0100, Paul Cercueil wrote:
> If we need to register a dummy fixed-frequency clock, always register it
> using a device-specific name.
>
> This supports the use case where a system has two of the same sensor,
> meaning two instances of the same driver, which previously both tried
> (and failed) to create a clock with the same name.
>
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> ---
> drivers/media/v4l2-core/v4l2-common.c | 11 ++++-------
> 1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
> index 554c591e1113..5f3295c3122a 100644
> --- a/drivers/media/v4l2-core/v4l2-common.c
> +++ b/drivers/media/v4l2-core/v4l2-common.c
> @@ -792,14 +792,11 @@ struct clk *__devm_v4l2_sensor_clk_get(struct device *dev, const char *id,
> if (ret)
> return ERR_PTR(ret == -EINVAL ? -EPROBE_DEFER : ret);
>
> - if (!id) {
> - clk_id = kasprintf(GFP_KERNEL, "clk-%s", dev_name(dev));
> - if (!clk_id)
> - return ERR_PTR(-ENOMEM);
> - id = clk_id;
> - }
> + clk_id = kasprintf(GFP_KERNEL, "clk-%s", dev_name(dev));
This will now fail if the same device needs to register two clocks. You
need to include the id in the name. Maybe something like
clk_id = kasprintf(GFP_KERNEL, "clk-%s-%s", dev_name(dev), id);
> + if (!clk_id)
> + return ERR_PTR(-ENOMEM);
>
> - clk_hw = devm_clk_hw_register_fixed_rate(dev, id, NULL, 0, rate);
> + clk_hw = devm_clk_hw_register_fixed_rate(dev, clk_id, NULL, 0, rate);
> if (IS_ERR(clk_hw))
> return ERR_CAST(clk_hw);
>
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] media: v4l2-common: Always register clock with device-specific name
2026-03-27 18:06 ` Laurent Pinchart
@ 2026-03-27 19:52 ` Paul Cercueil
0 siblings, 0 replies; 3+ messages in thread
From: Paul Cercueil @ 2026-03-27 19:52 UTC (permalink / raw)
To: Laurent Pinchart
Cc: Mauro Carvalho Chehab, Mehdi Djait, linux-media, linux-kernel
Hi Laurent,
Le vendredi 27 mars 2026 à 20:06 +0200, Laurent Pinchart a écrit :
> On Fri, Mar 27, 2026 at 06:52:12PM +0100, Paul Cercueil wrote:
> > If we need to register a dummy fixed-frequency clock, always
> > register it
> > using a device-specific name.
> >
> > This supports the use case where a system has two of the same
> > sensor,
> > meaning two instances of the same driver, which previously both
> > tried
> > (and failed) to create a clock with the same name.
> >
> > Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> > ---
> > drivers/media/v4l2-core/v4l2-common.c | 11 ++++-------
> > 1 file changed, 4 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/media/v4l2-core/v4l2-common.c
> > b/drivers/media/v4l2-core/v4l2-common.c
> > index 554c591e1113..5f3295c3122a 100644
> > --- a/drivers/media/v4l2-core/v4l2-common.c
> > +++ b/drivers/media/v4l2-core/v4l2-common.c
> > @@ -792,14 +792,11 @@ struct clk *__devm_v4l2_sensor_clk_get(struct
> > device *dev, const char *id,
> > if (ret)
> > return ERR_PTR(ret == -EINVAL ? -EPROBE_DEFER :
> > ret);
> >
> > - if (!id) {
> > - clk_id = kasprintf(GFP_KERNEL, "clk-%s",
> > dev_name(dev));
> > - if (!clk_id)
> > - return ERR_PTR(-ENOMEM);
> > - id = clk_id;
> > - }
> > + clk_id = kasprintf(GFP_KERNEL, "clk-%s", dev_name(dev));
>
> This will now fail if the same device needs to register two clocks.
> You
> need to include the id in the name. Maybe something like
>
> clk_id = kasprintf(GFP_KERNEL, "clk-%s-%s", dev_name(dev),
> id);
Ha, good point. I'll v2.
Cheers,
-Paul
>
> > + if (!clk_id)
> > + return ERR_PTR(-ENOMEM);
> >
> > - clk_hw = devm_clk_hw_register_fixed_rate(dev, id, NULL, 0,
> > rate);
> > + clk_hw = devm_clk_hw_register_fixed_rate(dev, clk_id,
> > NULL, 0, rate);
> > if (IS_ERR(clk_hw))
> > return ERR_CAST(clk_hw);
> >
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-27 19:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-27 17:52 [PATCH] media: v4l2-common: Always register clock with device-specific name Paul Cercueil
2026-03-27 18:06 ` Laurent Pinchart
2026-03-27 19:52 ` Paul Cercueil
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.