cleaned up chardev.c and chardev.h for future application. Moved chardev.c with comments and test code into test_chardev.c