Skip to contentSkip to conversation

staging: most: dim2: use dev_err_probe() for clock errors in rcar enable functions

PATCH Superseded Batu Ada Tutkun 3 participants 9 messages Jun 23 – Jul 7

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: most: dim2: use dev_err_probe() for clock errors in rcar enable functions

rcar_gen2_enable() and rcar_gen3_enable() use the old pattern of dev_err() followed by return PTR_ERR() when devm_clk_get() fails. fsl_mx6_enable() in the same file was already converted to use dev_err_probe() by a previous cleanup series.

Convert the remaining two functions for consistency. devm_clk_get() can return -EPROBE_DEFER, so dev_err_probe() is appropriate here: it suppresses the log message at error level when the failure is a deferred probe, avoiding misleading output during normal boot.

---
 drivers/staging/most/dim2/dim2.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/staging/most/dim2/dim2.c +6 -8
index 7953d4626..56f856d6d 100644
@@ -974,10 +974,9 @@ static int rcar_gen2_enable(struct platform_device *pdev)
 	int ret;
 
 	dev->clk = devm_clk_get(&pdev->dev, NULL);
-	if (IS_ERR(dev->clk)) {
-		dev_err(&pdev->dev, "cannot get clock\n");
-		return PTR_ERR(dev->clk);
-	}
+	if (IS_ERR(dev->clk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(dev->clk),
+				     "cannot get clock\n");
 
 	ret = clk_prepare_enable(dev->clk);
 	if (ret) {
@@ -1019,10 +1018,9 @@ static int rcar_gen3_enable(struct platform_device *pdev)
 	int ret;
 
 	dev->clk = devm_clk_get(&pdev->dev, NULL);
-	if (IS_ERR(dev->clk)) {
-		dev_err(&pdev->dev, "cannot get clock\n");
-		return PTR_ERR(dev->clk);
-	}
+	if (IS_ERR(dev->clk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(dev->clk),
+				     "cannot get clock\n");
 
 	ret = clk_prepare_enable(dev->clk);
 	if (ret) {
Signature · 1 line
2.53.0
#1 lore raw
Quoted 10 lines · Batu Ada Tutkun

rcar_gen2_enable() and rcar_gen3_enable() use the old pattern of dev_err() followed by return PTR_ERR() when devm_clk_get() fails. fsl_mx6_enable() in the same file was already converted to use dev_err_probe() by a previous cleanup series.

Convert the remaining two functions for consistency. devm_clk_get() can return -EPROBE_DEFER, so dev_err_probe() is appropriate here: it suppresses the log message at error level when the failure is a deferred probe, avoiding misleading output during normal boot.

This feels like an AI patch. Please state when you are using AI.

In fsl_mx6_enable(), the original code returned -EFAULT if devm_clk_get() failed so change it to propagate the error code and use dev_err_probe() made obvious sense. This was done in commit b7a013c12504 ("staging: most: dim2: use dev_err_probe and proper error codes for clock").

In this case, the logic is "monkey see, monkey do" which is reasonable AI logic but it's not enough motivation on its own Does devm_clk_get() actually return -EPROBE_DEFER? Does clk_prepare_enable() return -EPROBE_DEFER? Should that be changed as well?

Quoted 2 lines

---

^^^
You need to say if a patch has been tested or not here under the --- cut off line.

Quoted 2 lines
 drivers/staging/most/dim2/dim2.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

regards,
dan carpenter

#2 lore raw

Yes, this was drafted with AI assistance. Thank you for pointing it out.

You are right that the error code was not broken here. rcar_gen2 and gen3 already return PTR_ERR(dev->clk), so unlike the fsl_mx6 case there is no -EFAULT bug to fix. This is just a consistency cleanup, plus devm_clk_get() can return -EPROBE_DEFER when the clock provider has not registered yet so dev_err_probe() suppresses the misleading "cannot get clock" message during a normal deferred probe.

clk_prepare_enable() can't return -EPROBE_DEFER. By the time it is called the clock handle is already acquired and deferral only happens at acquisition. Because of that I deliberately left that path as dev_err().

Compile tested only. I do not have R-Car hardware.

Regards,
Batu Ada Tutkun

#3 lore raw
Quoted 3 lines · Batu Ada Tutkun

Yes, this was drafted with AI assistance. Thank you for pointing it out.

You are right that the error code was not broken here. rcar_gen2 and gen3 already return PTR_ERR(dev->clk), so unlike the fsl_mx6 case there is no -EFAULT bug to fix. This is just a consistency cleanup, plus devm_clk_get() can return -EPROBE_DEFER when the clock provider has not registered yet so dev_err_probe() suppresses the misleading "cannot get clock" message during a normal deferred probe.

I checked this and sure enough, clk_get() returns -EPROBE_DEFER. Please specifically mention clk_get() in the commit message in case someone wants to check the code...

Useless: grep "when the clock provider has not registered yet"
Useful: vim -t clk_get

Quoted 4 lines

clk_prepare_enable() can't return -EPROBE_DEFER. By the time it is called the clock handle is already acquired and deferral only happens at acquisition. Because of that I deliberately left that path as dev_err().

Compile tested only. I do not have R-Car hardware.

This is good information and it needs to be in the commit message under the --- cut off line. Obviously, I know that changing dev_err() to dev_err_probe() does not cause a problem, but I also want to know if this is something which is already affecting users in real life or if it's just a correctness thing.

So the patch is fine, but the commit message needs to be re-written.

regards,
dan carpenter

#4 lore raw

PATCH v2 1/1 staging: most: dim2: use dev_err_probe() for clock errors in rcar enable functions

In reply to Batu Ada Tutkun

rcar_gen2_enable() and rcar_gen3_enable() use the old pattern of dev_err() followed by return PTR_ERR() when devm_clk_get() fails. fsl_mx6_enable() in the same file was already converted to use dev_err_probe() by a previous cleanup series.

Convert the remaining two functions for consistency. devm_clk_get() calls clk_get() which can return -EPROBE_DEFER if the clock provider has not yet registered. Using dev_err_probe() suppresses the log at error level in that case, avoiding misleading "cannot get clock" output during a normal deferred probe.

clk_prepare_enable() cannot return -EPROBE_DEFER since the clock handle is already acquired at that point, so those error paths are left as dev_err().

---
Compile tested only. No R-Car hardware available. This is a correctness fix for the deferred probe path, not a response to a reported user visible issue.

Changes in v2:
- Mention clk_get() explicitly in commit message
- Add testing note under --- cut off line

 drivers/staging/most/video/video.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/most/video/video.c +2 -2
index 04351f8cc..1e1ff3c52 100644
@@ -33,14 +33,14 @@ struct most_video_dev {
 	bool mute;
 
 	struct list_head pending_mbos;
-	spinlock_t list_lock;
+	spinlock_t list_lock;	/* protects pending_mbos and mute */
 
 	struct v4l2_device v4l2_dev;
 	atomic_t access_ref;
 	struct video_device *vdev;
 	unsigned int ctrl_input;
 
-	struct mutex lock;
+	struct mutex lock;		/* serializes V4L2 ioctls */
 
 	wait_queue_head_t wait_data;
 };
Signature · 1 line
2.53.0
#5 lore raw
Quoted 16 lines · Batu Ada Tutkun

rcar_gen2_enable() and rcar_gen3_enable() use the old pattern of dev_err() followed by return PTR_ERR() when devm_clk_get() fails. fsl_mx6_enable() in the same file was already converted to use dev_err_probe() by a previous cleanup series.

Convert the remaining two functions for consistency. devm_clk_get() calls clk_get() which can return -EPROBE_DEFER if the clock provider has not yet registered. Using dev_err_probe() suppresses the log at error level in that case, avoiding misleading "cannot get clock" output during a normal deferred probe.

clk_prepare_enable() cannot return -EPROBE_DEFER since the clock handle is already acquired at that point, so those error paths are left as dev_err().

Quoted 9 lines

---
Compile tested only. No R-Car hardware available. This is a correctness fix for the deferred probe path, not a response to a reported user visible issue.

Changes in v2:
- Mention clk_get() explicitly in commit message
- Add testing note under --- cut off line

Wrong patch for the commit message.

drivers/staging/most/video/video.c struct most_video_dev { · line 36

Quoted 13 lines
 drivers/staging/most/video/video.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/most/video/video.c +1 -1
index 04351f8cc..1e1ff3c52 100644
@@ -33,14 +33,14 @@ struct most_video_dev {
 	bool mute;
 
 	struct list_head pending_mbos;
-	spinlock_t list_lock;
+	spinlock_t list_lock;	/* protects pending_mbos and mute */

It doesn't protect mute, really. Only half heartedly. And protecting mute is unnecessary.

drivers/staging/most/video/video.c struct most_video_dev { · line 43

Quoted 8 lines
drivers/staging/most/video/video.c +1 -1
 	struct v4l2_device v4l2_dev;
 	atomic_t access_ref;
 	struct video_device *vdev;
 	unsigned int ctrl_input;
 
-	struct mutex lock;
+	struct mutex lock;		/* serializes V4L2 ioctls */

I kind of hate this checkpatch warning... It's really hard to judge if this comment is accurate or useful.

regards,
dan carpenter

Quoted 5 lines
drivers/staging/most/video/video.c +0 -0
 	wait_queue_head_t wait_data;
 };
Signature · 1 line
2.53.0
#6 lore raw

PATCH v2 1/1 staging: most: dim2: use dev_err_probe() for clock errors in rcar enable functions

In reply to Batu Ada Tutkun

rcar_gen2_enable() and rcar_gen3_enable() use the old pattern of dev_err() followed by return PTR_ERR() when devm_clk_get() fails. fsl_mx6_enable() in the same file was already converted to use dev_err_probe() by a previous cleanup series.

Convert the remaining two functions for consistency. devm_clk_get() calls clk_get() which can return -EPROBE_DEFER if the clock provider has not yet registered. Using dev_err_probe() suppresses the log at error level in that case, avoiding misleading "cannot get clock" output during a normal deferred probe.

clk_prepare_enable() cannot return -EPROBE_DEFER since the clock handle is already acquired at that point, so those error paths are left as dev_err().

---
Compile tested only. No R-Car hardware available. This is a correctness fix for the deferred probe path, not a response to a reported user visible issue.

Changes in v2:
- Mention clk_get() explicitly in commit message
- Add testing note under --- cut off line

 drivers/staging/most/dim2/dim2.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/staging/most/dim2/dim2.c +6 -8
index 7953d4626..56f856d6d 100644
@@ -974,10 +974,9 @@ static int rcar_gen2_enable(struct platform_device *pdev)
 	int ret;
 
 	dev->clk = devm_clk_get(&pdev->dev, NULL);
-	if (IS_ERR(dev->clk)) {
-		dev_err(&pdev->dev, "cannot get clock\n");
-		return PTR_ERR(dev->clk);
-	}
+	if (IS_ERR(dev->clk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(dev->clk),
+				     "cannot get clock\n");
 
 	ret = clk_prepare_enable(dev->clk);
 	if (ret) {
@@ -1019,10 +1018,9 @@ static int rcar_gen3_enable(struct platform_device *pdev)
 	int ret;
 
 	dev->clk = devm_clk_get(&pdev->dev, NULL);
-	if (IS_ERR(dev->clk)) {
-		dev_err(&pdev->dev, "cannot get clock\n");
-		return PTR_ERR(dev->clk);
-	}
+	if (IS_ERR(dev->clk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(dev->clk),
+				     "cannot get clock\n");
 
 	ret = clk_prepare_enable(dev->clk);
 	if (ret) {
Signature · 1 line
2.53.0
Reviewed-by on v2 1/1
#7 lore raw
Quoted 17 lines · Batu Ada Tutkun

rcar_gen2_enable() and rcar_gen3_enable() use the old pattern of dev_err() followed by return PTR_ERR() when devm_clk_get() fails. fsl_mx6_enable() in the same file was already converted to use dev_err_probe() by a previous cleanup series.

Convert the remaining two functions for consistency. devm_clk_get() calls clk_get() which can return -EPROBE_DEFER if the clock provider has not yet registered. Using dev_err_probe() suppresses the log at error level in that case, avoiding misleading "cannot get clock" output during a normal deferred probe.

clk_prepare_enable() cannot return -EPROBE_DEFER since the clock handle is already acquired at that point, so those error paths are left as dev_err().

Quoted 9 lines

---
Compile tested only. No R-Car hardware available. This is a correctness fix for the deferred probe path, not a response to a reported user visible issue.

Changes in v2:
- Mention clk_get() explicitly in commit message
- Add testing note under --- cut off line

Perfect. Thanks.

regards,
dan carpenter

maintainer
#8 lore raw
In reply to Batu Ada Tutkun
Quoted 15 lines · Batu Ada Tutkun

rcar_gen2_enable() and rcar_gen3_enable() use the old pattern of dev_err() followed by return PTR_ERR() when devm_clk_get() fails. fsl_mx6_enable() in the same file was already converted to use dev_err_probe() by a previous cleanup series.

Convert the remaining two functions for consistency. devm_clk_get() calls clk_get() which can return -EPROBE_DEFER if the clock provider has not yet registered. Using dev_err_probe() suppresses the log at error level in that case, avoiding misleading "cannot get clock" output during a normal deferred probe.

clk_prepare_enable() cannot return -EPROBE_DEFER since the clock handle is already acquired at that point, so those error paths are left as dev_err().

Quoted 6 lines

---
Compile tested only. No R-Car hardware available. This is a correctness fix for the deferred probe path, not a response to a reported user visible issue.

You forgot to document your use of a LLM in the creation of this change.

thanks,

greg k-h