Kashif Rajput wrote:
> 
> I am sending the driver source that is causing the
> error when a device is made to connect. Shall be
> grateful, if anybody can suggest a remedy.

When _any_ device is connected, or just your (unknown) device?

I can build this driver and insmod it and connect a CPIA
webcam without any usb timeout messages or errors...
although I had to fix the driver in several places first.

Are you using exactly this source code, or did you post
some modified source code?

I'm using Linux 2.4.14.  What version are you using?

~Randy

> -----------START OF SOURCE--------------------
> #ifndef __KERNEL__
> #define __KERNEL__
> #endif
> 
> #ifndef MODULE
> #define MODULE
> #endif
> 
> #include <linux/config.h>
> #include <linux/module.h>
> 
> #if defined(CONFIG_MODVERSIONS) &&
> !defined(MODVERSIONS)
> #define MODVERSIONS
> #endif
> 
> #ifdef MOVERSIONS
> #include <linux/modversions.h>
> #endif
> 
> #if LINUX_VERSION_CODE < 0x020200
> #error "This modules needs kmod, so it won't run with
> 2.0"
> #endif
> 
> #include <linux/kernel.h>
> #include <linux/malloc.h>
> #include <linux/init.h>
> #include <linux/usb.h>
> #include <asm/uaccess.h>
> 
> #ifdef LINUX_24
> static struct file_operations usb_sample_fops   =
>  {
> open:           usb_open,
> write:          usbsample_write,
> read:           usbsample_read,
> release:        usbsample_release,
> };
> #define DEV_MNR 32
> static struct usb_driver sample_usb_driver      =
>  {
> name:           "sample",
> probe:          sample_probe,
> disconnect:     sample_disconnect,
> fops:           &usb_sample_fops,
> minor:          DEV_MNR,
> id_table:       sample_id_table,
> };
> #endif
> 
> struct sample_device    //device specific structure
> {
>         unsigned char data[8];
>         char *name;
>         struct urb myurb;
>         int maxp;
>         char output[80];
> };
> 
> static struct usb_device_id sample_id_table[]   =
>  {
>         {
>         USB_INTERFACE_INFO(3,1,2),
>         driver_info: (unsigned long)"mymouse"
>         },
> 
>         {
>         0,      //no more matches
>         }
> };
> 
> // Function Prototypes
> // ------------------
> static void *sample_probe(struct usb_device*, unsigned
> int ,const struct usb_device_id*);
> static void sample_disconnect(struct usb_device
> *udev,void *);
> void sample_irq(struct urb *);
> static int usb_open(struct inode *,struct file *);
> //--------------------
> 
> //Globally declared variables
> //---------------------------
> struct usb_driver sample_usb_driver;
> struct sample_device *sample;
> 
> //--------------------
> static void *sample_probe(struct usb_device* udev,
> unsigned int ifnum,const struct usb_device_id*
> id_table)
> {
>         struct usb_interface *iface;
>         struct usb_interface_descriptor *interface;
>         struct usb_endpoint_descriptor *endpoint;
>         int pipe,maxp;
> 
>         printk(KERN_ALERT"this is the probe
> function");
> 
>         if(udev->descriptor.idVendor    ==      0x059b
> &&
>                 udev->descriptor.idProduct       ==
>   0x0030)
>         {
> 
>         /*
>         sample  =       kmalloc(sizeof(struct
> sample_device),GFP_KERNEL);
> 
>         if(!sample)
>                 return NULL;
> 
>         memset(sample,0,sizeof(*sample));
> 
>         pipe        =
> usb_rcvintpipe(udev,endpoint->bEndpointAddress);
>         maxp        =
> usb_maxpacket(udev,pipe,usb_pipeout(pipe));
> 
>         if(maxp>8)
>                 maxp    =       8;
>         sample->maxp    =       maxp;
> 
> 
> FILL_BULK_URB(&sample->myurb,udev,pipe,sample->data,maxp,sample_irq,sample);
> 
>         if(usb_submit_urb(&sample->myurb))
>         {
>                 kfree(sample);
>                 return NULL;
>         }
> 
>         printk(KERN_ALERT"\nURB submitted too\n");
> 
>         return sample;
>         */
>         printk(KERN_INFO,"Probe() of the driver
> called");
> 
>         }
> 
>         return NULL;
> 
> }
> 
> static void sample_disconnect(struct usb_device
> *udev,void *clientdata)
> {
>         //struct sample_device *sample    =
> clientdata;
>         usb_unlink_urb(&sample->myurb);
>         kfree(sample);
>         printk(KERN_ALERT "usbsample driver disconnect
> function called");
>         return;
> }
> 
> void sample_irq(struct urb * myurb)
> {
>         char *pos       =       sample->output;
>     //    if(urb_status  != USB_ST_NOERROR) return;
> 
>         printk(KERN_ALERT "\nusbsample: sample_irq
> handle function called\n");
> }
> 
> //--------------------
> 
> static int usb_open(struct inode *inode,struct file
> *file)
> {
>         printk(KERN_ALERT "\nusbsample: open called
> for device\n");
> 
>         return 0;
> }
> 
> static ssize_t usbsample_read(struct file *filp, char
> *buf, size_t count, loff_t *f_pos)
> {
>         char *bufFrom;
>         sample  =       filp->private_data;
>         bufFrom     =       "This is the data being
> copied to the user space";
>         copy_to_user(buf,bufFrom,sizeof(bufFrom));
>         printk(KERN_INFO "The Usb_sample read function
> called");
> 
>         return 0;
> }
> 
> //----------------------
> 
> int sample_init(void)
> {
>         printk(KERN_ALERT"Entering the sample_init
> function");
>         return usb_register(&sample_usb_driver);
> }
> 
> void sample_exit(void)
> {
>         usb_deregister(&sample_usb_driver);
> }
> 
> module_init(sample_init);
> module_exit(sample_exit);
> 
> #endif
> -----------------END OF SOURCE------------------

_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to