[PATCH] mailbox: arm_mhuv3: Remove dev_err_probe() if error is -ENOMEM

Xichao Zhao posted 1 patch 1 month, 1 week ago
drivers/mailbox/arm_mhuv3.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
[PATCH] mailbox: arm_mhuv3: Remove dev_err_probe() if error is -ENOMEM
Posted by Xichao Zhao 1 month, 1 week ago
The dev_err_probe() doesn't do anything when error is '-ENOMEM'.
Therefore, remove the useless call to dev_err_probe(), and just
return the value instead.

Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com>
---
 drivers/mailbox/arm_mhuv3.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/mailbox/arm_mhuv3.c b/drivers/mailbox/arm_mhuv3.c
index b97e79a5870f..cae1f9bea050 100644
--- a/drivers/mailbox/arm_mhuv3.c
+++ b/drivers/mailbox/arm_mhuv3.c
@@ -775,8 +775,7 @@ static int mhuv3_initialize_channels(struct device *dev, struct mhuv3 *mhu)
 	mbox->chans = devm_kcalloc(dev, mhu->num_chans,
 				   sizeof(*mbox->chans), GFP_KERNEL);
 	if (!mbox->chans)
-		return dev_err_probe(dev, -ENOMEM,
-				     "Failed to initialize channels\n");
+		return -ENOMEM;
 
 	for (i = 0; i < NUM_EXT && !ret; i++)
 		if (mhu->ext[i])
-- 
2.34.1
Re: [PATCH] mailbox: arm_mhuv3: Remove dev_err_probe() if error is -ENOMEM
Posted by Sudeep Holla 1 month, 1 week ago
On Thu, Aug 21, 2025 at 05:32:53PM +0800, Xichao Zhao wrote:
> The dev_err_probe() doesn't do anything when error is '-ENOMEM'.
> Therefore, remove the useless call to dev_err_probe(), and just
> return the value instead.
> 

While I understand that it doesn't print the message for ENOMEM,

	grep dev_err_probe.*ENOMEM | wc -l

gave be 80 results, so not keen in just getting rid of one instance only.
No strong objection either if the subsystem maintainer prefers it this way.

-- 
Regards,
Sudeep
Re: [PATCH] mailbox: arm_mhuv3: Remove dev_err_probe() if error is -ENOMEM
Posted by Cristian Marussi 1 month, 1 week ago
On Thu, Aug 21, 2025 at 10:53:18AM +0100, Sudeep Holla wrote:
> On Thu, Aug 21, 2025 at 05:32:53PM +0800, Xichao Zhao wrote:

Hi,

> > The dev_err_probe() doesn't do anything when error is '-ENOMEM'.
> > Therefore, remove the useless call to dev_err_probe(), and just
> > return the value instead.
> > 
> 

Looking at dev_err_probe() comments...

/**
 * dev_err_probe - probe error check and log helper
 * @dev: the pointer to the struct device
 * @err: error value to test
 * @fmt: printf-style format string
 * @...: arguments as specified in the format string

[snip]

 * Using this helper in your probe function is totally fine even if @err        <<<<
 * is known to never be -EPROBE_DEFER.
 * The benefit compared to a normal dev_err() is the standardized format
 * of the error code, which is emitted symbolically (i.e. you get "EAGAIN"
 * instead of "-35"), and having the error code returned allows more
 * compact error paths.
 *
 * Returns @err.

I have not a strong opinion but it seems to me un-needed and potentially
impacting future backporting...IOW for me, as the mailbox maintaner prefers.

Thanks,
Cristian