3131#endif
3232
3333#define DRIVER_NAME "GPIO UPS driver (API " WITH_LIBGPIO_VERSION_STR ")"
34- #define DRIVER_VERSION "1.03 "
34+ #define DRIVER_VERSION "1.04 "
3535
3636/* driver description structure */
3737upsdrv_info_t upsdrv_info = {
@@ -78,7 +78,8 @@ static void reserve_lines_libgpiod(struct gpioups_t *gpioupsfd, int inner);
7878 */
7979static void reserve_lines_libgpiod (struct gpioups_t * gpioupsfdlocal , int inner ) {
8080 struct libgpiod_data_t * libgpiod_data = (struct libgpiod_data_t * )(gpioupsfdlocal -> lib_data );
81- upsdebugx (5 , "reserve_lines_libgpiod runOptions 0x%x, inner %d" , gpioupsfdlocal -> runOptions , inner );
81+ upsdebugx (5 , "reserve_lines_libgpiod runOptions 0x%x, inner %d" ,
82+ (unsigned int )gpioupsfdlocal -> runOptions , inner );
8283
8384 if (((gpioupsfdlocal -> runOptions & ROPT_REQRES ) != 0 ) == inner ) {
8485#if WITH_LIBGPIO_VERSION < 0x00020000
@@ -150,8 +151,11 @@ void gpio_open(struct gpioups_t *gpioupsfdlocal) {
150151 upslogx (LOG_NOTICE , "GPIO chip [%s] opened" , gpioupsfdlocal -> chipName );
151152 gpioupsfdlocal -> chipLinesCount = gpiod_chip_num_lines (libgpiod_data -> gpioChipHandle );
152153#else /* #if WITH_LIBGPIO_VERSION >= 0x00020000 */
154+ struct gpiod_chip_info * chipInfo ;
155+ struct gpiod_line_settings * lineSettings ;
156+
153157 upslogx (LOG_NOTICE , "GPIO chip [%s] opened, api version 2" , gpioupsfdlocal -> chipName );
154- struct gpiod_chip_info * chipInfo = gpiod_chip_get_info (libgpiod_data -> gpioChipHandle );
158+ chipInfo = gpiod_chip_get_info (libgpiod_data -> gpioChipHandle );
155159 gpioupsfdlocal -> chipLinesCount = gpiod_chip_info_get_num_lines (chipInfo );
156160 gpiod_chip_info_free (chipInfo );
157161#endif /* WITH_LIBGPIO_VERSION */
@@ -178,7 +182,7 @@ void gpio_open(struct gpioups_t *gpioupsfdlocal) {
178182 );
179183#else /* #if WITH_LIBGPIO_VERSION >= 0x00020000 */
180184 libgpiod_data -> values = xcalloc (gpioupsfdlocal -> upsLinesCount , sizeof (* libgpiod_data -> values ));
181- struct gpiod_line_settings * lineSettings = gpiod_line_settings_new ();
185+ lineSettings = gpiod_line_settings_new ();
182186 libgpiod_data -> lineConfig = gpiod_line_config_new ();
183187 libgpiod_data -> config = gpiod_request_config_new ();
184188 if (!lineSettings || !libgpiod_data -> lineConfig || !libgpiod_data -> config ) {
@@ -212,7 +216,8 @@ void gpio_open(struct gpioups_t *gpioupsfdlocal) {
212216#if WITH_LIBGPIO_VERSION >= 0x00020000
213217 gpioRc = gpiod_line_request_get_values (libgpiod_data -> request , gpioupsfdlocal -> upsLinesStates );
214218 if (gpioRc == 0 ) {
215- for (int i = 0 ; i < gpioupsfdlocal -> upsLinesCount ; i ++ ) {
219+ int i ;
220+ for (i = 0 ; i < gpioupsfdlocal -> upsLinesCount ; i ++ ) {
216221 gpioupsfdlocal -> upsLinesStates [i ] = libgpiod_data -> values [i ];
217222 }
218223 }
0 commit comments