drivers: base: opp: add allocate_opp_table() used by devres.c
authorLukasz Luba <l.luba@partner.samsung.com>
Wed, 23 Jan 2019 18:12:38 +0000 (19:12 +0100)
committerJunghoon Kim <jhoon20.kim@samsung.com>
Thu, 14 Feb 2019 05:58:20 +0000 (14:58 +0900)
The patch adds needed function for devres.c which implements
family of devm_* safe function. It is used for resource tracking
in case of deffer probe, when the driver probe function is called
a few times. The allocated OPP table must be freed and OPPs removed.

Change-Id: I9f098ea8a00bbef03ba680c4efe3b2fdf2e076d2
Signed-off-by: Lukasz Luba <l.luba@partner.samsung.com>
drivers/base/power/opp/core.c

index d5e7e8c..1879e7c 100644 (file)
@@ -765,6 +765,17 @@ static struct opp_table *_allocate_opp_table(struct device *dev)
        return opp_table;
 }
 
+struct opp_table *allocate_opp_table(struct device *dev)
+{
+       struct opp_table *opp_table;
+
+       mutex_lock(&opp_table_lock);
+       opp_table = _allocate_opp_table(dev);
+       mutex_unlock(&opp_table_lock);
+
+       return opp_table;
+}
+
 void _get_opp_table_kref(struct opp_table *opp_table)
 {
        kref_get(&opp_table->kref);