[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240822130722.1261891-2-andriy.shevchenko@linux.intel.com>
Date: Thu, 22 Aug 2024 16:05:38 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Hans de Goede <hdegoede@...hat.com>,
linux-kernel@...r.kernel.org,
platform-driver-x86@...r.kernel.org
Cc: "Rafael J. Wysocki" <rafael@...nel.org>,
Daniel Scally <djrscally@...il.com>
Subject: [PATCH v2 1/4] driver core: Ignore 0 in dev_err_probe()
In the similar way, ignore 0 error code (AKA "success") in
dev_err_probe(). This helps to simplify a code such as
if (ret < 0)
return dev_err_probe(int3472->dev, ret, err_msg);
return ret;
to
return dev_err_probe(int3472->dev, ret, err_msg);
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
---
drivers/base/core.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 4bc8b88d697e..830a14084bf6 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -4987,13 +4987,14 @@ define_dev_printk_level(_dev_info, KERN_INFO);
* This helper implements common pattern present in probe functions for error
* checking: print debug or error message depending if the error value is
* -EPROBE_DEFER and propagate error upwards.
+ *
* In case of -EPROBE_DEFER it sets also defer probe reason, which can be
* checked later by reading devices_deferred debugfs attribute.
* It replaces code sequence::
*
* if (err != -EPROBE_DEFER)
* dev_err(dev, ...);
- * else
+ * else if (err)
* dev_dbg(dev, ...);
* return err;
*
@@ -5003,12 +5004,16 @@ define_dev_printk_level(_dev_info, KERN_INFO);
*
* Using this helper in your probe function is totally fine even if @err is
* known to never be -EPROBE_DEFER.
+ *
+ * NOTE: The message is not going to be printed or saved in cases when @err
+ * is equal to -ENOMEM or 0.
+ *
* The benefit compared to a normal dev_err() is the standardized format
* of the error code, it being emitted symbolically (i.e. you get "EAGAIN"
* instead of "-35") and the fact that the error code is returned which allows
* more compact error paths.
*
- * Returns @err.
+ * Return: the value of @err.
*/
int dev_err_probe(const struct device *dev, int err, const char *fmt, ...)
{
@@ -5032,6 +5037,10 @@ int dev_err_probe(const struct device *dev, int err, const char *fmt, ...)
*/
break;
+ case 0:
+ /* Success, no need to issue an error message */
+ break;
+
default:
dev_err(dev, "error %pe: %pV", ERR_PTR(err), &vaf);
break;
--
2.43.0.rc1.1336.g36b5255a03ac
Powered by blists - more mailing lists