Linux USB subsystem --- register generic usb driver

原创 2012年03月26日 21:38:55

目的:对USB作深入学习,在此留下笔记。欢迎讨论。

[Linux 3.2] [driver/usb/core/driver.c]

函数:usb_register_device_driver


/**
 * usb_register_device_driver - register a USB device (not interface) driver
 * @new_udriver: USB operations for the device driver
 * @owner: module owner of this driver.
 *
 * Registers a USB device driver with the USB core.  The list of
 * unattached devices will be rescanned whenever a new driver is
 * added, allowing the new driver to attach to any recognized devices.
 * Returns a negative error code on failure and 0 on success.
 */
int usb_register_device_driver(struct usb_device_driver *new_udriver,
		struct module *owner)
{
	int retval = 0;

	if (usb_disabled())
		return -ENODEV;

	new_udriver->drvwrap.for_devices = 1;
	new_udriver->drvwrap.driver.name = (char *) new_udriver->name;
	new_udriver->drvwrap.driver.bus = &usb_bus_type;
	new_udriver->drvwrap.driver.probe = usb_probe_device;
	new_udriver->drvwrap.driver.remove = usb_unbind_device;
	new_udriver->drvwrap.driver.owner = owner;

	retval = driver_register(&new_udriver->drvwrap.driver);

	if (!retval) {
		pr_info("%s: registered new device driver %s\n",
			usbcore_name, new_udriver->name);
		usbfs_update_special();
	} else {
		printk(KERN_ERR "%s: error %d registering device "
			"	driver %s\n",
			usbcore_name, retval, new_udriver->name);
	}

	return retval;
}
EXPORT_SYMBOL_GPL(usb_register_device_driver);

此过程是注册一个usb的通用程驱动。驱动注册的过程与usbfs驱动注册类似。其结果是:在/sys/bus/usb/drivers/下面创建usb目录。在usb目录下面创建如下属性文件。

bind  uevent  unbind


至此,整个usb core的初始化过程完成。

后面将进入到USB host controller的初始化。

相关文章推荐

Linux USB subsystem --- EHCI host controller register

目的:对USB作深入学习,在此留下笔记。欢迎讨论。 [Linux 3.2] [driver/usb/host/ehci-hcd.c] 函数:ehci_hcd_init() stati...

Linux USB subsystem --- USBFS driver registration

Linux USB subsystem --- USBFS driver registration

s3c2440 usb host device controller驱动分析(五)-----generic driver

下面继续将一个generic driver。这个generic driver是针对usb device的。而class driver一般是针对usb interface的。其实这个generic dr...
  • a_jige
  • a_jige
  • 2013年10月17日 22:29
  • 1905

Linux USB subsystem -- initialize

USB initialization function -- usb_init()

The Linux USB Input Subsystem, Part I

The Linux USB Input Subsystem, Part I (2008-06-20 14:19:13) 转载       The L...
  • wenhui_
  • wenhui_
  • 2011年10月09日 13:43
  • 677

Linux USB subsystem --- USB create HCD

目的:对USB作深入学习,在此留下笔记。欢迎讨论。 [Linux-3.2][drivers/usb/core/hcd.c] 函数:usb_create_hcd(const struct h...

g_ncm Linux USB network gadget driver framework

最近在读Linux USB gadget network driver,写下笔记以后可以参考.

Linux USB Device Driver Primer

Linux USB Device driverProgramming Data Flow Types ~~~~~~~~~~~~~~~~ a) Controltransfers:are...
  • cumtpl
  • cumtpl
  • 2012年04月15日 12:04
  • 649

linux驱动模块加载出错insmod: error inserting './usb_driver.ko': -1 Unknown symbol in module

今天开始调试usb驱动,第一步加载模块部分就开始报错。网上检索,有位朋友总结一些类似情况。本人遇到的恰好是第二种情况,以前不太注意,没出错也就不追究,这次遇到了就一并把一些情况在此记上一笔。转载如下:...

Program for Linux USB-devices driver step by step (ONE)

Program for Linux USB-devices driver 开始啃硬骨头~ 这里我打算一步步给出USB device driver 的demo,希望有心能能够共同交流学习. 希望认识...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Linux USB subsystem --- register generic usb driver
举报原因:
原因补充:

(最多只允许输入30个字)