#include "usb_gpio.h" static struct gpio_chip ft232_chip; #include "gpio_callbacks.c" static void usb_gpio_exit(void) { if( gpiochip_remove(&ft232_chip)<0 ){ printk("<1>%s: Couldn't free GPIO-pins!\n",MOD_NAME); } printk("<1>%s: Bye!\n",MOD_NAME); } static int usb_gpio_init(void) { int ret; // Prepare user space handler call char *argv[] = { "/usr/bin/logger", "help!", NULL }; static char *envp[] = { "HOME=/", "TERM=linux", "PATH=/sbin:/bin:/usr/sbin:/usr/bin", NULL }; printk("<1>%s: Loading... \n",MOD_NAME); ft232_chip.label = MOD_NAME; //Callback functions ft232_chip.direction_input = set_in; ft232_chip.direction_output = set_out; ft232_chip.get = get_value; ft232_chip.set = set_value; //Automaticaly choose GPIO numbers - manual seems not to be possible ft232_chip.base = -1; //Number of GPIO pins ft232_chip.ngpio = NUM_OF_GPIO; //This indicates that get and set functions can sleep ft232_chip.can_sleep = 1; ft232_chip.owner = THIS_MODULE; ret = gpiochip_add(&ft232_chip); DEBUG_OUT("<1>%s: gpiochip_add returned %d\n",MOD_NAME,ret); if (ret){ printk("<1>%s: Can't register chip!\n",MOD_NAME); } //Call the user space handler return call_usermodehelper( argv[0], argv, envp, UMH_WAIT_PROC ); } module_init(usb_gpio_init); module_exit(usb_gpio_exit); MODULE_LICENSE("Dual BSD/GPL");