summaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorAndrzej Hajda <a.hajda@samsung.com>2020-07-13 16:43:21 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-02-23 08:12:39 +0100
commitb0465a4897047ece1e4275fefc88a66ee41c5379 (patch)
tree9813c7943ade3d19d55b65d6b19d3de667c44e02 /include/linux
parent5733959d6770324020e30dd9313cbeac0aec07ef (diff)
downloadlinux-stable-b0465a4897047ece1e4275fefc88a66ee41c5379.tar.gz
linux-stable-b0465a4897047ece1e4275fefc88a66ee41c5379.tar.bz2
linux-stable-b0465a4897047ece1e4275fefc88a66ee41c5379.zip
driver core: add device probe log helper
[ Upstream commit a787e5400a1ceeb0ef92d71ec43aeb35b1fa1334 ] During probe every time driver gets resource it should usually check for error printk some message if it is not -EPROBE_DEFER and return the error. This pattern is simple but requires adding few lines after any resource acquisition code, as a result it is often omitted or implemented only partially. dev_err_probe helps to replace such code sequences with simple call, so code: if (err != -EPROBE_DEFER) dev_err(dev, ...); return err; becomes: return dev_err_probe(dev, err, ...); Signed-off-by: Andrzej Hajda <a.hajda@samsung.com> Reviewed-by: Rafael J. Wysocki <rafael@kernel.org> Reviewed-by: Mark Brown <broonie@kernel.org> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20200713144324.23654-2-a.hajda@samsung.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Stable-dep-of: 6d710b769c1f ("serial: sc16is7xx: add check for unsupported SPI modes during probe") Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/device.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/linux/device.h b/include/linux/device.h
index bccd367c11de..0714d6e5d500 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -1581,6 +1581,9 @@ do { \
WARN_ONCE(condition, "%s %s: " format, \
dev_driver_string(dev), dev_name(dev), ## arg)
+extern __printf(3, 4)
+int dev_err_probe(const struct device *dev, int err, const char *fmt, ...);
+
/* Create alias, so I can be autoloaded. */
#define MODULE_ALIAS_CHARDEV(major,minor) \
MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor))