drivers/linuxgpiod: simplify gpio release
We already have a helper to release the gpio. Extend it to also release its corresponding gpio chip. As side effect, remove comparison with NULL. Change-Id: I47cd446edfaead662d63c3330f25a791b747e882 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7033 Tested-by: jenkins Reviewed-by: Steve Marple <stevemarple@googlemail.com>
This commit is contained in:
parent
1a3573d731
commit
eab88eadd7
|
@ -288,45 +288,26 @@ static bool linuxgpiod_swd_mode_possible(void)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void helper_release(struct gpiod_line *line)
|
static inline void helper_release(struct gpiod_line *line, struct gpiod_chip *chip)
|
||||||
{
|
{
|
||||||
if (line)
|
if (line)
|
||||||
gpiod_line_release(line);
|
gpiod_line_release(line);
|
||||||
|
if (chip)
|
||||||
|
gpiod_chip_close(chip);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int linuxgpiod_quit(void)
|
static int linuxgpiod_quit(void)
|
||||||
{
|
{
|
||||||
helper_release(gpiod_led);
|
helper_release(gpiod_led, gpiod_chip_led);
|
||||||
helper_release(gpiod_srst);
|
helper_release(gpiod_srst, gpiod_chip_srst);
|
||||||
helper_release(gpiod_swdio);
|
helper_release(gpiod_swdio, gpiod_chip_swdio);
|
||||||
helper_release(gpiod_swdio_dir);
|
helper_release(gpiod_swdio_dir, gpiod_chip_swdio_dir);
|
||||||
helper_release(gpiod_swclk);
|
helper_release(gpiod_swclk, gpiod_chip_swclk);
|
||||||
helper_release(gpiod_trst);
|
helper_release(gpiod_trst, gpiod_chip_trst);
|
||||||
helper_release(gpiod_tms);
|
helper_release(gpiod_tms, gpiod_chip_tms);
|
||||||
helper_release(gpiod_tck);
|
helper_release(gpiod_tck, gpiod_chip_tck);
|
||||||
helper_release(gpiod_tdi);
|
helper_release(gpiod_tdi, gpiod_chip_tdi);
|
||||||
helper_release(gpiod_tdo);
|
helper_release(gpiod_tdo, gpiod_chip_tdo);
|
||||||
|
|
||||||
if (gpiod_chip_led != NULL)
|
|
||||||
gpiod_chip_close(gpiod_chip_led);
|
|
||||||
if (gpiod_chip_srst != NULL)
|
|
||||||
gpiod_chip_close(gpiod_chip_srst);
|
|
||||||
if (gpiod_chip_swdio != NULL)
|
|
||||||
gpiod_chip_close(gpiod_chip_swdio);
|
|
||||||
if (gpiod_chip_swdio_dir != NULL)
|
|
||||||
gpiod_chip_close(gpiod_chip_swdio_dir);
|
|
||||||
if (gpiod_chip_swclk != NULL)
|
|
||||||
gpiod_chip_close(gpiod_chip_swclk);
|
|
||||||
if (gpiod_chip_trst != NULL)
|
|
||||||
gpiod_chip_close(gpiod_chip_trst);
|
|
||||||
if (gpiod_chip_tms != NULL)
|
|
||||||
gpiod_chip_close(gpiod_chip_tms);
|
|
||||||
if (gpiod_chip_tck != NULL)
|
|
||||||
gpiod_chip_close(gpiod_chip_tck);
|
|
||||||
if (gpiod_chip_tdi != NULL)
|
|
||||||
gpiod_chip_close(gpiod_chip_tdi);
|
|
||||||
if (gpiod_chip_tdo != NULL)
|
|
||||||
gpiod_chip_close(gpiod_chip_tdo);
|
|
||||||
|
|
||||||
return ERROR_OK;
|
return ERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue