Serial Programming

From: Harivansh S. Mehta (harivansh@dcmtech.co.in)
Date: Mon May 28 2001 - 23:24:47 EST


Hi,
I am developing a driver which reads some data from the serial port in the
raw mode. For doing the same i do a call to which fails. The call to
our_ioctl for get serial data fails with return value -14 which is EBADADDR.

The same read works if we send a direct read request from an application to
our driver. However when we call the same thing from within the driver
module, it fails .
Please suggest a way for this.

The code is something like this

FILE * fp;
init_module()
{
fp = filp_open ("/dev/ttyS0", O_RDWR);
}

int our_read(struct file *filp, char *buf, size_t size, loff_t *off)
{
        if (fp)
        {
            if (fp->f_op && fp->f_op->read)
                 retval = fp->f_op->read(filep,buf,size,&filep->f_pos);
        }
}

int our_ioctl(struct inode *in, struct file *f, unsigned int cmd,
                 unsigned long arg)
{
        switch (cmd)
        {
                case GET_SERIAL_DATA : return our_read(NULL, (char * ) arg,
MAX_READ, NULL);
                break;
        }
}

TIA
Harivansh S. Mehta
DCM Technologies Ltd.
India
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu May 31 2001 - 21:00:39 EST