mirror of
https://xff.cz/git/u-boot/
synced 2025-09-01 08:42:12 +02:00
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>
This commit is contained in:
@@ -130,6 +130,27 @@ int gpio_request(unsigned gpio, const char *label)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
Reference in New Issue
Block a user