From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Jiri Slaby <jirislaby@kernel.org>,
Javier Martinez Canillas <javierm@redhat.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v1 1/2] driver core: add a wrapper to device probe log helper to return pointer
Date: Mon, 14 Feb 2022 16:32:47 +0200 [thread overview]
Message-ID: <20220214143248.502-1-andriy.shevchenko@linux.intel.com> (raw)
Sometimes the ->probe() function can be split to the core and actual probe
parts. In such cases the core one may return a pointer to the allocated
resource, or error pointer in unsuccessful scenario. Allow that kind of
core function to use dev_err_probe_ptr(), so the following excerpt
ret = bar(...);
if (ret) {
dev_err_probe(dev, ret, ...);
return ERR_PTR(ret);
}
can be replaced with
ret = bar(...);
if (ret)
return dev_err_probe_ptr(dev, ret, ...);
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
include/linux/device.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/include/linux/device.h b/include/linux/device.h
index 93459724dcde..8650d3afbe7c 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -14,6 +14,7 @@
#include <linux/dev_printk.h>
#include <linux/energy_model.h>
+#include <linux/err.h>
#include <linux/ioport.h>
#include <linux/kobject.h>
#include <linux/klist.h>
@@ -982,6 +983,13 @@ 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, ...);
+/* As above, but returns error pointer */
+static inline __printf(3, 0)
+void *dev_err_probe_ptr(const struct device *dev, int err, const char *fmt, va_list args)
+{
+ return ERR_PTR(dev_err_probe(dev, err, fmt, args));
+}
+
/* Create alias, so I can be autoloaded. */
#define MODULE_ALIAS_CHARDEV(major,minor) \
MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor))
--
2.34.1
next reply other threads:[~2022-02-14 14:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-14 14:32 Andy Shevchenko [this message]
2022-02-14 14:32 ` [PATCH v1 2/2] serial: sh-sci: Switch to use dev_err_probe_ptr() Andy Shevchenko
2022-02-14 14:57 ` Geert Uytterhoeven
2022-02-14 19:12 ` kernel test robot
2022-02-14 19:12 ` kernel test robot
2022-02-15 1:40 ` kernel test robot
2022-02-15 1:40 ` kernel test robot
2023-06-11 9:17 ` Andi Shyti
2022-02-14 14:55 ` [PATCH v1 1/2] driver core: add a wrapper to device probe log helper to return pointer Geert Uytterhoeven
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220214143248.502-1-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=geert@linux-m68k.org \
--cc=gregkh@linuxfoundation.org \
--cc=javierm@redhat.com \
--cc=jirislaby@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.