{"out", 3},
};
- int index;
char gpio_buf[GPIO_BUFFER_MAX] = {0, };
int ret = read(gpio->fd_direction, &gpio_buf, GPIO_BUFFER_MAX);
CHECK_ERROR(ret <= 0);
- for (index = 0; index < ARRAY_SIZE(types); index++) {
- if (!strncmp(gpio_buf, types[index].type, types[index].len)) {
- // PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_HIGH and PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW : out type
- gpio->direction = (peripheral_gpio_direction_e)index;
+ for (size_t index = 0; index < ARRAY_SIZE(types); index++) {
+ if (strncmp(gpio_buf, types[index].type, types[index].len))
+ continue;
- /*
- * Also write to direction for the very first time after boot
- * to ensure that the pin is fully initialized.
- * Without this, writing to 'edge' is not possible.
- */
- ret = write(gpio->fd_direction, types[index].type, types[index].len);
- CHECK_ERROR(ret != types[index].len);
+ // PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_HIGH and PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW : out type
+ gpio->direction = (peripheral_gpio_direction_e)index;
- return PERIPHERAL_ERROR_NONE;
- }
+ /*
+ * Also write to direction for the very first time after boot
+ * to ensure that the pin is fully initialized.
+ * Without this, writing to 'edge' is not possible.
+ */
+ ret = write(gpio->fd_direction, types[index].type, types[index].len);
+ CHECK_ERROR(ret != types[index].len);
+
+ return PERIPHERAL_ERROR_NONE;
}
return PERIPHERAL_ERROR_IO_ERROR;
{"both", 4}
};
- int index;
char gpio_buf[GPIO_BUFFER_MAX] = {0, };
int ret = read(gpio->fd_edge, &gpio_buf, GPIO_BUFFER_MAX);
CHECK_ERROR(ret <= 0);
- for (index = 0; index < ARRAY_SIZE(types); index++) {
- if (!strncmp(gpio_buf, types[index].type, types[index].len)) {
- gpio->edge = (peripheral_gpio_edge_e)index;
- return PERIPHERAL_ERROR_NONE;
- }
+ for (size_t index = 0; index < ARRAY_SIZE(types); index++) {
+ if (strncmp(gpio_buf, types[index].type, types[index].len))
+ continue;
+
+ gpio->edge = (peripheral_gpio_edge_e)index;
+ return PERIPHERAL_ERROR_NONE;
}
return PERIPHERAL_ERROR_IO_ERROR;