[PARPORT] simple driver

From: Aditya Mittal (addy@ee.iitb.ac.in)
Date: Wed Apr 11 2001 - 10:01:02 EDT

  • Next message: Philip Blundell: "Re: [PARPORT] simple driver"

    i am trying to write a simple driver for the parallel port which can
    access the port in the SPP and EPP modes.
    My code is based on alessandro rubini's (Linux Device Drivers, O'rielly)
    code for such a driver.

    the module compiles proplerly except for some pointer initialization
    warnings, but when i try to do

    echo -n "adit" > /dev/scope0 (/dev/scope0 is the parport in SPP mode)

    i get an error like..

    kmalloc: Size (3287312980) too large

    i get this kind of an error even if i try to write to the device using
    write(fd,buf,size).
    also this large number is different every time.
    the code corrresponding to this part is (the write method)...

    read_write_t scope_write(struct inode *inode, struct file *filp,
              const char *buf, count_t count)
    {

         unsigned port = scope_base+(MINOR(inode->i_rdev)&0x0f);
         unsigned char *kbuf=kmalloc(count, GFP_KERNEL), *ptr;
         int retval=count;

         if (!kbuf) return -ENOMEM;
         copy_from_user(kbuf, buf, count);
         ptr=kbuf;

         while(retval--)
              outb(*(ptr++),port);

         kfree(kbuf);
         return retval;
    } /* end of scope_write */

    can someone point out the mistake i am making?

    thanx,
    Aditya Mittal

    -- To unsubscribe, send mail to: linux-parport-request@torque.net --
    -- with the single word "unsubscribe" in the body of the message. --



    This archive was generated by hypermail 2b29 : Wed Apr 11 2001 - 10:35:56 EDT