* [PATCH 5/7] media: meson-ir-tx: Ensure clock is disabled on unbind
[not found] <cover.1783673420.git.sean@mess.org>
@ 2026-07-10 8:53 ` Sean Young
2026-07-10 9:05 ` sashiko-bot
2026-07-12 13:26 ` Martin Blumenstingl
2026-07-10 8:53 ` [PATCH 6/7] media: meson-ir-tx: Ensure rc_free_device() is called " Sean Young
1 sibling, 2 replies; 5+ messages in thread
From: Sean Young @ 2026-07-10 8:53 UTC (permalink / raw)
To: linux-media, Sean Young, Mauro Carvalho Chehab, Neil Armstrong,
Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Viktor Prutyanov
Cc: Mauro Carvalho Chehab, linux-arm-kernel, linux-amlogic,
linux-kernel
clk_prepare_enabled() needs a call to clk_disable_prepare() on
driver unbind. Make it devm managed.
Fixes: 49be1c78d575 ("media: rc: introduce Meson IR TX driver")
Signed-off-by: Sean Young <sean@mess.org>
---
drivers/media/rc/meson-ir-tx.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/rc/meson-ir-tx.c b/drivers/media/rc/meson-ir-tx.c
index fded2c256f2a..e7bb107e6a84 100644
--- a/drivers/media/rc/meson-ir-tx.c
+++ b/drivers/media/rc/meson-ir-tx.c
@@ -288,8 +288,8 @@ static int meson_irtx_mod_clock_probe(struct meson_irtx *ir,
if (!np)
return -ENODEV;
- clock = devm_clk_get(ir->dev, "xtal");
- if (IS_ERR(clock) || clk_prepare_enable(clock))
+ clock = devm_clk_get_enabled(ir->dev, "xtal");
+ if (IS_ERR(clock))
return -ENODEV;
*clk_nr = IRB_MOD_XTAL3_CLK;
--
2.55.0
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 6/7] media: meson-ir-tx: Ensure rc_free_device() is called on unbind
[not found] <cover.1783673420.git.sean@mess.org>
2026-07-10 8:53 ` [PATCH 5/7] media: meson-ir-tx: Ensure clock is disabled on unbind Sean Young
@ 2026-07-10 8:53 ` Sean Young
2026-07-12 13:23 ` Martin Blumenstingl
1 sibling, 1 reply; 5+ messages in thread
From: Sean Young @ 2026-07-10 8:53 UTC (permalink / raw)
To: linux-media, Sean Young, Mauro Carvalho Chehab, Neil Armstrong,
Kevin Hilman, Jerome Brunet, Martin Blumenstingl, Patrice Chotard,
Hans Verkuil
Cc: linux-arm-kernel, linux-amlogic, linux-kernel
Make rc_dev devm managed.
Fixes: dccc0c3ddf8f ("media: rc: fix race between unregister and urb/irq callbacks")
Signed-off-by: Sean Young <sean@mess.org>
---
drivers/media/rc/meson-ir-tx.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/media/rc/meson-ir-tx.c b/drivers/media/rc/meson-ir-tx.c
index e7bb107e6a84..abb107d19e8c 100644
--- a/drivers/media/rc/meson-ir-tx.c
+++ b/drivers/media/rc/meson-ir-tx.c
@@ -345,7 +345,7 @@ static int meson_irtx_probe(struct platform_device *pdev)
if (ret)
return dev_err_probe(dev, ret, "irq request failed\n");
- rc = rc_allocate_device(RC_DRIVER_IR_RAW_TX);
+ rc = devm_rc_allocate_device(dev, RC_DRIVER_IR_RAW_TX);
if (!rc)
return -ENOMEM;
@@ -358,10 +358,8 @@ static int meson_irtx_probe(struct platform_device *pdev)
rc->s_tx_duty_cycle = meson_irtx_set_duty_cycle;
ret = devm_rc_register_device(dev, rc);
- if (ret < 0) {
- rc_free_device(rc);
+ if (ret < 0)
return dev_err_probe(dev, ret, "rc_dev registration failed\n");
- }
return 0;
}
--
2.55.0
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 5/7] media: meson-ir-tx: Ensure clock is disabled on unbind
2026-07-10 8:53 ` [PATCH 5/7] media: meson-ir-tx: Ensure clock is disabled on unbind Sean Young
@ 2026-07-10 9:05 ` sashiko-bot
2026-07-12 13:26 ` Martin Blumenstingl
1 sibling, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-07-10 9:05 UTC (permalink / raw)
To: Sean Young; +Cc: linux-amlogic, neil.armstrong
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [Low] The commit message refers to non-existent clock API functions.
Pre-existing issues:
- [High] The driver masks `-EPROBE_DEFER` and other error codes by unconditionally returning `-ENODEV` when `devm_clk_get_enabled()` or `platform_get_irq()` fails, breaking probe deferral.
- [High] The `rc_dev` structure allocated during probe is permanently leaked on driver unbind due to the use of `rc_allocate_device()` without ensuring a corresponding `rc_free_device()` call.
--
--- Patch [5]: [PATCH 5/7] media: meson-ir-tx: Ensure clock is disabled on unbind ---
commit e95895078113495fea5b981fafe002c5ff1f56c1
Author: Sean Young <sean@mess.org>
media: meson-ir-tx: Ensure clock is disabled on unbind
This patch changes the clock acquisition in the meson-ir-tx driver to use
the devres managed devm_clk_get_enabled(). This ensures the clock is
automatically disabled and unprepared when the driver unbinds.
> clk_prepare_enabled() needs a call to clk_disable_prepare() on
> driver unbind. Make it devm managed.
[Severity: Low]
This isn't a bug, but there are typos in the function names mentioned here.
Should they be clk_prepare_enable() and clk_disable_unprepare() instead?
> diff --git a/drivers/media/rc/meson-ir-tx.c b/drivers/media/rc/meson-ir-tx.c
> index fded2c256f2a6..e7bb107e6a843 100644
> --- a/drivers/media/rc/meson-ir-tx.c
> +++ b/drivers/media/rc/meson-ir-tx.c
> @@ -288,8 +288,8 @@ static int meson_irtx_mod_clock_probe(struct meson_irtx *ir,
> if (!np)
> return -ENODEV;
>
> - clock = devm_clk_get(ir->dev, "xtal");
> - if (IS_ERR(clock) || clk_prepare_enable(clock))
> + clock = devm_clk_get_enabled(ir->dev, "xtal");
> + if (IS_ERR(clock))
> return -ENODEV;
[Severity: High]
This is a pre-existing issue, but does this incorrectly mask -EPROBE_DEFER?
If devm_clk_get_enabled() returns -EPROBE_DEFER, returning a hardcoded
-ENODEV will permanently fail the probe instead of allowing it to defer.
Would it be better to return PTR_ERR(clock) here?
The same issue appears to happen with platform_get_irq() in
meson_irtx_probe():
drivers/media/rc/meson-ir-tx.c:meson_irtx_probe() {
...
irq = platform_get_irq(pdev, 0);
if (irq < 0)
return -ENODEV;
...
}
Would it be better to propagate these error codes directly?
[Severity: High]
This is another pre-existing issue, but does this driver permanently leak
the rc_dev structure on unbind?
The driver allocates the structure manually in meson_irtx_probe():
drivers/media/rc/meson-ir-tx.c:meson_irtx_probe() {
...
rc = rc_allocate_device(RC_DRIVER_IR_RAW_TX);
...
ret = devm_rc_register_device(dev, rc);
...
}
Since devm_rc_register_device() only ties rc_unregister_device() to the
devres cleanup, and there is no matching rc_free_device() call or use of
devm_rc_allocate_device(), does the initial reference count remain
un-dropped when the driver is unbound?
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1783673420.git.sean@mess.org?part=5
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 6/7] media: meson-ir-tx: Ensure rc_free_device() is called on unbind
2026-07-10 8:53 ` [PATCH 6/7] media: meson-ir-tx: Ensure rc_free_device() is called " Sean Young
@ 2026-07-12 13:23 ` Martin Blumenstingl
0 siblings, 0 replies; 5+ messages in thread
From: Martin Blumenstingl @ 2026-07-12 13:23 UTC (permalink / raw)
To: Sean Young
Cc: linux-media, Mauro Carvalho Chehab, Neil Armstrong, Kevin Hilman,
Jerome Brunet, Patrice Chotard, Hans Verkuil, linux-arm-kernel,
linux-amlogic, linux-kernel
On Fri, Jul 10, 2026 at 10:53 AM Sean Young <sean@mess.org> wrote:
>
> Make rc_dev devm managed.
>
> Fixes: dccc0c3ddf8f ("media: rc: fix race between unregister and urb/irq callbacks")
> Signed-off-by: Sean Young <sean@mess.org>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 5/7] media: meson-ir-tx: Ensure clock is disabled on unbind
2026-07-10 8:53 ` [PATCH 5/7] media: meson-ir-tx: Ensure clock is disabled on unbind Sean Young
2026-07-10 9:05 ` sashiko-bot
@ 2026-07-12 13:26 ` Martin Blumenstingl
1 sibling, 0 replies; 5+ messages in thread
From: Martin Blumenstingl @ 2026-07-12 13:26 UTC (permalink / raw)
To: Sean Young
Cc: linux-media, Mauro Carvalho Chehab, Neil Armstrong, Kevin Hilman,
Jerome Brunet, Viktor Prutyanov, Mauro Carvalho Chehab,
linux-arm-kernel, linux-amlogic, linux-kernel
On Fri, Jul 10, 2026 at 10:53 AM Sean Young <sean@mess.org> wrote:
>
> clk_prepare_enabled() needs a call to clk_disable_prepare() on
> driver unbind. Make it devm managed.
>
> Fixes: 49be1c78d575 ("media: rc: introduce Meson IR TX driver")
> Signed-off-by: Sean Young <sean@mess.org>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
The additional error that sashiko reported will need to be fixed too.
Let's do that in a separate patch though to keep things simple.
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-07-12 13:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <cover.1783673420.git.sean@mess.org>
2026-07-10 8:53 ` [PATCH 5/7] media: meson-ir-tx: Ensure clock is disabled on unbind Sean Young
2026-07-10 9:05 ` sashiko-bot
2026-07-12 13:26 ` Martin Blumenstingl
2026-07-10 8:53 ` [PATCH 6/7] media: meson-ir-tx: Ensure rc_free_device() is called " Sean Young
2026-07-12 13:23 ` Martin Blumenstingl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox