- 論壇徽章:
- 3
|
原帖由 xiaoyao183 于 2008-8-15 16:27 發(fā)表 ![]()
請問在串口驅(qū)動中 從tty_io.c中的操作如何調(diào)用到 serial_core.c中相應(yīng)的操作
這兩個文件中的操作有關(guān)系嗎 舉例:從應(yīng)用層如何實(shí)現(xiàn)write 的啊 感謝
- static ssize_t tty_write(struct file * file, const char __user * buf, size_t count,
- loff_t *ppos)
- {
- struct tty_struct * tty;
- struct inode *inode = file->f_dentry->d_inode;
- ssize_t ret;
- struct tty_ldisc *ld;
-
- tty = (struct tty_struct *)file->private_data;
- if (tty_paranoia_check(tty, inode, "tty_write"))
- return -EIO;
- if (!tty || !tty->driver->write || (test_bit(TTY_IO_ERROR, &tty->flags)))
- return -EIO;
- ld = tty_ldisc_ref_wait(tty);
- if (!ld->write)
- ret = -EIO;
- else
- ret = do_tty_write(ld->write, tty, file, buf, count);
- tty_ldisc_deref(ld);
- return ret;
- }
復(fù)制代碼
這一句:ret = do_tty_write(ld->write, tty, file, buf, count);
你跟進(jìn)去看一下-->
ret = write(tty, file, tty->write_buf, size);
仔細(xì)看代碼實(shí)現(xiàn),就知道了。 |
|