Skip to contentSkip to conversation

regulator: arizona-micsupp: Avoid potential memory leak reading init_data

PATCH In review Charles Keepax 3 participants 16 messages Mar 28, 2017 – Apr 6, 2017

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

PATCH v2 1/8 regulator: arizona-micsupp: Avoid potential memory leak reading init_data

The device argument passed to of_get_regulator_init_data is used to do some devres memory allocation. Currently the driver passes the MFD device pointer to this function, this could result in the init_data allocation being leaked if the regulator is unbound but the MFD isn't.

Correct this issue by correctly passing the local platform device.

---

New patch in the series since v1.

 drivers/regulator/arizona-micsupp.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/regulator/arizona-micsupp.c +5 -4
index 22bd714..5e38861 100644
@@ -199,7 +199,8 @@ static const struct regulator_init_data arizona_micsupp_ext_default = {
 	.num_consumer_supplies = 1,
 };
 
-static int arizona_micsupp_of_get_pdata(struct arizona *arizona,
+static int arizona_micsupp_of_get_pdata(struct device *dev,
+					struct arizona *arizona,
 					struct regulator_config *config,
 					const struct regulator_desc *desc)
 {
@@ -213,7 +214,7 @@ static int arizona_micsupp_of_get_pdata(struct arizona *arizona,
 	if (np) {
 		config->of_node = np;
 
-		init_data = of_get_regulator_init_data(arizona->dev, np, desc);
+		init_data = of_get_regulator_init_data(dev, np, desc);
 
 		if (init_data) {
 			init_data->consumer_supplies = &micsupp->supply;
@@ -268,8 +269,8 @@ static int arizona_micsupp_probe(struct platform_device *pdev)
 
 	if (IS_ENABLED(CONFIG_OF)) {
 		if (!dev_get_platdata(arizona->dev)) {
-			ret = arizona_micsupp_of_get_pdata(arizona, &config,
-							   desc);
+			ret = arizona_micsupp_of_get_pdata(&pdev->dev, arizona,
+							   &config, desc);
 			if (ret < 0)
 				return ret;
 		}
Signature · 1 line
2.1.4
#1 lore raw

PATCH v2 2/8 regulator: arizona-ldo1: Avoid potential memory leak reading init_data

The device argument passed to of_get_regulator_init_data is used to do some devres memory allocation. Currently the driver passes the MFD device pointer to this function, this could result in the init_data allocation being leaked if the regulator is unbound but the MFD isn't.

Correct this issue by correctly passing the local platform device.

---

New patch in the series since v1.

 drivers/regulator/arizona-ldo1.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/regulator/arizona-ldo1.c +5 -4
index e76d094..b726fa1 100644
@@ -186,7 +186,8 @@ static const struct regulator_init_data arizona_ldo1_wm5110 = {
 	.num_consumer_supplies = 1,
 };
 
-static int arizona_ldo1_of_get_pdata(struct arizona *arizona,
+static int arizona_ldo1_of_get_pdata(struct device *dev,
+				     struct arizona *arizona,
 				     struct regulator_config *config,
 				     const struct regulator_desc *desc)
 {
@@ -212,8 +213,7 @@ static int arizona_ldo1_of_get_pdata(struct arizona *arizona,
 	if (init_node) {
 		config->of_node = init_node;
 
-		init_data = of_get_regulator_init_data(arizona->dev, init_node,
-						       desc);
+		init_data = of_get_regulator_init_data(dev, init_node, desc);
 
 		if (init_data) {
 			init_data->consumer_supplies = &ldo1->supply;
@@ -283,7 +283,8 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
 
 	if (IS_ENABLED(CONFIG_OF)) {
 		if (!dev_get_platdata(arizona->dev)) {
-			ret = arizona_ldo1_of_get_pdata(arizona, &config, desc);
+			ret = arizona_ldo1_of_get_pdata(&pdev->dev, arizona,
+							&config, desc);
 			if (ret < 0)
 				return ret;
 		}
Signature · 1 line
2.1.4
maintainer
#2 lore raw

Applied "regulator: arizona-ldo1: Avoid potential memory leak reading init_data" to the regulator tree

The patch

regulator: arizona-ldo1: Avoid potential memory leak reading init_data

has been applied to the regulator tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From 0feb837a42c95fee901e03f76a1266db85ceb6ec Mon Sep 17 00:00:00 2001

From: Charles Keepax <[email protected]>
Date: Tue, 28 Mar 2017 15:14:38 +0100
Subject: [PATCH] regulator: arizona-ldo1: Avoid potential memory leak reading
init_data

The device argument passed to of_get_regulator_init_data is used to do some devres memory allocation. Currently the driver passes the MFD device pointer to this function, this could result in the init_data allocation being leaked if the regulator is unbound but the MFD isn't.

Correct this issue by correctly passing the local platform device.

---
 drivers/regulator/arizona-ldo1.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/regulator/arizona-ldo1.c +5 -4
index 302b57cb89c6..cf558168664d 100644
@@ -186,7 +186,8 @@ static const struct regulator_init_data arizona_ldo1_wm5110 = {
 	.num_consumer_supplies = 1,
 };
 
-static int arizona_ldo1_of_get_pdata(struct arizona *arizona,
+static int arizona_ldo1_of_get_pdata(struct device *dev,
+				     struct arizona *arizona,
 				     struct regulator_config *config,
 				     const struct regulator_desc *desc)
 {
@@ -212,8 +213,7 @@ static int arizona_ldo1_of_get_pdata(struct arizona *arizona,
 	if (init_node) {
 		config->of_node = init_node;
 
-		init_data = of_get_regulator_init_data(arizona->dev, init_node,
-						       desc);
+		init_data = of_get_regulator_init_data(dev, init_node, desc);
 
 		if (init_data) {
 			init_data->consumer_supplies = &ldo1->supply;
@@ -283,7 +283,8 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
 
 	if (IS_ENABLED(CONFIG_OF)) {
 		if (!dev_get_platdata(arizona->dev)) {
-			ret = arizona_ldo1_of_get_pdata(arizona, &config, desc);
+			ret = arizona_ldo1_of_get_pdata(&pdev->dev, arizona,
+							&config, desc);
 			if (ret < 0)
 				return ret;
 		}
Signature · 1 line
2.11.0
#3 lore raw

PATCH v2 3/8 MAINTAINERS: Add missing regulator regex for Wolfson Arizona parts

In reply to Charles Keepax

The maintainers entry for the Wolfson parts seems to be missing an entry that covers the Arizona regulator drivers, correct this by adding one.

---

New patch in the series since v1.

 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index c265a5f..c35e0ce 100644
@@ -13616,6 +13616,7 @@ F:	drivers/mfd/cs47l24*
 F:	drivers/power/supply/wm83*.c
 F:	drivers/rtc/rtc-wm83*.c
 F:	drivers/regulator/wm8*.c
+F:	drivers/regulator/arizona*
 F:	drivers/video/backlight/wm83*_bl.c
 F:	drivers/watchdog/wm83*_wdt.c
 F:	include/linux/mfd/arizona/
Signature · 1 line
2.1.4
maintainer
#4 lore raw

Applied "MAINTAINERS: Add missing regulator regex for Wolfson Arizona parts" to the regulator tree

The patch

MAINTAINERS: Add missing regulator regex for Wolfson Arizona parts

has been applied to the regulator tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From cdf4275e957c6bad3756e98942341667f1d7de7d Mon Sep 17 00:00:00 2001

From: Charles Keepax <ckeepax-yzvPICuk2AATkU/[email protected]>
Date: Tue, 28 Mar 2017 15:14:39 +0100
Subject: [PATCH] MAINTAINERS: Add missing regulator regex for Wolfson Arizona
parts

The maintainers entry for the Wolfson parts seems to be missing an entry that covers the Arizona regulator drivers, correct this by adding one.

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index 9bf5aa617cf2..ef0c801aff45 100644
@@ -13119,6 +13119,7 @@ F:	drivers/mfd/cs47l24*
 F:	drivers/power/supply/wm83*.c
 F:	drivers/rtc/rtc-wm83*.c
 F:	drivers/regulator/wm8*.c
+F:	drivers/regulator/arizona*
 F:	drivers/video/backlight/wm83*_bl.c
 F:	drivers/watchdog/wm83*_wdt.c
 F:	include/linux/mfd/arizona/
Signature · 6 lines
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw

PATCH v2 4/8 regulator: helpers: Add regmap set_soft_start helper

In reply to Charles Keepax

Add a helper function regulator_set_soft_start_regmap to allow regmap based regulators to easily enable soft start.

---

Changes since v1:
- Added documentation for the new regulator_desc fields to the kernel doc.

 drivers/regulator/helpers.c      | 18 ++++++++++++++++++
 include/linux/regulator/driver.h |  8 ++++++++
 2 files changed, 26 insertions(+)
drivers/regulator/helpers.c +18 -0
index 379cdac..a75e7da 100644
@@ -446,6 +446,24 @@ int regulator_set_bypass_regmap(struct regulator_dev *rdev, bool enable)
 EXPORT_SYMBOL_GPL(regulator_set_bypass_regmap);
 
 /**
+ * regulator_set_soft_start_regmap - Default set_soft_start() using regmap
+ *
+ * @rdev: device to operate on.
+ */
+int regulator_set_soft_start_regmap(struct regulator_dev *rdev)
+{
+	unsigned int val;
+
+	val = rdev->desc->soft_start_val_on;
+	if (!val)
+		val = rdev->desc->soft_start_mask;
+
+	return regmap_update_bits(rdev->regmap, rdev->desc->soft_start_reg,
+				  rdev->desc->soft_start_mask, val);
+}
+EXPORT_SYMBOL_GPL(regulator_set_soft_start_regmap);
+
+/**
  * regulator_get_bypass_regmap - Default get_bypass() using regmap
  *
  * @rdev: device to operate on.
include/linux/regulator/driver.h +8 -0
index dac8e7b1..1054c03 100644
@@ -292,6 +292,10 @@ enum regulator_type {
  *			   set_active_discharge
  * @active_discharge_reg: Register for control when using regmap
  *			  set_active_discharge
+ * @soft_start_reg: Register for control when using regmap set_soft_start
+ * @soft_start_mask: Mask for control when using regmap set_soft_start
+ * @soft_start_val_on: Enabling value for control when using regmap
+ *                     set_soft_start
  *
  * @enable_time: Time taken for initial enable of regulator (in uS).
  * @off_on_delay: guard time (in uS), before re-enabling a regulator
@@ -345,6 +349,9 @@ struct regulator_desc {
 	unsigned int active_discharge_off;
 	unsigned int active_discharge_mask;
 	unsigned int active_discharge_reg;
+	unsigned int soft_start_reg;
+	unsigned int soft_start_mask;
+	unsigned int soft_start_val_on;
 
 	unsigned int enable_time;
 
@@ -476,6 +483,7 @@ int regulator_set_voltage_time_sel(struct regulator_dev *rdev,
 				   unsigned int new_selector);
 int regulator_set_bypass_regmap(struct regulator_dev *rdev, bool enable);
 int regulator_get_bypass_regmap(struct regulator_dev *rdev, bool *enable);
+int regulator_set_soft_start_regmap(struct regulator_dev *rdev);
 
 int regulator_set_active_discharge_regmap(struct regulator_dev *rdev,
 					  bool enable);
Signature · 1 line
2.1.4
maintainer
#6 lore raw

Applied "regulator: helpers: Add regmap set_soft_start helper" to the regulator tree

The patch

regulator: helpers: Add regmap set_soft_start helper

has been applied to the regulator tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From a7a453f56a1a116027f84ac53b365eb045a0e279 Mon Sep 17 00:00:00 2001

From: Charles Keepax <ckeepax-yzvPICuk2AATkU/[email protected]>
Date: Tue, 28 Mar 2017 15:14:40 +0100
Subject: [PATCH] regulator: helpers: Add regmap set_soft_start helper

Add a helper function regulator_set_soft_start_regmap to allow regmap based regulators to easily enable soft start.

---
 drivers/regulator/helpers.c      | 18 ++++++++++++++++++
 include/linux/regulator/driver.h |  8 ++++++++
 2 files changed, 26 insertions(+)
drivers/regulator/helpers.c +18 -0
index 379cdacc05d8..a75e7da49af8 100644
@@ -446,6 +446,24 @@ int regulator_set_bypass_regmap(struct regulator_dev *rdev, bool enable)
 EXPORT_SYMBOL_GPL(regulator_set_bypass_regmap);
 
 /**
+ * regulator_set_soft_start_regmap - Default set_soft_start() using regmap
+ *
+ * @rdev: device to operate on.
+ */
+int regulator_set_soft_start_regmap(struct regulator_dev *rdev)
+{
+	unsigned int val;
+
+	val = rdev->desc->soft_start_val_on;
+	if (!val)
+		val = rdev->desc->soft_start_mask;
+
+	return regmap_update_bits(rdev->regmap, rdev->desc->soft_start_reg,
+				  rdev->desc->soft_start_mask, val);
+}
+EXPORT_SYMBOL_GPL(regulator_set_soft_start_regmap);
+
+/**
  * regulator_get_bypass_regmap - Default get_bypass() using regmap
  *
  * @rdev: device to operate on.
include/linux/regulator/driver.h +8 -0
index dac8e7b16bc6..1054c033e783 100644
@@ -292,6 +292,10 @@ enum regulator_type {
  *			   set_active_discharge
  * @active_discharge_reg: Register for control when using regmap
  *			  set_active_discharge
+ * @soft_start_reg: Register for control when using regmap set_soft_start
+ * @soft_start_mask: Mask for control when using regmap set_soft_start
+ * @soft_start_val_on: Enabling value for control when using regmap
+ *                     set_soft_start
  *
  * @enable_time: Time taken for initial enable of regulator (in uS).
  * @off_on_delay: guard time (in uS), before re-enabling a regulator
@@ -345,6 +349,9 @@ struct regulator_desc {
 	unsigned int active_discharge_off;
 	unsigned int active_discharge_mask;
 	unsigned int active_discharge_reg;
+	unsigned int soft_start_reg;
+	unsigned int soft_start_mask;
+	unsigned int soft_start_val_on;
 
 	unsigned int enable_time;
 
@@ -476,6 +483,7 @@ int regulator_set_voltage_time_sel(struct regulator_dev *rdev,
 				   unsigned int new_selector);
 int regulator_set_bypass_regmap(struct regulator_dev *rdev, bool enable);
 int regulator_get_bypass_regmap(struct regulator_dev *rdev, bool *enable);
+int regulator_set_soft_start_regmap(struct regulator_dev *rdev);
 
 int regulator_set_active_discharge_regmap(struct regulator_dev *rdev,
 					  bool enable);
Signature · 6 lines
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#7 lore raw

PATCH v2 5/8 regulator: helpers: Add regmap set_pull_down helper

In reply to Charles Keepax

Add a helper function regulator_set_pull_down_regmap to allow regmap based regulators to easily enable pull down.

---

Turns out I don't actually need this patch for the series, but since I had gone to the effort of writing the code anyway, thought I might as well keep it in. Will be useful if someone does want to use a pull down on a regmap regulators and it is has been pretty well tested here.

Changes since v1:
- Added documentation for the new regulator_desc fields to the kernel doc.

 drivers/regulator/helpers.c      | 18 ++++++++++++++++++
 include/linux/regulator/driver.h |  8 ++++++++
 2 files changed, 26 insertions(+)
drivers/regulator/helpers.c +18 -0
index a75e7da..2ae7c3a 100644
@@ -464,6 +464,24 @@ int regulator_set_soft_start_regmap(struct regulator_dev *rdev)
 EXPORT_SYMBOL_GPL(regulator_set_soft_start_regmap);
 
 /**
+ * regulator_set_pull_down_regmap - Default set_pull_down() using regmap
+ *
+ * @rdev: device to operate on.
+ */
+int regulator_set_pull_down_regmap(struct regulator_dev *rdev)
+{
+	unsigned int val;
+
+	val = rdev->desc->pull_down_val_on;
+	if (!val)
+		val = rdev->desc->pull_down_mask;
+
+	return regmap_update_bits(rdev->regmap, rdev->desc->pull_down_reg,
+				  rdev->desc->pull_down_mask, val);
+}
+EXPORT_SYMBOL_GPL(regulator_set_pull_down_regmap);
+
+/**
  * regulator_get_bypass_regmap - Default get_bypass() using regmap
  *
  * @rdev: device to operate on.
include/linux/regulator/driver.h +8 -0
index 1054c03..8a9078d 100644
@@ -296,6 +296,10 @@ enum regulator_type {
  * @soft_start_mask: Mask for control when using regmap set_soft_start
  * @soft_start_val_on: Enabling value for control when using regmap
  *                     set_soft_start
+ * @pull_down_reg: Register for control when using regmap set_pull_down
+ * @pull_down_mask: Mask for control when using regmap set_pull_down
+ * @pull_down_val_on: Enabling value for control when using regmap
+ *                     set_pull_down
  *
  * @enable_time: Time taken for initial enable of regulator (in uS).
  * @off_on_delay: guard time (in uS), before re-enabling a regulator
@@ -352,6 +356,9 @@ struct regulator_desc {
 	unsigned int soft_start_reg;
 	unsigned int soft_start_mask;
 	unsigned int soft_start_val_on;
+	unsigned int pull_down_reg;
+	unsigned int pull_down_mask;
+	unsigned int pull_down_val_on;
 
 	unsigned int enable_time;
 
@@ -484,6 +491,7 @@ int regulator_set_voltage_time_sel(struct regulator_dev *rdev,
 int regulator_set_bypass_regmap(struct regulator_dev *rdev, bool enable);
 int regulator_get_bypass_regmap(struct regulator_dev *rdev, bool *enable);
 int regulator_set_soft_start_regmap(struct regulator_dev *rdev);
+int regulator_set_pull_down_regmap(struct regulator_dev *rdev);
 
 int regulator_set_active_discharge_regmap(struct regulator_dev *rdev,
 					  bool enable);
Signature · 1 line
2.1.4
maintainer
#8 lore raw

Applied "regulator: helpers: Add regmap set_pull_down helper" to the regulator tree

The patch

regulator: helpers: Add regmap set_pull_down helper

has been applied to the regulator tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From f7d37bc3cb20828ac43b22cbd40222877ee2c46a Mon Sep 17 00:00:00 2001

From: Charles Keepax <ckeepax-yzvPICuk2AATkU/[email protected]>
Date: Tue, 28 Mar 2017 15:14:41 +0100
Subject: [PATCH] regulator: helpers: Add regmap set_pull_down helper

Add a helper function regulator_set_pull_down_regmap to allow regmap based regulators to easily enable pull down.

---
 drivers/regulator/helpers.c      | 18 ++++++++++++++++++
 include/linux/regulator/driver.h |  8 ++++++++
 2 files changed, 26 insertions(+)
drivers/regulator/helpers.c +18 -0
index a75e7da49af8..2ae7c3ac5940 100644
@@ -464,6 +464,24 @@ int regulator_set_soft_start_regmap(struct regulator_dev *rdev)
 EXPORT_SYMBOL_GPL(regulator_set_soft_start_regmap);
 
 /**
+ * regulator_set_pull_down_regmap - Default set_pull_down() using regmap
+ *
+ * @rdev: device to operate on.
+ */
+int regulator_set_pull_down_regmap(struct regulator_dev *rdev)
+{
+	unsigned int val;
+
+	val = rdev->desc->pull_down_val_on;
+	if (!val)
+		val = rdev->desc->pull_down_mask;
+
+	return regmap_update_bits(rdev->regmap, rdev->desc->pull_down_reg,
+				  rdev->desc->pull_down_mask, val);
+}
+EXPORT_SYMBOL_GPL(regulator_set_pull_down_regmap);
+
+/**
  * regulator_get_bypass_regmap - Default get_bypass() using regmap
  *
  * @rdev: device to operate on.
include/linux/regulator/driver.h +8 -0
index 1054c033e783..8a9078dd2a5f 100644
@@ -296,6 +296,10 @@ enum regulator_type {
  * @soft_start_mask: Mask for control when using regmap set_soft_start
  * @soft_start_val_on: Enabling value for control when using regmap
  *                     set_soft_start
+ * @pull_down_reg: Register for control when using regmap set_pull_down
+ * @pull_down_mask: Mask for control when using regmap set_pull_down
+ * @pull_down_val_on: Enabling value for control when using regmap
+ *                     set_pull_down
  *
  * @enable_time: Time taken for initial enable of regulator (in uS).
  * @off_on_delay: guard time (in uS), before re-enabling a regulator
@@ -352,6 +356,9 @@ struct regulator_desc {
 	unsigned int soft_start_reg;
 	unsigned int soft_start_mask;
 	unsigned int soft_start_val_on;
+	unsigned int pull_down_reg;
+	unsigned int pull_down_mask;
+	unsigned int pull_down_val_on;
 
 	unsigned int enable_time;
 
@@ -484,6 +491,7 @@ int regulator_set_voltage_time_sel(struct regulator_dev *rdev,
 int regulator_set_bypass_regmap(struct regulator_dev *rdev, bool enable);
 int regulator_get_bypass_regmap(struct regulator_dev *rdev, bool *enable);
 int regulator_set_soft_start_regmap(struct regulator_dev *rdev);
+int regulator_set_pull_down_regmap(struct regulator_dev *rdev);
 
 int regulator_set_active_discharge_regmap(struct regulator_dev *rdev,
 					  bool enable);
Signature · 6 lines
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#9 lore raw

PATCH v2 6/8 regulator: arizona-micbias: Add regulator driver for Arizona micbiases

In reply to Charles Keepax

Add a driver for controlling the micbias regulators on the Arizona class audio CODECs. This will replace earlier fixed support that initialised the micbias's with fixed settings from platform data, although that platform data can still be used to configure the constraints on this new regulator.

---

Changes since v1:
- Use active_discharge rather than pull_down as that is what the regulator actually does.
- Pass the micbias device rather than the arizona device to of_get_regulator_init_data to avoid leaking init_data
- Update the pdata to use an actual regulator_init_data
- Tidy up the code to make it a little easier to follow

 drivers/regulator/Makefile          |   2 +-
 drivers/regulator/arizona-micbias.c | 228 ++++++++++++++++++++++++++++++++++++
 include/linux/mfd/arizona/pdata.h   |   6 +-
 3 files changed, 231 insertions(+), 5 deletions(-)
 create mode 100644 drivers/regulator/arizona-micbias.c
drivers/regulator/Makefile +1 -1
index ef7725e..b670e87 100644
@@ -19,7 +19,7 @@ obj-$(CONFIG_REGULATOR_ACT8865) += act8865-regulator.o
 obj-$(CONFIG_REGULATOR_ACT8945A) += act8945a-regulator.o
 obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o
 obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o
-obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o
+obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o arizona-micbias.o
 obj-$(CONFIG_REGULATOR_AS3711) += as3711-regulator.o
 obj-$(CONFIG_REGULATOR_AS3722) += as3722-regulator.o
 obj-$(CONFIG_REGULATOR_AXP20X) += axp20x-regulator.o
drivers/regulator/arizona-micbias.c new file +228 -0

228 lines not on this page · raw message

include/linux/mfd/arizona/pdata.h +2 -4
index 64faeef..89a3512 100644
@@ -56,11 +56,9 @@
 struct regulator_init_data;
 
 struct arizona_micbias {
-	int mV;                    /** Regulated voltage */
+	/* Regulator configuration */
+	const struct regulator_init_data *init_data;
 	unsigned int ext_cap:1;    /** External capacitor fitted */
-	unsigned int discharge:1;  /** Actively discharge */
-	unsigned int soft_start:1; /** Disable aggressive startup ramp rate */
-	unsigned int bypass:1;     /** Use bypass mode */
 };
 
 struct arizona_micd_config {
Signature · 1 line
2.1.4
#10 lore raw

Re: [alsa-devel] [PATCH v2 6/8] regulator: arizona-micbias: Add regulator driver for Arizona micbiases

reproduce:

Hi Charles,

[auto build test WARNING on regulator/for-next]
[also build test WARNING on v4.11-rc4 next-20170328]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Charles-Keepax/regulator-arizona-micsupp-Avoid-potential-memory-leak-reading-init_data/20170329-112224
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
config: i386-randconfig-x0-03291136 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

In file included from include/linux/err.h:4:0,
from include/linux/clk.h:15,
from drivers//mfd/arizona-core.c:13:
drivers//mfd/arizona-core.c: In function 'arizona_dev_init':
drivers//mfd/arizona-core.c:1408:33: error: 'struct arizona_micbias' has no member named 'mV'

      if (!arizona->pdata.micbias[i].mV &&
                                    ^
   include/linux/compiler.h:160:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
>> drivers//mfd/arizona-core.c:1408:3: note: in expansion of macro 'if'
      if (!arizona->pdata.micbias[i].mV &&
      ^~
   drivers//mfd/arizona-core.c:1409:33: error: 'struct arizona_micbias' has no member named 'bypass'
          !arizona->pdata.micbias[i].bypass)
                                    ^
   include/linux/compiler.h:160:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
>> drivers//mfd/arizona-core.c:1408:3: note: in expansion of macro 'if'
      if (!arizona->pdata.micbias[i].mV &&
      ^~
   drivers//mfd/arizona-core.c:1408:33: error: 'struct arizona_micbias' has no member named 'mV'
      if (!arizona->pdata.micbias[i].mV &&
                                    ^
   include/linux/compiler.h:160:42: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                             ^~~~
>> drivers//mfd/arizona-core.c:1408:3: note: in expansion of macro 'if'
      if (!arizona->pdata.micbias[i].mV &&
      ^~
   drivers//mfd/arizona-core.c:1409:33: error: 'struct arizona_micbias' has no member named 'bypass'
          !arizona->pdata.micbias[i].bypass)
                                    ^
   include/linux/compiler.h:160:42: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                             ^~~~
>> drivers//mfd/arizona-core.c:1408:3: note: in expansion of macro 'if'
      if (!arizona->pdata.micbias[i].mV &&
      ^~
   drivers//mfd/arizona-core.c:1408:33: error: 'struct arizona_micbias' has no member named 'mV'
      if (!arizona->pdata.micbias[i].mV &&
                                    ^
   include/linux/compiler.h:171:16: note: in definition of macro '__trace_if'
      ______r = !!(cond);     \
                   ^~~~
>> drivers//mfd/arizona-core.c:1408:3: note: in expansion of macro 'if'
      if (!arizona->pdata.micbias[i].mV &&
      ^~
   drivers//mfd/arizona-core.c:1409:33: error: 'struct arizona_micbias' has no member named 'bypass'
          !arizona->pdata.micbias[i].bypass)
                                    ^
   include/linux/compiler.h:171:16: note: in definition of macro '__trace_if'
      ______r = !!(cond);     \
                   ^~~~
>> drivers//mfd/arizona-core.c:1408:3: note: in expansion of macro 'if'
      if (!arizona->pdata.micbias[i].mV &&
      ^~
   drivers//mfd/arizona-core.c:1413:33: error: 'struct arizona_micbias' has no member named 'mV'
      if (!arizona->pdata.micbias[i].mV)
                                    ^
   include/linux/compiler.h:160:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
   drivers//mfd/arizona-core.c:1413:3: note: in expansion of macro 'if'
      if (!arizona->pdata.micbias[i].mV)
      ^~
   drivers//mfd/arizona-core.c:1413:33: error: 'struct arizona_micbias' has no member named 'mV'
      if (!arizona->pdata.micbias[i].mV)
                                    ^
   include/linux/compiler.h:160:42: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                             ^~~~
   drivers//mfd/arizona-core.c:1413:3: note: in expansion of macro 'if'
      if (!arizona->pdata.micbias[i].mV)
      ^~
   drivers//mfd/arizona-core.c:1413:33: error: 'struct arizona_micbias' has no member named 'mV'
      if (!arizona->pdata.micbias[i].mV)
                                    ^
   include/linux/compiler.h:171:16: note: in definition of macro '__trace_if'
      ______r = !!(cond);     \
                   ^~~~
   drivers//mfd/arizona-core.c:1413:3: note: in expansion of macro 'if'
      if (!arizona->pdata.micbias[i].mV)
      ^~
   drivers//mfd/arizona-core.c:1414:29: error: 'struct arizona_micbias' has no member named 'mV'
       arizona->pdata.micbias[i].mV = 2800;
                                ^
   drivers//mfd/arizona-core.c:1416:35: error: 'struct arizona_micbias' has no member named 'mV'
      val = (arizona->pdata.micbias[i].mV - 1500) / 100;
                                      ^
   In file included from include/linux/err.h:4:0,
                    from include/linux/clk.h:15,
                    from drivers//mfd/arizona-core.c:13:
   drivers//mfd/arizona-core.c:1423:32: error: 'struct arizona_micbias' has no member named 'discharge'
      if (arizona->pdata.micbias[i].discharge)
                                   ^
   include/linux/compiler.h:160:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
   drivers//mfd/arizona-core.c:1423:3: note: in expansion of macro 'if'
      if (arizona->pdata.micbias[i].discharge)
      ^~
   drivers//mfd/arizona-core.c:1423:32: error: 'struct arizona_micbias' has no member named 'discharge'
      if (arizona->pdata.micbias[i].discharge)
                                   ^
   include/linux/compiler.h:160:42: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                             ^~~~
   drivers//mfd/arizona-core.c:1423:3: note: in expansion of macro 'if'
      if (arizona->pdata.micbias[i].discharge)
      ^~
   drivers//mfd/arizona-core.c:1423:32: error: 'struct arizona_micbias' has no member named 'discharge'
      if (arizona->pdata.micbias[i].discharge)
                                   ^
   include/linux/compiler.h:171:16: note: in definition of macro '__trace_if'
      ______r = !!(cond);     \
                   ^~~~
   drivers//mfd/arizona-core.c:1423:3: note: in expansion of macro 'if'
      if (arizona->pdata.micbias[i].discharge)
      ^~
   drivers//mfd/arizona-core.c:1426:32: error: 'struct arizona_micbias' has no member named 'soft_start'
      if (arizona->pdata.micbias[i].soft_start)
                                   ^
   include/linux/compiler.h:160:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
   drivers//mfd/arizona-core.c:1426:3: note: in expansion of macro 'if'
      if (arizona->pdata.micbias[i].soft_start)
      ^~
   drivers//mfd/arizona-core.c:1426:32: error: 'struct arizona_micbias' has no member named 'soft_start'
      if (arizona->pdata.micbias[i].soft_start)
                                   ^
   include/linux/compiler.h:160:42: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                             ^~~~
   drivers//mfd/arizona-core.c:1426:3: note: in expansion of macro 'if'
      if (arizona->pdata.micbias[i].soft_start)
      ^~
   drivers//mfd/arizona-core.c:1426:32: error: 'struct arizona_micbias' has no member named 'soft_start'
      if (arizona->pdata.micbias[i].soft_start)
                                   ^
   include/linux/compiler.h:171:16: note: in definition of macro '__trace_if'
      ______r = !!(cond);     \
                   ^~~~
   drivers//mfd/arizona-core.c:1426:3: note: in expansion of macro 'if'
      if (arizona->pdata.micbias[i].soft_start)
      ^~
   drivers//mfd/arizona-core.c:1429:32: error: 'struct arizona_micbias' has no member named 'bypass'
      if (arizona->pdata.micbias[i].bypass)
                                   ^
   include/linux/compiler.h:160:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
   drivers//mfd/arizona-core.c:1429:3: note: in expansion of macro 'if'
      if (arizona->pdata.micbias[i].bypass)

vim +/if +1408 drivers//mfd/arizona-core.c

3cc72986 Mark Brown 2012-06-19  1392  				   ARIZONA_CLK_32K_SRC_MASK,
3cc72986 Mark Brown 2012-06-19  1393  				   arizona->pdata.clk32k_src - 1);
767c6dc0 Mark Brown 2013-03-19  1394  		arizona_clk32k_enable(arizona);
3cc72986 Mark Brown 2012-06-19  1395  		break;
3cc72986 Mark Brown 2012-06-19  1396  	case ARIZONA_32KZ_NONE:
3cc72986 Mark Brown 2012-06-19  1397  		regmap_update_bits(arizona->regmap, ARIZONA_CLOCK_32K_1,
3cc72986 Mark Brown 2012-06-19  1398  				   ARIZONA_CLK_32K_SRC_MASK, 2);
3cc72986 Mark Brown 2012-06-19  1399  		break;
3cc72986 Mark Brown 2012-06-19  1400  	default:
3cc72986 Mark Brown 2012-06-19  1401  		dev_err(arizona->dev, "Invalid 32kHz clock source: %d\n",
3cc72986 Mark Brown 2012-06-19  1402  			arizona->pdata.clk32k_src);
3cc72986 Mark Brown 2012-06-19  1403  		ret = -EINVAL;
59db9691 Mark Brown 2012-07-09  1404  		goto err_reset;
3cc72986 Mark Brown 2012-06-19  1405  	}
3cc72986 Mark Brown 2012-06-19  1406  
3d91f828 Mark Brown 2013-01-29  1407  	for (i = 0; i < ARIZONA_MAX_MICBIAS; i++) {
544c7aad Mark Brown 2013-01-29 @1408  		if (!arizona->pdata.micbias[i].mV &&
544c7aad Mark Brown 2013-01-29  1409  		    !arizona->pdata.micbias[i].bypass)
3d91f828 Mark Brown 2013-01-29  1410  			continue;
3d91f828 Mark Brown 2013-01-29  1411  
544c7aad Mark Brown 2013-01-29  1412  		/* Apply default for bypass mode */
544c7aad Mark Brown 2013-01-29  1413  		if (!arizona->pdata.micbias[i].mV)
544c7aad Mark Brown 2013-01-29  1414  			arizona->pdata.micbias[i].mV = 2800;
544c7aad Mark Brown 2013-01-29  1415  
3d91f828 Mark Brown 2013-01-29  1416  		val = (arizona->pdata.micbias[i].mV - 1500) / 100;

:::::: The code at line 1408 was first introduced by commit
:::::: 544c7aadd7d4309ed01fcd787d393db67eb7eaea mfd: arizona: Support configuring MICBIASes into bypass mode

:::::: TO: Mark Brown <broonie-yzvPICuk2AATkU/[email protected]> :::::: CC: Samuel Ortiz <sameo-VuQAYsv1563Yd54FQh9/[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#11 lore raw

Re: [alsa-devel] [PATCH v2 6/8] regulator: arizona-micbias: Add regulator driver for Arizona micbiases

Quoted 6 lines · kbuild test robot

Hi Charles,

[auto build test WARNING on regulator/for-next]
[also build test WARNING on v4.11-rc4 next-20170328]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

Quoted 8 lines
url:    https://github.com/0day-ci/linux/commits/Charles-Keepax/regulator-arizona-micsupp-Avoid-potential-memory-leak-reading-init_data/20170329-112224
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
config: i386-randconfig-x0-03291136 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

Hmm... this is due to the tree missing the patch that Lee already applied from version 1. I guess perhaps we should pull that back into this series or he could make an immutable branch you can pull in?

Thanks,
Charles

#12 lore raw

Re: [alsa-devel] [PATCH v2 6/8] regulator: arizona-micbias: Add regulator driver for Arizona micbiases

In reply to Charles Keepax
reproduce: wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross…

Hi Charles,

[auto build test ERROR on regulator/for-next]
[also build test ERROR on v4.11-rc4 next-20170328]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Charles-Keepax/regulator-arizona-micsupp-Avoid-potential-memory-leak-reading-init_data/20170329-112224
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 6.2.0

reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=ia64

All errors (new ones prefixed by >>):

drivers//mfd/arizona-core.c: In function 'arizona_dev_init':

>> drivers//mfd/arizona-core.c:1408:33: error: 'struct arizona_micbias' has no member named 'mV'
      if (!arizona->pdata.micbias[i].mV &&
                                    ^
>> drivers//mfd/arizona-core.c:1409:33: error: 'struct arizona_micbias' has no member named 'bypass'
          !arizona->pdata.micbias[i].bypass)
                                    ^
   drivers//mfd/arizona-core.c:1413:33: error: 'struct arizona_micbias' has no member named 'mV'
      if (!arizona->pdata.micbias[i].mV)
                                    ^
   drivers//mfd/arizona-core.c:1414:29: error: 'struct arizona_micbias' has no member named 'mV'
       arizona->pdata.micbias[i].mV = 2800;
                                ^
   drivers//mfd/arizona-core.c:1416:35: error: 'struct arizona_micbias' has no member named 'mV'
      val = (arizona->pdata.micbias[i].mV - 1500) / 100;
                                      ^
>> drivers//mfd/arizona-core.c:1423:32: error: 'struct arizona_micbias' has no member named 'discharge'
      if (arizona->pdata.micbias[i].discharge)
                                   ^
>> drivers//mfd/arizona-core.c:1426:32: error: 'struct arizona_micbias' has no member named 'soft_start'
      if (arizona->pdata.micbias[i].soft_start)
                                   ^
   drivers//mfd/arizona-core.c:1429:32: error: 'struct arizona_micbias' has no member named 'bypass'
      if (arizona->pdata.micbias[i].bypass)
                                   ^

vim +1408 drivers//mfd/arizona-core.c

3cc72986 Mark Brown     2012-06-19  1402  			arizona->pdata.clk32k_src);
3cc72986 Mark Brown     2012-06-19  1403  		ret = -EINVAL;
59db9691 Mark Brown     2012-07-09  1404  		goto err_reset;
3cc72986 Mark Brown     2012-06-19  1405  	}
3cc72986 Mark Brown     2012-06-19  1406  
3d91f828 Mark Brown     2013-01-29  1407  	for (i = 0; i < ARIZONA_MAX_MICBIAS; i++) {
544c7aad Mark Brown     2013-01-29 @1408  		if (!arizona->pdata.micbias[i].mV &&
544c7aad Mark Brown     2013-01-29 @1409  		    !arizona->pdata.micbias[i].bypass)
3d91f828 Mark Brown     2013-01-29  1410  			continue;
3d91f828 Mark Brown     2013-01-29  1411  
544c7aad Mark Brown     2013-01-29  1412  		/* Apply default for bypass mode */
544c7aad Mark Brown     2013-01-29 @1413  		if (!arizona->pdata.micbias[i].mV)
544c7aad Mark Brown     2013-01-29 @1414  			arizona->pdata.micbias[i].mV = 2800;
544c7aad Mark Brown     2013-01-29  1415  
3d91f828 Mark Brown     2013-01-29  1416  		val = (arizona->pdata.micbias[i].mV - 1500) / 100;
544c7aad Mark Brown     2013-01-29  1417  
3d91f828 Mark Brown     2013-01-29  1418  		val <<= ARIZONA_MICB1_LVL_SHIFT;
3d91f828 Mark Brown     2013-01-29  1419  
3d91f828 Mark Brown     2013-01-29  1420  		if (arizona->pdata.micbias[i].ext_cap)
3d91f828 Mark Brown     2013-01-29  1421  			val |= ARIZONA_MICB1_EXT_CAP;
3d91f828 Mark Brown     2013-01-29  1422  
3d91f828 Mark Brown     2013-01-29 @1423  		if (arizona->pdata.micbias[i].discharge)
3d91f828 Mark Brown     2013-01-29  1424  			val |= ARIZONA_MICB1_DISCH;
3d91f828 Mark Brown     2013-01-29  1425  
f773fc6d Charles Keepax 2013-05-21 @1426  		if (arizona->pdata.micbias[i].soft_start)
3d91f828 Mark Brown     2013-01-29  1427  			val |= ARIZONA_MICB1_RATE;
3d91f828 Mark Brown     2013-01-29  1428  
544c7aad Mark Brown     2013-01-29  1429  		if (arizona->pdata.micbias[i].bypass)

:::::: The code at line 1408 was first introduced by commit
:::::: 544c7aadd7d4309ed01fcd787d393db67eb7eaea mfd: arizona: Support configuring MICBIASes into bypass mode

:::::: TO: Mark Brown <broonie-yzvPICuk2AATkU/[email protected]> :::::: CC: Samuel Ortiz <sameo-VuQAYsv1563Yd54FQh9/[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#13 lore raw

PATCH v2 7/8 regulator: arizona-micbias: Add description of micbias binding

In reply to Charles Keepax

Add the new micbias regulators into the Arizona regulator binding document.

---

No changes since v1.

 Documentation/devicetree/bindings/regulator/arizona-regulator.txt | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/regulator/arizona-regulator.txt +6 -0
index 443564d..68a13d5 100644
@@ -15,3 +15,9 @@ Optional subnodes:
     Documentation/devicetree/bindings/regulator/regulator.txt
   - micvdd : Initial data for the MICVDD regulator, as covered in
     Documentation/devicetree/bindings/regulator/regulator.txt
+
+  - MICBIASx : Initial data for the MICBIAS regulators, as covered in
+    Documentation/devicetree/bindings/regulator/regulator.txt but the
+    following additional properties are also supported:
+      - wlf,ext-cap : Specifies if the MICBIAS has external decoupling
+        capacitors attached.
Signature · 1 line
2.1.4
#14 lore raw

PATCH v2 8/8 ASoC: arizona: Add support for new micbias regulators

In reply to Charles Keepax

Change the widgets from the old SND_SOC_DAPM_SUPPLY widgets into SND_SOC_DAPM_REGULATOR_SUPPLY widgets now that we have proper regulator support for the micbiases.

---

No changes since v1.

 sound/soc/codecs/cs47l24.c | 6 ++----
 sound/soc/codecs/wm5102.c  | 9 +++------
 sound/soc/codecs/wm5110.c  | 9 +++------
 sound/soc/codecs/wm8997.c  | 9 +++------
 sound/soc/codecs/wm8998.c  | 9 +++------
 5 files changed, 14 insertions(+), 28 deletions(-)
sound/soc/codecs/cs47l24.c +2 -4
index 47e6fdd..c5dc322 100644
@@ -386,10 +386,8 @@ SND_SOC_DAPM_PGA_E("IN2R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN2R_ENA_SHIFT,
 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
 		   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
 
-SND_SOC_DAPM_SUPPLY("MICBIAS1", ARIZONA_MIC_BIAS_CTRL_1,
-		    ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0),
-SND_SOC_DAPM_SUPPLY("MICBIAS2", ARIZONA_MIC_BIAS_CTRL_2,
-		    ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0),
+SND_SOC_DAPM_REGULATOR_SUPPLY("MICBIAS1", 0, SND_SOC_DAPM_REGULATOR_BYPASS),
+SND_SOC_DAPM_REGULATOR_SUPPLY("MICBIAS2", 0, SND_SOC_DAPM_REGULATOR_BYPASS),
 
 SND_SOC_DAPM_PGA("Noise Generator", ARIZONA_COMFORT_NOISE_GENERATOR,
 		 ARIZONA_NOISE_GEN_ENA_SHIFT, 0, NULL, 0),
sound/soc/codecs/wm5102.c +3 -6
index 1fe358e..2a817f8 100644
@@ -1137,12 +1137,9 @@ SND_SOC_DAPM_PGA_E("IN3R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN3R_ENA_SHIFT,
 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
 		   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
 
-SND_SOC_DAPM_SUPPLY("MICBIAS1", ARIZONA_MIC_BIAS_CTRL_1,
-		    ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0),
-SND_SOC_DAPM_SUPPLY("MICBIAS2", ARIZONA_MIC_BIAS_CTRL_2,
-		    ARIZONA_MICB2_ENA_SHIFT, 0, NULL, 0),
-SND_SOC_DAPM_SUPPLY("MICBIAS3", ARIZONA_MIC_BIAS_CTRL_3,
-		    ARIZONA_MICB3_ENA_SHIFT, 0, NULL, 0),
+SND_SOC_DAPM_REGULATOR_SUPPLY("MICBIAS1", 0, SND_SOC_DAPM_REGULATOR_BYPASS),
+SND_SOC_DAPM_REGULATOR_SUPPLY("MICBIAS2", 0, SND_SOC_DAPM_REGULATOR_BYPASS),
+SND_SOC_DAPM_REGULATOR_SUPPLY("MICBIAS3", 0, SND_SOC_DAPM_REGULATOR_BYPASS),
 
 SND_SOC_DAPM_PGA("Noise Generator", ARIZONA_COMFORT_NOISE_GENERATOR,
 		 ARIZONA_NOISE_GEN_ENA_SHIFT, 0, NULL, 0),
sound/soc/codecs/wm5110.c +3 -6
index 1bc9421..57f3b41 100644
@@ -1157,12 +1157,9 @@ SND_SOC_DAPM_PGA_E("IN4R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN4R_ENA_SHIFT,
 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
 		   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
 
-SND_SOC_DAPM_SUPPLY("MICBIAS1", ARIZONA_MIC_BIAS_CTRL_1,
-		    ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0),
-SND_SOC_DAPM_SUPPLY("MICBIAS2", ARIZONA_MIC_BIAS_CTRL_2,
-		    ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0),
-SND_SOC_DAPM_SUPPLY("MICBIAS3", ARIZONA_MIC_BIAS_CTRL_3,
-		    ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0),
+SND_SOC_DAPM_REGULATOR_SUPPLY("MICBIAS1", 0, SND_SOC_DAPM_REGULATOR_BYPASS),
+SND_SOC_DAPM_REGULATOR_SUPPLY("MICBIAS2", 0, SND_SOC_DAPM_REGULATOR_BYPASS),
+SND_SOC_DAPM_REGULATOR_SUPPLY("MICBIAS3", 0, SND_SOC_DAPM_REGULATOR_BYPASS),
 
 SND_SOC_DAPM_PGA("Noise Generator", ARIZONA_COMFORT_NOISE_GENERATOR,
 		 ARIZONA_NOISE_GEN_ENA_SHIFT, 0, NULL, 0),
sound/soc/codecs/wm8997.c +3 -6
index 49401a8..455d88a 100644
@@ -452,12 +452,9 @@ SND_SOC_DAPM_PGA_E("IN2R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN2R_ENA_SHIFT,
 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
 		   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
 
-SND_SOC_DAPM_SUPPLY("MICBIAS1", ARIZONA_MIC_BIAS_CTRL_1,
-		    ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0),
-SND_SOC_DAPM_SUPPLY("MICBIAS2", ARIZONA_MIC_BIAS_CTRL_2,
-		    ARIZONA_MICB2_ENA_SHIFT, 0, NULL, 0),
-SND_SOC_DAPM_SUPPLY("MICBIAS3", ARIZONA_MIC_BIAS_CTRL_3,
-		    ARIZONA_MICB3_ENA_SHIFT, 0, NULL, 0),
+SND_SOC_DAPM_REGULATOR_SUPPLY("MICBIAS1", 0, SND_SOC_DAPM_REGULATOR_BYPASS),
+SND_SOC_DAPM_REGULATOR_SUPPLY("MICBIAS2", 0, SND_SOC_DAPM_REGULATOR_BYPASS),
+SND_SOC_DAPM_REGULATOR_SUPPLY("MICBIAS3", 0, SND_SOC_DAPM_REGULATOR_BYPASS),
 
 SND_SOC_DAPM_PGA("Noise Generator", ARIZONA_COMFORT_NOISE_GENERATOR,
 		 ARIZONA_NOISE_GEN_ENA_SHIFT, 0, NULL, 0),
sound/soc/codecs/wm8998.c +3 -6
index 44f4471..a5e87ba 100644
@@ -587,12 +587,9 @@ SND_SOC_DAPM_PGA_E("IN2 PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN2L_ENA_SHIFT,
 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
 		   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
 
-SND_SOC_DAPM_SUPPLY("MICBIAS1", ARIZONA_MIC_BIAS_CTRL_1,
-		    ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0),
-SND_SOC_DAPM_SUPPLY("MICBIAS2", ARIZONA_MIC_BIAS_CTRL_2,
-		    ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0),
-SND_SOC_DAPM_SUPPLY("MICBIAS3", ARIZONA_MIC_BIAS_CTRL_3,
-		    ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0),
+SND_SOC_DAPM_REGULATOR_SUPPLY("MICBIAS1", 0, SND_SOC_DAPM_REGULATOR_BYPASS),
+SND_SOC_DAPM_REGULATOR_SUPPLY("MICBIAS2", 0, SND_SOC_DAPM_REGULATOR_BYPASS),
+SND_SOC_DAPM_REGULATOR_SUPPLY("MICBIAS3", 0, SND_SOC_DAPM_REGULATOR_BYPASS),
 
 SND_SOC_DAPM_PGA("Tone Generator 1", ARIZONA_TONE_GENERATOR_1,
 		 ARIZONA_TONE1_ENA_SHIFT, 0, NULL, 0),
Signature · 1 line
2.1.4
maintainer
#15 lore raw

Applied "regulator: arizona-micsupp: Avoid potential memory leak reading init_data" to the regulator tree

In reply to Charles Keepax

The patch

regulator: arizona-micsupp: Avoid potential memory leak reading init_data

has been applied to the regulator tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From 2543ef3173889373fc07df61520e1bb42a99c85e Mon Sep 17 00:00:00 2001

From: Charles Keepax <[email protected]>
Date: Tue, 28 Mar 2017 15:14:37 +0100
Subject: [PATCH] regulator: arizona-micsupp: Avoid potential memory leak
reading init_data

The device argument passed to of_get_regulator_init_data is used to do some devres memory allocation. Currently the driver passes the MFD device pointer to this function, this could result in the init_data allocation being leaked if the regulator is unbound but the MFD isn't.

Correct this issue by correctly passing the local platform device.

---
 drivers/regulator/arizona-micsupp.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/regulator/arizona-micsupp.c +5 -4
index fcb98dbda837..0ed14e41de11 100644
@@ -197,7 +197,8 @@ static const struct regulator_init_data arizona_micsupp_ext_default = {
 	.num_consumer_supplies = 1,
 };
 
-static int arizona_micsupp_of_get_pdata(struct arizona *arizona,
+static int arizona_micsupp_of_get_pdata(struct device *dev,
+					struct arizona *arizona,
 					struct regulator_config *config,
 					const struct regulator_desc *desc)
 {
@@ -211,7 +212,7 @@ static int arizona_micsupp_of_get_pdata(struct arizona *arizona,
 	if (np) {
 		config->of_node = np;
 
-		init_data = of_get_regulator_init_data(arizona->dev, np, desc);
+		init_data = of_get_regulator_init_data(dev, np, desc);
 
 		if (init_data) {
 			init_data->consumer_supplies = &micsupp->supply;
@@ -266,8 +267,8 @@ static int arizona_micsupp_probe(struct platform_device *pdev)
 
 	if (IS_ENABLED(CONFIG_OF)) {
 		if (!dev_get_platdata(arizona->dev)) {
-			ret = arizona_micsupp_of_get_pdata(arizona, &config,
-							   desc);
+			ret = arizona_micsupp_of_get_pdata(&pdev->dev, arizona,
+							   &config, desc);
 			if (ret < 0)
 				return ret;
 		}
Signature · 1 line
2.11.0