精华内容
下载资源
问答
  • usb驱动接口

    2017-09-04 16:26:31
    电脑重装系统,需要重装USB驱动,支持32和64位系统。 下载该压缩包,解压后放,通过制定扫描路径进行USB驱动安装。
  • usb驱动框架

    2020-06-09 13:53:06
    该文件是usb驱动的一个框架,很多usb的驱动都可以在这个文件的基础上进行修改得到. 下面就是该源文件,中文部分是我的注释,如有错误的地方,欢迎指出. /* * USB Skeleton driver - 2.2 * * Copyright (C) 2001-2004 ...

    文件路径为kernel/driver/usb/usb_skelton.c
    该文件是usb驱动的一个框架,很多usb的驱动都可以在这个文件的基础上进行修改得到.
    下面就是该源文件,中文部分是我的注释,如有错误的地方,欢迎指出.
    每一个USB设备在内核中抽象为一个数据结构 usb_device,
    它描述了一个USB设备的所有的特性。
    usb_skel_init 中包括该驱动程序向系统注册的函数:usb_register(&skel_driver)
    该函数功能是:
    1。内核有一个USB设备大的链表,所谓的注册就是把这个驱动挂到该链表中
    2。检查总线上的所有USB设备的配置空间,如果有和usb-skeleton中的id_table相同,这就是说该驱动可以驱动在id_table中对上号的设备,如果设备能对应上id_table驱动会把skel_driver这个数据结构挂到usb_device(本文中是usb_skel)上,
    然后调用probe函数来初始化整个设备和做一些准备工作。

    总体来说该驱动框架分析过程应顺着这几个函数:

    module_init(usb_skel_init)—>usb_skel_init()中的
    usb_register(&skel_driver)---->(驱动中的id_table和设备配置能对上号)skel_driver中的
    .probe = skel_probe,----->probe函数中
    usb_register_dev(interface, &skel_class)语句————>
    skel_class 中的.fops = &skel_fops,---->skel_fops中就是
    系统调用对应的函数指针,对应的函数实现了系统调用函数的具体功能,这些函数仅当进行系统调用的时候被执行。
    这就是usb_skeleton 就是usb驱动框架。
    些驱动的指导思想是尽量实现硬件的功能,而不是在这些功能之上添加策略。
    驱动中更重要的是同步问题,继续学习中。
    初学linux驱动,这篇文章只是做个总结,理一下思路,并不是深入研究后的结果。其中还有好多不明白的地方,
    希望大家指出其中的问题,

    #include <linux/kernel.h>
    #include <linux/errno.h>
    #include <linux/init.h>
    #include <linux/slab.h>
    #include <linux/module.h>
    #include <linux/kref.h>
    #include <linux/uaccess.h>
    #include <linux/usb.h>
    #include <linux/mutex.h>
    
    /* Define these values to match your devices */
    #define USB_SKEL_VENDOR_ID 0xfff0
    #define USB_SKEL_PRODUCT_ID 0xfff0
    
    /* table of devices that work with this driver */
    static const struct usb_device_id skel_table[] = {
    	{USB_DEVICE(USB_SKEL_VENDOR_ID, USB_SKEL_PRODUCT_ID)},
    	{} /* Terminating entry */
    };
    MODULE_DEVICE_TABLE(usb, skel_table);
    
    /* Get a minor range for your devices from the usb maintainer */
    #define USB_SKEL_MINOR_BASE 192
    
    /* our private defines. if this grows any larger, use your own .h file */
    #define MAX_TRANSFER (PAGE_SIZE - 512)
    /* MAX_TRANSFER is chosen so that the VM is not stressed by
       allocations > PAGE_SIZE and the number of packets in a page
       is an integer 512 is the largest possible packet on EHCI */
    #define WRITES_IN_FLIGHT 8
    /* arbitrarily chosen */
    
    /* //一个自定义的结构体,用来存储驱动的相关信息
    //分别是设备,接口,设备句柄,主设备号的起始值,设备个数,中断端点数,批量输入端点数,批量输出端点数,
     //输入缓冲区首指针,大小,usb的端点地址
     //输出缓冲区首指针,大小,urb数组,usb的端点地址
      //工作队列,设备使用计数,信号量 */
    struct usb_skel
    {
    	struct usb_device *udev;		 /* the usb device for this device */
    	struct usb_interface *interface; /* the interface for this device */
    	struct semaphore limit_sem;		 /* limiting the number of writes in progress */
    	struct usb_anchor submitted;	 /* in case we need to retract our submissions */
    	struct urb *bulk_in_urb;		 /* the urb to read data with */
    	unsigned char *bulk_in_buffer;	 /* the buffer to receive data */
    	size_t bulk_in_size;			 /* the size of the receive buffer */
    	size_t bulk_in_filled;			 /* number of bytes in the buffer */
    	size_t bulk_in_copied;			 /* already copied to user space */
    	__u8 bulk_in_endpointAddr;		 /* the address of the bulk in endpoint */
    	__u8 bulk_out_endpointAddr;		 /* the address of the bulk out endpoint */
    	int errors;						 /* the last request tanked */
    	int open_count;					 /* count the number of openers */
    	bool ongoing_read;				 /* a read is going on */
    	bool processed_urb;				 /* indicates we haven't processed the urb */
    	spinlock_t err_lock;			 /* lock for errors */
    	struct kref kref;
    	struct mutex io_mutex;				  /* synchronize I/O with disconnect */
    	struct completion bulk_in_completion; /* to wait for an ongoing read */
    };
    #define to_skel_dev(d) container_of(d, struct usb_skel, kref)
    
    static struct usb_driver skel_driver;
    static void skel_draw_down(struct usb_skel *dev);
    
    static void skel_delete(struct kref *kref)
    {
    	struct usb_skel *dev = to_skel_dev(kref);
    
    	usb_free_urb(dev->bulk_in_urb);
    	usb_put_dev(dev->udev);
    	kfree(dev->bulk_in_buffer);
    	kfree(dev);
    }
    
    static int skel_open(struct inode *inode, struct file *file)
    {
    	struct usb_skel *dev;
    	struct usb_interface *interface;
    	int subminor;
    	int retval = 0;
    
    	subminor = iminor(inode);
    
    	interface = usb_find_interface(&skel_driver, subminor);
    	if (!interface)
    	{
    		err("%s - error, can't find device for minor %d",
    			__func__, subminor);
    		retval = -ENODEV;
    		goto exit;
    	}
    
    	dev = usb_get_intfdata(interface);
    	if (!dev)
    	{
    		retval = -ENODEV;
    		goto exit;
    	}
    
    	/* increment our usage count for the device */
    	kref_get(&dev->kref);
    
    	/* lock the device to allow correctly handling errors
    	 * in resumption */
    	mutex_lock(&dev->io_mutex);
    
    	if (!dev->open_count++)
    	{
    		retval = usb_autopm_get_interface(interface);
    		if (retval)
    		{
    			dev->open_count--;
    			mutex_unlock(&dev->io_mutex);
    			kref_put(&dev->kref, skel_delete);
    			goto exit;
    		}
    	} /* else { //uncomment this block if you want exclusive open
    		retval = -EBUSY;
    		dev->open_count--;
    		mutex_unlock(&dev->io_mutex);
    		kref_put(&dev->kref, skel_delete);
    		goto exit;
    	} */
    	/* prevent the device from being autosuspended */
    
    	/* save our object in the file's private structure */
    	file->private_data = dev;
    	mutex_unlock(&dev->io_mutex);
    
    exit:
    	return retval;
    }
    
    static int skel_release(struct inode *inode, struct file *file)
    {
    	struct usb_skel *dev;
    
    	dev = file->private_data;
    	if (dev == NULL)
    		return -ENODEV;
    
    	/* allow the device to be autosuspended */
    	mutex_lock(&dev->io_mutex);
    	if (!--dev->open_count && dev->interface)
    		usb_autopm_put_interface(dev->interface);
    	mutex_unlock(&dev->io_mutex);
    
    	/* decrement the count on our device */
    	kref_put(&dev->kref, skel_delete);
    	return 0;
    }
    
    static int skel_flush(struct file *file, fl_owner_t id)
    {
    	struct usb_skel *dev;
    	int res;
    
    	dev = file->private_data;
    	if (dev == NULL)
    		return -ENODEV;
    
    	/* wait for io to stop */
    	mutex_lock(&dev->io_mutex);
    	skel_draw_down(dev);
    
    	/* read out errors, leave subsequent opens a clean slate */
    	spin_lock_irq(&dev->err_lock);
    	res = dev->errors ? (dev->errors == -EPIPE ? -EPIPE : -EIO) : 0;
    	dev->errors = 0;
    	spin_unlock_irq(&dev->err_lock);
    
    	mutex_unlock(&dev->io_mutex);
    
    	return res;
    }
    
    static void skel_read_bulk_callback(struct urb *urb)
    {
    	struct usb_skel *dev;
    
    	dev = urb->context;
    
    	spin_lock(&dev->err_lock);
    	/* sync/async unlink faults aren't errors */
    	if (urb->status)
    	{
    		if (!(urb->status == -ENOENT ||
    			  urb->status == -ECONNRESET ||
    			  urb->status == -ESHUTDOWN))
    			err("%s - nonzero write bulk status received: %d",
    				__func__, urb->status);
    
    		dev->errors = urb->status;
    	}
    	else
    	{
    		dev->bulk_in_filled = urb->actual_length;
    	}
    	dev->ongoing_read = 0;
    	spin_unlock(&dev->err_lock);
    
    	complete(&dev->bulk_in_completion);
    }
    
    static int skel_do_read_io(struct usb_skel *dev, size_t count)
    {
    	int rv;
    
    	/* prepare a read */
    	usb_fill_bulk_urb(dev->bulk_in_urb,
    					  dev->udev,
    					  usb_rcvbulkpipe(dev->udev,
    									  dev->bulk_in_endpointAddr),
    					  dev->bulk_in_buffer,
    					  min(dev->bulk_in_size, count),
    					  skel_read_bulk_callback,
    					  dev);
    	/* tell everybody to leave the URB alone */
    	spin_lock_irq(&dev->err_lock);
    	dev->ongoing_read = 1;
    	spin_unlock_irq(&dev->err_lock);
    
    	/* do it */
    	rv = usb_submit_urb(dev->bulk_in_urb, GFP_KERNEL);
    	if (rv < 0)
    	{
    		err("%s - failed submitting read urb, error %d",
    			__func__, rv);
    		dev->bulk_in_filled = 0;
    		rv = (rv == -ENOMEM) ? rv : -EIO;
    		spin_lock_irq(&dev->err_lock);
    		dev->ongoing_read = 0;
    		spin_unlock_irq(&dev->err_lock);
    	}
    
    	return rv;
    }
    
    static ssize_t skel_read(struct file *file, char *buffer, size_t count,
    						 loff_t *ppos)
    {
    	struct usb_skel *dev;
    	int rv;
    	bool ongoing_io;
    
    	dev = file->private_data;
    
    	/* if we cannot read at all, return EOF */
    	if (!dev->bulk_in_urb || !count)
    		return 0;
    
    	/* no concurrent readers */
    	rv = mutex_lock_interruptible(&dev->io_mutex);
    	if (rv < 0)
    		return rv;
    
    	if (!dev->interface)
    	{ /* disconnect() was called */
    		rv = -ENODEV;
    		goto exit;
    	}
    
    	/* if IO is under way, we must not touch things */
    retry:
    	spin_lock_irq(&dev->err_lock);
    	ongoing_io = dev->ongoing_read;
    	spin_unlock_irq(&dev->err_lock);
    
    	if (ongoing_io)
    	{
    		/* nonblocking IO shall not wait */
    		if (file->f_flags & O_NONBLOCK)
    		{
    			rv = -EAGAIN;
    			goto exit;
    		}
    		/*
    		 * IO may take forever
    		 * hence wait in an interruptible state
    		 */
    		rv = wait_for_completion_interruptible(&dev->bulk_in_completion);
    		if (rv < 0)
    			goto exit;
    		/*
    		 * by waiting we also semiprocessed the urb
    		 * we must finish now
    		 */
    		dev->bulk_in_copied = 0;
    		dev->processed_urb = 1;
    	}
    
    	if (!dev->processed_urb)
    	{
    		/*
    		 * the URB hasn't been processed
    		 * do it now
    		 */
    		wait_for_completion(&dev->bulk_in_completion);
    		dev->bulk_in_copied = 0;
    		dev->processed_urb = 1;
    	}
    
    	/* errors must be reported */
    	rv = dev->errors;
    	if (rv < 0)
    	{
    		/* any error is reported once */
    		dev->errors = 0;
    		/* to preserve notifications about reset */
    		rv = (rv == -EPIPE) ? rv : -EIO;
    		/* no data to deliver */
    		dev->bulk_in_filled = 0;
    		/* report it */
    		goto exit;
    	}
    
    	/*
    	 * if the buffer is filled we may satisfy the read
    	 * else we need to start IO
    	 */
    
    	if (dev->bulk_in_filled)
    	{
    		/* we had read data */
    		size_t available = dev->bulk_in_filled - dev->bulk_in_copied;
    		size_t chunk = min(available, count);
    
    		if (!available)
    		{
    			/*
    			 * all data has been used
    			 * actual IO needs to be done
    			 */
    			rv = skel_do_read_io(dev, count);
    			if (rv < 0)
    				goto exit;
    			else
    				goto retry;
    		}
    		/*
    		 * data is available
    		 * chunk tells us how much shall be copied
    		 */
    
    		if (copy_to_user(buffer,
    						 dev->bulk_in_buffer + dev->bulk_in_copied,
    						 chunk))
    			rv = -EFAULT;
    		else
    			rv = chunk;
    
    		dev->bulk_in_copied += chunk;
    
    		/*
    		 * if we are asked for more than we have,
    		 * we start IO but don't wait
    		 */
    		if (available < count)
    			skel_do_read_io(dev, count - chunk);
    	}
    	else
    	{
    		/* no data in the buffer */
    		rv = skel_do_read_io(dev, count);
    		if (rv < 0)
    			goto exit;
    		else if (!(file->f_flags & O_NONBLOCK))
    			goto retry;
    		rv = -EAGAIN;
    	}
    exit:
    	mutex_unlock(&dev->io_mutex);
    	return rv;
    }
    
    static void skel_write_bulk_callback(struct urb *urb)
    {
    	struct usb_skel *dev;
    
    	dev = urb->context;
    
    	/* sync/async unlink faults aren't errors */
    	if (urb->status)
    	{
    		if (!(urb->status == -ENOENT ||
    			  urb->status == -ECONNRESET ||
    			  urb->status == -ESHUTDOWN))
    			err("%s - nonzero write bulk status received: %d",
    				__func__, urb->status);
    
    		spin_lock(&dev->err_lock);
    		dev->errors = urb->status;
    		spin_unlock(&dev->err_lock);
    	}
    
    	/* free up our allocated buffer */
    	usb_free_coherent(urb->dev, urb->transfer_buffer_length,
    					  urb->transfer_buffer, urb->transfer_dma);
    	up(&dev->limit_sem);
    }
    
    static ssize_t skel_write(struct file *file, const char *user_buffer,
    						  size_t count, loff_t *ppos)
    {
    	struct usb_skel *dev;
    	int retval = 0;
    	struct urb *urb = NULL;
    	char *buf = NULL;
    	size_t writesize = min(count, (size_t)MAX_TRANSFER);
    
    	dev = file->private_data;
    
    	/* verify that we actually have some data to write */
    	if (count == 0)
    		goto exit;
    
    	/*
    	 * limit the number of URBs in flight to stop a user from using up all
    	 * RAM
    	 */
    	if (!(file->f_flags & O_NONBLOCK))
    	{
    		if (down_interruptible(&dev->limit_sem))
    		{
    			retval = -ERESTARTSYS;
    			goto exit;
    		}
    	}
    	else
    	{
    		if (down_trylock(&dev->limit_sem))
    		{
    			retval = -EAGAIN;
    			goto exit;
    		}
    	}
    
    	spin_lock_irq(&dev->err_lock);
    	retval = dev->errors;
    	if (retval < 0)
    	{
    		/* any error is reported once */
    		dev->errors = 0;
    		/* to preserve notifications about reset */
    		retval = (retval == -EPIPE) ? retval : -EIO;
    	}
    	spin_unlock_irq(&dev->err_lock);
    	if (retval < 0)
    		goto error;
    
    	/* create a urb, and a buffer for it, and copy the data to the urb */
    	urb = usb_alloc_urb(0, GFP_KERNEL);
    	if (!urb)
    	{
    		retval = -ENOMEM;
    		goto error;
    	}
    
    	buf = usb_alloc_coherent(dev->udev, writesize, GFP_KERNEL,
    							 &urb->transfer_dma);
    	if (!buf)
    	{
    		retval = -ENOMEM;
    		goto error;
    	}
    
    	if (copy_from_user(buf, user_buffer, writesize))
    	{
    		retval = -EFAULT;
    		goto error;
    	}
    
    	/* this lock makes sure we don't submit URBs to gone devices */
    	mutex_lock(&dev->io_mutex);
    	if (!dev->interface)
    	{ /* disconnect() was called */
    		mutex_unlock(&dev->io_mutex);
    		retval = -ENODEV;
    		goto error;
    	}
    
    	/* initialize the urb properly */
    	usb_fill_bulk_urb(urb, dev->udev,
    					  usb_sndbulkpipe(dev->udev, dev->bulk_out_endpointAddr),
    					  buf, writesize, skel_write_bulk_callback, dev);
    	urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
    	usb_anchor_urb(urb, &dev->submitted);
    
    	/* send the data out the bulk port */
    	retval = usb_submit_urb(urb, GFP_KERNEL);
    	mutex_unlock(&dev->io_mutex);
    	if (retval)
    	{
    		err("%s - failed submitting write urb, error %d", __func__,
    			retval);
    		goto error_unanchor;
    	}
    
    	/*
    	 * release our reference to this urb, the USB core will eventually free
    	 * it entirely
    	 */
    	usb_free_urb(urb);
    
    	return writesize;
    
    error_unanchor:
    	usb_unanchor_urb(urb);
    error:
    	if (urb)
    	{
    		usb_free_coherent(dev->udev, writesize, buf, urb->transfer_dma);
    		usb_free_urb(urb);
    	}
    	up(&dev->limit_sem);
    
    exit:
    	return retval;
    }
    
    static const struct file_operations skel_fops = {
    	.owner = THIS_MODULE,
    	.read = skel_read,
    	.write = skel_write,
    	.open = skel_open,
    	.release = skel_release,
    	.flush = skel_flush,
    	.llseek = noop_llseek,
    };
    
    /*
     * usb class driver info in order to get a minor number from the usb core,
     * and to have the device registered with the driver core
     */
    static struct usb_class_driver skel_class = {
    	.name = "skel%d",
    	.fops = &skel_fops,
    	.minor_base = USB_SKEL_MINOR_BASE,
    };
    
    static int skel_probe(struct usb_interface *interface,
    					  const struct usb_device_id *id)
    {
    	struct usb_skel *dev;					  //设备信息
    	struct usb_host_interface *iface_desc;	  //接口函数
    	struct usb_endpoint_descriptor *endpoint; //端点结构体
    	size_t buffer_size;						  //缓冲区大小
    	int i;
    	int retval = -ENOMEM;
    
    	/* 分配内存空间 for our device state and初始化*/
    	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
    	if (!dev)
    	{
    		err("Out of memory");
    		goto error;
    	}
    	kref_init(&dev->kref);
    	sema_init(&dev->limit_sem, WRITES_IN_FLIGHT);
    	mutex_init(&dev->io_mutex);
    	spin_lock_init(&dev->err_lock);
    	init_usb_anchor(&dev->submitted);
    	init_completion(&dev->bulk_in_completion);
    
    	dev->udev = usb_get_dev(interface_to_usbdev(interface));
    	dev->interface = interface;
    
    	/* 设置端点信息 */
    	/* 仅使用第一个批量输入和输出的端点 */
    	iface_desc = interface->cur_altsetting;
    	for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i)
    	{
    		endpoint = &iface_desc->endpoint[i].desc;
    
    		if (!dev->bulk_in_endpointAddr &&
    			usb_endpoint_is_bulk_in(endpoint))
    		{
    			/* we found a 主体 in endpoint */
    			buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
    			dev->bulk_in_size = buffer_size;
    			dev->bulk_in_endpointAddr = endpoint->bEndpointAddress;
    			dev->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL);
    			if (!dev->bulk_in_buffer)
    			{
    				err("Could not allocate bulk_in_buffer");
    				goto error;
    			}
    			dev->bulk_in_urb = usb_alloc_urb(0, GFP_KERNEL);
    			if (!dev->bulk_in_urb)
    			{
    				err("Could not allocate bulk_in_urb");
    				goto error;
    			}
    		}
    
    		if (!dev->bulk_out_endpointAddr &&
    			usb_endpoint_is_bulk_out(endpoint))
    		{
    			/* we found a bulk out endpoint */
    			dev->bulk_out_endpointAddr = endpoint->bEndpointAddress;
    		}
    	}
    
    	//没有找到可用端点
    	if (!(dev->bulk_in_endpointAddr && dev->bulk_out_endpointAddr))
    	{
    		err("Could not find both bulk-in and bulk-out endpoints");
    		goto error;
    	}
    
    	/* 将设备信息保存在此接口设备中,就是向系统注册一些以后会用的的信息 */
    	usb_set_intfdata(interface, dev);
    
    	/*我们现在可以注册设备,因为它已经准备好了 即向这个interface注册一个skel_class结构
    
    此处是重点!*/
    	retval = usb_register_dev(interface, &skel_class);
    	if (retval)
    	{
    		/* 有东西阻止我们注册设备 */
    		err("Not able to get a minor for this device.");
    		usb_set_intfdata(interface, NULL);
    		goto error;
    	}
    
    	/*让用户知道此设备现在连接到的节点,USB骨架设备现在连接到USBSkel-%d */
    	dev_info(&interface->dev,
    			 "USB Skeleton device now attached to USBSkel-%d",
    			 interface->minor);
    	return 0;
    
    error:
    	if (dev)
    		/* this frees allocated memory */
    		kref_put(&dev->kref, skel_delete);
    	return retval;
    }
    //当设备被拔出集线器时,USB子系统会自动调用disconnect
    static void skel_disconnect(struct usb_interface *interface)
    {
    	struct usb_skel *dev;
    	int minor = interface->minor;
    
    	dev = usb_get_intfdata(interface);
    	usb_set_intfdata(interface, NULL);
    
    	/* give back our minor */
    	usb_deregister_dev(interface, &skel_class);
    
    	/* prevent more I/O from starting */
    	mutex_lock(&dev->io_mutex);
    	dev->interface = NULL;
    	mutex_unlock(&dev->io_mutex);
    
    	usb_kill_anchored_urbs(&dev->submitted);
    
    	/* decrement our usage count */
    	kref_put(&dev->kref, skel_delete);
    
    	dev_info(&interface->dev, "USB Skeleton #%d now disconnected", minor);
    }
    
    static void skel_draw_down(struct usb_skel *dev)
    {
    	int time;
    
    	time = usb_wait_anchor_empty_timeout(&dev->submitted, 1000);
    	if (!time)
    		usb_kill_anchored_urbs(&dev->submitted);
    	usb_kill_urb(dev->bulk_in_urb);
    }
    
    static int skel_suspend(struct usb_interface *intf, pm_message_t message)
    {
    	struct usb_skel *dev = usb_get_intfdata(intf);
    
    	if (!dev)
    		return 0;
    	skel_draw_down(dev);
    	return 0;
    }
    
    static int skel_resume(struct usb_interface *intf)
    {
    	return 0;
    }
    
    static int skel_pre_reset(struct usb_interface *intf)
    {
    	struct usb_skel *dev = usb_get_intfdata(intf);
    
    	mutex_lock(&dev->io_mutex);
    	skel_draw_down(dev);
    
    	return 0;
    }
    
    static int skel_post_reset(struct usb_interface *intf)
    {
    	struct usb_skel *dev = usb_get_intfdata(intf);
    
    	/* we are sure no URBs are active - no locking needed */
    	dev->errors = -EPIPE;
    	mutex_unlock(&dev->io_mutex);
    
    	return 0;
    }
    
    static struct usb_driver skel_driver = {
    	.name = "skeleton",
    	.probe = skel_probe,
    	.disconnect = skel_disconnect,
    	.suspend = skel_suspend,
    	.resume = skel_resume,
    	.pre_reset = skel_pre_reset,
    	.post_reset = skel_post_reset,
    	.id_table = skel_table,
    	.supports_autosuspend = 1,
    };
    
    static int __init usb_skel_init(void)
    {
    	int result;
    	//设备注册
    	/* register this driver with the USB subsystem */
    	result = usb_register(&skel_driver);
    	if (result)
    		err("usb_register failed. Error number %d", result);
    
    	return result;
    }
    //设备注销
    static void __exit usb_skel_exit(void)
    {
    	/* deregister this driver with the USB subsystem */
    	usb_deregister(&skel_driver);
    }
    
    module_init(usb_skel_init);
    module_exit(usb_skel_exit);
    
    MODULE_LICENSE("GPL");
    
    
    展开全文
  • 1、先进入内核目录: $ cd /home/xiaogang.lu/hisi/new_project/Hi3516A_SDK_V1.0.5.0/osdrv/opensource/kernel/linux-3.4.y 2、执行命令: $ make ARCH=arm CROSS_COMPILE=arm-hisiv300-linux- ... 配置路径: ...

    1、先进入内核目录:
        $ cd /home/xiaogang.lu/hisi/new_project/Hi3516A_SDK_V1.0.5.0/osdrv/opensource/kernel/linux-3.4.y
        
    2、执行命令:
        $ make ARCH=arm CROSS_COMPILE=arm-hisiv300-linux- menuconfig


      配置路径:
      | Symbol: TOUCHSCREEN_USB_COMPOSITE [=y]                                                                                      |
      | Type  : tristate                                                                                                            |
      | Prompt: USB Touchscreen Driver                                                                                              |
      |   Defined at drivers/input/touchscreen/Kconfig:624                                                                          |
      |   Depends on: !S390 && !UML && INPUT [=y] && INPUT_TOUCHSCREEN [=y] && USB_ARCH_HAS_HCD [=y]                                |
      |   Location:                                                                                                                 |
      |     -> Device Drivers                                                                                                       |
      |       -> Input device support                                                                                               |
      |         -> Generic input layer (needed for keyboard, mouse, ...) (INPUT [=y])                                               |
      |           -> Touchscreens (INPUT_TOUCHSCREEN [=y])                                                                          |
      |   Selects: USB [=y] 

    展开全文
  • 软件介绍: 本驱动用于Mini-usb bios编程器,安装方法很简单,先将下载的驱动解压,然后连接编程器,当弹出找到新硬件窗口时,将驱动程序路径设置为刚才的解压文件夹即可。
  • M1刷卡器USB驱动

    2017-03-21 09:37:50
    M1刷卡器USB驱动安装步骤: 在桌面我的电脑上单击鼠标右键 →选择属性 →进入硬件选项→打开设备管理器→(会提示一个CP210X的设备)选定右键 →更新驱动程序 →选择从列表或指定位置安装(高级) →下一步 →选择在搜索...
  • 1、USB HID HID:Human Interface Devices的缩写,即人体学输入设备或人体学接入设备。USB HID则为USB人体学输入...驱动路径:drivers/hid/usbhid 驱动相关文件: usbkbd.c为usb键盘驱动,usbmouse.c为usb鼠标驱动。

    1、USB HID

    HID:Human Interface Devices的缩写,即人体学输入设备或人体学接入设备。USB HID则为USB人体学输入设备,最典型的是USB鼠标和USB键盘。


    2、驱动路径和相关文件

    驱动路径:drivers/hid/usbhid

    驱动相关文件:


    usbkbd.c为usb键盘驱动,usbmouse.c为usb鼠标驱动。

    展开全文
  • MTK智能机usb驱动下载刷机必备驱动大全 使用说明: 1.ADB联机驱动 这个是豌豆荚和91助手同步手机时候的驱动,开启USB调试后,接上电脑,即可提示发现新硬件,这时候把路径指向【ADB联机驱动】即可。 2.刷机驱动...
  • 用于DNW下载程序”,安装时先将驱动解压在当前目录下得到“USB驱动程序”文件夹,然后开发板上电使其进入选择菜单,连接好USB线,PC机右下角提示发现新硬件,根据安装向导提示指定驱动路径——“USB驱动程序”文件夹...
  • USB驱动问题

    千次阅读 2011-11-29 18:10:09
    USB驱动是好的,突然无法正常工工作!识别不到USB键盘鼠标,识别不到U盘,连灯都不亮,貌似不能供电。 设备管理器里边显示黄色感叹号!右键查看属性,在常规的设备状态里面可以看到错误信息为: Windows 无法...
     
    

    【问题描述】

    USB原驱动是好的,突然无法正常工工作!识别不到USB键盘鼠标,识别不到U盘,连灯都不亮,貌似不能供电。

    设备管理器里边显示黄色感叹号!右键查看属性,在常规的设备状态里面可以看到错误信息为:

    Windows 无法加载这个硬件的设备驱动程序。驱动程序可能已损坏或不见了。 (代码 39)

     

    【解决方法】


    1. 在注册表里按照路径HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class查找该ID: 36fc9e60-c456-11cf-8056-444553540000, 如下图所示:


    2. 删除Upperfilters(可能无此项)和Lowerfilters 两项

    3. 在设备管理器里,选中带感叹号的USB设备,右键,选择卸载。

    4. 重启计算机。搞定~~~~~~

    【后记】其他驱动问题也可参照该方法

    展开全文
  • USB驱动初探

    2011-02-09 16:20:00
    调了N久68013,最后还是放弃了,使用STM32的USB 调到驱动,建立驱动环境,win7调驱动总感觉格格不入,在xp下建立开发环境 vc6, xpddk_2600,driverstudio_3.2 先安装vc6,安装ddk,最后安装...
  • 软件介绍: 欧姆龙PLC编程电缆在windows7系统下的驱动,将USB电缆连接PLC后直接指定驱动路径安装即可。32位和64位系统都能驱动。
  • Xilinx Platfrom Cable Usb驱动安装

    千次阅读 2018-10-30 18:11:26
    安装ISE后Xilinx Platfrom Cable Usb不能自动安装驱动,烧录器灯不亮,此时需要手动安装驱动。 注意:32位系统:驱动安装路径为:D:\Xilinx_ISE_DS_Win_14.7_1015_1\Xilinx\14.7\ISE_DS\ISE\bin\nt  64位系统:...
  • 注意,该文件是2.4的内核的驱动源文件,并不保证在2.6内核中可用.文件路径为kernel/driver/usb/usb_skelton.c ...该文件是usb驱动的一个框架,很多usb的驱动都可以在这个文件的基础上进行修改得到. 下面就是该源文...
  • 在内核中使能Mass Storage Gadget ,如下图,配置路径是Linux/arm64 4.14.0 Kernel Configuration → Device Drivers → USB support → USB Gadget Support -&gt;Mass Storage Gadget 使能Pseudo文件系统,如...
  • ft232r usb uart驱动

    2017-09-14 09:42:37
    1. 交换机开机,将console口连交换机,usb口连笔记本  2. 打开设备管理器 找到未安装的usb驱动 右击更新驱动 路径选择解压后的文件夹 然后刷新下设备管理器 是否有未安装的驱动直到安装成功。
  • 一 CP2102芯片下载地址https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers下载到的文件双击安装弹出窗里选择同意这里可以选择安装路径然后在弹出的窗口输入电脑账号密码就...
  • 天语W619小黄蜂usb驱动下载,附件安装驱动器教程 语言: 简体中文 版本: 星级: 时间: 12-07-30 适用机型: W619 大小: 1.7M 下载次数: 2473次 上传者: admin 立即下载...
  • ft232r usb uart 驱动

    2013-02-07 22:59:14
    ft232r usb uart 驱动在WindowsXP系统下测试ft232芯片可用,用于console口转usb口... 打开设备管理器 找到未安装的usb驱动 右击更新驱动 路径选择解压后的文件夹 然后刷新下设备管理器 是否有未安装的驱动直到安装成功
  • 通过secureCRT+dnw给ok6410下载文件时DNW总是显示USB连接不OK,安装官方给的USB驱动总是不成功,后来更改驱动的安装路径,将驱动放在一个自定义的浅路径中,再在设备管理器中更新其驱动,成功!!!解决了困扰我很长...
  • fl2440 usb驱动移植

    2015-05-09 15:52:31
    内核版本是linux -3.0 对于linux内核自带驱动的移植总的来说分为2大部:1 将设备加入设备...进入内核目录下的 mach-smdk2440.c这个文件 (路径/arch/arm/mach-s3c2440/mach-smdk2440.c) 添加头文件 #include #in
  • 一 CP2102芯片下载地址https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers下载到的文件双击安装弹出窗里选择同意这里可以选择安装路径然后在弹出的窗口输入电脑账号密码就...
  • 安装TCM后usb驱动路径C:/Program Files/Symbol/TCM2/USB Driver
  • 因为项目里面有USB音频外设,所以需要分析一下UAC驱动。 ...代码路径:sound\usb\card.c 我们先来看看初始化部分,主要是初始化usb_audio_driver结构体 static const struct usb_device_...
  • 删除万能声卡驱动路径:EFI/clover/kexts/other,在kext文件夹下找到 VoodooHDA 删除即可,没有删除默认加载万能声卡驱动,无法加载apple alc放入声卡驱动EFI-clover-kexts-other放入AppleAlc和Lilu 修改clover补丁...
  • USB子系统相关内容参考《精通Linux设备驱动程序》第11章。USB鼠标驱动程序可以参考内核中的鼠标...1、创建usb_driver结构体变量,设置id_table为usb鼠标设备,并注册usb驱动。static struct usb_device_id usb_mouse_i
  • 1、插入U盘后,打印提示盘符sda1,指令find . -name sda1查找对应路径为: ./dev/block/platform/soc0/soc/2100000....2、而fstab.freescale中的usb挂载路径为: /devices/soc0/soc/2100000.aips-bus/2184000.usb...
  • 自制WindowsCE上usb驱动的.cab安装包

    千次阅读 2017-12-22 11:56:43
    1.前言做WindowsCE(以下简称CE)开发中会遇到一些USB的设备,此时一般需要USB设备厂家提供相关的驱动,但由于CE系统经由Windows精简以及硬件配套与PC不同,厂家提供的驱动的安装路径一般会存在默认CE硬件设备的...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 443
精华内容 177
关键字:

usb驱动路径