lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 16 Aug 2022 14:55:34 +0200
From:   Christophe JAILLET <christophe.jaillet@...adoo.fr>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        "Rafael J. Wysocki" <rafael@...nel.org>
Cc:     linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
        Christophe JAILLET <christophe.jaillet@...adoo.fr>,
        Robin Murphy <robin.murphy@....com>
Subject: [PATCH] driver core: Have dev_err_probe() handle the dev_fmt() macro

dev_err() and co. functions handle the dev_fmt() macro if it is defined.
This helps to have a common prefix for all messages generated with this
API.

dev_err_probe() looks like dev_err() but, up to now, does not expand the
dev_fmt() macro.

Add it.

Suggested-by: Robin Murphy <robin.murphy@....com>
Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
---
Example of where it would be useful is discussed at:
  https://lore.kernel.org/all/aaeba9c12ccdb29f48fe19137cb5abeea85fbb24.1659732652.git.christophe.jaillet@wanadoo.fr/


I've left the kerneldoc in the .c file near _dev_err_probe(). I don't know
if it should be moved in the .h file close to dev_err_probe().
---
 drivers/base/core.c    | 7 +++++--
 include/linux/device.h | 4 +++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 753e7cca0f40..89cab273a7b5 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -4830,6 +4830,9 @@ define_dev_printk_level(_dev_info, KERN_INFO);
  *
  * 	return dev_err_probe(dev, err, ...);
  *
+ * Just as dev_err() does, dev_err_probe() also takes the dev_fmt() macro into
+ * consideration if it is defined.
+ *
  * Note that it is deemed acceptable to use this function for error
  * prints during probe even if the @err is known to never be -EPROBE_DEFER.
  * The benefit compared to a normal dev_err() is the standardized format
@@ -4838,7 +4841,7 @@ define_dev_printk_level(_dev_info, KERN_INFO);
  * Returns @err.
  *
  */
-int dev_err_probe(const struct device *dev, int err, const char *fmt, ...)
+int _dev_err_probe(const struct device *dev, int err, const char *fmt, ...)
 {
 	struct va_format vaf;
 	va_list args;
@@ -4858,7 +4861,7 @@ int dev_err_probe(const struct device *dev, int err, const char *fmt, ...)
 
 	return err;
 }
-EXPORT_SYMBOL_GPL(dev_err_probe);
+EXPORT_SYMBOL_GPL(_dev_err_probe);
 
 static inline bool fwnode_is_primary(struct fwnode_handle *fwnode)
 {
diff --git a/include/linux/device.h b/include/linux/device.h
index 424b55df0272..412a0ee2d44e 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -1093,7 +1093,9 @@ void device_links_supplier_sync_state_pause(void);
 void device_links_supplier_sync_state_resume(void);
 
 extern __printf(3, 4)
-int dev_err_probe(const struct device *dev, int err, const char *fmt, ...);
+int _dev_err_probe(const struct device *dev, int err, const char *fmt, ...);
+#define dev_err_probe(dev, err, fmt, ...) \
+	_dev_err_probe(dev, err, dev_fmt(fmt), ##__VA_ARGS__)
 
 /* Create alias, so I can be autoloaded. */
 #define MODULE_ALIAS_CHARDEV(major,minor) \
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ