本文整理汇总了C++中devres_free函数的典型用法代码示例。如果您正苦于以下问题:C++ devres_free函数的具体用法?C++ devres_free怎么用?C++ devres_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了devres_free函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: devres_alloc
static struct regulator *_devm_regulator_get(struct device *dev, const char *id,
int get_type)
{
struct regulator **ptr, *regulator;
ptr = devres_alloc(devm_regulator_release, sizeof(*ptr), GFP_KERNEL);
if (!ptr)
return ERR_PTR(-ENOMEM);
switch (get_type) {
case NORMAL_GET:
regulator = regulator_get(dev, id);
break;
case EXCLUSIVE_GET:
regulator = regulator_get_exclusive(dev, id);
break;
case OPTIONAL_GET:
regulator = regulator_get_optional(dev, id);
break;
default:
regulator = ERR_PTR(-EINVAL);
}
if (!IS_ERR(regulator)) {
*ptr = regulator;
devres_add(dev, ptr);
} else {
devres_free(ptr);
}
return regulator;
}
开发者ID:mikuhatsune001,项目名称:linux2.6.32,代码行数:32,代码来源:devres.c
示例2: devm_hello_create_file
struct dentry* devm_hello_create_file(
struct device *dev,
const char *name,
umode_t mode,
struct dentry *parent,
void *data,
const struct file_operations* fops)
{
struct dentry *pfile = NULL;
void *ptr = NULL;
if(!fops || !name || name[0] == '\0')
return NULL;
ptr = devres_alloc(devm_hello_release, 0, GFP_KERNEL);
if (!ptr)
return NULL;
pfile = debugfs_create_file(name, mode, parent, data, fops);
if (pfile) {
devres_add(dev, ptr);
} else {
devres_free(ptr);
}
return pfile;
}
开发者ID:timkoma,项目名称:kernel_training,代码行数:27,代码来源:debugfs_api.c
示例3: devm_regulator_register_supply_alias
/**
* devm_regulator_register_supply_alias - Resource managed
* regulator_register_supply_alias()
*
* @dev: device that will be given as the regulator "consumer"
* @id: Supply name or regulator ID
* @alias_dev: device that should be used to lookup the supply
* @alias_id: Supply name or regulator ID that should be used to lookup the
* supply
*
* The supply alias will automatically be unregistered when the source
* device is unbound.
*/
int devm_regulator_register_supply_alias(struct device *dev, const char *id,
struct device *alias_dev,
const char *alias_id)
{
struct regulator_supply_alias_match *match;
int ret;
match = devres_alloc(devm_regulator_destroy_supply_alias,
sizeof(struct regulator_supply_alias_match),
GFP_KERNEL);
if (!match)
return -ENOMEM;
match->dev = dev;
match->id = id;
ret = regulator_register_supply_alias(dev, id, alias_dev, alias_id);
if (ret < 0) {
devres_free(match);
return ret;
}
devres_add(dev, match);
return 0;
}
开发者ID:mikuhatsune001,项目名称:linux2.6.32,代码行数:39,代码来源:devres.c
示例4: devres_release
/**
* devres_release - Find a device resource and destroy it, calling release
* @dev: Device to find resource from
* @release: Look for resources associated with this release function
* @match: Match function (optional)
* @match_data: Data for the match function
*
* Find the latest devres of @dev associated with @release and for
* which @match returns 1. If @match is NULL, it's considered to
* match all. If found, the resource is removed atomically, the
* release function called and the resource freed.
*
* RETURNS:
* 0 if devres is found and freed, -ENOENT if not found.
*/
int devres_release(struct device *dev, dr_release_t release,
dr_match_t match, void *match_data)
{
void *res;
res = devres_remove(dev, release, match, match_data);
if (unlikely(!res))
return -ENOENT;
(*release)(dev, res);
devres_free(res);
return 0;
}
开发者ID:NETFORCE2,项目名称:OpenWrt-14.07-Barrier-Breaker,代码行数:28,代码来源:compat-3.5.c
示例5: input_register_polled_device
/**
* input_register_polled_device - register polled device
* @dev: device to register
*
* The function registers previously initialized polled input device
* with input layer. The device should be allocated with call to
* input_allocate_polled_device(). Callers should also set up poll()
* method and set up capabilities (id, name, phys, bits) of the
* corresponding input_dev structure.
*/
int input_register_polled_device(struct input_polled_dev *dev)
{
struct input_polled_devres *devres = NULL;
struct input_dev *input = dev->input;
int error;
if (dev->devres_managed) {
devres = devres_alloc(devm_input_polldev_unregister,
sizeof(*devres), GFP_KERNEL);
if (!devres)
return -ENOMEM;
devres->polldev = dev;
}
input_set_drvdata(input, dev);
INIT_DELAYED_WORK(&dev->work, input_polled_device_work);
if (!dev->poll_interval)
dev->poll_interval = 500;
if (!dev->poll_interval_max)
dev->poll_interval_max = dev->poll_interval;
input->open = input_open_polled_device;
input->close = input_close_polled_device;
input->dev.groups = input_polldev_attribute_groups;
error = input_register_device(input);
if (error) {
devres_free(devres);
return error;
}
/*
* Take extra reference to the underlying input device so
* that it survives call to input_unregister_polled_device()
* and is deleted only after input_free_polled_device()
* has been invoked. This is needed to ease task of freeing
* sparse keymaps.
*/
input_get_device(input);
if (dev->devres_managed) {
dev_dbg(input->dev.parent, "%s: registering %s with devres.\n",
__func__, dev_name(&input->dev));
devres_add(input->dev.parent, devres);
}
return 0;
}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:61,代码来源:input-polldev.c
示例6: devres_alloc
struct clk *devm_clk_get(struct device *dev, const char *id)
{
struct clk **ptr, *clk;
ptr = devres_alloc(devm_clk_release, sizeof(*ptr), GFP_KERNEL);
if (!ptr)
return ERR_PTR(-ENOMEM);
clk = clk_get(dev, id);
if (!IS_ERR(clk)) {
*ptr = clk;
devres_add(dev, ptr);
} else {
devres_free(ptr);
}
return clk;
}
开发者ID:ezequielgarcia,项目名称:linux,代码行数:18,代码来源:clk-devres.c
示例7: devres_alloc
/**
* devm_iio_fifo_allocate - Resource-managed iio_kfifo_allocate()
* @dev: Device to allocate kfifo buffer for
*
* RETURNS:
* Pointer to allocated iio_buffer on success, NULL on failure.
*/
struct iio_buffer *devm_iio_kfifo_allocate(struct device *dev)
{
struct iio_buffer **ptr, *r;
ptr = devres_alloc(devm_iio_kfifo_release, sizeof(*ptr), GFP_KERNEL);
if (!ptr)
return NULL;
r = iio_kfifo_allocate();
if (r) {
*ptr = r;
devres_add(dev, ptr);
} else {
devres_free(ptr);
}
return r;
}
开发者ID:Sangil-Lee,项目名称:ZynqFPGA,代码行数:25,代码来源:kfifo_buf.c
示例8: devres_alloc
void *devm_memremap(struct device *dev, resource_size_t offset,
size_t size, unsigned long flags)
{
void **ptr, *addr;
ptr = devres_alloc(devm_memremap_release, sizeof(*ptr), GFP_KERNEL);
if (!ptr)
return NULL;
addr = memremap(offset, size, flags);
if (addr) {
*ptr = addr;
devres_add(dev, ptr);
} else
devres_free(ptr);
return addr;
}
开发者ID:DenisLug,项目名称:mptcp,代码行数:18,代码来源:memremap.c
示例9: devres_alloc
/**
* devm_ioremap_wc - Managed ioremap_wc()
* @dev: Generic device to remap IO address for
* @offset: BUS offset to map
* @size: Size of map
*
* Managed ioremap_wc(). Map is automatically unmapped on driver detach.
*/
void __iomem *devm_ioremap_wc(struct device *dev, resource_size_t offset,
resource_size_t size)
{
void __iomem **ptr, *addr;
ptr = devres_alloc(devm_ioremap_release, sizeof(*ptr), GFP_KERNEL);
if (!ptr)
return NULL;
addr = ioremap_wc(offset, size);
if (addr) {
*ptr = addr;
devres_add(dev, ptr);
} else
devres_free(ptr);
return addr;
}
开发者ID:pironex,项目名称:pia-linux-kernel,代码行数:26,代码来源:devres.c
示例10: devm_snd_soc_register_card
/**
* devm_snd_soc_register_card - resource managed card registration
* @dev: Device used to manage card
* @card: Card to register
*
* Register a card with automatic unregistration when the device is
* unregistered.
*/
int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card)
{
struct snd_soc_card **ptr;
int ret;
ptr = devres_alloc(devm_card_release, sizeof(*ptr), GFP_KERNEL);
if (!ptr)
return -ENOMEM;
ret = snd_soc_register_card(card);
if (ret == 0) {
*ptr = card;
devres_add(dev, ptr);
} else {
devres_free(ptr);
}
return ret;
}
开发者ID:020gzh,项目名称:linux,代码行数:27,代码来源:soc-devres.c
示例11: devres_alloc
struct kobject *devm_kobject_create_and_add(struct device *dev, const char *name, struct kobject *parent)
{
struct kobject **ptr, *kobj;
ptr = devres_alloc(devm_kobject_release, sizeof(*ptr), GFP_KERNEL);
if (!ptr)
return ERR_PTR(-ENOMEM);
kobj = kobject_create_and_add("kobject_example", &dev->kobj);
if (kobj) {
*ptr = kobj;
devres_add(dev, ptr);
}
else {
devres_free(ptr);
}
return kobj;
}
开发者ID:timkoma,项目名称:kernel_training,代码行数:19,代码来源:debugfs_api.c
示例12: snd_devm_add_child
static int snd_devm_add_child(struct device *dev, struct device *child)
{
struct device **dr;
int ret;
dr = devres_alloc(snd_devm_unregister_child, sizeof(*dr), GFP_KERNEL);
if (!dr)
return -ENOMEM;
ret = device_add(child);
if (ret) {
devres_free(dr);
return ret;
}
*dr = child;
devres_add(dev, dr);
return 0;
}
开发者ID:the-snowwhite,项目名称:linux-socfpga,代码行数:20,代码来源:bcm2835.c
示例13: devm_snd_dmaengine_pcm_register
/**
* devm_snd_dmaengine_pcm_register - resource managed dmaengine PCM registration
* @dev: The parent device for the PCM device
* @config: Platform specific PCM configuration
* @flags: Platform specific quirks
*
* Register a dmaengine based PCM device with automatic unregistration when the
* device is unregistered.
*/
int devm_snd_dmaengine_pcm_register(struct device *dev,
const struct snd_dmaengine_pcm_config *config, unsigned int flags)
{
struct device **ptr;
int ret;
ptr = devres_alloc(devm_dmaengine_pcm_release, sizeof(*ptr), GFP_KERNEL);
if (!ptr)
return -ENOMEM;
ret = snd_dmaengine_pcm_register(dev, config, flags);
if (ret == 0) {
*ptr = dev;
devres_add(dev, ptr);
} else {
devres_free(ptr);
}
return ret;
}
开发者ID:020gzh,项目名称:linux,代码行数:29,代码来源:soc-devres.c
示例14: devm_snd_soc_register_platform
/**
* devm_snd_soc_register_platform - resource managed platform registration
* @dev: Device used to manage platform
* @platform_drv: platform to register
*
* Register a platform driver with automatic unregistration when the device is
* unregistered.
*/
int devm_snd_soc_register_platform(struct device *dev,
const struct snd_soc_platform_driver *platform_drv)
{
struct device **ptr;
int ret;
ptr = devres_alloc(devm_platform_release, sizeof(*ptr), GFP_KERNEL);
if (!ptr)
return -ENOMEM;
ret = snd_soc_register_platform(dev, platform_drv);
if (ret == 0) {
*ptr = dev;
devres_add(dev, ptr);
} else {
devres_free(ptr);
}
return ret;
}
开发者ID:020gzh,项目名称:linux,代码行数:28,代码来源:soc-devres.c
示例15: bcm2835_devm_add_vchi_ctx
static int bcm2835_devm_add_vchi_ctx(struct device *dev)
{
struct bcm2835_vchi_ctx *vchi_ctx;
int ret;
vchi_ctx = devres_alloc(bcm2835_devm_free_vchi_ctx, sizeof(*vchi_ctx),
GFP_KERNEL);
if (!vchi_ctx)
return -ENOMEM;
ret = bcm2835_new_vchi_ctx(dev, vchi_ctx);
if (ret) {
devres_free(vchi_ctx);
return ret;
}
devres_add(dev, vchi_ctx);
return 0;
}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:20,代码来源:bcm2835.c
示例16: devm_gpio_request
int devm_gpio_request(struct device *dev, unsigned gpio, const char *label)
{
unsigned *dr;
int rc;
dr = devres_alloc(devm_gpio_release, sizeof(unsigned), GFP_KERNEL);
if (!dr)
return -ENOMEM;
rc = gpio_request(gpio, label);
if (rc) {
devres_free(dr);
return rc;
}
*dr = gpio;
devres_add(dev, dr);
return 0;
}
开发者ID:0x000000FF,项目名称:Linux4Edison,代码行数:20,代码来源:devres.c
示例17: devm_register_reboot_notifier
int devm_register_reboot_notifier(struct device *dev, struct notifier_block *nb)
{
struct notifier_block **rcnb;
int ret;
rcnb = devres_alloc(devm_unregister_reboot_notifier,
sizeof(*rcnb), GFP_KERNEL);
if (!rcnb)
return -ENOMEM;
ret = register_reboot_notifier(nb);
if (!ret) {
*rcnb = nb;
devres_add(dev, rcnb);
} else {
devres_free(rcnb);
}
return ret;
}
开发者ID:ReneNyffenegger,项目名称:linux,代码行数:20,代码来源:reboot.c
示例18: devm_irq_sim_init
/**
* irq_sim_init - Initialize the interrupt simulator for a managed device.
*
* @dev: Device to initialize the simulator object for.
* @sim: The interrupt simulator object to initialize.
* @num_irqs: Number of interrupts to allocate
*
* Returns 0 on success and a negative error number on failure.
*/
int devm_irq_sim_init(struct device *dev, struct irq_sim *sim,
unsigned int num_irqs)
{
struct irq_sim_devres *dr;
int rv;
dr = devres_alloc(devm_irq_sim_release, sizeof(*dr), GFP_KERNEL);
if (!dr)
return -ENOMEM;
rv = irq_sim_init(sim, num_irqs);
if (rv) {
devres_free(dr);
return rv;
}
dr->sim = sim;
devres_add(dev, dr);
return 0;
}
开发者ID:ReneNyffenegger,项目名称:linux,代码行数:30,代码来源:irq_sim.c
示例19: devm_hello_create_u32
struct dentry* devm_hello_create_u32(struct device *dev, const char *name, umode_t mode, struct dentry *parent, u32 *pvalue)
{
struct dentry *pu32 = NULL;\
void *ptr = NULL;
if(!pvalue || !name || name[0] == '\0')
return NULL;
ptr = devres_alloc(devm_hello_release, 0, GFP_KERNEL);
if (!ptr)
return NULL;
pu32 = debugfs_create_u32(name, mode, parent, pvalue);
if (pu32) {
devres_add(dev, ptr);
} else {
devres_free(ptr);
}
return pu32;
}
开发者ID:timkoma,项目名称:kernel_training,代码行数:21,代码来源:debugfs_api.c
示例20: devres_alloc_node
void *devm_memremap(struct device *dev, resource_size_t offset,
size_t size, unsigned long flags)
{
void **ptr, *addr;
ptr = devres_alloc_node(devm_memremap_release, sizeof(*ptr), GFP_KERNEL,
dev_to_node(dev));
if (!ptr)
return ERR_PTR(-ENOMEM);
addr = memremap(offset, size, flags);
if (addr) {
*ptr = addr;
devres_add(dev, ptr);
} else {
devres_free(ptr);
return ERR_PTR(-ENXIO);
}
return addr;
}
开发者ID:AshishNamdev,项目名称:linux,代码行数:21,代码来源:memremap.c
注:本文中的devres_free函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论