• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ device_unlock函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: gpp_wp_show

static ssize_t gpp_wp_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{
	struct mmc_card *card = mmc_dev_to_card(dev);
	int err;
	u8 wp_status = 0;

	if (card == NULL)
		return -ENODEV;

	device_lock(dev);
	if (gpp_wppart < EXT_CSD_PART_CONFIG_ACC_GP0) {
		device_unlock(dev);
		return -EINVAL;
	}

	err = mmc_wp_status(card, gpp_wppart, gpp_wpgroup, &wp_status);
	if (err) {
		device_unlock(dev);
		return err;
	}

	device_unlock(dev);

	return sprintf(buf, "%d\n", wp_status);
}
开发者ID:BORETS24,项目名称:za580,代码行数:26,代码来源:mmc.c


示例2: gpp_wp_set

/*
 * protect: 1 means permanent write protect. Right now only allow this
 * protection method
 */
static ssize_t gpp_wp_set(struct device *dev, struct device_attribute *attr,
		const char *buf, size_t n)
{
	long protect;
	struct mmc_card *card = mmc_dev_to_card(dev);
	int err;

	if (card == NULL)
		return -ENODEV;

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

	if (protect != PERMANENT_PROTECT)
		return -EINVAL;

	device_lock(dev);

	if (gpp_wppart != EXT_CSD_PART_CONFIG_ACC_GP0 ||
			gpp_wpgroup != GPP_WPG0) {
		device_unlock(dev);
		return -EINVAL;
	}

	err = mmc_set_user_wp(card, gpp_wppart, gpp_wpgroup);
	if (err) {
		pr_err("%s: err to set write protect\n", __func__);
		n = err;
	}
	device_unlock(dev);
	return n;
}
开发者ID:BORETS24,项目名称:za580,代码行数:36,代码来源:mmc.c


示例3: driver_detach

/**
 * driver_detach - detach driver from all devices it controls.
 * @drv: driver.
 */
void driver_detach(struct device_driver *drv)
{
	struct device_private *dev_prv;
	struct device *dev;

	for (;;) {
		spin_lock(&drv->p->klist_devices.k_lock);
		if (list_empty(&drv->p->klist_devices.k_list)) {
			spin_unlock(&drv->p->klist_devices.k_lock);
			break;
		}
		dev_prv = list_entry(drv->p->klist_devices.k_list.prev,
				     struct device_private,
				     knode_driver.n_node);
		dev = dev_prv->device;
		get_device(dev);
		spin_unlock(&drv->p->klist_devices.k_lock);

		if (dev->parent)	/* Needed for USB */
			device_lock(dev->parent);
		device_lock(dev);
		if (dev->driver == drv)
			__device_release_driver(dev);
		device_unlock(dev);
		if (dev->parent)
			device_unlock(dev->parent);
		put_device(dev);
	}
}
开发者ID:Kernel-Saram,项目名称:LG-SU760-Kernel,代码行数:33,代码来源:dd.c


示例4: __driver_attach

static int __driver_attach(struct device *dev, void *data)
{
	struct device_driver *drv = data;

	/*
	 * Lock device and try to bind to it. We drop the error
	 * here and always return 0, because we need to keep trying
	 * to bind to devices and some drivers will return an error
	 * simply if it didn't support the device.
	 *
	 * driver_probe_device() will spit a warning if there
	 * is an error.
	 */

	if (!driver_match_device(drv, dev))
		return 0;

	if (dev->parent)	/* Needed for USB */
		device_lock(dev->parent);
	device_lock(dev);
	if (!dev->driver)
		driver_probe_device(drv, dev);
	device_unlock(dev);
	if (dev->parent)
		device_unlock(dev->parent);

	return 0;
}
开发者ID:Kernel-Saram,项目名称:LG-SU760-Kernel,代码行数:28,代码来源:dd.c


示例5: eeh_report_failure

/**
 * eeh_report_failure - Tell device driver that device is dead.
 * @dev: PCI device
 * @userdata: return value
 *
 * This informs the device driver that the device is permanently
 * dead, and that no further recovery attempts will be made on it.
 */
static int eeh_report_failure(struct pci_dev *dev, void *userdata)
{
	struct pci_driver *driver;

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

	driver = eeh_pcid_get(dev);
	if (!driver) goto out;

	eeh_disable_irq(dev);

	if (!driver->err_handler ||
	    !driver->err_handler->error_detected) {
		eeh_pcid_put(dev);
		goto out;
	}

	driver->err_handler->error_detected(dev, pci_channel_io_perm_failure);

	eeh_pcid_put(dev);
out:
	device_unlock(&dev->dev);
	return 0;
}
开发者ID:Maxell0,项目名称:pi_plus,代码行数:33,代码来源:eeh_driver.c


示例6: eeh_report_resume

/**
 * eeh_report_resume - Tell device to resume normal operations
 * @dev: PCI device
 * @userdata: return value
 *
 * This routine must be called to notify the device driver that it
 * could resume so that the device driver can do some initialization
 * to make the recovered device work again.
 */
static int eeh_report_resume(struct pci_dev *dev, void *userdata)
{
	struct pci_driver *driver;

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

	driver = eeh_pcid_get(dev);
	if (!driver) goto out;

	eeh_enable_irq(dev);

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

	driver->err_handler->resume(dev);

	eeh_pcid_put(dev);
out:
	device_unlock(&dev->dev);
	return 0;
}
开发者ID:Maxell0,项目名称:pi_plus,代码行数:34,代码来源:eeh_driver.c


示例7: eeh_report_reset

/**
 * eeh_report_reset - Tell device that slot has been reset
 * @dev: PCI device
 * @userdata: return value
 *
 * This routine must be called while EEH tries to reset particular
 * PCI device so that the associated PCI device driver could take
 * some actions, usually to save data the driver needs so that the
 * driver can work again while the device is recovered.
 */
static int eeh_report_reset(struct pci_dev *dev, void *userdata)
{
	enum pci_ers_result rc, *res = userdata;
	struct pci_driver *driver;

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

	driver = eeh_pcid_get(dev);
	if (!driver) goto out;

	eeh_enable_irq(dev);

	if (!driver->err_handler ||
	    !driver->err_handler->slot_reset) {
		eeh_pcid_put(dev);
		goto out;
	}

	rc = driver->err_handler->slot_reset(dev);
	if ((*res == PCI_ERS_RESULT_NONE) ||
	    (*res == PCI_ERS_RESULT_RECOVERED)) *res = rc;
	if (*res == PCI_ERS_RESULT_DISCONNECT &&
	     rc == PCI_ERS_RESULT_NEED_RESET) *res = rc;

	eeh_pcid_put(dev);
out:
	device_unlock(&dev->dev);
	return 0;
}
开发者ID:Maxell0,项目名称:pi_plus,代码行数:40,代码来源:eeh_driver.c


示例8: flush_regions_dimms

static int flush_regions_dimms(struct device *dev, void *data)
{
	device_lock(dev);
	device_unlock(dev);
	device_for_each_child(dev, NULL, flush_namespaces);
	return 0;
}
开发者ID:shengwenhui,项目名称:aufs4-linux,代码行数:7,代码来源:core.c


示例9: smbus_do_alert

/* If this is the alerting device, notify its driver */
static int smbus_do_alert(struct device *dev, void *addrp)
{
	struct i2c_client *client = i2c_verify_client(dev);
	struct alert_data *data = addrp;
	struct i2c_driver *driver;

	if (!client || client->addr != data->addr)
		return 0;
	if (client->flags & I2C_CLIENT_TEN)
		return 0;

	/*
	 * Drivers should either disable alerts, or provide at least
	 * a minimal handler.  Lock so the driver won't change.
	 */
	device_lock(dev);
	if (client->dev.driver) {
		driver = to_i2c_driver(client->dev.driver);
		if (driver->alert)
			driver->alert(client, data->flag);
		else
			dev_warn(&client->dev, "no driver alert()!\n");
	} else
		dev_dbg(&client->dev, "alert with no driver\n");
	device_unlock(dev);

	/* Stop iterating after we find the device */
	return -EBUSY;
}
开发者ID:BozkurTR,项目名称:kernel,代码行数:30,代码来源:i2c-smbus.c


示例10: store_port_power

static ssize_t store_port_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;

	int power_on, port;
	int err;

	err = sscanf(buf, "%d %d", &power_on, &port);
	if (err < 2 || port < 0 || port > 3 || power_on < 0 || power_on > 1) {
		pr_err("port power fail: port_power 1 2(port 2 enable 1)\n");
		return count;
	}

	pr_debug("%s: Port:%d power: %d\n", __func__, port, power_on);
	device_lock(dev);
	s5p_ehci_port_control(pdev, port, power_on);

	/*HSIC IPC control the ACTIVE_STATE*/
	if (pdata && pdata->noti_host_states && port == CP_PORT)
		pdata->noti_host_states(pdev, power_on ? S5P_HOST_ON :
			S5P_HOST_OFF);
	device_unlock(dev);
	return count;
}
开发者ID:ameswilliam,项目名称:starkissed-kernel-ekgc100,代码行数:27,代码来源:ehci-s5p.c


示例11: size_show

static ssize_t size_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{
	struct nd_pfn *nd_pfn = to_nd_pfn_safe(dev);
	ssize_t rc;

	device_lock(dev);
	if (dev->driver) {
		struct nd_pfn_sb *pfn_sb = nd_pfn->pfn_sb;
		u64 offset = __le64_to_cpu(pfn_sb->dataoff);
		struct nd_namespace_common *ndns = nd_pfn->ndns;
		u32 start_pad = __le32_to_cpu(pfn_sb->start_pad);
		u32 end_trunc = __le32_to_cpu(pfn_sb->end_trunc);
		struct nd_namespace_io *nsio = to_nd_namespace_io(&ndns->dev);

		rc = sprintf(buf, "%llu\n", (unsigned long long)
				resource_size(&nsio->res) - start_pad
				- end_trunc - offset);
	} else {
		/* no size to convey if the pfn instance is disabled */
		rc = -ENXIO;
	}
	device_unlock(dev);

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


示例12: gpp_wpgroup_set

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

	if (card == NULL)
		return -ENODEV;

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

	if (group < 0 || gpp_wppart < EXT_CSD_PART_CONFIG_ACC_GP0 ||
			gpp_wppart >
			EXT_CSD_PART_CONFIG_ACC_GP0 + EXT_CSD_GPP_NUM - 1)
		return -EINVAL;

	if (group > card->ext_csd.gpp_sz[gpp_wppart -
			EXT_CSD_PART_CONFIG_ACC_GP0] - 1)
		return -EINVAL;

	device_lock(dev);
	gpp_wpgroup = group;
	device_unlock(dev);
	return n;
}
开发者ID:TheSSJ,项目名称:android_kernel_asus_moorefield,代码行数:26,代码来源:mmc.c


示例13: eeh_report_mmio_enabled

/**
 * eeh_report_mmio_enabled - Tell drivers that MMIO has been enabled
 * @dev: PCI device
 * @userdata: return value
 *
 * Tells each device driver that IO ports, MMIO and config space I/O
 * are now enabled. Collects up and merges the device driver responses.
 * Cumulative response passed back in "userdata".
 */
static int eeh_report_mmio_enabled(struct pci_dev *dev, void *userdata)
{
	enum pci_ers_result rc, *res = userdata;
	struct pci_driver *driver;

	device_lock(&dev->dev);
	driver = eeh_pcid_get(dev);
	if (!driver) goto out;

	if (!driver->err_handler ||
	    !driver->err_handler->mmio_enabled) {
		eeh_pcid_put(dev);
		goto out;
	}

	rc = driver->err_handler->mmio_enabled(dev);

	/* A driver that needs a reset trumps all others */
	if (rc == PCI_ERS_RESULT_NEED_RESET) *res = rc;
	if (*res == PCI_ERS_RESULT_NONE) *res = rc;

	eeh_pcid_put(dev);
out:
	device_unlock(&dev->dev);
	return 0;
}
开发者ID:Maxell0,项目名称:pi_plus,代码行数:35,代码来源:eeh_driver.c


示例14: carl9170_usb_firmware_failed

static void carl9170_usb_firmware_failed(struct ar9170 *ar)
{
	struct device *parent = ar->udev->dev.parent;
	struct usb_device *udev;

	/*
	 * Store a copy of the usb_device pointer locally.
	 * This is because device_release_driver initiates
	 * carl9170_usb_disconnect, which in turn frees our
	 * driver context (ar).
	 */
	udev = ar->udev;

	complete(&ar->fw_load_wait);

	/* unbind anything failed */
	if (parent)
		device_lock(parent);

	device_release_driver(&udev->dev);
	if (parent)
		device_unlock(parent);

	usb_put_dev(udev);
}
开发者ID:JonnyH,项目名称:pandora-kernel,代码行数:25,代码来源:usb.c


示例15: nfc_genl_dump_targets

static int nfc_genl_dump_targets(struct sk_buff *skb,
				 struct netlink_callback *cb)
{
	int i = cb->args[0];
	struct nfc_dev *dev = (struct nfc_dev *) cb->args[1];
	int rc;

	if (!dev) {
		dev = __get_device_from_cb(cb);
		if (IS_ERR(dev))
			return PTR_ERR(dev);

		cb->args[1] = (long) dev;
	}

	device_lock(&dev->dev);

	cb->seq = dev->targets_generation;

	while (i < dev->n_targets) {
		rc = nfc_genl_send_target(skb, &dev->targets[i], cb,
					  NLM_F_MULTI);
		if (rc < 0)
			break;

		i++;
	}

	device_unlock(&dev->dev);

	cb->args[0] = i;

	return skb->len;
}
开发者ID:Seagate,项目名称:SMR_FS-EXT4,代码行数:34,代码来源:netlink.c


示例16: device_attach

/**
 * device_attach - try to attach device to a driver.
 * @dev: device.
 *
 * Walk the list of drivers that the bus has and call
 * driver_probe_device() for each pair. If a compatible
 * pair is found, break out and return.
 *
 * Returns 1 if the device was bound to a driver;
 * 0 if no matching driver was found;
 * -ENODEV if the device is not registered.
 *
 * When called for a USB interface, @dev->parent lock must be held.
 */
int device_attach(struct device *dev)
{
	int ret = 0;

	device_lock(dev);
	if (dev->driver) {
		if (klist_node_attached(&dev->p->knode_driver)) {
			ret = 1;
			goto out_unlock;
		}
		ret = device_bind_driver(dev);
		if (ret == 0)
			ret = 1;
		else {
			dev->driver = NULL;
			ret = 0;
		}
	} else {
		pm_runtime_get_noresume(dev);
		ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach);
		pm_runtime_put_sync(dev);
	}
out_unlock:
	device_unlock(dev);
	return ret;
}
开发者ID:andi34,项目名称:Dhollmen_Kernel,代码行数:40,代码来源:dd.c


示例17: driver_override_store

static ssize_t driver_override_store(struct device *_dev,
				     struct device_attribute *attr,
				     const char *buf, size_t count)
{
	struct amba_device *dev = to_amba_device(_dev);
	char *driver_override, *old, *cp;

	/* We need to keep extra room for a newline */
	if (count >= (PAGE_SIZE - 1))
		return -EINVAL;

	driver_override = kstrndup(buf, count, GFP_KERNEL);
	if (!driver_override)
		return -ENOMEM;

	cp = strchr(driver_override, '\n');
	if (cp)
		*cp = '\0';

	device_lock(_dev);
	old = dev->driver_override;
	if (strlen(driver_override)) {
		dev->driver_override = driver_override;
	} else {
	       kfree(driver_override);
	       dev->driver_override = NULL;
	}
	device_unlock(_dev);

	kfree(old);

	return count;
}
开发者ID:lcavalcante,项目名称:linux,代码行数:33,代码来源:bus.c


示例18: mode_store

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

	device_lock(dev);
	nvdimm_bus_lock(dev);
	if (dev->driver)
		rc = -EBUSY;
	else {
		size_t n = len - 1;

		if (strncmp(buf, "pmem\n", n) == 0
				|| strncmp(buf, "pmem", n) == 0) {
			/* TODO: allocate from PMEM support */
			rc = -ENOTTY;
		} else if (strncmp(buf, "ram\n", n) == 0
				|| strncmp(buf, "ram", n) == 0)
			nd_pfn->mode = PFN_MODE_RAM;
		else if (strncmp(buf, "none\n", n) == 0
				|| strncmp(buf, "none", n) == 0)
			nd_pfn->mode = PFN_MODE_NONE;
		else
			rc = -EINVAL;
	}
	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:guanhe0,项目名称:kernel,代码行数:33,代码来源:pfn_devs.c


示例19: ccwgroup_online_store

static ssize_t ccwgroup_online_store(struct device *dev,
				     struct device_attribute *attr,
				     const char *buf, size_t count)
{
	struct ccwgroup_device *gdev = to_ccwgroupdev(dev);
	unsigned long value;
	int ret;

	device_lock(dev);
	if (!dev->driver) {
		ret = -EINVAL;
		goto out;
	}

	ret = kstrtoul(buf, 0, &value);
	if (ret)
		goto out;

	if (value == 1)
		ret = ccwgroup_set_online(gdev);
	else if (value == 0)
		ret = ccwgroup_set_offline(gdev);
	else
		ret = -EINVAL;
out:
	device_unlock(dev);
	return (ret == 0) ? count : ret;
}
开发者ID:7799,项目名称:linux,代码行数:28,代码来源:ccwgroup.c


示例20: 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 usb_hcd *hcd = dev_get_drvdata(dev);
	struct s5p_ehci_hcd *s5p_ehci = to_s5p_ehci(hcd);
	int power_on;
	int irq;
	int retval;

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

	device_lock(dev);

	if (!power_on && s5p_ehci->power_on) {
		dev_info(dev, "EHCI turn off\n");
		pm_runtime_forbid(dev);
		s5p_ehci->power_on = 0;
		usb_remove_hcd(hcd);

		if (s5p_ehci->phy) {
			/* Shutdown PHY only if it wasn't shutdown before */
			if (!s5p_ehci->post_lpa_resume)
				usb_phy_shutdown(s5p_ehci->phy);
		} else if (s5p_ehci->pdata->phy_exit) {
			s5p_ehci->pdata->phy_exit(pdev, USB_PHY_TYPE_HOST);
		}
	} else if (power_on) {
		dev_info(dev, "EHCI turn on\n");
		if (s5p_ehci->power_on) {
			pm_runtime_forbid(dev);
			usb_remove_hcd(hcd);
		} else {
			s5p_ehci_phy_init(pdev);
		}

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

		/*
		 * EHCI root hubs are expected to handle remote wakeup.
		 * So, wakeup flag init defaults for root hubs.
		 */
		device_wakeup_enable(&hcd->self.root_hub->dev);

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ device_unregister函数代码示例发布时间:2022-05-30
下一篇:
C++ device_unit函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap