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

C++ devres_add函数代码示例

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

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



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

示例1: 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


示例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: 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


示例4: of_regulator_match

/**
 * of_regulator_match - extract multiple regulator init data from device tree.
 * @dev: device requesting the data
 * @node: parent device node of the regulators
 * @matches: match table for the regulators
 * @num_matches: number of entries in match table
 *
 * This function uses a match table specified by the regulator driver to
 * parse regulator init data from the device tree. @node is expected to
 * contain a set of child nodes, each providing the init data for one
 * regulator. The data parsed from a child node will be matched to a regulator
 * based on either the deprecated property regulator-compatible if present,
 * or otherwise the child node's name. Note that the match table is modified
 * in place and an additional of_node reference is taken for each matched
 * regulator.
 *
 * Returns the number of matches found or a negative error code on failure.
 */
int of_regulator_match(struct device *dev, struct device_node *node,
		       struct of_regulator_match *matches,
		       unsigned int num_matches)
{
	unsigned int count = 0;
	unsigned int i;
	const char *name;
	struct device_node *child;
	struct devm_of_regulator_matches *devm_matches;

	if (!dev || !node)
		return -EINVAL;

	devm_matches = devres_alloc(devm_of_regulator_put_matches,
				    sizeof(struct devm_of_regulator_matches),
				    GFP_KERNEL);
	if (!devm_matches)
		return -ENOMEM;

	devm_matches->matches = matches;
	devm_matches->num_matches = num_matches;

	devres_add(dev, devm_matches);

	for (i = 0; i < num_matches; i++) {
		struct of_regulator_match *match = &matches[i];
		match->init_data = NULL;
		match->of_node = NULL;
	}

	for_each_child_of_node(node, child) {
		name = of_get_property(child,
					"regulator-compatible", NULL);
		if (!name)
			name = child->name;
		for (i = 0; i < num_matches; i++) {
			struct of_regulator_match *match = &matches[i];
			if (match->of_node)
				continue;

			if (strcmp(match->name, name))
				continue;

			match->init_data =
				of_get_regulator_init_data(dev, child,
							   match->desc);
			if (!match->init_data) {
				dev_err(dev,
					"failed to parse DT for regulator %pOFn\n",
					child);
				of_node_put(child);
				return -EINVAL;
			}
			match->of_node = of_node_get(child);
			count++;
			break;
		}
	}
开发者ID:Anjali05,项目名称:linux,代码行数:76,代码来源:of_regulator.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

/**
 * 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


示例9: 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


示例10: 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


示例11: 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


示例12: fw_add_devm_name

/* add firmware name into devres list */
static int fw_add_devm_name(struct device *dev, const char *name)
{
	struct fw_name_devm *fwn;

	fwn = fw_find_devm_name(dev, name);
	if (fwn)
		return 1;

	fwn = devres_alloc(fw_name_devm_release, sizeof(struct fw_name_devm) +
			   strlen(name) + 1, GFP_KERNEL);
	if (!fwn)
		return -ENOMEM;

	fwn->magic = (unsigned long)&fw_cache;
	strcpy(fwn->name, name);
	devres_add(dev, fwn);

	return 0;
}
开发者ID:03199618,项目名称:linux,代码行数:20,代码来源:firmware_class.c


示例13: 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


示例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: 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


示例16: 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


示例17: 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


示例18: 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


示例19: 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


示例20: 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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ devres_free函数代码示例发布时间:2022-05-30
下一篇:
C++ devopen函数代码示例发布时间: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