“…To support this function, the cgi will call the driver, the next application show how driver be called. int main(int argc, char **argv) { int led_no,on; unsigned char led=0xff; if (argc != 3 || sscanf(argv [1], "%d", &led_no) != 1 || sscanf(argv [2],"%d", &on) != 1 ||on < 0 || on > 1 || led_no < 0 || led_no > 7) { fprintf(stderr, "Usage: leds led_no 0|1\n"); exit(1); } if(on) led&=~(0x1<<led_no);else led|=(0x1<<led_no); fd = open(LED_DEV, O_RDWR); if(fd < 0) {printf("####XSB_EDR_8LED test device open fail####%d \n",fd); return (-1);} write(fd,&led,1); } close(fd); return(0); } The above example shows that error checking and driver interface are mixed in same file. After business workflow added, the code will be very complicated.…”