aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Boyd <sboyd@codeaurora.org>2017-03-16 21:07:14 -0400
committerMark Brown <broonie@kernel.org>2017-03-17 09:12:22 -0400
commit0630b614391f8cbc35e837b4645ec8faaaa6465e (patch)
tree3d312fb1d2fb9f6d5470a22769d96d77b66f12b7
parentb7cd1b1386ff46e60452ad1f16530645761ca7b8 (diff)
regulator: Mark supply_name const and duplicate it as such
The supply_name member of struct regulator can be const as we don't change it in the regulator core. Furthermore, when we copy the supply name we can use kstrdup_const() here to avoid a copy if the name is in the ro data section. Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/regulator/core.c4
-rw-r--r--drivers/regulator/internal.h2
2 files changed, 3 insertions, 3 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index f20ad0a8fc38..49a0b6a2e237 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1343,7 +1343,7 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
1343 /* non-fatal */ 1343 /* non-fatal */
1344 } 1344 }
1345 } else { 1345 } else {
1346 regulator->supply_name = kstrdup(supply_name, GFP_KERNEL); 1346 regulator->supply_name = kstrdup_const(supply_name, GFP_KERNEL);
1347 if (regulator->supply_name == NULL) 1347 if (regulator->supply_name == NULL)
1348 goto overflow_err; 1348 goto overflow_err;
1349 } 1349 }
@@ -1799,7 +1799,7 @@ static void _regulator_put(struct regulator *regulator)
1799 put_device(&rdev->dev); 1799 put_device(&rdev->dev);
1800 mutex_unlock(&rdev->mutex); 1800 mutex_unlock(&rdev->mutex);
1801 1801
1802 kfree(regulator->supply_name); 1802 kfree_const(regulator->supply_name);
1803 kfree(regulator); 1803 kfree(regulator);
1804 1804
1805 module_put(rdev->owner); 1805 module_put(rdev->owner);
diff --git a/drivers/regulator/internal.h b/drivers/regulator/internal.h
index 1dd575b28564..66a8ea0c8386 100644
--- a/drivers/regulator/internal.h
+++ b/drivers/regulator/internal.h
@@ -29,7 +29,7 @@ struct regulator {
29 int uA_load; 29 int uA_load;
30 int min_uV; 30 int min_uV;
31 int max_uV; 31 int max_uV;
32 char *supply_name; 32 const char *supply_name;
33 struct device_attribute dev_attr; 33 struct device_attribute dev_attr;
34 struct regulator_dev *rdev; 34 struct regulator_dev *rdev;
35 struct dentry *debugfs; 35 struct dentry *debugfs;