Skip to contentSkip to conversation

regulator: mp5416: alphabetically sort header includes

PATCH In review Robert Marko 2 participants 5 messages Jun 4, 2022 – Jun 7, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 regulator: mp5416: alphabetically sort header includes

Sort the header include list alphabetically.

---
 drivers/regulator/mp5416.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/regulator/mp5416.c +3 -3
index 39cebec0edb6..d8245080df03 100644
@@ -6,14 +6,14 @@
 //
 // Author: Saravanan Sekar <[email protected]>
 
+#include <linux/err.h>
+#include <linux/i2c.h>
+#include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/init.h>
-#include <linux/err.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
 #include <linux/regulator/driver.h>
-#include <linux/i2c.h>
 
 #define MP5416_REG_CTL0			0x00
 #define MP5416_REG_CTL1			0x01
Signature · 1 line
2.36.1
#1 lore raw

PATCH 2/3 regulator: mp5416: use OF match data

In preparation for adding support for MP5496 which slightly differs from MP5416 convert the driver to use OF match data instead of always using the MP5416 regulator_desc for regulator registration.

---
 drivers/regulator/mp5416.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/regulator/mp5416.c +8 -2
index d8245080df03..011a825570ea 100644
@@ -11,6 +11,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
 #include <linux/regulator/driver.h>
@@ -178,6 +179,7 @@ static int mp5416_i2c_probe(struct i2c_client *client)
 {
 	struct device *dev = &client->dev;
 	struct regulator_config config = { NULL, };
+	static const struct regulator_desc *desc;
 	struct regulator_dev *rdev;
 	struct regmap *regmap;
 	int i;
@@ -188,12 +190,16 @@ static int mp5416_i2c_probe(struct i2c_client *client)
 		return PTR_ERR(regmap);
 	}
 
+	desc = of_device_get_match_data(dev);
+	if (!desc)
+		return -ENODEV;
+
 	config.dev = dev;
 	config.regmap = regmap;
 
 	for (i = 0; i < MP5416_MAX_REGULATORS; i++) {
 		rdev = devm_regulator_register(dev,
-					       &mp5416_regulators_desc[i],
+					       &desc[i],
 					       &config);
 		if (IS_ERR(rdev)) {
 			dev_err(dev, "Failed to register regulator!\n");
@@ -205,7 +211,7 @@ static int mp5416_i2c_probe(struct i2c_client *client)
 }
 
 static const struct of_device_id mp5416_of_match[] = {
-	{ .compatible = "mps,mp5416" },
+	{ .compatible = "mps,mp5416", .data = &mp5416_regulators_desc },
 	{},
 };
 MODULE_DEVICE_TABLE(of, mp5416_of_match);
Signature · 1 line
2.36.1
#2 lore raw

PATCH 3/3 regulator: mp5416: add support for MP5496

In reply to Robert Marko

MP5496 is the updated version of MP5416 with the only difference being that now all Buck regulators have the same 0.6-2.1875V range with a 12.5mV step.

---
 drivers/regulator/mp5416.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/regulator/mp5416.c +13 -0
index 011a825570ea..71e20e8d78ac 100644
@@ -175,6 +175,17 @@ static struct regulator_desc mp5416_regulators_desc[MP5416_MAX_REGULATORS] = {
 	MP5416LDO("ldo4", 4, BIT(1)),
 };
 
+static struct regulator_desc mp5496_regulators_desc[MP5416_MAX_REGULATORS] = {
+	MP5416BUCK("buck1", 1, mp5416_I_limits1, MP5416_REG_CTL1, BIT(0), 1),
+	MP5416BUCK("buck2", 2, mp5416_I_limits2, MP5416_REG_CTL1, BIT(1), 1),
+	MP5416BUCK("buck3", 3, mp5416_I_limits1, MP5416_REG_CTL1, BIT(2), 1),
+	MP5416BUCK("buck4", 4, mp5416_I_limits2, MP5416_REG_CTL2, BIT(5), 1),
+	MP5416LDO("ldo1", 1, BIT(4)),
+	MP5416LDO("ldo2", 2, BIT(3)),
+	MP5416LDO("ldo3", 3, BIT(2)),
+	MP5416LDO("ldo4", 4, BIT(1)),
+};
+
 static int mp5416_i2c_probe(struct i2c_client *client)
 {
 	struct device *dev = &client->dev;
@@ -212,12 +223,14 @@ static int mp5416_i2c_probe(struct i2c_client *client)
 
 static const struct of_device_id mp5416_of_match[] = {
 	{ .compatible = "mps,mp5416", .data = &mp5416_regulators_desc },
+	{ .compatible = "mps,mp5496", .data = &mp5496_regulators_desc },
 	{},
 };
 MODULE_DEVICE_TABLE(of, mp5416_of_match);
 
 static const struct i2c_device_id mp5416_id[] = {
 	{ "mp5416", },
+	{ "mp5496", },
 	{ },
 };
 MODULE_DEVICE_TABLE(i2c, mp5416_id);
Signature · 1 line
2.36.1
#3 lore raw
In reply to Robert Marko

Le 04/06/2022 à 16:56, Robert Marko a écrit :

Quoted 12 lines

Sort the header include list alphabetically.

---
  drivers/regulator/mp5416.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
drivers/regulator/mp5416.c +0 -0
index 39cebec0edb6..d8245080df03 100644

drivers/regulator/mp5416.c line 12

Quoted 7 lines
drivers/regulator/mp5416.c +3 -0
@@ -6,14 +6,14 @@
  //
  // Author: Saravanan Sekar <[email protected]>
 
+#include <linux/err.h>
+#include <linux/i2c.h>
+#include <linux/init.h>
  #include <linux/kernel.h>

Nitpick: it seems that kernel.h is not needed here. (at least it compile without it).

CJ

Quoted 10 lines
drivers/regulator/mp5416.c +0 -3
  #include <linux/module.h>
-#include <linux/init.h>
-#include <linux/err.h>
  #include <linux/platform_device.h>
  #include <linux/regmap.h>
  #include <linux/regulator/driver.h>
-#include <linux/i2c.h>
 
  #define MP5416_REG_CTL0			0x00
  #define MP5416_REG_CTL1			0x01
#4 lore raw
Quoted 17 lines · Christophe JAILLET
Quoted 15 lines · Robert Marko

Sort the header include list alphabetically.

---
  drivers/regulator/mp5416.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
drivers/regulator/mp5416.c +0 -0
index 39cebec0edb6..d8245080df03 100644
@@ -6,14 +6,14 @@
  //
  // Author: Saravanan Sekar <[email protected]>
 
Quoted 7 lines

drivers/regulator/mp5416.c line 12

Quoted 4 lines
drivers/regulator/mp5416.c +3 -0
+#include <linux/err.h>
+#include <linux/i2c.h>
+#include <linux/init.h>
  #include <linux/kernel.h>

Nitpick: it seems that kernel.h is not needed here. (at least it compile without it).

Hi,

It also seems to work fine without it, will send a patch to remove it.

Regards,
Robert

Quoted 14 lines

CJ

Quoted 10 lines
drivers/regulator/mp5416.c +0 -3
  #include <linux/module.h>
-#include <linux/init.h>
-#include <linux/err.h>
  #include <linux/platform_device.h>
  #include <linux/regmap.h>
  #include <linux/regulator/driver.h>
-#include <linux/i2c.h>
 
  #define MP5416_REG_CTL0                     0x00
  #define MP5416_REG_CTL1                     0x01