Index: lib/libgpio/gpio.3 =================================================================== --- lib/libgpio/gpio.3 +++ lib/libgpio/gpio.3 @@ -41,6 +41,8 @@ .Fn gpio_open "unsigned int unit" .Ft "gpio_handle_t" .Fn gpio_open_device "const char *device" +.Ft "gpio_handle_t" +.Fn gpio_fdopen "int fd" .Ft void .Fn gpio_close "gpio_handle_t handle" .Ft int @@ -88,9 +90,10 @@ The library operates with a .Ft gpio_handle_t opaque type which can be created with -.Fn gpio_open +.Fn gpio_open , +.Fn gpio_open_device , or -.Fn gpio_open_device . +.Fn gpio_fdopen . When no more GPIO operations are needed, this handle can be destroyed with .Fn gpio_close . Index: lib/libgpio/gpio.c =================================================================== --- lib/libgpio/gpio.c +++ lib/libgpio/gpio.c @@ -50,10 +50,15 @@ gpio_handle_t gpio_open_device(const char *device) { - int fd, maxpins; + return (gpio_fdopen(open(device, O_RDONLY))); +} + +gpio_handle_t +gpio_fdopen(int fd) +{ + int maxpins; int serr; - fd = open(device, O_RDONLY); if (fd < 0) return (GPIO_INVALID_HANDLE); /* Index: lib/libgpio/libgpio.h =================================================================== --- lib/libgpio/libgpio.h +++ lib/libgpio/libgpio.h @@ -58,6 +58,7 @@ */ gpio_handle_t gpio_open(unsigned int); gpio_handle_t gpio_open_device(const char *); +gpio_handle_t gpio_fdopen(int); void gpio_close(gpio_handle_t); /* * Get a list of all the GPIO pins.