summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2016-07-05 02:20:48 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-07-04 13:02:56 -0400
commitc406563c02de0968dd1cd84eb1c4c0b25fbca447 (patch)
tree503d99051441122c0103025f8b54bef8150c0103
parenta2302565befa08bcac8f74333594947688acd9f4 (diff)
platform: tegra_prod: Add devm_tegra_prod_get_from_node()
Add managed version of the prod API devm_tegra_prod_get_from_node() so that client need not to explicitly clean the allocated resources. Change-Id: I9dbc7f16228dd8179ef123e55a0ff8be3753d447 Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Reviewed-on: http://git-master/r/1175452 Reviewed-on: https://git-master.nvidia.com/r/1768538 Tested-by: Nicolin Chen <nicolinc@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Sachin Nikam <snikam@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
-rw-r--r--drivers/platform/tegra/tegra_prod.c22
-rw-r--r--include/linux/tegra_prod.h18
2 files changed, 40 insertions, 0 deletions
diff --git a/drivers/platform/tegra/tegra_prod.c b/drivers/platform/tegra/tegra_prod.c
index 89246a6d6..269da5a47 100644
--- a/drivers/platform/tegra/tegra_prod.c
+++ b/drivers/platform/tegra/tegra_prod.c
@@ -557,3 +557,25 @@ struct tegra_prod *tegra_prod_get_from_node(struct device_node *np)
557 return tegra_prod_init(np); 557 return tegra_prod_init(np);
558} 558}
559EXPORT_SYMBOL(tegra_prod_get_from_node); 559EXPORT_SYMBOL(tegra_prod_get_from_node);
560
561struct tegra_prod *devm_tegra_prod_get_from_node(struct device *dev,
562 struct device_node *np)
563{
564 struct tegra_prod **ptr, *prod_list;
565
566 ptr = devres_alloc(devm_tegra_prod_release, sizeof(*ptr), GFP_KERNEL);
567 if (!ptr)
568 return ERR_PTR(-ENOMEM);
569
570 prod_list = tegra_prod_init(np);
571 if (IS_ERR(prod_list)) {
572 devres_free(ptr);
573 return prod_list;
574 }
575
576 *ptr = prod_list;
577 devres_add(dev, ptr);
578
579 return prod_list;
580}
581EXPORT_SYMBOL(devm_tegra_prod_get_from_node);
diff --git a/include/linux/tegra_prod.h b/include/linux/tegra_prod.h
index c79519c50..37e84022b 100644
--- a/include/linux/tegra_prod.h
+++ b/include/linux/tegra_prod.h
@@ -88,6 +88,24 @@ struct tegra_prod *devm_tegra_prod_get(struct device *dev);
88struct tegra_prod *tegra_prod_get_from_node(struct device_node *np); 88struct tegra_prod *tegra_prod_get_from_node(struct device_node *np);
89 89
90/** 90/**
91 * devm_tegra_prod_get_from_node(): Get the prod handle from the node.
92 * @dev: Device handle.
93 * @np: Node pointer on which prod setting nodes are available.
94 *
95 * Parse the prod-setting node of the node pointer "np" and keep all prod
96 * setting data in prod handle.
97 * This handle is used for setting prod configurations.
98 *
99 * Returns valid prod_list handle on success or pointer to the error
100 * when it failed.
101 * The allocated resource is released by driver core framework when device
102 * is unbinded and so no need to call any release APIs for the tegra_prod
103 * handle.
104 */
105struct tegra_prod *devm_tegra_prod_get_from_node(struct device *dev,
106 struct device_node *np);
107
108/**
91 * tegra_prod_put(): Put the allocated prod handle. 109 * tegra_prod_put(): Put the allocated prod handle.
92 * @tegra_prod: Tegra prod handle which was allocated by function 110 * @tegra_prod: Tegra prod handle which was allocated by function
93 * devm_tegra_prod_get() or tegra_prod_get_from_node(). 111 * devm_tegra_prod_get() or tegra_prod_get_from_node().