I'm trying to describe my problem from the beginning. I'm a newbie in linux diver development, so please point out my problems about my consideration in my project.
I'm now developing a linux driver for a modem, but not a typical one. I hope it can work as a net adapter, rather than a modem. It is connected with computer with serial port. Because of the nature of my problem, I have to use a USB-serial converter. Most of the answer suggest to use a user space driver instead. However, as I want to provide a networking interface like eth0, I have to make it in the kernel. Besides open/read/write ttyUSB0 file, I do not have any other idea solving this problem.
I'm now using code like this
struct file *f;
mm_segment_t oldfs;
struct tty_struct *tty;
struct termios term;
unsigned char buffer[255];
f=filp_open("/dev/ttyS0",O_RDWR | O_NDELAY,0);
oldfs=getfs();
set_fs(KERNEL_DS);
f->f_pos=0;
tty=(struct tty_struct*)f->private_data;
tty->termios->c_flag=B9600 | CRTSCTS | CS8 | CLOCAL | CREAD;
At this time, tty->termios is NULL, so I can not do the last step. What I do is:
struct ktermio term;
//setting the termio
tty->termios = &term;
And the result of this is that the setting is not applied to the serial port. Even if I change it to a absolutely wrong baud rate, I still receive fragments. Some of them are correct, while some are not. What is the problem, and what should I do.