mirror of
https://github.com/openocd-org/openocd.git
synced 2025-10-14 02:58:23 +08:00
jtag: linuxgpiod: use libgpiod v2 API for gpiod_line_request()
Work in progress. Target is to replace v1 gpiod_line_request() Define and use dummy functions from v2 for v1: - gpiod_line_config_new(), - gpiod_line_config_free(), Not yet used: - gpiod_line_config_add_line_settings(), - gpiod_chip_request_lines(). Change-Id: I9e2d3013845c5d12942f5e07c9721fcd151d6840 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8207 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
This commit is contained in:
@@ -49,6 +49,11 @@ struct gpiod_line_settings {
|
||||
int active_low;
|
||||
};
|
||||
|
||||
struct gpiod_line_config {
|
||||
unsigned int gpio_num;
|
||||
struct gpiod_line_settings *line_settings;
|
||||
};
|
||||
|
||||
static struct gpiod_line_settings *gpiod_line_settings_new(void)
|
||||
{
|
||||
static struct gpiod_line_settings my;
|
||||
@@ -58,6 +63,15 @@ static struct gpiod_line_settings *gpiod_line_settings_new(void)
|
||||
return &my;
|
||||
}
|
||||
|
||||
static struct gpiod_line_config *gpiod_line_config_new(void)
|
||||
{
|
||||
static struct gpiod_line_config my;
|
||||
|
||||
my = (struct gpiod_line_config) { 0 };
|
||||
|
||||
return &my;
|
||||
}
|
||||
|
||||
static struct gpiod_request_config *gpiod_request_config_new(void)
|
||||
{
|
||||
static struct gpiod_request_config my;
|
||||
@@ -71,6 +85,10 @@ static void gpiod_line_settings_free(struct gpiod_line_settings *settings)
|
||||
{
|
||||
}
|
||||
|
||||
static void gpiod_line_config_free(struct gpiod_line_config *config)
|
||||
{
|
||||
}
|
||||
|
||||
static void gpiod_request_config_free(struct gpiod_request_config *config)
|
||||
{
|
||||
}
|
||||
@@ -415,9 +433,10 @@ static int helper_get_line(enum adapter_gpio_config_index idx)
|
||||
}
|
||||
|
||||
struct gpiod_line_settings *line_settings = gpiod_line_settings_new();
|
||||
struct gpiod_line_config *line_config = gpiod_line_config_new();
|
||||
struct gpiod_request_config *req_cfg = gpiod_request_config_new();
|
||||
|
||||
if (!line_settings || !req_cfg) {
|
||||
if (!line_settings || !line_config || !req_cfg) {
|
||||
LOG_ERROR("Cannot configure LinuxGPIOD line for %s", adapter_gpio_get_name(idx));
|
||||
retval = ERROR_JTAG_INIT_FAILED;
|
||||
goto err_out;
|
||||
@@ -479,6 +498,7 @@ static int helper_get_line(enum adapter_gpio_config_index idx)
|
||||
|
||||
err_out:
|
||||
gpiod_line_settings_free(line_settings);
|
||||
gpiod_line_config_free(line_config);
|
||||
gpiod_request_config_free(req_cfg);
|
||||
|
||||
return retval;
|
||||
|
Reference in New Issue
Block a user