當前位置: 首頁>>代碼示例>>C++>>正文


C++ BLOCKING_INIT_NOTIFIER_HEAD函數代碼示例

本文整理匯總了C++中BLOCKING_INIT_NOTIFIER_HEAD函數的典型用法代碼示例。如果您正苦於以下問題:C++ BLOCKING_INIT_NOTIFIER_HEAD函數的具體用法?C++ BLOCKING_INIT_NOTIFIER_HEAD怎麽用?C++ BLOCKING_INIT_NOTIFIER_HEAD使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了BLOCKING_INIT_NOTIFIER_HEAD函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: omap_mbox_register

int omap_mbox_register(struct device *parent, struct omap_mbox **list)
{
	int ret;
	int i;

	mboxes = list;
	if (!mboxes)
		return -EINVAL;

	for (i = 0; mboxes[i]; i++) {
		struct omap_mbox *mbox = mboxes[i];
		mbox->dev = device_create(&omap_mbox_class,
				parent, 0, mbox, "%s", mbox->name);
		if (IS_ERR(mbox->dev)) {
			ret = PTR_ERR(mbox->dev);
			goto err_out;
		}

		BLOCKING_INIT_NOTIFIER_HEAD(&mbox->notifier);
	}
	return 0;

err_out:
	while (i--)
		device_unregister(mboxes[i]->dev);
	return ret;
}
開發者ID:03199618,項目名稱:linux,代碼行數:27,代碼來源:omap-mailbox.c

示例2: axp_mfd_probe

static int __devinit axp_mfd_probe(struct i2c_client *client,
				  const struct i2c_device_id *id)
{
	struct axp_platform_data *pdata = client->dev.platform_data;
	struct axp_mfd_chip *chip;
	int ret;
	chip = kzalloc(sizeof(struct axp_mfd_chip), GFP_KERNEL);
	if (chip == NULL)
		return -ENOMEM;

	axp = client;
	axp_cfg_board = pdata->axp_cfg;

	chip->client = client;
	chip->dev = &client->dev;
	chip->ops = &axp_mfd_ops[id->driver_data];

	mutex_init(&chip->lock);
	INIT_WORK(&chip->irq_work, axp_mfd_irq_work);
	BLOCKING_INIT_NOTIFIER_HEAD(&chip->notifier_list);

	i2c_set_clientdata(client, chip);

	ret = chip->ops->init_chip(chip);
	if (ret)
		goto out_free_chip;
    /*
	ret = request_irq(client->irq, axp_mfd_irq_handler,
		IRQF_DISABLED, "axp_mfd", chip);
  	if (ret) {
  		dev_err(&client->dev, "failed to request irq %d\n",
  				client->irq);
  		goto out_free_chip;
  	}
    */

	ret = axp_mfd_add_subdevs(chip, pdata);
	if (ret)
		goto out_free_irq;

	/* PM hookup */
	if(!pm_power_off)
		pm_power_off = axp_power_off;

	ret = axp_mfd_create_attrs(chip);
	if(ret){
		return ret;
	}

	return 0;

out_free_irq:
	free_irq(client->irq, chip);

out_free_chip:
	i2c_set_clientdata(client, NULL);
	kfree(chip);

	return ret;
}
開發者ID:J1nx-Hackable-Gadgets,項目名稱:amlogic-common-3.0.8,代碼行數:60,代碼來源:axp-mfd.c

示例3: ipc_pipe_open

/**
 * @brief open a IPC pipe.
 * 
 * @param[in] pipe_id : IPC pipe ID.
 *
 * @return  not NULL means success, NULL means failure.
 */
struct ipc_pipe* ipc_pipe_open(int pipe_id)
{
	struct ipc_pipe *pipe;
	int ret;
	int first;

	if (pipe_id < 0 || pipe_id >= __IPC_PIPE_NUM_MAX)
		return NULL;

	pipe = idr_find(&ipc_pipe_idr, pipe_id);
	if (pipe != NULL) {
		return NULL;
	}

	pipe = (struct ipc_pipe*)kzalloc(sizeof(*pipe), GFP_KERNEL);
	if (pipe == NULL)
		return NULL;

	pipe->id = pipe_id;
	pipe->freeQ = ipcmsg_queue_create();
	pipe->recvQ = ipcmsg_queue_create();
	pipe->sendQ = ipcmsg_queue_create();
	pipe->qset = 0;
	pipe->quantum = DEFAULT_PIPE_QUANTUM;
	pipe->qset_limit = DEFAULT_PIPE_QSET;

	spin_lock_init(&pipe->lock);
	
	BLOCKING_INIT_NOTIFIER_HEAD(&pipe->notifier);
	init_waitqueue_head(&pipe->write_wq);
	init_waitqueue_head(&pipe->read_wq);

	first = all_pipes_unused();

	mark_pipe_used(pipe);

	ret = save_opened_pipe(pipe);
	if (ret)
		goto _error;

	switch_pipe_state(pipe, IPC_PIPE_STATE_OPENED);

	if (first) {
		// we are the first opened pipe.
		ipc_msg_register_handler(IPCMSG_CMD_PIPE, pipe_ipcmsg_handler, NULL);
	}

	return pipe;

_error:
	mark_pipe_unused(pipe);

	kfree(pipe);

	return NULL;
}
開發者ID:avila-devlogic,項目名稱:D33_KK_Kernel,代碼行數:63,代碼來源:rk_ipc_pipe.c

示例4: kzalloc

/**
 * iommu_group_alloc - Allocate a new group
 * @name: Optional name to associate with group, visible in sysfs
 *
 * This function is called by an iommu driver to allocate a new iommu
 * group.  The iommu group represents the minimum granularity of the iommu.
 * Upon successful return, the caller holds a reference to the supplied
 * group in order to hold the group until devices are added.  Use
 * iommu_group_put() to release this extra reference count, allowing the
 * group to be automatically reclaimed once it has no devices or external
 * references.
 */
struct iommu_group *iommu_group_alloc(void)
{
	struct iommu_group *group;
	int ret;

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

	group->kobj.kset = iommu_group_kset;
	mutex_init(&group->mutex);
	INIT_LIST_HEAD(&group->devices);
	BLOCKING_INIT_NOTIFIER_HEAD(&group->notifier);

	mutex_lock(&iommu_group_mutex);

again:
	if (unlikely(0 == ida_pre_get(&iommu_group_ida, GFP_KERNEL))) {
		kfree(group);
		mutex_unlock(&iommu_group_mutex);
		return ERR_PTR(-ENOMEM);
	}

	if (-EAGAIN == ida_get_new(&iommu_group_ida, &group->id))
		goto again;

	mutex_unlock(&iommu_group_mutex);

	ret = kobject_init_and_add(&group->kobj, &iommu_group_ktype,
				   NULL, "%d", group->id);
	if (ret) {
		mutex_lock(&iommu_group_mutex);
		ida_remove(&iommu_group_ida, group->id);
		mutex_unlock(&iommu_group_mutex);
		kfree(group);
		return ERR_PTR(ret);
	}

	group->devices_kobj = kobject_create_and_add("devices", &group->kobj);
	if (!group->devices_kobj) {
		kobject_put(&group->kobj); /* triggers .release & free */
		return ERR_PTR(-ENOMEM);
	}

	/*
	 * The devices_kobj holds a reference on the group kobject, so
	 * as long as that exists so will the group.  We can therefore
	 * use the devices_kobj for reference counting.
	 */
	kobject_put(&group->kobj);

	pr_debug("Allocated group %d\n", group->id);

	return group;
}
開發者ID:ramlaxman,項目名稱:linux,代碼行數:67,代碼來源:iommu.c

示例5: bus_register

/**
 *	bus_register - register a bus with the system.
 *	@bus:	bus.
 *
 *	Once we have that, we registered the bus with the kobject
 *	infrastructure, then register the children subsystems it has:
 *	the devices and drivers that belong to the bus.
 */
int bus_register(struct bus_type * bus)
{
	int retval = -ENOMEM;
	struct blocking_notifier_head *notifier_head;

	notifier_head = alloc_save_notifier_for_bus(bus);
	if (!notifier_head)
		goto out;

	BLOCKING_INIT_NOTIFIER_HEAD(notifier_head);

	retval = kobject_set_name(&bus->subsys.kset.kobj, "%s", bus->name);
	if (retval)
		goto out;

	subsys_set_kset(bus, bus_subsys);
	retval = subsystem_register(&bus->subsys);
	if (retval)
		goto out;

	kobject_set_name(&bus->devices.kobj, "devices");
	bus->devices.subsys = &bus->subsys;
	retval = kset_register(&bus->devices);
	if (retval)
		goto bus_devices_fail;

	kobject_set_name(&bus->drivers.kobj, "drivers");
	bus->drivers.subsys = &bus->subsys;
	bus->drivers.ktype = &ktype_driver;
	retval = kset_register(&bus->drivers);
	if (retval)
		goto bus_drivers_fail;

	klist_init(&bus->klist_devices, klist_devices_get, klist_devices_put);
	klist_init(&bus->klist_drivers, klist_drivers_get, klist_drivers_put);

	retval = add_probe_files(bus);
	if (retval)
		goto bus_probe_files_fail;

	bus_add_attrs(bus);

	pr_debug("bus type '%s' registered\n", bus->name);
	return 0;

bus_probe_files_fail:
	kset_unregister(&bus->drivers);
bus_drivers_fail:
	kset_unregister(&bus->devices);
bus_devices_fail:
	subsystem_unregister(&bus->subsys);
out:
	return retval;
}
開發者ID:xf739645524,項目名稱:kernel-rhel5,代碼行數:62,代碼來源:bus.c

示例6: kzalloc

struct mmi_hall_data *mmi_hall_init(void)
{
	struct mmi_hall_data *mdata = kzalloc(
			sizeof(struct mmi_hall_data), GFP_KERNEL);
	if (mdata) {
		int i;
		for (i = 0; i < MMI_HALL_MAX; i++)
			BLOCKING_INIT_NOTIFIER_HEAD(&mdata->nhead[i]);
		pr_debug("%s: data structure init-ed\n", __func__);
	}
	return mdata;
}
開發者ID:akhilnarang,項目名稱:ThugLife_falcon,代碼行數:12,代碼來源:stml0xx_mmi_notifications.c

示例7: omap_dss_register_device

int omap_dss_register_device(struct omap_dss_device *dssdev)
{
	static int dev_num;

	WARN_ON(!dssdev->driver_name);

	reset_device(&dssdev->dev, 1);
	dssdev->dev.bus = &dss_bus_type;
	dssdev->dev.parent = &dss_bus;
	dssdev->dev.release = omap_dss_dev_release;
	dev_set_name(&dssdev->dev, "display%d", dev_num++);

	BLOCKING_INIT_NOTIFIER_HEAD(&dssdev->notifier);

	return device_register(&dssdev->dev);
}
開發者ID:mephistophilis,項目名稱:samsung_nowplus_kernel,代碼行數:16,代碼來源:core.c

示例8: bus_register

/**
 *	bus_register - register a bus with the system.
 *	@bus:	bus.
 *
 *	Once we have that, we registered the bus with the kobject
 *	infrastructure, then register the children subsystems it has:
 *	the devices and drivers that belong to the bus.
 */
int bus_register(struct bus_type * bus)
{
	int retval;

	BLOCKING_INIT_NOTIFIER_HEAD(&bus->bus_notifier);

	retval = kobject_set_name(&bus->subsys.kset.kobj, "%s", bus->name);
	if (retval)
		goto out;

	subsys_set_kset(bus, bus_subsys);
	retval = subsystem_register(&bus->subsys);
	if (retval)
		goto out;

	kobject_set_name(&bus->devices.kobj, "devices");
	bus->devices.subsys = &bus->subsys;
	retval = kset_register(&bus->devices);
	if (retval)
		goto bus_devices_fail;

	kobject_set_name(&bus->drivers.kobj, "drivers");
	bus->drivers.subsys = &bus->subsys;
	bus->drivers.ktype = &ktype_driver;
	retval = kset_register(&bus->drivers);
	if (retval)
		goto bus_drivers_fail;

	klist_init(&bus->klist_devices, klist_devices_get, klist_devices_put);
	klist_init(&bus->klist_drivers, NULL, NULL);
	retval = bus_add_attrs(bus);
	if (retval)
		goto bus_attrs_fail;

	pr_debug("bus type '%s' registered\n", bus->name);
	return 0;

bus_attrs_fail:
	kset_unregister(&bus->drivers);
bus_drivers_fail:
	kset_unregister(&bus->devices);
bus_devices_fail:
	subsystem_unregister(&bus->subsys);
out:
	return retval;
}
開發者ID:B-Rich,項目名稱:linux_drivers,代碼行數:54,代碼來源:bus.c

示例9: muic_notifier_init

static int __init muic_notifier_init(void)
{
	int ret = 0;

	pr_info("%s\n", __func__);

	switch_device = sec_device_create(NULL, "switch");
	if (IS_ERR(switch_device)) {
		pr_err("%s Failed to create device(switch)!\n", __func__);
		ret = -ENODEV;
		goto out;
	}

	BLOCKING_INIT_NOTIFIER_HEAD(&(muic_notifier.notifier_call_chain));
	muic_notifier.cmd = MUIC_NOTIFY_CMD_DETACH;
	muic_notifier.attached_dev = ATTACHED_DEV_UNKNOWN_MUIC;

out:
	return ret;
}
開發者ID:MikeForeskin,項目名稱:Vindicator-S6-MM,代碼行數:20,代碼來源:muic_notifier.c

示例10: muic_notifier_init

static int __init muic_notifier_init(void)
{
	int ret = 0;

	printk(KERN_DEBUG "[muic] %s\n", __func__);

#ifdef CONFIG_SEC_SYSFS
	switch_device = sec_device_create(NULL, "switch");
	if (IS_ERR(switch_device)) {
		printk(KERN_ERR "[muic] Failed to create device(switch)!\n");
		ret = -ENODEV;
		goto out;
	}
#endif

	BLOCKING_INIT_NOTIFIER_HEAD(&(muic_notifier.notifier_call_chain));
	muic_notifier.cmd = MUIC_NOTIFY_CMD_DETACH;
	muic_notifier.attached_dev = ATTACHED_DEV_UNKNOWN_MUIC;

#ifdef CONFIG_SEC_SYSFS
out:
#endif
	return ret;
}
開發者ID:ShedrockN4,項目名稱:wiliteneo,代碼行數:24,代碼來源:muic_notifier.c

示例11: dss_init_device

void dss_init_device(struct platform_device *pdev,
		struct omap_dss_device *dssdev)
{
	struct device_attribute *attr;
	int i;
	int r;

	switch (dssdev->type) {
#ifdef CONFIG_OMAP2_DSS_DPI
	case OMAP_DISPLAY_TYPE_DPI:
		r = dpi_init_display(dssdev);
		break;
#endif
#ifdef CONFIG_OMAP2_DSS_RFBI
	case OMAP_DISPLAY_TYPE_DBI:
		r = rfbi_init_display(dssdev);
		break;
#endif
#ifdef CONFIG_OMAP2_DSS_VENC
	case OMAP_DISPLAY_TYPE_VENC:
		r = venc_init_display(dssdev);
		break;
#endif
#ifdef CONFIG_OMAP2_DSS_SDI
	case OMAP_DISPLAY_TYPE_SDI:
		r = sdi_init_display(dssdev);
		break;
#endif
#ifdef CONFIG_OMAP2_DSS_DSI
	case OMAP_DISPLAY_TYPE_DSI:
		r = dsi_init_display(dssdev);
		break;
#endif
	case OMAP_DISPLAY_TYPE_HDMI:
		r = hdmi_init_display(dssdev);
		break;
	default:
		DSSERR("Support for display '%s' not compiled in.\n",
				dssdev->name);
		return;
	}

	if (r) {
		DSSERR("failed to init display %s\n", dssdev->name);
		return;
	}

	BLOCKING_INIT_NOTIFIER_HEAD(&dssdev->state_notifiers);

	/* create device sysfs files */
	i = 0;
	while ((attr = display_sysfs_attrs[i++]) != NULL) {
		r = device_create_file(&dssdev->dev, attr);
		if (r)
			DSSERR("failed to create sysfs file\n");
	}

	/* create display? sysfs links */
	r = sysfs_create_link(&pdev->dev.kobj, &dssdev->dev.kobj,
			dev_name(&dssdev->dev));
	if (r)
		DSSERR("failed to create sysfs display link\n");
}
開發者ID:b7acc,項目名稱:kernel_omap_bowser-common,代碼行數:63,代碼來源:display.c

示例12: axp_mfd_probe

static int __devinit axp_mfd_probe(struct i2c_client *client,
				  const struct i2c_device_id *id)
{
	struct axp_platform_data *pdata = client->dev.platform_data;
	struct axp_mfd_chip *chip;
	int ret;
	chip = kzalloc(sizeof(struct axp_mfd_chip), GFP_KERNEL);
	if (chip == NULL)
		return -ENOMEM;

	axp = client;

	chip->client = client;
	chip->dev = &client->dev;
	chip->ops = &axp_mfd_ops[id->driver_data];

	mutex_init(&chip->lock);
	INIT_WORK(&chip->irq_work, axp_mfd_irq_work);
	BLOCKING_INIT_NOTIFIER_HEAD(&chip->notifier_list);

	i2c_set_clientdata(client, chip);

	ret = chip->ops->init_chip(chip);
	if (ret)
		goto out_free_chip;

	ret = request_irq(client->irq, axp_mfd_irq_handler,
		IRQF_DISABLED, "axp_mfd", chip);
  	if (ret) {
  		dev_err(&client->dev, "failed to request irq %d\n",
  				client->irq);
  		goto out_free_chip;
  	}

	/* The irq for the A20 NMI pin needs to be enabled separately */
	if (sunxi_is_sun7i() && client->irq == SW_INT_IRQNO_ENMI) {
		writel(0x01, NMI_IRQ_PEND_REG);   /* Clear any pending irqs */
		writel(0x01, NMI_IRQ_ENABLE_REG); /* Enable NMI irq pin */
	}

	ret = axp_mfd_add_subdevs(chip, pdata);
	if (ret)
		goto out_free_irq;

	/* PM hookup */
	if(!pm_power_off)
		pm_power_off = axp_power_off;

	ret = axp_mfd_create_attrs(chip);
	if(ret){
		return ret;
	}
	
	/* set ac/usb_in shutdown mean restart */
  	ret = script_parser_fetch("target", "power_start", &power_start, sizeof(int));
  	if (ret)
  	{
    	printk("[AXP]axp driver uning configuration failed(%d)\n", __LINE__);
     	power_start = 0;
     	printk("[AXP]power_start = %d\n",power_start);
  	}
  	
	return 0;

out_free_irq:
	free_irq(client->irq, chip);

out_free_chip:
	i2c_set_clientdata(client, NULL);
	kfree(chip);

	return ret;
}
開發者ID:EddyKuo,項目名稱:linux-sdk-kernel-source,代碼行數:73,代碼來源:axp-mfd.c

示例13: adp5520_probe

static int __devinit adp5520_probe(struct i2c_client *client,
					const struct i2c_device_id *id)
{
	struct adp5520_platform_data *pdata = client->dev.platform_data;
	struct platform_device *pdev;
	struct adp5520_chip *chip;
	int ret;

	if (!i2c_check_functionality(client->adapter,
					I2C_FUNC_SMBUS_BYTE_DATA)) {
		dev_err(&client->dev, "SMBUS Word Data not Supported\n");
		return -EIO;
	}

	if (pdata == NULL) {
		dev_err(&client->dev, "missing platform data\n");
		return -ENODEV;
	}

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

	i2c_set_clientdata(client, chip);
	chip->client = client;

	chip->dev = &client->dev;
	chip->irq = client->irq;
	chip->id = id->driver_data;
	mutex_init(&chip->lock);

	if (chip->irq) {
		BLOCKING_INIT_NOTIFIER_HEAD(&chip->notifier_list);

		ret = request_threaded_irq(chip->irq, NULL, adp5520_irq_thread,
				IRQF_TRIGGER_LOW | IRQF_ONESHOT,
				"adp5520", chip);
		if (ret) {
			dev_err(&client->dev, "failed to request irq %d\n",
					chip->irq);
			goto out_free_chip;
		}
	}

	ret = adp5520_write(chip->dev, ADP5520_MODE_STATUS, ADP5520_nSTNBY);
	if (ret) {
		dev_err(&client->dev, "failed to write\n");
		goto out_free_irq;
	}

	if (pdata->keys) {
		pdev = platform_device_register_data(chip->dev, "adp5520-keys",
				chip->id, pdata->keys, sizeof(*pdata->keys));
		if (IS_ERR(pdev)) {
			ret = PTR_ERR(pdev);
			goto out_remove_subdevs;
		}
	}

	if (pdata->gpio) {
		pdev = platform_device_register_data(chip->dev, "adp5520-gpio",
				chip->id, pdata->gpio, sizeof(*pdata->gpio));
		if (IS_ERR(pdev)) {
			ret = PTR_ERR(pdev);
			goto out_remove_subdevs;
		}
	}

	if (pdata->leds) {
		pdev = platform_device_register_data(chip->dev, "adp5520-led",
				chip->id, pdata->leds, sizeof(*pdata->leds));
		if (IS_ERR(pdev)) {
			ret = PTR_ERR(pdev);
			goto out_remove_subdevs;
		}
	}

	if (pdata->backlight) {
		pdev = platform_device_register_data(chip->dev,
						"adp5520-backlight",
						chip->id,
						pdata->backlight,
						sizeof(*pdata->backlight));
		if (IS_ERR(pdev)) {
			ret = PTR_ERR(pdev);
			goto out_remove_subdevs;
		}
	}

	return 0;

out_remove_subdevs:
	adp5520_remove_subdevs(chip);

out_free_irq:
	if (chip->irq)
		free_irq(chip->irq, chip);

out_free_chip:
	kfree(chip);
//.........這裏部分代碼省略.........
開發者ID:Core2idiot,項目名稱:Kernel-Samsung-3.0...-,代碼行數:101,代碼來源:adp5520.c

示例14: twl6030_usb_probe

static int __devinit twl6030_usb_probe(struct platform_device *pdev)
{
	struct twl6030_usb	*twl;
	int			status,err,vbus_state;
	struct twl4030_usb_data *pdata;
	struct device *dev = &pdev->dev;
	pdata = dev->platform_data;

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

	twl->dev		= &pdev->dev;
	twl->irq1		= platform_get_irq(pdev, 0);
	twl->irq2		= platform_get_irq(pdev, 1);
	twl->otg.dev		= twl->dev;
	twl->otg.label		= "twl6030";
	twl->otg.set_host	= twl6030_set_host;
	twl->otg.set_peripheral	= twl6030_set_peripheral;
	twl->otg.set_suspend	= twl6030_set_suspend;
	twl->asleep		= 1;
	#ifndef CONFIG_USB_ETH_RNDIS
	twl->otg.set_power	= twl6030_set_input_current_limit;
	twl->otg.set_vbus	= twl6030_set_vbus;
	#endif
	twl->otg.set_hz_mode	= twl6030_set_hz_mode;
	twl->otg.init		= phy_init;
	twl->otg.shutdown	= phy_shutdown;
	twl->otg.enable_irq	= twl6030_enable_irq;
	twl->otg.set_clk	= set_phy_clk;
	twl->otg.shutdown	= phy_shutdown;
	twl->prev_vbus		= 0;
	twl->vusb = regulator_get(NULL, "usb-phy");
        if (IS_ERR(twl->vusb)) {
            pr_err("Unable to get usb-phy regulator\n");
        }
        
        twl->mbid=quanta_get_mbid();
        printk(KERN_INFO "%s mbid=%d\n",__func__,twl->mbid);
        err = regulator_set_voltage(twl->vusb, 3300000,
                    3300000);
        //regulator_disable(twl->vusb);

	/* init spinlock for workqueue */
	spin_lock_init(&twl->lock);

	err = twl6030_usb_ldo_init(twl);
	if (err) {
		dev_err(&pdev->dev, "ldo init failed\n");
		kfree(twl);
		return err;
	}
	otg_set_transceiver(&twl->otg);

	platform_set_drvdata(pdev, twl);
	if (device_create_file(&pdev->dev, &dev_attr_vbus))
		dev_warn(&pdev->dev, "could not create sysfs file\n");

	BLOCKING_INIT_NOTIFIER_HEAD(&twl->otg.notifier);
        INIT_WORK(&twl->vbus_work, vbus_monitor_work_func);
        INIT_WORK(&twl->id_work, id_monitor_work_func);
	/* Our job is to use irqs and status from the power module
	 * to keep the transceiver disabled when nothing's connected.
	 *
	 * FIXME we actually shouldn't start enabling it until the
	 * USB controller drivers have said they're ready, by calling
	 * set_host() and/or set_peripheral() ... OTG_capable boards
	 * need both handles, otherwise just one suffices.
	 */
	twl->irq_enabled = true;
	status = request_threaded_irq(twl->irq1, NULL, twl6030_usbotg_irq,
			IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
			"twl6030_usb", twl);
	if (status < 0) {
		dev_dbg(&pdev->dev, "can't get IRQ %d, err %d\n",
			twl->irq1, status);
		kfree(twl);
		return status;
	}

	status = request_threaded_irq(twl->irq2, NULL, twl6030_usb_irq,
			IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
			"twl6030_usb", twl);
	if (status < 0) {
		dev_dbg(&pdev->dev, "can't get IRQ %d, err %d\n",
			twl->irq2, status);
		kfree(twl);
		return status;
	}

        vbus_state = twl6030_readb(twl, TWL6030_MODULE_CHARGER,
						CONTROLLER_STAT1);
        wake_lock_init(&twlusb_lock, WAKE_LOCK_SUSPEND, "usb_wake_lock");

	ctrl_base = ioremap(0x4A002000, SZ_1K);
	/* power down the phy by default can be enabled on connect */
	__raw_writel(PHY_PD, ctrl_base + CONTROL_DEV_CONF);

	dev_info(&pdev->dev, "Initialized TWL6030 USB module\n");
	return 0;
//.........這裏部分代碼省略.........
開發者ID:Loki154,項目名稱:Android-kernel-for-kindle-fire,代碼行數:101,代碼來源:twl6030-usb.c

示例15: bus_register

/* _VMKLNX_CODECHECK_: bus_register */
int bus_register(struct bus_type * bus)
{
	int retval;

#if defined(__VMKLNX__)
	VMK_ReturnStatus status;
	bus->bus_notifier.head = NULL;
	status = vmk_SemaCreate(&bus->bus_notifier.rwsem,
		vmk_ModuleStackTop(), bus->name, 1);
	if (status != VMK_OK) {
		retval = -EINVAL;
		goto out;
	}
#else
	BLOCKING_INIT_NOTIFIER_HEAD(&bus->bus_notifier);
#endif

	retval = kobject_set_name(&bus->subsys.kobj, "%s", bus->name);
	if (retval)
		goto out;

	bus->subsys.kobj.kset = &bus_subsys;

	retval = subsystem_register(&bus->subsys);
	if (retval)
		goto out;

	retval = bus_create_file(bus, &bus_attr_uevent);
	if (retval)
		goto bus_uevent_fail;

	kobject_set_name(&bus->devices.kobj, "devices");
	bus->devices.kobj.parent = &bus->subsys.kobj;
	retval = kset_register(&bus->devices);
	if (retval)
		goto bus_devices_fail;

	kobject_set_name(&bus->drivers.kobj, "drivers");
	bus->drivers.kobj.parent = &bus->subsys.kobj;
	bus->drivers.ktype = &driver_ktype;
	retval = kset_register(&bus->drivers);
	if (retval)
		goto bus_drivers_fail;

	klist_init(&bus->klist_devices, klist_devices_get, klist_devices_put);
	klist_init(&bus->klist_drivers, NULL, NULL);

	bus->drivers_autoprobe = 1;
	retval = add_probe_files(bus);
	if (retval)
		goto bus_probe_files_fail;

	retval = bus_add_attrs(bus);
	if (retval)
		goto bus_attrs_fail;

	pr_debug("bus type '%s' registered\n", bus->name);
	return 0;

bus_attrs_fail:
	remove_probe_files(bus);
bus_probe_files_fail:
	kset_unregister(&bus->drivers);
bus_drivers_fail:
	kset_unregister(&bus->devices);
bus_devices_fail:
	bus_remove_file(bus, &bus_attr_uevent);
bus_uevent_fail:
	subsystem_unregister(&bus->subsys);
out:
	return retval;
}
開發者ID:loginab,項目名稱:esxdrivers,代碼行數:73,代碼來源:bus.c


注:本文中的BLOCKING_INIT_NOTIFIER_HEAD函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。