Skip to contentSkip to conversation

regulator: core: Constify the regulator_desc passed in when registering

PATCH New Mark Brown 1 participant 3 messages Apr 4, 2012

Subsystems (2)
lore
Share & tools
lore
author
#1 lore raw

PATCH 2/3 regulator: wm8350: Constify regulator_desc

In reply to Mark Brown
---
 drivers/regulator/wm8350-regulator.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/regulator/wm8350-regulator.c +1 -1
index ab1e183..552b1ed 100644
@@ -1269,7 +1269,7 @@ static struct regulator_ops wm8350_isink_ops = {
 	.enable_time = wm8350_isink_enable_time,
 };
 
-static struct regulator_desc wm8350_reg[NUM_WM8350_REGULATORS] = {
+static const struct regulator_desc wm8350_reg[NUM_WM8350_REGULATORS] = {
 	{
 		.name = "DCDC1",
 		.id = WM8350_DCDC_1,
Signature · 1 line
1.7.9.1
author
#2 lore raw

PATCH 3/3 regulator: wm8994: Constify regulator_desc

In reply to Mark Brown
---
 drivers/regulator/wm8994-regulator.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/regulator/wm8994-regulator.c +1 -1
index 75ed402..8a4897a 100644
@@ -209,7 +209,7 @@ static struct regulator_ops wm8994_ldo2_ops = {
 	.set_voltage = wm8994_ldo2_set_voltage,
 };
 
-static struct regulator_desc wm8994_ldo_desc[] = {
+static const struct regulator_desc wm8994_ldo_desc[] = {
 	{
 		.name = "LDO1",
 		.id = 1,
Signature · 1 line
1.7.9.1

Mark Brown

author
#0 lore raw

PATCH 1/3 regulator: core: Constify the regulator_desc passed in when registering

Drivers should be able to declare their descriptors const and the framework shouldn't ever be modifying the desciptor. Make the parameter and the pointer in regulator_dev const to enforce this.

---
 drivers/regulator/core.c         |    3 ++-
 include/linux/regulator/driver.h |    5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/regulator/core.c +2 -1
index c056abd..c4b6267 100644
@@ -2829,7 +2829,8 @@ static void rdev_init_debugfs(struct regulator_dev *rdev)
  * Called by regulator drivers to register a regulator.
  * Returns 0 on success.
  */
-struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
+struct regulator_dev *
+regulator_register(const struct regulator_desc *regulator_desc,
 	struct device *dev, const struct regulator_init_data *init_data,
 	void *driver_data, struct device_node *of_node)
 {
include/linux/regulator/driver.h +3 -2
index fa8b55b..1dcdf00 100644
@@ -184,7 +184,7 @@ struct regulator_desc {
  * no other direct access).
  */
 struct regulator_dev {
-	struct regulator_desc *desc;
+	const struct regulator_desc *desc;
 	int exclusive;
 	u32 use_count;
 	u32 open_count;
@@ -210,7 +210,8 @@ struct regulator_dev {
 	struct dentry *debugfs;
 };
 
-struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
+struct regulator_dev *
+regulator_register(const struct regulator_desc *regulator_desc,
 	struct device *dev, const struct regulator_init_data *init_data,
 	void *driver_data, struct device_node *of_node);
 void regulator_unregister(struct regulator_dev *rdev);
Signature · 1 line
1.7.9.1