Commit 0630b614 authored by Stephen Boyd's avatar Stephen Boyd Committed by Mark Brown

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: default avatarStephen Boyd <sboyd@codeaurora.org>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent b7cd1b13
...@@ -1343,7 +1343,7 @@ static struct regulator *create_regulator(struct regulator_dev *rdev, ...@@ -1343,7 +1343,7 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
/* non-fatal */ /* non-fatal */
} }
} else { } else {
regulator->supply_name = kstrdup(supply_name, GFP_KERNEL); regulator->supply_name = kstrdup_const(supply_name, GFP_KERNEL);
if (regulator->supply_name == NULL) if (regulator->supply_name == NULL)
goto overflow_err; goto overflow_err;
} }
...@@ -1799,7 +1799,7 @@ static void _regulator_put(struct regulator *regulator) ...@@ -1799,7 +1799,7 @@ static void _regulator_put(struct regulator *regulator)
put_device(&rdev->dev); put_device(&rdev->dev);
mutex_unlock(&rdev->mutex); mutex_unlock(&rdev->mutex);
kfree(regulator->supply_name); kfree_const(regulator->supply_name);
kfree(regulator); kfree(regulator);
module_put(rdev->owner); module_put(rdev->owner);
......
...@@ -29,7 +29,7 @@ struct regulator { ...@@ -29,7 +29,7 @@ struct regulator {
int uA_load; int uA_load;
int min_uV; int min_uV;
int max_uV; int max_uV;
char *supply_name; const char *supply_name;
struct device_attribute dev_attr; struct device_attribute dev_attr;
struct regulator_dev *rdev; struct regulator_dev *rdev;
struct dentry *debugfs; struct dentry *debugfs;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment