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


C++ device_lock函数代码示例

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


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

示例1: uuid_store

static ssize_t uuid_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t len)
{
	struct nd_btt *nd_btt = to_nd_btt(dev);
	ssize_t rc;

	device_lock(dev);
	rc = nd_uuid_store(dev, &nd_btt->uuid, buf, len);
	dev_dbg(dev, "%s: result: %zd wrote: %s%s", __func__,
			rc, buf, buf[len - 1] == '\n' ? "" : "\n");
	device_unlock(dev);

	return rc ? rc : len;
}
开发者ID:suntodai,项目名称:prd,代码行数:14,代码来源:btt_devs.c

示例2: report_error_detected

static int report_error_detected(struct pci_dev *dev, void *data)
{
	pci_ers_result_t vote;
	const struct pci_error_handlers *err_handler;
	struct aer_broadcast_data *result_data;
	result_data = (struct aer_broadcast_data *) data;

	device_lock(&dev->dev);
	dev->error_state = result_data->state;

	if (!dev->driver ||
		!dev->driver->err_handler ||
		!dev->driver->err_handler->error_detected) {
		if (result_data->state == pci_channel_io_frozen &&
			!(dev->hdr_type & PCI_HEADER_TYPE_BRIDGE)) {
			/*
			 * In case of fatal recovery, if one of down-
			 * stream device has no driver. We might be
			 * unable to recover because a later insmod
			 * of a driver for this device is unaware of
			 * its hw state.
			 */
			dev_printk(KERN_DEBUG, &dev->dev, "device has %s\n",
				   dev->driver ?
				   "no AER-aware driver" : "no driver");
		}

		/*
		 * If there's any device in the subtree that does not
		 * have an error_detected callback, returning
		 * PCI_ERS_RESULT_NO_AER_DRIVER prevents calling of
		 * the subsequent mmio_enabled/slot_reset/resume
		 * callbacks of "any" device in the subtree. All the
		 * devices in the subtree are left in the error state
		 * without recovery.
		 */

		if (!(dev->hdr_type & PCI_HEADER_TYPE_BRIDGE))
			vote = PCI_ERS_RESULT_NO_AER_DRIVER;
		else
			vote = PCI_ERS_RESULT_NONE;
	} else {
		err_handler = dev->driver->err_handler;
		vote = err_handler->error_detected(dev, result_data->state);
	}

	result_data->result = merge_result(result_data->result, vote);
	device_unlock(&dev->dev);
	return 0;
}
开发者ID:7799,项目名称:linux,代码行数:50,代码来源:aerdrv_core.c

示例3: store_ehci_power

static ssize_t store_ehci_power(struct device *dev,
                                struct device_attribute *attr,
                                const char *buf, size_t count)
{
    struct platform_device *pdev = to_platform_device(dev);
    struct s5p_ehci_platdata *pdata = pdev->dev.platform_data;
    struct s5p_ehci_hcd *s5p_ehci = platform_get_drvdata(pdev);
    struct usb_hcd *hcd = s5p_ehci->hcd;
    int power_on;
    int irq;
    int retval;

    if (sscanf(buf, "%d", &power_on) != 1)
        return -EINVAL;

    device_lock(dev);

    pm_runtime_get_sync(dev);
    if (!power_on && s5p_ehci->power_on) {
        printk(KERN_DEBUG "%s: EHCI turns off\n", __func__);
        s5p_ehci->power_on = 0;
        usb_remove_hcd(hcd);

        if (pdata && pdata->phy_exit)
            pdata->phy_exit(pdev, S5P_USB_PHY_HSIC);
    } else if (power_on) {
        printk(KERN_DEBUG "%s: EHCI turns on\n", __func__);
        if (s5p_ehci->power_on) {
            usb_remove_hcd(hcd);
        }

        if (pdata && pdata->phy_init)
            pdata->phy_init(pdev, S5P_USB_PHY_HSIC);
        s5p_ehci_configurate(hcd);

        irq = platform_get_irq(pdev, 0);
        retval = usb_add_hcd(hcd, irq,
                             IRQF_DISABLED | IRQF_SHARED);
        if (retval < 0) {
            dev_err(dev, "Power On Fail\n");
            goto exit;
        }

        s5p_ehci->power_on = 1;
    }
exit:
    pm_runtime_put_sync(dev);
    device_unlock(dev);
    return count;
}
开发者ID:amuxtux,项目名称:exynos4210,代码行数:50,代码来源:ehci-s5p.c

示例4: namespace_store

static ssize_t namespace_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t len)
{
	ssize_t rc;

	nvdimm_bus_lock(dev);
	device_lock(dev);
	rc = __namespace_store(dev, attr, buf, len);
	dev_dbg(dev, "%s: result: %zd wrote: %s%s", __func__,
			rc, buf, buf[len - 1] == '\n' ? "" : "\n");
	device_unlock(dev);
	nvdimm_bus_unlock(dev);

	return rc;
}
开发者ID:suntodai,项目名称:prd,代码行数:15,代码来源:btt_devs.c

示例5: ar9170_usb_firmware_failed

static void ar9170_usb_firmware_failed(struct ar9170_usb *aru)
{
	struct device *parent = aru->udev->dev.parent;

	complete(&aru->firmware_loading_complete);

	/* unbind anything failed */
	if (parent)
		device_lock(parent);
	device_release_driver(&aru->udev->dev);
	if (parent)
		device_unlock(parent);

	usb_put_dev(aru->udev);
}
开发者ID:kronenpj,项目名称:samsung-s3c6410-android.2.0,代码行数:15,代码来源:usb.c

示例6: autosuspend_delay_ms_store

static ssize_t autosuspend_delay_ms_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t n)
{
	long delay;

	if (!dev->power.use_autosuspend)
		return -EIO;

	if (kstrtol(buf, 10, &delay) != 0 || delay != (int) delay)
		return -EINVAL;

	device_lock(dev);
	pm_runtime_set_autosuspend_delay(dev, delay);
	device_unlock(dev);
	return n;
}
开发者ID:ParrotSec,项目名称:linux-psec,代码行数:16,代码来源:sysfs.c

示例7: floppy_request

static int floppy_request(vnode *node, int cmd, ULONG sector, ULONG count, char *buffer)
{
	if (sector>=FLOPPY_SECTOR_COUNT) return -EINVAL;
	device_lock(node);
	if (sector+count>=FLOPPY_SECTOR_COUNT)
		count=FLOPPY_SECTOR_COUNT-sector;
	switch (cmd) {
		case REQUEST_READ:
			fdc_read_block(sector,buffer,count);
			break;
		case REQUEST_WRITE:
			fdc_rw(sector,buffer,0,count);
			break;
	}
	device_unlock(node);
	return count;
}
开发者ID:BackupTheBerlios,项目名称:nupkux-svn,代码行数:17,代码来源:fdc_lib.c

示例8: align_store

static ssize_t align_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t len)
{
	struct nd_pfn *nd_pfn = to_nd_pfn_safe(dev);
	ssize_t rc;

	device_lock(dev);
	nvdimm_bus_lock(dev);
	rc = nd_size_select_store(dev, buf, &nd_pfn->align,
			nd_pfn_supported_alignments());
	dev_dbg(dev, "%s: result: %zd wrote: %s%s", __func__,
			rc, buf, buf[len - 1] == '\n' ? "" : "\n");
	nvdimm_bus_unlock(dev);
	device_unlock(dev);

	return rc ? rc : len;
}
开发者ID:SantoshShilimkar,项目名称:linux,代码行数:17,代码来源:pfn_devs.c

示例9: fimc_md_register_platform_entity

static int fimc_md_register_platform_entity(struct fimc_md *fmd,
					    struct platform_device *pdev,
					    int plat_entity)
{
	struct device *dev = &pdev->dev;
	int ret = -EPROBE_DEFER;
	void *drvdata;

	/* Lock to ensure dev->driver won't change. */
	device_lock(dev);

	if (!dev->driver || !try_module_get(dev->driver->owner))
		goto dev_unlock;

	drvdata = dev_get_drvdata(dev);
	/* Some subdev didn't probe successfully id drvdata is NULL */
	if (drvdata) {
		switch (plat_entity) {
		case IDX_FIMC:
			ret = register_fimc_entity(fmd, drvdata);
			break;
		case IDX_FLITE:
			ret = register_fimc_lite_entity(fmd, drvdata);
			break;
		case IDX_CSIS:
			ret = register_csis_entity(fmd, pdev, drvdata);
			break;
		case IDX_IS_ISP:
			ret = register_fimc_is_entity(fmd, drvdata);
			break;
		default:
			ret = -ENODEV;
		}
	}

	module_put(dev->driver->owner);
dev_unlock:
	device_unlock(dev);
	if (ret == -EPROBE_DEFER)
		dev_info(&fmd->pdev->dev, "deferring %s device registration\n",
			dev_name(dev));
	else if (ret < 0)
		dev_err(&fmd->pdev->dev, "%s device registration failed (%d)\n",
			dev_name(dev), ret);
	return ret;
}
开发者ID:020gzh,项目名称:linux,代码行数:46,代码来源:media-dev.c

示例10: sector_size_store

static ssize_t sector_size_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t len)
{
	struct nd_btt *nd_btt = to_nd_btt(dev);
	ssize_t rc;

	device_lock(dev);
	nvdimm_bus_lock(dev);
	rc = nd_sector_size_store(dev, buf, &nd_btt->lbasize,
			btt_lbasize_supported);
	dev_dbg(dev, "%s: result: %zd wrote: %s%s", __func__,
			rc, buf, buf[len - 1] == '\n' ? "" : "\n");
	nvdimm_bus_unlock(dev);
	device_unlock(dev);

	return rc ? rc : len;
}
开发者ID:suntodai,项目名称:prd,代码行数:17,代码来源:btt_devs.c

示例11: report_resume

static int report_resume(struct pci_dev *dev, void *data)
{
	const struct pci_error_handlers *err_handler;

	device_lock(&dev->dev);
	dev->error_state = pci_channel_io_normal;

	if (!dev->driver ||
		!dev->driver->err_handler ||
		!dev->driver->err_handler->resume)
		goto out;

	err_handler = dev->driver->err_handler;
	err_handler->resume(dev);
out:
	device_unlock(&dev->dev);
	return 0;
}
开发者ID:AshishNamdev,项目名称:linux,代码行数:18,代码来源:aerdrv_core.c

示例12: alt_name_store

static ssize_t alt_name_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t len)
{
	struct nd_region *nd_region = to_nd_region(dev->parent);
	ssize_t rc;

	device_lock(dev);
	nvdimm_bus_lock(dev);
	wait_nvdimm_bus_probe_idle(dev);
	rc = __alt_name_store(dev, buf, len);
	if (rc >= 0)
		rc = nd_namespace_label_update(nd_region, dev);
	dev_dbg(dev, "%s: %s(%zd)\n", __func__, rc < 0 ? "fail " : "", rc);
	nvdimm_bus_unlock(dev);
	device_unlock(dev);

	return rc < 0 ? rc : len;
}
开发者ID:Kirill2013,项目名称:kasan,代码行数:18,代码来源:namespace_devs.c

示例13: control_store

static ssize_t control_store(struct device * dev, struct device_attribute *attr,
			     const char * buf, size_t n)
{
	char *cp;
	int len = n;

	cp = memchr(buf, '\n', n);
	if (cp)
		len = cp - buf;
	device_lock(dev);
	if (len == sizeof ctrl_auto - 1 && strncmp(buf, ctrl_auto, len) == 0)
		pm_runtime_allow(dev);
	else if (len == sizeof ctrl_on - 1 && strncmp(buf, ctrl_on, len) == 0)
		pm_runtime_forbid(dev);
	else
		n = -EINVAL;
	device_unlock(dev);
	return n;
}
开发者ID:ParrotSec,项目名称:linux-psec,代码行数:19,代码来源:sysfs.c

示例14: gpp_wppart_set

static ssize_t gpp_wppart_set(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t n)
{
	long part;
	struct mmc_card *card = mmc_dev_to_card(dev);

	if (card == NULL)
		return -ENODEV;
	if (kstrtol(buf, 10, &part) != 0 || part != (u32)part)
		return -EINVAL;
	if (part > EXT_CSD_GPP_NUM || part <= 0)
		return -EINVAL;
	if (!card->ext_csd.gpp_sz[part - 1])
		return -EINVAL;
	device_lock(dev);
	/* make GPP number recognized by eMMC device */
	gpp_wppart = part + EXT_CSD_PART_CONFIG_ACC_GP0 - 1;
	device_unlock(dev);
	return n;
}
开发者ID:TheSSJ,项目名称:android_kernel_asus_moorefield,代码行数:20,代码来源:mmc.c

示例15: report_slot_reset

static int report_slot_reset(struct pci_dev *dev, void *data)
{
	pci_ers_result_t vote;
	const struct pci_error_handlers *err_handler;
	struct aer_broadcast_data *result_data;
	result_data = (struct aer_broadcast_data *) data;

	device_lock(&dev->dev);
	if (!dev->driver ||
		!dev->driver->err_handler ||
		!dev->driver->err_handler->slot_reset)
		goto out;

	err_handler = dev->driver->err_handler;
	vote = err_handler->slot_reset(dev);
	result_data->result = merge_result(result_data->result, vote);
out:
	device_unlock(&dev->dev);
	return 0;
}
开发者ID:AshishNamdev,项目名称:linux,代码行数:20,代码来源:aerdrv_core.c


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