本文整理汇总了C++中device_unlock函数的典型用法代码示例。如果您正苦于以下问题:C++ device_unlock函数的具体用法?C++ device_unlock怎么用?C++ device_unlock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了device_unlock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}