Rename drv.c to something more fitting to its contents, and move state machine code to its own header.