summaryrefslogtreecommitdiff
path: root/drivers/regulator/core.c
diff options
context:
space:
mode:
authorStephen Boyd <sboyd@codeaurora.org>2017-03-16 18:07:14 -0700
committerMark Brown <broonie@kernel.org>2017-03-17 13:12:22 +0000
commit0630b614391f8cbc35e837b4645ec8faaaa6465e (patch)
tree3d312fb1d2fb9f6d5470a22769d96d77b66f12b7 /drivers/regulator/core.c
parentb7cd1b1386ff46e60452ad1f16530645761ca7b8 (diff)
downloadlwn-0630b614391f8cbc35e837b4645ec8faaaa6465e.tar.gz
lwn-0630b614391f8cbc35e837b4645ec8faaaa6465e.zip
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>
Diffstat (limited to 'drivers/regulator/core.c')
-rw-r--r--drivers/regulator/core.c4
1 files changed, 2 insertions, 2 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,
/* non-fatal */
}
} else {
- regulator->supply_name = kstrdup(supply_name, GFP_KERNEL);
+ regulator->supply_name = kstrdup_const(supply_name, GFP_KERNEL);
if (regulator->supply_name == NULL)
goto overflow_err;
}
@@ -1799,7 +1799,7 @@ static void _regulator_put(struct regulator *regulator)
put_device(&rdev->dev);
mutex_unlock(&rdev->mutex);
- kfree(regulator->supply_name);
+ kfree_const(regulator->supply_name);
kfree(regulator);
module_put(rdev->owner);