Chinaunix

标题: 驱动模块中变量的值要怎么确定 [打印本页]

作者: ychhj    时间: 2016-05-04 11:05
标题: 驱动模块中变量的值要怎么确定
如下的 file->f_flags 的值要怎么确定

static int lp_open(struct inode * inode, struct file * file)
{
        unsigned int minor = iminor(inode);
        int ret = 0;

        lock_kernel();
        if (minor >= LP_NO) {
                ret = -ENXIO;
                goto out;
        }
        if ((LP_F(minor) & LP_EXIST) == 0) {
                ret = -ENXIO;
                goto out;
        }
        if (test_and_set_bit(LP_BUSY_BIT_POS, &LP_F(minor))) {
                ret = -EBUSY;
                goto out;
/* If ABORTOPEN is set and the printer is offline or out of paper,
           we may still want to open it to perform ioctl()s.  Therefore we
           have commandeered O_NONBLOCK, even though it is being used in
           a non-standard manner.  This is strictly a Linux hack, and
           should most likely only ever be used by the tunelp application. */
        if ((LP_F(minor) & LP_ABORTOPEN) && !(file->f_flags & O_NONBLOCK)) {
                int status;
                lp_claim_parport_or_block (&lp_table[minor]);
                status = r_str(minor);
                lp_release_parport (&lp_table[minor]);
                if (status & LP_POUTPA) {
                        printk(KERN_INFO "lp%d out of paper\n", minor);
                        LP_F(minor) &= ~LP_BUSY;
                        ret = -ENOSPC;
                        goto out;

作者: 墙根下的水壶    时间: 2016-05-04 11:57
函数的第一个参数是file, 应该看这个file创建的时候有没有O_NONBLOCK属性了




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2