summaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2014-10-04 11:29:49 -0600
committerSimon Glass <sjg@chromium.org>2014-10-23 19:29:52 -0600
commitd44f597b12b8f8099c3c52c3eb09540966cafe79 (patch)
treeaeecc26ed1a0938d0e567b08af389b63088d4664 /drivers/gpio
parent4b8f11c2cc1dc23cf721073e6440c4e151b89bdd (diff)
downloadu-boot-d44f597b12b8f8099c3c52c3eb09540966cafe79.tar.gz
u-boot-d44f597b12b8f8099c3c52c3eb09540966cafe79.tar.xz
u-boot-d44f597b12b8f8099c3c52c3eb09540966cafe79.zip
dm: gpio: Add gpio_requestf() helper for printf() strings
Add a helper which permits a printf()-style format string for the requester string. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpio-uclass.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index 6367093210..45e9a5ad22 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -131,6 +131,27 @@ int gpio_request(unsigned gpio, const char *label)
}
/**
+ * gpio_requestf() - [COMPAT] Request GPIO
+ * @gpio: GPIO number
+ * @fmt: Format string for the requested GPIO
+ * @...: Arguments for the printf() format string
+ *
+ * This function implements the API that's compatible with current
+ * GPIO API used in U-Boot. The request is forwarded to particular
+ * GPIO driver. Returns 0 on success, negative value on error.
+ */
+int gpio_requestf(unsigned gpio, const char *fmt, ...)
+{
+ va_list args;
+ char buf[40];
+
+ va_start(args, fmt);
+ vscnprintf(buf, sizeof(buf), fmt, args);
+ va_end(args);
+ return gpio_request(gpio, buf);
+}
+
+/**
* gpio_free() - [COMPAT] Relinquish GPIO
* gpio: GPIO number
*