gpio: refactor