当前位置: 首页>>代码示例>>C++>>正文


C++ device_unregister函数代码示例

本文整理汇总了C++中device_unregister函数的典型用法代码示例。如果您正苦于以下问题:C++ device_unregister函数的具体用法?C++ device_unregister怎么用?C++ device_unregister使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了device_unregister函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: my_bus_exit

static void my_bus_exit(void)
{
	device_unregister(&my_bus);
	bus_unregister(&my_bus_type);
}
开发者ID:embedclub,项目名称:project,代码行数:5,代码来源:Bus.c

示例2: sensors_unregister

void sensors_unregister(struct device *dev)
{
	device_unregister(dev);
}
开发者ID:ASAZING,项目名称:Android-Kernel-Gt-s7390l,代码行数:4,代码来源:sensors_core.c

示例3: omap_dss_unregister_device

static void omap_dss_unregister_device(struct omap_dss_device *dssdev)
{
	device_unregister(&dssdev->dev);
}
开发者ID:lchao-bit,项目名称:linaro-kernel,代码行数:4,代码来源:core.c

示例4: read_lock_irq

/**
 * zfcp_unit_enqueue - enqueue unit to unit list of a port.
 * @port: pointer to port where unit is added
 * @fcp_lun: FCP LUN of unit to be enqueued
 * Returns: pointer to enqueued unit on success, ERR_PTR on error
 * Locks: config_mutex must be held to serialize changes to the unit list
 *
 * Sets up some unit internal structures and creates sysfs entry.
 */
struct zfcp_unit *zfcp_unit_enqueue(struct zfcp_port *port, u64 fcp_lun)
{
	struct zfcp_unit *unit;

	read_lock_irq(&zfcp_data.config_lock);
	if (zfcp_get_unit_by_lun(port, fcp_lun)) {
		read_unlock_irq(&zfcp_data.config_lock);
		return ERR_PTR(-EINVAL);
	}
	read_unlock_irq(&zfcp_data.config_lock);

	unit = kzalloc(sizeof(struct zfcp_unit), GFP_KERNEL);
	if (!unit)
		return ERR_PTR(-ENOMEM);

	atomic_set(&unit->refcount, 0);
	init_waitqueue_head(&unit->remove_wq);
	INIT_WORK(&unit->scsi_work, zfcp_scsi_scan_work);

	unit->port = port;
	unit->fcp_lun = fcp_lun;

	if (dev_set_name(&unit->sysfs_device, "0x%016llx",
			 (unsigned long long) fcp_lun)) {
		kfree(unit);
		return ERR_PTR(-ENOMEM);
	}
	unit->sysfs_device.parent = &port->sysfs_device;
	unit->sysfs_device.release = zfcp_sysfs_unit_release;
	dev_set_drvdata(&unit->sysfs_device, unit);

	/* mark unit unusable as long as sysfs registration is not complete */
	atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &unit->status);

	spin_lock_init(&unit->latencies.lock);
	unit->latencies.write.channel.min = 0xFFFFFFFF;
	unit->latencies.write.fabric.min = 0xFFFFFFFF;
	unit->latencies.read.channel.min = 0xFFFFFFFF;
	unit->latencies.read.fabric.min = 0xFFFFFFFF;
	unit->latencies.cmd.channel.min = 0xFFFFFFFF;
	unit->latencies.cmd.fabric.min = 0xFFFFFFFF;

	if (device_register(&unit->sysfs_device)) {
		put_device(&unit->sysfs_device);
		return ERR_PTR(-EINVAL);
	}

	if (sysfs_create_group(&unit->sysfs_device.kobj,
			       &zfcp_sysfs_unit_attrs)) {
		device_unregister(&unit->sysfs_device);
		return ERR_PTR(-EINVAL);
	}

	zfcp_unit_get(unit);

	write_lock_irq(&zfcp_data.config_lock);
	list_add_tail(&unit->list, &port->unit_list_head);
	atomic_clear_mask(ZFCP_STATUS_COMMON_REMOVE, &unit->status);
	atomic_set_mask(ZFCP_STATUS_COMMON_RUNNING, &unit->status);

	write_unlock_irq(&zfcp_data.config_lock);

	zfcp_port_get(port);

	return unit;
}
开发者ID:3null,项目名称:fastsocket,代码行数:75,代码来源:zfcp_aux.c

示例5: rpmsg_remove_device

static int rpmsg_remove_device(struct device *dev, void *data)
{
	device_unregister(dev);

	return 0;
}
开发者ID:mjduddin,项目名称:B14CKB1RD_kernel_m8,代码行数:6,代码来源:virtio_rpmsg_bus.c

示例6: camera_detector_exit

static void __exit camera_detector_exit(void) {

	detect_print("Bye, camera detect driver exit\n");
	device_unregister(&camera_detector_device);
}
开发者ID:jiangdoudou,项目名称:a31_422_v33_lichee,代码行数:5,代码来源:camera_detector.c

示例7: amba_device_add

/**
 *	amba_device_add - add a previously allocated AMBA device structure
 *	@dev: AMBA device allocated by amba_device_alloc
 *	@parent: resource parent for this devices resources
 *
 *	Claim the resource, and read the device cell ID if not already
 *	initialized.  Register the AMBA device with the Linux device
 *	manager.
 */
int amba_device_add(struct amba_device *dev, struct resource *parent)
{
	u32 size;
	void __iomem *tmp;
	int i, ret;

	WARN_ON(dev->irq[0] == (unsigned int)-1);
	WARN_ON(dev->irq[1] == (unsigned int)-1);

	ret = request_resource(parent, &dev->res);
	if (ret)
		goto err_out;

	/* Hard-coded primecell ID instead of plug-n-play */
	if (dev->periphid != 0)
		goto skip_probe;

	/*
	 * Dynamically calculate the size of the resource
	 * and use this for iomap
	 */
	size = resource_size(&dev->res);
	tmp = ioremap(dev->res.start, size);
	if (!tmp) {
		ret = -ENOMEM;
		goto err_release;
	}

//	ret = amba_get_enable_pclk(dev);
	ret = 0;
	if (ret == 0) {
		u32 pid, cid;

		/*
		 * Read pid and cid based on size of resource
		 * they are located at end of region
		 */
		for (pid = 0, i = 0; i < 4; i++)
			pid |= (readl(tmp + size - 0x20 + 4 * i) & 255) <<
				(i * 8);
		for (cid = 0, i = 0; i < 4; i++)
			cid |= (readl(tmp + size - 0x10 + 4 * i) & 255) <<
				(i * 8);

//		amba_put_disable_pclk(dev);

		if (cid == AMBA_CID)
			dev->periphid = pid;

		if (!dev->periphid)
			ret = -ENODEV;
	}

	iounmap(tmp);

	if (ret)
		goto err_release;

 skip_probe:
	ret = device_add(&dev->dev);
	if (ret)
		goto err_release;

	if (dev->irq[0])
		ret = device_create_file(&dev->dev, &dev_attr_irq0);
	if (ret == 0 && dev->irq[1])
		ret = device_create_file(&dev->dev, &dev_attr_irq1);
	if (ret == 0)
		return ret;

	device_unregister(&dev->dev);

 err_release:
	release_resource(&dev->res);
 err_out:
	return ret;
}
开发者ID:Dee-UK,项目名称:RK3288_Lollipop_Kernel,代码行数:86,代码来源:bus.c

示例8: asus_oled_probe

static int asus_oled_probe(struct usb_interface *interface, const struct usb_device_id *id)
{
	struct usb_device *udev = interface_to_usbdev(interface);
	struct asus_oled_dev *odev = NULL;
	int retval = -ENOMEM;
	uint16_t dev_width = 0;
	oled_pack_mode_t pack_mode = PACK_MODE_LAST;
	const struct oled_dev_desc_str * dev_desc = oled_dev_desc_table;
	const char *desc = 0;

	if (id == 0) {
		// Even possible? Just to make sure...
		dev_err(&interface->dev, "No usb_device_id provided!\n");
		return -ENODEV;
	}

	for (; dev_desc->idVendor; dev_desc++)
	{
		if (dev_desc->idVendor == id->idVendor
			&& dev_desc->idProduct == id->idProduct)
		{
			dev_width = dev_desc->devWidth;
			desc = dev_desc->devDesc;
			pack_mode = dev_desc->packMode;
			break;
		}
	}

	if ( !desc || dev_width < 1 || pack_mode == PACK_MODE_LAST) {
		dev_err(&interface->dev, "Missing or incomplete device description!\n");
		return -ENODEV;
	}

	odev = kzalloc(sizeof(struct asus_oled_dev), GFP_KERNEL);

	if (odev == NULL) {
		dev_err(&interface->dev, "Out of memory\n");
		return -ENOMEM;
	}

	odev->udev = usb_get_dev(udev);
	odev->pic_mode = ASUS_OLED_STATIC;
	odev->dev_width = dev_width;
	odev->pack_mode = pack_mode;
	odev->height = 0;
	odev->width = 0;
	odev->x_shift = 0;
	odev->y_shift = 0;
	odev->buf_offs = 0;
	odev->buf_size = 0;
	odev->last_val = 0;
	odev->buf = NULL;
	odev->enabled = 1;
	odev->dev = 0;

	usb_set_intfdata (interface, odev);

	if ((retval = device_create_file(&interface->dev, &ASUS_OLED_DEVICE_ATTR(enabled)))) {
		goto err_files;
	}

	if ((retval = device_create_file(&interface->dev, &ASUS_OLED_DEVICE_ATTR(picture)))) {
		goto err_files;
	}

	odev->dev = device_create(oled_class, &interface->dev, MKDEV(0,0),
				NULL,"oled_%d", ++oled_num);

	if (IS_ERR(odev->dev)) {
		retval = PTR_ERR(odev->dev);
		goto err_files;
	}

	dev_set_drvdata(odev->dev, odev);

	if ( (retval = device_create_file(odev->dev, &dev_attr_enabled))) {
		goto err_class_enabled;
	}

	if ( (retval = device_create_file(odev->dev, &dev_attr_picture))) {
		goto err_class_picture;
	}

	dev_info(&interface->dev, "Attached Asus OLED device: %s [width %u, pack_mode %d]\n", desc, odev->dev_width, odev->pack_mode);

	if (start_off)
		enable_oled(odev, 0);

	return 0;

err_class_picture:
	device_remove_file(odev->dev, &dev_attr_picture);

err_class_enabled:
	device_remove_file(odev->dev, &dev_attr_enabled);
	device_unregister(odev->dev);

err_files:
	device_remove_file(&interface->dev, &ASUS_OLED_DEVICE_ATTR(enabled));
	device_remove_file(&interface->dev, &ASUS_OLED_DEVICE_ATTR(picture));
//.........这里部分代码省略.........
开发者ID:johnny,项目名称:CobraDroidBeta,代码行数:101,代码来源:asus_oled.c

示例9: kzalloc


//.........这里部分代码省略.........
	int ret;

	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
	if (!dev)
		return ERR_PTR(-ENOMEM);

	dev->parent = parent;
	dev->of_node = node;
	dev->release = qcom_glink_smem_release;
	dev_set_name(dev, "%s:%s", node->parent->name, node->name);
	ret = device_register(dev);
	if (ret) {
		pr_err("failed to register glink edge\n");
		put_device(dev);
		return ERR_PTR(ret);
	}

	ret = of_property_read_u32(dev->of_node, "qcom,remote-pid",
				   &remote_pid);
	if (ret) {
		dev_err(dev, "failed to parse qcom,remote-pid\n");
		goto err_put_dev;
	}

	rx_pipe = devm_kzalloc(dev, sizeof(*rx_pipe), GFP_KERNEL);
	tx_pipe = devm_kzalloc(dev, sizeof(*tx_pipe), GFP_KERNEL);
	if (!rx_pipe || !tx_pipe) {
		ret = -ENOMEM;
		goto err_put_dev;
	}

	ret = qcom_smem_alloc(remote_pid,
			      SMEM_GLINK_NATIVE_XPRT_DESCRIPTOR, 32);
	if (ret && ret != -EEXIST) {
		dev_err(dev, "failed to allocate glink descriptors\n");
		goto err_put_dev;
	}

	descs = qcom_smem_get(remote_pid,
			      SMEM_GLINK_NATIVE_XPRT_DESCRIPTOR, &size);
	if (IS_ERR(descs)) {
		dev_err(dev, "failed to acquire xprt descriptor\n");
		ret = PTR_ERR(descs);
		goto err_put_dev;
	}

	if (size != 32) {
		dev_err(dev, "glink descriptor of invalid size\n");
		ret = -EINVAL;
		goto err_put_dev;
	}

	tx_pipe->tail = &descs[0];
	tx_pipe->head = &descs[1];
	rx_pipe->tail = &descs[2];
	rx_pipe->head = &descs[3];

	ret = qcom_smem_alloc(remote_pid, SMEM_GLINK_NATIVE_XPRT_FIFO_0,
			      SZ_16K);
	if (ret && ret != -EEXIST) {
		dev_err(dev, "failed to allocate TX fifo\n");
		goto err_put_dev;
	}

	tx_pipe->fifo = qcom_smem_get(remote_pid, SMEM_GLINK_NATIVE_XPRT_FIFO_0,
				      &tx_pipe->native.length);
	if (IS_ERR(tx_pipe->fifo)) {
		dev_err(dev, "failed to acquire TX fifo\n");
		ret = PTR_ERR(tx_pipe->fifo);
		goto err_put_dev;
	}

	rx_pipe->native.avail = glink_smem_rx_avail;
	rx_pipe->native.peak = glink_smem_rx_peak;
	rx_pipe->native.advance = glink_smem_rx_advance;
	rx_pipe->remote_pid = remote_pid;

	tx_pipe->native.avail = glink_smem_tx_avail;
	tx_pipe->native.write = glink_smem_tx_write;
	tx_pipe->remote_pid = remote_pid;

	*rx_pipe->tail = 0;
	*tx_pipe->head = 0;

	glink = qcom_glink_native_probe(dev,
					GLINK_FEATURE_INTENT_REUSE,
					&rx_pipe->native, &tx_pipe->native,
					false);
	if (IS_ERR(glink)) {
		ret = PTR_ERR(glink);
		goto err_put_dev;
	}

	return glink;

err_put_dev:
	device_unregister(dev);

	return ERR_PTR(ret);
}
开发者ID:the-snowwhite,项目名称:linux-socfpga,代码行数:101,代码来源:qcom_glink_smem.c

示例10: gio_device_unregister

void gio_device_unregister(struct gio_device *giodev)
{
	device_unregister(&giodev->dev);
}
开发者ID:0xroot,项目名称:Blackphone-BP1-Kernel,代码行数:4,代码来源:ip22-gio.c

示例11: snd_devm_unregister_child

static void snd_devm_unregister_child(struct device *dev, void *res)
{
	struct device *childdev = *(struct device **)res;

	device_unregister(childdev);
}
开发者ID:SantoshShilimkar,项目名称:linux,代码行数:6,代码来源:bcm2835.c

示例12: rpi_power_switch_init

int __init rpi_power_switch_init(void)
{
	int ret = 0;

	old_pm_power_off = pm_power_off;
	pm_power_off = rpi_power_switch_power_off;

	pr_info("Adafruit Industries' power switch driver v%s\n",
		RPI_POWER_SWITCH_VERSION);

	INIT_DELAYED_WORK(&initiate_shutdown_work, initiate_shutdown);


	/* Register our own class for the power switch */
	ret = class_register(&power_switch_class);
        if (ret < 0) {
		pr_err("%s: Unable to register class\n", power_switch_class.name);
		goto out0;     
	}


        /* Create devices for each PWM present */
	switch_dev = device_create(&power_switch_class, &platform_bus,
                                MKDEV(0, 0), NULL, "pswitch%u", 0);
	if (IS_ERR(switch_dev)) {
		pr_err("%s: device_create failed\n", power_switch_class.name);
		ret = PTR_ERR(switch_dev);
		goto out1;
        }

	ret = sysfs_create_group(&switch_dev->kobj,
				 &rpi_power_switch_attribute_group);
	if (ret < 0) {
		pr_err("%s: create_group failed\n", power_switch_class.name);
		goto out2;
	}

	/* GPIO register memory must be mapped before doing any direct
	 * accesses such as changing GPIO alt functions or changing GPIO
	 * pull ups or pull downs.
	 */
	gpio_reg = ioremap(GPIO_BASE, 1024);

	/* Set the specified pin as a GPIO input */
	SET_GPIO_INPUT(gpio_pin);

	/* Set the pin as a pulldown.  Most pins should default to having
	 * pulldowns, and this seems most intuitive.
	 */
	set_gpio_pull(gpio_pin, GPIO_PULL_UP);

	gpio_request(gpio_pin, "Power switch");
	gpio_direction_input(gpio_pin);

	/* The targeted polarity should be the opposite of the current value.
	 * I.e. we want the pin to transition to this state in order to
	 * initiate a shutdown.
	 */
	gpio_pol = !gpio_get_value(gpio_pin);

	/* Request an interrupt to fire when the pin transitions to our
	 * desired state.
	 */
	ret = request_irq(__gpio_to_irq(gpio_pin), power_isr,
			  gpio_pol?IRQF_TRIGGER_RISING:IRQF_TRIGGER_FALLING,
			  "Power button", NULL);
	if (ret) {
		pr_err("Unable to request IRQ\n");
		goto out3;
	}

	return 0;


	/* Error handling */
out3:
	sysfs_remove_group(&switch_dev->kobj,&rpi_power_switch_attribute_group);
out2:
	device_unregister(switch_dev);
out1:
	class_unregister(&power_switch_class);
out0:
	iounmap(gpio_reg);
	pm_power_off = old_pm_power_off;
	return ret;
}
开发者ID:LinuxEmbed,项目名称:LinuxEmbed-RPI-Linux,代码行数:86,代码来源:rpi_power_switch.c

示例13: led_classdev_register

/**
 * led_classdev_register - register a new object of led_classdev class.
 * @parent: The device to register.
 * @led_cdev: the led_classdev structure for this device.
 */
int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
{
	int rc;

	led_cdev->dev = device_create(leds_class, parent, 0, led_cdev,
				      "%s", led_cdev->name);
	if (IS_ERR(led_cdev->dev))
		return PTR_ERR(led_cdev->dev);

	/* register the attributes */
	rc = device_create_file(led_cdev->dev, &led_class_attrs[2]);
	if (rc)
		goto err_out;

#ifdef CONFIG_LEDS_TRIGGERS
	init_rwsem(&led_cdev->trigger_lock);
#endif
	/* add to the list of leds */
	down_write(&leds_list_lock);
	list_add_tail(&led_cdev->node, &leds_list);
	up_write(&leds_list_lock);

	if (!led_cdev->max_brightness)
		led_cdev->max_brightness = LED_FULL;

	rc = device_create_file(led_cdev->dev, &led_class_attrs[3]);
	if (rc)
		goto err_out_attr_max;

	led_update_brightness(led_cdev);

#ifdef CONFIG_LEDS_TRIGGERS
#ifndef SUPPORT_LCD_ACL_CTL
	rc = device_create_file(led_cdev->dev, &led_class_attrs[4]);
#else
	rc = device_create_file(led_cdev->dev, &led_class_attrs[5]);
#endif
	if (rc)
		goto err_out_led_list;

	led_trigger_set_default(led_cdev);
#endif

    #if 1  // Archer custom feature
	/* register the attributes */
	rc = device_create_file(led_cdev->dev, &led_class_attrs[1]);
	if (rc)
		goto err_out;
    
	led_update_lcd_gamma(led_cdev);


#ifdef SUPPORT_LCD_ACL_CTL
	/* register the attributes */
	rc = device_create_file(led_cdev->dev, &led_class_attrs[4]);
	if (rc)
		goto err_out;
    
	lcd_update_ACL_state(led_cdev);
#endif

	rc = device_create_file(led_cdev->dev, &led_class_attrs[0]);
	if (rc)
		goto err_out;
    
	led_update_flashlight(led_cdev);
    #endif 
	printk(KERN_INFO "Registered led device: %s\n",	led_cdev->name);

	return 0;

#ifdef CONFIG_LEDS_TRIGGERS
err_out_led_list:
	device_remove_file(led_cdev->dev, &led_class_attrs[3]);

#endif
err_out_attr_max:
	device_remove_file(led_cdev->dev, &led_class_attrs[2]);
	device_remove_file(led_cdev->dev, &led_class_attrs[1]);
#ifdef SUPPORT_LCD_ACL_CTL	
	device_remove_file(led_cdev->dev, &led_class_attrs[4]);
#endif	
	list_del(&led_cdev->node);
err_out:
	device_unregister(led_cdev->dev);
	return rc;
}
开发者ID:mephistophilis,项目名称:samsung_nowplus_kernel,代码行数:92,代码来源:led-class.c

示例14: amba_device_register

/**
 *	amba_device_register - register an AMBA device
 *	@dev: AMBA device to register
 *	@parent: parent memory resource
 *
 *	Setup the AMBA device, reading the cell ID if present.
 *	Claim the resource, and register the AMBA device with
 *	the Linux device manager.
 */
int amba_device_register(struct amba_device *dev, struct resource *parent)
{
	u32 size;
	void __iomem *tmp;
	int i, ret;

	device_initialize(&dev->dev);

	/*
	 * Copy from device_add
	 */
	if (dev->dev.init_name) {
		dev_set_name(&dev->dev, "%s", dev->dev.init_name);
		dev->dev.init_name = NULL;
	}

	dev->dev.release = amba_device_release;
	dev->dev.bus = &amba_bustype;
	dev->dev.dma_mask = &dev->dma_mask;
	dev->res.name = dev_name(&dev->dev);

	if (!dev->dev.coherent_dma_mask && dev->dma_mask)
		dev_warn(&dev->dev, "coherent dma mask is unset\n");

	ret = request_resource(parent, &dev->res);
	if (ret)
		goto err_out;

	/*
	 * Dynamically calculate the size of the resource
	 * and use this for iomap
	 */
	size = resource_size(&dev->res);
	tmp = ioremap(dev->res.start, size);
	if (!tmp) {
		ret = -ENOMEM;
		goto err_release;
	}

	ret = amba_get_enable_pclk(dev);
	if (ret == 0) {
		u32 pid, cid;

		/*
		 * Read pid and cid based on size of resource
		 * they are located at end of region
		 */
		for (pid = 0, i = 0; i < 4; i++)
			pid |= (readl(tmp + size - 0x20 + 4 * i) & 255) <<
				(i * 8);
		for (cid = 0, i = 0; i < 4; i++)
			cid |= (readl(tmp + size - 0x10 + 4 * i) & 255) <<
				(i * 8);

		amba_put_disable_pclk(dev);

		if (cid == AMBA_CID)
			dev->periphid = pid;

		if (!dev->periphid)
			ret = -ENODEV;
	}

	iounmap(tmp);

	if (ret)
		goto err_release;

	ret = device_add(&dev->dev);
	if (ret)
		goto err_release;

	if (dev->irq[0] != NO_IRQ)
		ret = device_create_file(&dev->dev, &dev_attr_irq0);
	if (ret == 0 && dev->irq[1] != NO_IRQ)
		ret = device_create_file(&dev->dev, &dev_attr_irq1);
	if (ret == 0)
		return ret;

	device_unregister(&dev->dev);

 err_release:
	release_resource(&dev->res);
 err_out:
	return ret;
}
开发者ID:Adjustxx,项目名称:Savaged-Zen,代码行数:95,代码来源:bus.c

示例15: ide_unregister

void ide_unregister(unsigned int index)
{
	ide_drive_t *drive;
	ide_hwif_t *hwif, *g;
	static ide_hwif_t tmp_hwif; /* protected by ide_cfg_sem */
	ide_hwgroup_t *hwgroup;
	int irq_count = 0, unit;

	BUG_ON(index >= MAX_HWIFS);

	BUG_ON(in_interrupt());
	BUG_ON(irqs_disabled());
	down(&ide_cfg_sem);
	spin_lock_irq(&ide_lock);
	hwif = &ide_hwifs[index];
	if (!hwif->present)
		goto abort;
	for (unit = 0; unit < MAX_DRIVES; ++unit) {
		drive = &hwif->drives[unit];
		if (!drive->present)
			continue;
		spin_unlock_irq(&ide_lock);
		device_unregister(&drive->gendev);
		wait_for_completion(&drive->gendev_rel_comp);
		spin_lock_irq(&ide_lock);
	}
	hwif->present = 0;

	spin_unlock_irq(&ide_lock);

	ide_proc_unregister_port(hwif);

	hwgroup = hwif->hwgroup;
	/*
	 * free the irq if we were the only hwif using it
	 */
	g = hwgroup->hwif;
	do {
		if (g->irq == hwif->irq)
			++irq_count;
		g = g->next;
	} while (g != hwgroup->hwif);
	if (irq_count == 1)
		free_irq(hwif->irq, hwgroup);

	spin_lock_irq(&ide_lock);
	/*
	 * Note that we only release the standard ports,
	 * and do not even try to handle any extra ports
	 * allocated for weird IDE interface chipsets.
	 */
	ide_hwif_release_regions(hwif);

	/*
	 * Remove us from the hwgroup, and free
	 * the hwgroup if we were the only member
	 */
	if (hwif->next == hwif) {
		BUG_ON(hwgroup->hwif != hwif);
		kfree(hwgroup);
	} else {
		/* There is another interface in hwgroup.
		 * Unlink us, and set hwgroup->drive and ->hwif to
		 * something sane.
		 */
		g = hwgroup->hwif;
		while (g->next != hwif)
			g = g->next;
		g->next = hwif->next;
		if (hwgroup->hwif == hwif) {
			/* Chose a random hwif for hwgroup->hwif.
			 * It's guaranteed that there are no drives
			 * left in the hwgroup.
			 */
			BUG_ON(hwgroup->drive != NULL);
			hwgroup->hwif = g;
		}
		BUG_ON(hwgroup->hwif == hwif);
	}

	/* More messed up locking ... */
	spin_unlock_irq(&ide_lock);
	device_unregister(&hwif->gendev);
	wait_for_completion(&hwif->gendev_rel_comp);

	/*
	 * Remove us from the kernel's knowledge
	 */
	blk_unregister_region(MKDEV(hwif->major, 0), MAX_DRIVES<<PARTN_BITS);
	kfree(hwif->sg_table);
	unregister_blkdev(hwif->major, hwif->name);
	spin_lock_irq(&ide_lock);

	if (hwif->dma_base) {
		(void) ide_release_dma(hwif);

		hwif->dma_base = 0;
		hwif->dma_master = 0;
		hwif->dma_command = 0;
		hwif->dma_vendor1 = 0;
//.........这里部分代码省略.........
开发者ID:NikhilNJ,项目名称:screenplay-dx,代码行数:101,代码来源:ide.c


注:本文中的device_unregister函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。