diff mbox series

ucfwhandler: workaround for libgpiod changes

Message ID 20181214215503.5620-1-sbabic@denx.de
State Accepted
Headers show
Series ucfwhandler: workaround for libgpiod changes | expand

Commit Message

Stefano Babic Dec. 14, 2018, 9:55 p.m. UTC
libgpiod changed API, but there is no way to get the version at build
time. gpiod_line_request_output() was replaced by by gpiod_line_request_flags_output()
while gpiod_line_request_output() does not have the flags parameter
anymore (not used by the handler).

A compiler flag in SWUpdate is added to handle different versions of the
library.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 handlers/Config.in      | 12 ++++++++++++
 handlers/ucfw_handler.c |  8 ++++++++
 2 files changed, 20 insertions(+)
diff mbox series

Patch

diff --git a/handlers/Config.in b/handlers/Config.in
index 12a50b4..f08c6f6 100644
--- a/handlers/Config.in
+++ b/handlers/Config.in
@@ -211,4 +211,16 @@  config UCFWHANDLER
 comment "Microcontroller handler depends on libgpiod"
 	depends on !HAVE_LIBGPIOD
 
+config UCFW_OLD_LIBGPIOD
+	bool "Support older libgpiod version"
+	depends on HAVE_LIBGPIOD
+	depends on UCFWHANDLER
+	default n
+	help
+	  The libgpiod library changed the api gpiod_line_request_output.
+	  The old function was replaced by gpiod_line_request_flags_output
+	  while the new one dropped "flags" from the list of parameters.
+	  Rather there is no way to get this changes from the library
+	  at build time.
+
 endmenu
diff --git a/handlers/ucfw_handler.c b/handlers/ucfw_handler.c
index 4cc7e11..1d71b05 100644
--- a/handlers/ucfw_handler.c
+++ b/handlers/ucfw_handler.c
@@ -139,13 +139,21 @@  static int switch_mode(char *devreset, int resoffset, char *devprog, int progoff
 		goto freegpios;
 	}
 
+#ifdef CONFIG_UCFW_OLD_LIBGPIOD
 	status = gpiod_line_request_output(linereset, RESET_CONSUMER, false, 0);
+#else
+	status = gpiod_line_request_output(linereset, RESET_CONSUMER, 0);
+#endif
 	if (status) {
 		ret  =-ENODEV;
 		ERROR("Cannot request reset line");
 		goto freegpios;
 	}
+#ifdef CONFIG_UCFW_OLD_LIBGPIOD
 	status = gpiod_line_request_output(lineprog, PROG_CONSUMER, false, mode);
+#else
+	status = gpiod_line_request_output(lineprog, PROG_CONSUMER, mode);
+#endif
 	if (status) {
 		ret  =-ENODEV;
 		ERROR("Cannot request prog line");