[PATCH] regulator: mt6315: Fix off-by-one for .n_voltages

2021-03-10 Thread Axel Lin
The valid selector is 0 ~ 0xbf, so the .n_voltages should be 0xc0.

Signed-off-by: Axel Lin 
---
 drivers/regulator/mt6315-regulator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/mt6315-regulator.c 
b/drivers/regulator/mt6315-regulator.c
index fc7654624dd6..9edc34981ee0 100644
--- a/drivers/regulator/mt6315-regulator.c
+++ b/drivers/regulator/mt6315-regulator.c
@@ -41,7 +41,7 @@ struct mt6315_chip {
.type = REGULATOR_VOLTAGE,  \
.id = _bid, \
.owner = THIS_MODULE,   \
-   .n_voltages = 0xbf, \
+   .n_voltages = 0xc0, \
.linear_ranges = mt_volt_range1,\
.n_linear_ranges = ARRAY_SIZE(mt_volt_range1),  \
.vsel_reg = _vsel,  \
-- 
2.25.1



Re: [PATCH] spi: mediatek: Re-license MTK SPI driver as Dual MIT/GPL

2021-03-03 Thread Axel Lin
Leilk Liu  於 2021年3月3日 週三 上午10:57寫道:
>
> From: "leilk.liu" 
>
> It is wanted to use MTK spi bus driver with GPL-2.0 or MIT license.
> But now it is only licensed as GPL-2.0, so re-license it as dual
> MIT/GPL.
>
> Signed-off-by: leilk.liu 
Acked-by: Axel Lin 


[PATCH] regulator: pf8x00: Use regulator_map_voltage_ascend for pf8x00_buck7_ops

2021-02-15 Thread Axel Lin
The voltages in pf8x00_sw7_voltages are in ascendant order, so use
regulator_map_voltage_ascend.

Signed-off-by: Axel Lin 
---
 drivers/regulator/pf8x00-regulator.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/regulator/pf8x00-regulator.c 
b/drivers/regulator/pf8x00-regulator.c
index 9b28bd63208d..5d319fb81288 100644
--- a/drivers/regulator/pf8x00-regulator.c
+++ b/drivers/regulator/pf8x00-regulator.c
@@ -359,6 +359,7 @@ static const struct regulator_ops pf8x00_buck7_ops = {
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
.list_voltage = regulator_list_voltage_table,
+   .map_voltage = regulator_map_voltage_ascend,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.get_current_limit = regulator_get_current_limit_regmap,
-- 
2.25.1



[PATCH] regulator: mt6315: Return REGULATOR_MODE_INVALID for invalid mode

2021-02-14 Thread Axel Lin
-EINVAL is not a valid return value for .of_map_mode, return
REGULATOR_MODE_INVALID instead.

Signed-off-by: Axel Lin 
---
 drivers/regulator/mt6315-regulator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/mt6315-regulator.c 
b/drivers/regulator/mt6315-regulator.c
index d49a1534d8e9..fc7654624dd6 100644
--- a/drivers/regulator/mt6315-regulator.c
+++ b/drivers/regulator/mt6315-regulator.c
@@ -69,7 +69,7 @@ static unsigned int mt6315_map_mode(u32 mode)
case MT6315_BUCK_MODE_LP:
return REGULATOR_MODE_IDLE;
default:
-   return -EINVAL;
+   return REGULATOR_MODE_INVALID;
}
 }
 
-- 
2.25.1



[PATCH] regulator: pf8x00: Fix typo for PF8200 chip name

2021-01-28 Thread Axel Lin
Trivial typo fix.

Signed-off-by: Axel Lin 
---
 drivers/regulator/pf8x00-regulator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/pf8x00-regulator.c 
b/drivers/regulator/pf8x00-regulator.c
index 827da25466cc..9b28bd63208d 100644
--- a/drivers/regulator/pf8x00-regulator.c
+++ b/drivers/regulator/pf8x00-regulator.c
@@ -529,7 +529,7 @@ static int pf8x00_identify(struct pf8x00_chip *chip)
name = "PF8121A";
break;
case PF8200:
-   name = "PF8100";
+   name = "PF8200";
break;
default:
dev_err(chip->dev, "Unknown pf8x00 device id 0x%x\n", dev_id);
-- 
2.25.1



[PATCH] regulator: rt4801: Select REGMAP_I2C to fix build error

2020-08-19 Thread Axel Lin
Fix build error when CONFIG_REGMAP_I2C is not set.

Signed-off-by: Axel Lin 
---
 drivers/regulator/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index ebce11cbab44..f719ed5a8c33 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -907,6 +907,7 @@ config REGULATOR_ROHM
 config REGULATOR_RT4801
tristate "Richtek RT4801 Regulators"
depends on I2C
+   select REGMAP_I2C
help
  This adds support for voltage regulators in Richtek RT4801 Display 
Bias IC.
  The device supports two regulators (DSVP/DSVN).
-- 
2.25.1



[PATCH] regulator: lp8755: Get rid of lp8755_read/lp8755_write/lp8755_update_bits

2020-08-02 Thread Axel Lin
Just use regmap_read/regmap_write/regmap_update_bits instead.

Signed-off-by: Axel Lin 
---
 drivers/regulator/lp8755.c | 82 ++
 1 file changed, 21 insertions(+), 61 deletions(-)

diff --git a/drivers/regulator/lp8755.c b/drivers/regulator/lp8755.c
index 4291df077c39..8cc9963023f2 100644
--- a/drivers/regulator/lp8755.c
+++ b/drivers/regulator/lp8755.c
@@ -49,53 +49,15 @@ struct lp8755_chip {
struct regulator_dev *rdev[LP8755_BUCK_MAX];
 };
 
-/**
- *lp8755_read : read a single register value from lp8755.
- *@pchip : device to read from
- *@reg   : register to read from
- *@val   : pointer to store read value
- */
-static int lp8755_read(struct lp8755_chip *pchip, unsigned int reg,
-  unsigned int *val)
-{
-   return regmap_read(pchip->regmap, reg, val);
-}
-
-/**
- *lp8755_write : write a single register value to lp8755.
- *@pchip : device to write to
- *@reg   : register to write to
- *@val   : value to be written
- */
-static int lp8755_write(struct lp8755_chip *pchip, unsigned int reg,
-   unsigned int val)
-{
-   return regmap_write(pchip->regmap, reg, val);
-}
-
-/**
- *lp8755_update_bits : set the values of bit fields in lp8755 register.
- *@pchip : device to read from
- *@reg   : register to update
- *@mask  : bitmask to be changed
- *@val   : value for bitmask
- */
-static int lp8755_update_bits(struct lp8755_chip *pchip, unsigned int reg,
- unsigned int mask, unsigned int val)
-{
-   return regmap_update_bits(pchip->regmap, reg, mask, val);
-}
-
 static int lp8755_buck_enable_time(struct regulator_dev *rdev)
 {
int ret;
unsigned int regval;
enum lp8755_bucks id = rdev_get_id(rdev);
-   struct lp8755_chip *pchip = rdev_get_drvdata(rdev);
 
-   ret = lp8755_read(pchip, 0x12 + id, ®val);
+   ret = regmap_read(rdev->regmap, 0x12 + id, ®val);
if (ret < 0) {
-   dev_err(pchip->dev, "i2c access error %s\n", __func__);
+   dev_err(&rdev->dev, "i2c access error %s\n", __func__);
return ret;
}
return (regval & 0xff) * 100;
@@ -115,17 +77,17 @@ static int lp8755_buck_set_mode(struct regulator_dev 
*rdev, unsigned int mode)
break;
case REGULATOR_MODE_NORMAL:
/* enable automatic pwm/pfm mode */
-   ret = lp8755_update_bits(pchip, 0x08 + id, 0x20, 0x00);
+   ret = regmap_update_bits(rdev->regmap, 0x08 + id, 0x20, 0x00);
if (ret < 0)
goto err_i2c;
break;
case REGULATOR_MODE_IDLE:
/* enable automatic pwm/pfm/lppfm mode */
-   ret = lp8755_update_bits(pchip, 0x08 + id, 0x20, 0x20);
+   ret = regmap_update_bits(rdev->regmap, 0x08 + id, 0x20, 0x20);
if (ret < 0)
goto err_i2c;
 
-   ret = lp8755_update_bits(pchip, 0x10, 0x01, 0x01);
+   ret = regmap_update_bits(rdev->regmap, 0x10, 0x01, 0x01);
if (ret < 0)
goto err_i2c;
break;
@@ -135,12 +97,12 @@ static int lp8755_buck_set_mode(struct regulator_dev 
*rdev, unsigned int mode)
regbval = (0x01 << id);
}
 
-   ret = lp8755_update_bits(pchip, 0x06, 0x01 << id, regbval);
+   ret = regmap_update_bits(rdev->regmap, 0x06, 0x01 << id, regbval);
if (ret < 0)
goto err_i2c;
return ret;
 err_i2c:
-   dev_err(pchip->dev, "i2c access error %s\n", __func__);
+   dev_err(&rdev->dev, "i2c access error %s\n", __func__);
return ret;
 }
 
@@ -149,9 +111,8 @@ static unsigned int lp8755_buck_get_mode(struct 
regulator_dev *rdev)
int ret;
unsigned int regval;
enum lp8755_bucks id = rdev_get_id(rdev);
-   struct lp8755_chip *pchip = rdev_get_drvdata(rdev);
 
-   ret = lp8755_read(pchip, 0x06, ®val);
+   ret = regmap_read(rdev->regmap, 0x06, ®val);
if (ret < 0)
goto err_i2c;
 
@@ -159,7 +120,7 @@ static unsigned int lp8755_buck_get_mode(struct 
regulator_dev *rdev)
if (regval & (0x01 << id))
return REGULATOR_MODE_FAST;
 
-   ret = lp8755_read(pchip, 0x08 + id, ®val);
+   ret = regmap_read(rdev->regmap, 0x08 + id, ®val);
if (ret < 0)
goto err_i2c;
 
@@ -171,7 +132,7 @@ static unsigned int lp8755_buck_get_mode(struct 
regulator_dev *rdev)
return REGULATOR_MODE_NORMAL;
 
 err_i2c:
-   dev_err(pchip->dev, "i2c access error %s\n", __func__);
+   dev_err(&rdev->dev, "i2c access error %s\n", __func__);
return 0;
 }
 
@@ -180,7 +141,6 @@ static int lp8755_buck_set_ramp(struct regulator_dev *rdev

[PATCH] regulator: cros-ec-regulator: Add NULL test for devm_kmemdup call

2020-08-01 Thread Axel Lin
Fix possible NULL pointer dereference.

Signed-off-by: Axel Lin 
---
 drivers/regulator/cros-ec-regulator.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/regulator/cros-ec-regulator.c 
b/drivers/regulator/cros-ec-regulator.c
index 3117bbd2826b..eb3fc1db4edc 100644
--- a/drivers/regulator/cros-ec-regulator.c
+++ b/drivers/regulator/cros-ec-regulator.c
@@ -170,6 +170,9 @@ static int cros_ec_regulator_init_info(struct device *dev,
data->voltages_mV =
devm_kmemdup(dev, resp.voltages_mv,
 sizeof(u16) * data->num_voltages, GFP_KERNEL);
+   if (!data->voltages_mV)
+   return -ENOMEM;
+
data->desc.n_voltages = data->num_voltages;
 
/* Make sure the returned name is always a valid string */
-- 
2.25.1



[PATCH] regulator: qcom_spmi: Improve readability for setting up enable/mode pin control

2020-07-31 Thread Axel Lin
By checking data->pin_ctrl_enable / data->pin_ctrl_hpm flags first, then
use switch-case to improve readability.

Signed-off-by: Axel Lin 
---
 drivers/regulator/qcom_spmi-regulator.c | 70 -
 1 file changed, 34 insertions(+), 36 deletions(-)

diff --git a/drivers/regulator/qcom_spmi-regulator.c 
b/drivers/regulator/qcom_spmi-regulator.c
index 5ee7c5305d95..05080483fe1b 100644
--- a/drivers/regulator/qcom_spmi-regulator.c
+++ b/drivers/regulator/qcom_spmi-regulator.c
@@ -1633,45 +1633,43 @@ static int spmi_regulator_init_registers(struct 
spmi_regulator *vreg,
return ret;
 
/* Set up enable pin control. */
-   if ((type == SPMI_REGULATOR_LOGICAL_TYPE_SMPS
-|| type == SPMI_REGULATOR_LOGICAL_TYPE_LDO
-|| type == SPMI_REGULATOR_LOGICAL_TYPE_VS)
-   && !(data->pin_ctrl_enable
-   & SPMI_REGULATOR_PIN_CTRL_ENABLE_HW_DEFAULT)) {
-   ctrl_reg[SPMI_COMMON_IDX_ENABLE] &=
-   ~SPMI_COMMON_ENABLE_FOLLOW_ALL_MASK;
-   ctrl_reg[SPMI_COMMON_IDX_ENABLE] |=
-   data->pin_ctrl_enable & SPMI_COMMON_ENABLE_FOLLOW_ALL_MASK;
+   if (!(data->pin_ctrl_enable & 
SPMI_REGULATOR_PIN_CTRL_ENABLE_HW_DEFAULT)) {
+   switch (type) {
+   case SPMI_REGULATOR_LOGICAL_TYPE_SMPS:
+   case SPMI_REGULATOR_LOGICAL_TYPE_LDO:
+   case SPMI_REGULATOR_LOGICAL_TYPE_VS:
+   ctrl_reg[SPMI_COMMON_IDX_ENABLE] &=
+   ~SPMI_COMMON_ENABLE_FOLLOW_ALL_MASK;
+   ctrl_reg[SPMI_COMMON_IDX_ENABLE] |=
+   data->pin_ctrl_enable & 
SPMI_COMMON_ENABLE_FOLLOW_ALL_MASK;
+   break;
+   default:
+   break;
+   }
}
 
/* Set up mode pin control. */
-   if ((type == SPMI_REGULATOR_LOGICAL_TYPE_SMPS
-   || type == SPMI_REGULATOR_LOGICAL_TYPE_LDO)
-   && !(data->pin_ctrl_hpm
-   & SPMI_REGULATOR_PIN_CTRL_HPM_HW_DEFAULT)) {
-   ctrl_reg[SPMI_COMMON_IDX_MODE] &=
-   ~SPMI_COMMON_MODE_FOLLOW_ALL_MASK;
-   ctrl_reg[SPMI_COMMON_IDX_MODE] |=
-   data->pin_ctrl_hpm & SPMI_COMMON_MODE_FOLLOW_ALL_MASK;
-   }
-
-   if (type == SPMI_REGULATOR_LOGICAL_TYPE_VS
-  && !(data->pin_ctrl_hpm & SPMI_REGULATOR_PIN_CTRL_HPM_HW_DEFAULT)) {
-   ctrl_reg[SPMI_COMMON_IDX_MODE] &=
-   ~SPMI_COMMON_MODE_FOLLOW_AWAKE_MASK;
-   ctrl_reg[SPMI_COMMON_IDX_MODE] |=
-  data->pin_ctrl_hpm & SPMI_COMMON_MODE_FOLLOW_AWAKE_MASK;
-   }
-
-   if ((type == SPMI_REGULATOR_LOGICAL_TYPE_ULT_LO_SMPS
-   || type == SPMI_REGULATOR_LOGICAL_TYPE_ULT_HO_SMPS
-   || type == SPMI_REGULATOR_LOGICAL_TYPE_ULT_LDO)
-   && !(data->pin_ctrl_hpm
-   & SPMI_REGULATOR_PIN_CTRL_HPM_HW_DEFAULT)) {
-   ctrl_reg[SPMI_COMMON_IDX_MODE] &=
-   ~SPMI_COMMON_MODE_FOLLOW_AWAKE_MASK;
-   ctrl_reg[SPMI_COMMON_IDX_MODE] |=
-  data->pin_ctrl_hpm & SPMI_COMMON_MODE_FOLLOW_AWAKE_MASK;
+   if (!(data->pin_ctrl_hpm & SPMI_REGULATOR_PIN_CTRL_HPM_HW_DEFAULT)) {
+   switch (type) {
+   case SPMI_REGULATOR_LOGICAL_TYPE_SMPS:
+   case SPMI_REGULATOR_LOGICAL_TYPE_LDO:
+   ctrl_reg[SPMI_COMMON_IDX_MODE] &=
+   ~SPMI_COMMON_MODE_FOLLOW_ALL_MASK;
+   ctrl_reg[SPMI_COMMON_IDX_MODE] |=
+   data->pin_ctrl_hpm & 
SPMI_COMMON_MODE_FOLLOW_ALL_MASK;
+   break;
+   case SPMI_REGULATOR_LOGICAL_TYPE_VS:
+   case SPMI_REGULATOR_LOGICAL_TYPE_ULT_LO_SMPS:
+   case SPMI_REGULATOR_LOGICAL_TYPE_ULT_HO_SMPS:
+   case SPMI_REGULATOR_LOGICAL_TYPE_ULT_LDO:
+   ctrl_reg[SPMI_COMMON_IDX_MODE] &=
+   ~SPMI_COMMON_MODE_FOLLOW_AWAKE_MASK;
+   ctrl_reg[SPMI_COMMON_IDX_MODE] |=
+   data->pin_ctrl_hpm & 
SPMI_COMMON_MODE_FOLLOW_AWAKE_MASK;
+   break;
+   default:
+   break;
+   }
}
 
/* Write back any control register values that were modified. */
-- 
2.25.1



[PATCH] regulator: pca9450: Convert to use module_i2c_driver

2020-07-24 Thread Axel Lin
Use module_i2c_driver to simplify driver init boilerplate.

Signed-off-by: Axel Lin 
---
 drivers/regulator/pca9450-regulator.c | 12 +---
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/regulator/pca9450-regulator.c 
b/drivers/regulator/pca9450-regulator.c
index 02250459aa90..eb5822bf53e0 100644
--- a/drivers/regulator/pca9450-regulator.c
+++ b/drivers/regulator/pca9450-regulator.c
@@ -826,17 +826,7 @@ static struct i2c_driver pca9450_i2c_driver = {
.probe = pca9450_i2c_probe,
 };
 
-static int __init pca9450_i2c_init(void)
-{
-   return i2c_add_driver(&pca9450_i2c_driver);
-}
-module_init(pca9450_i2c_init);
-
-static void __exit pca9450_i2c_exit(void)
-{
-   i2c_del_driver(&pca9450_i2c_driver);
-}
-module_exit(pca9450_i2c_exit);
+module_i2c_driver(pca9450_i2c_driver);
 
 MODULE_AUTHOR("Robin Gong ");
 MODULE_DESCRIPTION("NXP PCA9450 Power Management IC driver");
-- 
2.25.1



[PATCH] mfd/axp20x-i2c: Fix "CONFIG_ACPI" is not defined warning

2020-07-07 Thread Axel Lin
Fix below build warning:

drivers/mfd/axp20x-i2c.c:82:5: warning: "CONFIG_ACPI" is not defined, evaluates 
to 0 [-Wundef]
   82 | #if CONFIG_ACPI
  | ^~~

Fixes: 20f359cb236b ("mfd: axp20x-i2c: Do not define 'struct acpi_device_id' 
when !CONFIG_ACPI")
Signed-off-by: Axel Lin 
---
 drivers/mfd/axp20x-i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/axp20x-i2c.c b/drivers/mfd/axp20x-i2c.c
index bd271fbe1ec1..3c930316d48b 100644
--- a/drivers/mfd/axp20x-i2c.c
+++ b/drivers/mfd/axp20x-i2c.c
@@ -79,7 +79,7 @@ static const struct i2c_device_id axp20x_i2c_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, axp20x_i2c_id);
 
-#if CONFIG_ACPI
+#ifdef CONFIG_ACPI
 static const struct acpi_device_id axp20x_i2c_acpi_match[] = {
{
.id = "INT33F4",
-- 
2.25.1



[PATCH] regulator: fan53880: Add missing .owner field in regulator_desc

2020-07-06 Thread Axel Lin
Add missing .owner field in regulator_desc, which is used for refcounting.

Signed-off-by: Axel Lin 
---
 drivers/regulator/fan53880.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/regulator/fan53880.c b/drivers/regulator/fan53880.c
index 285acc705a55..575d289b8e04 100644
--- a/drivers/regulator/fan53880.c
+++ b/drivers/regulator/fan53880.c
@@ -45,6 +45,7 @@ static const struct regulator_ops fan53880_ops = {
.of_match =of_match_ptr("LDO"#_num),\
.regulators_node = of_match_ptr("regulators"),  \
.type =REGULATOR_VOLTAGE,   \
+   .owner =   THIS_MODULE, \
.linear_ranges =   (struct linear_range[]) {\
  REGULATOR_LINEAR_RANGE(_default, 0x0, 0x0, 0),\
  REGULATOR_LINEAR_RANGE(80, 0xf, 0x73, 25000), \
@@ -69,6 +70,7 @@ static const struct regulator_desc fan53880_regulators[] = {
.of_match =of_match_ptr("BUCK"),
.regulators_node = of_match_ptr("regulators"),
.type =REGULATOR_VOLTAGE,
+   .owner =   THIS_MODULE,
.linear_ranges =   (struct linear_range[]) {
  REGULATOR_LINEAR_RANGE(110, 0x0, 0x0, 0),
  REGULATOR_LINEAR_RANGE(60, 0x1f, 0xf7, 12500),
@@ -87,6 +89,7 @@ static const struct regulator_desc fan53880_regulators[] = {
.of_match =of_match_ptr("BOOST"),
.regulators_node = of_match_ptr("regulators"),
.type =REGULATOR_VOLTAGE,
+   .owner =   THIS_MODULE,
.linear_ranges =   (struct linear_range[]) {
  REGULATOR_LINEAR_RANGE(500, 0x0, 0x0, 0),
  REGULATOR_LINEAR_RANGE(300, 0x4, 0x70, 25000),
-- 
2.25.1



[PATCH] regulator: mt6358: Remove BROKEN dependency

2020-06-16 Thread Axel Lin
The MFD part is merged into v5.8-rc1, thus remove BROKEN dependency.

Signed-off-by: Axel Lin 
---
 drivers/regulator/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index c398e90e0e73..f60eeaae7afd 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -694,7 +694,7 @@ config REGULATOR_MT6323
 
 config REGULATOR_MT6358
tristate "MediaTek MT6358 PMIC"
-   depends on MFD_MT6397 && BROKEN
+   depends on MFD_MT6397
help
  Say y here to select this option to enable the power regulator of
  MediaTek MT6358 PMIC.
-- 
2.25.1



Re: [RESEND][PATCH 2/2] regulator: da9062: Simplify da9062_buck_set_mode for BUCK_MODE_MANUAL case

2019-10-08 Thread Axel Lin
Mark Brown  於 2019年10月8日 週二 下午6:51寫道:
>
> On Tue, Oct 08, 2019 at 06:48:15PM +0800, Axel Lin wrote:
> > Mark Brown  於 2019年10月8日 週二 下午6:44寫道:
>
> > > It doesn't seem to apply against current code.
>
> > I just test apply it and It looks fine to be applied by linux-next tree.
> > Or which branch of regulator tree should I generate the patch?
>
> Well, I queued it for 5.5.  I've not seen if it's got dependencies
> against 5.4 yet but you chased me so...

Ok, I see the problem.
commit a72865f05782 ("regulator: da9062: fix suspend_enable/disable
preparation") is in for-5.4 branch
but not in for-5.5 branch. So it does not apply to for-5.5 branch.

But if I generate the patch on for-5.5 branch, I think you will get
conflict when merge for-5.4 and for-5.5 to for-next.


Re: [RESEND][PATCH 2/2] regulator: da9062: Simplify da9062_buck_set_mode for BUCK_MODE_MANUAL case

2019-10-08 Thread Axel Lin
Mark Brown  於 2019年10月8日 週二 下午6:44寫道:
>
> On Tue, Oct 08, 2019 at 06:41:21PM +0800, Axel Lin wrote:
>
> > I'm wondering if any issue with this patch?
> > Note, this patch is for da9062 (not for da9063 which is already applied).
>
> It doesn't seem to apply against current code.
I just test apply it and It looks fine to be applied by linux-next tree.
Or which branch of regulator tree should I generate the patch?


Re: [RESEND][PATCH 2/2] regulator: da9062: Simplify da9062_buck_set_mode for BUCK_MODE_MANUAL case

2019-10-08 Thread Axel Lin
Axel Lin  於 2019年10月7日 週一 下午7:50寫道:
>
> The sleep flag bit decides the mode for BUCK_MODE_MANUAL case, simplify
> the logic as the result is the same.
>
> Signed-off-by: Axel Lin 
> Reviewed-by: Adam Thomson 
Hi Mark,

I'm wondering if any issue with this patch?
Note, this patch is for da9062 (not for da9063 which is already applied).

Regards,
Axel


[PATCH 1/3] regulator: rk808: Constify rk817 regulator_ops

2019-10-07 Thread Axel Lin
These regulator_ops variables never need to be modified, make them const so
compiler can put them to .rodata.

Signed-off-by: Axel Lin 
---
 drivers/regulator/rk808-regulator.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/regulator/rk808-regulator.c 
b/drivers/regulator/rk808-regulator.c
index 61bd5ef0806c..eda056fce65f 100644
--- a/drivers/regulator/rk808-regulator.c
+++ b/drivers/regulator/rk808-regulator.c
@@ -686,7 +686,7 @@ static const struct regulator_linear_range 
rk805_buck_1_2_voltage_ranges[] = {
REGULATOR_LINEAR_RANGE(230, 63, 63, 0),
 };
 
-static struct regulator_ops rk809_buck5_ops_range = {
+static const struct regulator_ops rk809_buck5_ops_range = {
.list_voltage   = regulator_list_voltage_linear_range,
.map_voltage= regulator_map_voltage_linear_range,
.get_voltage_sel= regulator_get_voltage_sel_regmap,
@@ -700,7 +700,7 @@ static struct regulator_ops rk809_buck5_ops_range = {
.set_suspend_disable= rk817_set_suspend_disable,
 };
 
-static struct regulator_ops rk817_reg_ops = {
+static const struct regulator_ops rk817_reg_ops = {
.list_voltage   = regulator_list_voltage_linear,
.map_voltage= regulator_map_voltage_linear,
.get_voltage_sel= regulator_get_voltage_sel_regmap,
@@ -713,7 +713,7 @@ static struct regulator_ops rk817_reg_ops = {
.set_suspend_disable= rk817_set_suspend_disable,
 };
 
-static struct regulator_ops rk817_boost_ops = {
+static const struct regulator_ops rk817_boost_ops = {
.list_voltage   = regulator_list_voltage_linear,
.map_voltage= regulator_map_voltage_linear,
.get_voltage_sel= regulator_get_voltage_sel_regmap,
@@ -725,7 +725,7 @@ static struct regulator_ops rk817_boost_ops = {
.set_suspend_disable= rk817_set_suspend_disable,
 };
 
-static struct regulator_ops rk817_buck_ops_range = {
+static const struct regulator_ops rk817_buck_ops_range = {
.list_voltage   = regulator_list_voltage_linear_range,
.map_voltage= regulator_map_voltage_linear_range,
.get_voltage_sel= regulator_get_voltage_sel_regmap,
@@ -743,7 +743,7 @@ static struct regulator_ops rk817_buck_ops_range = {
.set_suspend_disable= rk817_set_suspend_disable,
 };
 
-static struct regulator_ops rk817_switch_ops = {
+static const struct regulator_ops rk817_switch_ops = {
.enable = regulator_enable_regmap,
.disable= regulator_disable_regmap,
.is_enabled = rk8xx_is_enabled_wmsk_regmap,
-- 
2.20.1



[PATCH 3/3] regulator: rk808: Remove rk817_set_suspend_voltage function

2019-10-07 Thread Axel Lin
The implement is exactly the same as rk808_set_suspend_voltage, so just
use rk808_set_suspend_voltage instead.

Signed-off-by: Axel Lin 
---
 drivers/regulator/rk808-regulator.c | 17 +
 1 file changed, 1 insertion(+), 16 deletions(-)

diff --git a/drivers/regulator/rk808-regulator.c 
b/drivers/regulator/rk808-regulator.c
index d0d1b868b0cd..5b4003226484 100644
--- a/drivers/regulator/rk808-regulator.c
+++ b/drivers/regulator/rk808-regulator.c
@@ -411,21 +411,6 @@ static int rk808_set_suspend_voltage(struct regulator_dev 
*rdev, int uv)
  sel);
 }
 
-static int rk817_set_suspend_voltage(struct regulator_dev *rdev, int uv)
-{
-   unsigned int reg;
-   int sel = regulator_map_voltage_linear(rdev, uv, uv);
-   /* only ldo1~ldo9 */
-   if (sel < 0)
-   return -EINVAL;
-
-   reg = rdev->desc->vsel_reg + RK808_SLP_REG_OFFSET;
-
-   return regmap_update_bits(rdev->regmap, reg,
- rdev->desc->vsel_mask,
- sel);
-}
-
 static int rk808_set_suspend_voltage_range(struct regulator_dev *rdev, int uv)
 {
unsigned int reg;
@@ -708,7 +693,7 @@ static const struct regulator_ops rk817_reg_ops = {
.enable = regulator_enable_regmap,
.disable= regulator_disable_regmap,
.is_enabled = rk8xx_is_enabled_wmsk_regmap,
-   .set_suspend_voltage= rk817_set_suspend_voltage,
+   .set_suspend_voltage= rk808_set_suspend_voltage,
.set_suspend_enable = rk817_set_suspend_enable,
.set_suspend_disable= rk817_set_suspend_disable,
 };
-- 
2.20.1



[PATCH 2/3] regulator: rk808: Fix warning message in rk817_set_ramp_delay

2019-10-07 Thread Axel Lin
The default in rk817_set_ramp_delay is 25MV rather than 10MV.

Signed-off-by: Axel Lin 
---
 drivers/regulator/rk808-regulator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/rk808-regulator.c 
b/drivers/regulator/rk808-regulator.c
index eda056fce65f..d0d1b868b0cd 100644
--- a/drivers/regulator/rk808-regulator.c
+++ b/drivers/regulator/rk808-regulator.c
@@ -388,7 +388,7 @@ static int rk817_set_ramp_delay(struct regulator_dev *rdev, 
int ramp_delay)
break;
default:
dev_warn(&rdev->dev,
-"%s ramp_delay: %d not supported, setting 1\n",
+"%s ramp_delay: %d not supported, setting 25000\n",
 rdev->desc->name, ramp_delay);
}
 
-- 
2.20.1



[RESEND][PATCH 1/2] regulator: da9062: Simplify the code iterating all regulators

2019-10-07 Thread Axel Lin
It's more straightforward to use for statement here.

Signed-off-by: Axel Lin 
Acked-by: Steve Twiss 
---
This was sent on https://lkml.org/lkml/2019/7/11/208 with Adam's Ack.
 drivers/regulator/da9062-regulator.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/regulator/da9062-regulator.c 
b/drivers/regulator/da9062-regulator.c
index 710e67081d53..9bb895006455 100644
--- a/drivers/regulator/da9062-regulator.c
+++ b/drivers/regulator/da9062-regulator.c
@@ -942,8 +942,7 @@ static int da9062_regulator_probe(struct platform_device 
*pdev)
regulators->n_regulators = max_regulators;
platform_set_drvdata(pdev, regulators);
 
-   n = 0;
-   while (n < regulators->n_regulators) {
+   for (n = 0; n < regulators->n_regulators; n++) {
/* Initialise regulator structure */
regl = ®ulators->regulator[n];
regl->hw = chip;
@@ -1002,8 +1001,6 @@ static int da9062_regulator_probe(struct platform_device 
*pdev)
regl->desc.name);
return PTR_ERR(regl->rdev);
}
-
-   n++;
}
 
/* LDOs overcurrent event support */
-- 
2.20.1



[RESEND][PATCH 2/2] regulator: da9062: Simplify da9062_buck_set_mode for BUCK_MODE_MANUAL case

2019-10-07 Thread Axel Lin
The sleep flag bit decides the mode for BUCK_MODE_MANUAL case, simplify
the logic as the result is the same.

Signed-off-by: Axel Lin 
Reviewed-by: Adam Thomson 
---
This was sent on https://lkml.org/lkml/2019/9/26/24 with Adam's Review.
 drivers/regulator/da9062-regulator.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/regulator/da9062-regulator.c 
b/drivers/regulator/da9062-regulator.c
index 9bb895006455..4b24518f75b5 100644
--- a/drivers/regulator/da9062-regulator.c
+++ b/drivers/regulator/da9062-regulator.c
@@ -136,7 +136,7 @@ static int da9062_buck_set_mode(struct regulator_dev *rdev, 
unsigned mode)
 static unsigned da9062_buck_get_mode(struct regulator_dev *rdev)
 {
struct da9062_regulator *regl = rdev_get_drvdata(rdev);
-   unsigned int val, mode = 0;
+   unsigned int val;
int ret;
 
ret = regmap_field_read(regl->mode, &val);
@@ -146,7 +146,6 @@ static unsigned da9062_buck_get_mode(struct regulator_dev 
*rdev)
switch (val) {
default:
case BUCK_MODE_MANUAL:
-   mode = REGULATOR_MODE_FAST | REGULATOR_MODE_STANDBY;
/* Sleep flag bit decides the mode */
break;
case BUCK_MODE_SLEEP:
@@ -162,11 +161,9 @@ static unsigned da9062_buck_get_mode(struct regulator_dev 
*rdev)
return 0;
 
if (val)
-   mode &= REGULATOR_MODE_STANDBY;
+   return REGULATOR_MODE_STANDBY;
else
-   mode &= REGULATOR_MODE_NORMAL | REGULATOR_MODE_FAST;
-
-   return mode;
+   return REGULATOR_MODE_FAST;
 }
 
 /*
-- 
2.20.1



[PATCH] regulator: pbias: Get rid of struct pbias_regulator_data

2019-10-07 Thread Axel Lin
Only the desc field is really used, so use struct regulator_desc instead.
Then struct pbias_regulator_data can be removed.

Signed-off-by: Axel Lin 
---
 drivers/regulator/pbias-regulator.c | 69 +++--
 1 file changed, 26 insertions(+), 43 deletions(-)

diff --git a/drivers/regulator/pbias-regulator.c 
b/drivers/regulator/pbias-regulator.c
index a59811060bdc..bfc15dd3f730 100644
--- a/drivers/regulator/pbias-regulator.c
+++ b/drivers/regulator/pbias-regulator.c
@@ -38,15 +38,6 @@ struct pbias_reg_info {
int n_voltages;
 };
 
-struct pbias_regulator_data {
-   struct regulator_desc desc;
-   void __iomem *pbias_addr;
-   struct regulator_dev *dev;
-   struct regmap *syscon;
-   const struct pbias_reg_info *info;
-   int voltage;
-};
-
 struct pbias_of_data {
unsigned int offset;
 };
@@ -157,13 +148,13 @@ MODULE_DEVICE_TABLE(of, pbias_of_match);
 static int pbias_regulator_probe(struct platform_device *pdev)
 {
struct device_node *np = pdev->dev.of_node;
-   struct pbias_regulator_data *drvdata;
struct resource *res;
struct regulator_config cfg = { };
+   struct regulator_desc *desc;
+   struct regulator_dev *rdev;
struct regmap *syscon;
const struct pbias_reg_info *info;
-   int ret = 0;
-   int count, idx, data_idx = 0;
+   int ret, count, idx;
const struct pbias_of_data *data;
unsigned int offset;
 
@@ -172,10 +163,8 @@ static int pbias_regulator_probe(struct platform_device 
*pdev)
if (count < 0)
return count;
 
-   drvdata = devm_kcalloc(&pdev->dev,
-  count, sizeof(struct pbias_regulator_data),
-  GFP_KERNEL);
-   if (!drvdata)
+   desc = devm_kcalloc(&pdev->dev, count, sizeof(*desc), GFP_KERNEL);
+   if (!desc)
return -ENOMEM;
 
syscon = syscon_regmap_lookup_by_phandle(np, "syscon");
@@ -198,7 +187,7 @@ static int pbias_regulator_probe(struct platform_device 
*pdev)
cfg.regmap = syscon;
cfg.dev = &pdev->dev;
 
-   for (idx = 0; idx < PBIAS_NUM_REGS && data_idx < count; idx++) {
+   for (idx = 0; idx < PBIAS_NUM_REGS && count; idx++) {
if (!pbias_matches[idx].init_data ||
!pbias_matches[idx].of_node)
continue;
@@ -207,41 +196,35 @@ static int pbias_regulator_probe(struct platform_device 
*pdev)
if (!info)
return -ENODEV;
 
-   drvdata[data_idx].syscon = syscon;
-   drvdata[data_idx].info = info;
-   drvdata[data_idx].desc.name = info->name;
-   drvdata[data_idx].desc.owner = THIS_MODULE;
-   drvdata[data_idx].desc.type = REGULATOR_VOLTAGE;
-   drvdata[data_idx].desc.ops = &pbias_regulator_voltage_ops;
-   drvdata[data_idx].desc.volt_table = info->pbias_volt_table;
-   drvdata[data_idx].desc.n_voltages = info->n_voltages;
-   drvdata[data_idx].desc.enable_time = info->enable_time;
-   drvdata[data_idx].desc.vsel_reg = offset;
-   drvdata[data_idx].desc.vsel_mask = info->vmode;
-   drvdata[data_idx].desc.enable_reg = offset;
-   drvdata[data_idx].desc.enable_mask = info->enable_mask;
-   drvdata[data_idx].desc.enable_val = info->enable;
-   drvdata[data_idx].desc.disable_val = info->disable_val;
+   desc->name = info->name;
+   desc->owner = THIS_MODULE;
+   desc->type = REGULATOR_VOLTAGE;
+   desc->ops = &pbias_regulator_voltage_ops;
+   desc->volt_table = info->pbias_volt_table;
+   desc->n_voltages = info->n_voltages;
+   desc->enable_time = info->enable_time;
+   desc->vsel_reg = offset;
+   desc->vsel_mask = info->vmode;
+   desc->enable_reg = offset;
+   desc->enable_mask = info->enable_mask;
+   desc->enable_val = info->enable;
+   desc->disable_val = info->disable_val;
 
cfg.init_data = pbias_matches[idx].init_data;
-   cfg.driver_data = &drvdata[data_idx];
cfg.of_node = pbias_matches[idx].of_node;
 
-   drvdata[data_idx].dev = devm_regulator_register(&pdev->dev,
-   &drvdata[data_idx].desc, &cfg);
-   if (IS_ERR(drvdata[data_idx].dev)) {
-   ret = PTR_ERR(drvdata[data_idx].dev);
+   rdev = devm_regulator_register(&pdev->dev, desc, &cfg);
+   if (IS_ERR(rdev)) {
+   ret = PTR_ERR(rdev);
   

Re: [PATCH 1/2] regulator: da9062: Simplify da9062_buck_set_mode for BUCK_MODE_MANUAL case

2019-10-01 Thread Axel Lin
Adam Thomson  於 2019年9月26日 週四 下午5:22寫道:
>
> On 26 September 2019 06:51, Axel Lin wrote:
>
> > The sleep flag bit decides the mode for BUCK_MODE_MANUAL case, simplify
> > the logic as the result is the same.
> >
> > Signed-off-by: Axel Lin 
>
> This patch will need to be rebased on Marco's update titled:
>
> "regulator: da9062: fix suspend_enable/disable preparation"
This patch is on top of above commit.
Should be applied cleanly.

Thanks,
Axel


[PATCH] regulator: ti-abb: Fix timeout in ti_abb_wait_txdone/ti_abb_clear_all_txdone

2019-09-29 Thread Axel Lin
ti_abb_wait_txdone() may return -ETIMEDOUT when ti_abb_check_txdone()
returns true in the latest iteration of the while loop because the timeout
value is abb->settling_time + 1. Similarly, ti_abb_clear_all_txdone() may
return -ETIMEDOUT when ti_abb_check_txdone() returns false in the latest
iteration of the while loop. Fix it.

Signed-off-by: Axel Lin 
---
 drivers/regulator/ti-abb-regulator.c | 26 --
 1 file changed, 8 insertions(+), 18 deletions(-)

diff --git a/drivers/regulator/ti-abb-regulator.c 
b/drivers/regulator/ti-abb-regulator.c
index cced1ffb896c..89b9314d64c9 100644
--- a/drivers/regulator/ti-abb-regulator.c
+++ b/drivers/regulator/ti-abb-regulator.c
@@ -173,19 +173,14 @@ static int ti_abb_wait_txdone(struct device *dev, struct 
ti_abb *abb)
while (timeout++ <= abb->settling_time) {
status = ti_abb_check_txdone(abb);
if (status)
-   break;
+   return 0;
 
udelay(1);
}
 
-   if (timeout > abb->settling_time) {
-   dev_warn_ratelimited(dev,
-"%s:TRANXDONE timeout(%duS) int=0x%08x\n",
-__func__, timeout, readl(abb->int_base));
-   return -ETIMEDOUT;
-   }
-
-   return 0;
+   dev_warn_ratelimited(dev, "%s:TRANXDONE timeout(%duS) int=0x%08x\n",
+__func__, timeout, readl(abb->int_base));
+   return -ETIMEDOUT;
 }
 
 /**
@@ -205,19 +200,14 @@ static int ti_abb_clear_all_txdone(struct device *dev, 
const struct ti_abb *abb)
 
status = ti_abb_check_txdone(abb);
if (!status)
-   break;
+   return 0;
 
udelay(1);
}
 
-   if (timeout > abb->settling_time) {
-   dev_warn_ratelimited(dev,
-"%s:TRANXDONE timeout(%duS) int=0x%08x\n",
-__func__, timeout, readl(abb->int_base));
-   return -ETIMEDOUT;
-   }
-
-   return 0;
+   dev_warn_ratelimited(dev, "%s:TRANXDONE timeout(%duS) int=0x%08x\n",
+__func__, timeout, readl(abb->int_base));
+   return -ETIMEDOUT;
 }
 
 /**
-- 
2.20.1



[PATCH 1/2] regulator: da9062: Simplify da9062_buck_set_mode for BUCK_MODE_MANUAL case

2019-09-25 Thread Axel Lin
The sleep flag bit decides the mode for BUCK_MODE_MANUAL case, simplify
the logic as the result is the same.

Signed-off-by: Axel Lin 
---
 drivers/regulator/da9062-regulator.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/regulator/da9062-regulator.c 
b/drivers/regulator/da9062-regulator.c
index 710e67081d53..739a40f256f6 100644
--- a/drivers/regulator/da9062-regulator.c
+++ b/drivers/regulator/da9062-regulator.c
@@ -136,7 +136,7 @@ static int da9062_buck_set_mode(struct regulator_dev *rdev, 
unsigned mode)
 static unsigned da9062_buck_get_mode(struct regulator_dev *rdev)
 {
struct da9062_regulator *regl = rdev_get_drvdata(rdev);
-   unsigned int val, mode = 0;
+   unsigned int val;
int ret;
 
ret = regmap_field_read(regl->mode, &val);
@@ -146,7 +146,6 @@ static unsigned da9062_buck_get_mode(struct regulator_dev 
*rdev)
switch (val) {
default:
case BUCK_MODE_MANUAL:
-   mode = REGULATOR_MODE_FAST | REGULATOR_MODE_STANDBY;
/* Sleep flag bit decides the mode */
break;
case BUCK_MODE_SLEEP:
@@ -162,11 +161,9 @@ static unsigned da9062_buck_get_mode(struct regulator_dev 
*rdev)
return 0;
 
if (val)
-   mode &= REGULATOR_MODE_STANDBY;
+   return REGULATOR_MODE_STANDBY;
else
-   mode &= REGULATOR_MODE_NORMAL | REGULATOR_MODE_FAST;
-
-   return mode;
+   return REGULATOR_MODE_FAST;
 }
 
 /*
-- 
2.20.1



[PATCH 2/2] regulator: da9063: Simplify da9063_buck_set_mode for BUCK_MODE_MANUAL case

2019-09-25 Thread Axel Lin
The sleep flag bit decides the mode for BUCK_MODE_MANUAL case, simplify
the logic as the result is the same.

Signed-off-by: Axel Lin 
---
 drivers/regulator/da9063-regulator.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/regulator/da9063-regulator.c 
b/drivers/regulator/da9063-regulator.c
index 28b1b20f45bd..2aceb3b7afc2 100644
--- a/drivers/regulator/da9063-regulator.c
+++ b/drivers/regulator/da9063-regulator.c
@@ -225,7 +225,7 @@ static unsigned da9063_buck_get_mode(struct regulator_dev 
*rdev)
 {
struct da9063_regulator *regl = rdev_get_drvdata(rdev);
struct regmap_field *field;
-   unsigned int val, mode = 0;
+   unsigned int val;
int ret;
 
ret = regmap_field_read(regl->mode, &val);
@@ -235,7 +235,6 @@ static unsigned da9063_buck_get_mode(struct regulator_dev 
*rdev)
switch (val) {
default:
case BUCK_MODE_MANUAL:
-   mode = REGULATOR_MODE_FAST | REGULATOR_MODE_STANDBY;
/* Sleep flag bit decides the mode */
break;
case BUCK_MODE_SLEEP:
@@ -262,11 +261,9 @@ static unsigned da9063_buck_get_mode(struct regulator_dev 
*rdev)
return 0;
 
if (val)
-   mode &= REGULATOR_MODE_STANDBY;
+   return REGULATOR_MODE_STANDBY;
else
-   mode &= REGULATOR_MODE_NORMAL | REGULATOR_MODE_FAST;
-
-   return mode;
+   return REGULATOR_MODE_FAST;
 }
 
 /*
-- 
2.20.1



[PATCH] regulator: pbias: Use of_device_get_match_data

2019-09-25 Thread Axel Lin
Use of_device_get_match_data to simplify the code a bit.

Signed-off-by: Axel Lin 
---
 drivers/regulator/pbias-regulator.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/regulator/pbias-regulator.c 
b/drivers/regulator/pbias-regulator.c
index 92b41a6a4dc2..a59811060bdc 100644
--- a/drivers/regulator/pbias-regulator.c
+++ b/drivers/regulator/pbias-regulator.c
@@ -164,7 +164,6 @@ static int pbias_regulator_probe(struct platform_device 
*pdev)
const struct pbias_reg_info *info;
int ret = 0;
int count, idx, data_idx = 0;
-   const struct of_device_id *match;
const struct pbias_of_data *data;
unsigned int offset;
 
@@ -183,9 +182,8 @@ static int pbias_regulator_probe(struct platform_device 
*pdev)
if (IS_ERR(syscon))
return PTR_ERR(syscon);
 
-   match = of_match_device(of_match_ptr(pbias_of_match), &pdev->dev);
-   if (match && match->data) {
-   data = match->data;
+   data = of_device_get_match_data(&pdev->dev);
+   if (data) {
offset = data->offset;
} else {
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-- 
2.20.1



[PATCH] regulator: fixed: Prevent NULL pointer dereference when !CONFIG_OF

2019-09-21 Thread Axel Lin
Use of_device_get_match_data which has NULL test for match before
dereference match->data. Add NULL test for drvtype so it still works
for fixed_voltage_ops when !CONFIG_OF.

Signed-off-by: Axel Lin 
---
 drivers/regulator/fixed.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index d90a6fd8cbc7..f81533070058 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -144,8 +144,7 @@ static int reg_fixed_voltage_probe(struct platform_device 
*pdev)
struct device *dev = &pdev->dev;
struct fixed_voltage_config *config;
struct fixed_voltage_data *drvdata;
-   const struct fixed_dev_type *drvtype =
-   of_match_device(dev->driver->of_match_table, dev)->data;
+   const struct fixed_dev_type *drvtype = of_device_get_match_data(dev);
struct regulator_config cfg = { };
enum gpiod_flags gflags;
int ret;
@@ -177,7 +176,7 @@ static int reg_fixed_voltage_probe(struct platform_device 
*pdev)
drvdata->desc.type = REGULATOR_VOLTAGE;
drvdata->desc.owner = THIS_MODULE;
 
-   if (drvtype->has_enable_clock) {
+   if (drvtype && drvtype->has_enable_clock) {
drvdata->desc.ops = &fixed_voltage_clkenabled_ops;
 
drvdata->enable_clock = devm_clk_get(dev, NULL);
-- 
2.20.1



[PATCH v2] regulator: lp87565: Simplify lp87565_buck_set_ramp_delay

2019-09-07 Thread Axel Lin
Use rdev->regmap/&rdev->dev instead of lp87565->regmap/lp87565->dev.
In additional, the lp87565->dev actually is the parent mfd device,
so the dev_err message is misleading here with lp87565->dev.

Signed-off-by: Axel Lin 
---
v2: Add lp87565 prefix in subject line

 drivers/regulator/lp87565-regulator.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/regulator/lp87565-regulator.c 
b/drivers/regulator/lp87565-regulator.c
index 0c440c5e2832..4ae12ac1f4c6 100644
--- a/drivers/regulator/lp87565-regulator.c
+++ b/drivers/regulator/lp87565-regulator.c
@@ -65,7 +65,6 @@ static int lp87565_buck_set_ramp_delay(struct regulator_dev 
*rdev,
   int ramp_delay)
 {
int id = rdev_get_id(rdev);
-   struct lp87565 *lp87565 = rdev_get_drvdata(rdev);
unsigned int reg;
int ret;
 
@@ -86,11 +85,11 @@ static int lp87565_buck_set_ramp_delay(struct regulator_dev 
*rdev,
else
reg = 0;
 
-   ret = regmap_update_bits(lp87565->regmap, regulators[id].ctrl2_reg,
+   ret = regmap_update_bits(rdev->regmap, regulators[id].ctrl2_reg,
 LP87565_BUCK_CTRL_2_SLEW_RATE,
 reg << __ffs(LP87565_BUCK_CTRL_2_SLEW_RATE));
if (ret) {
-   dev_err(lp87565->dev, "SLEW RATE write failed: %d\n", ret);
+   dev_err(&rdev->dev, "SLEW RATE write failed: %d\n", ret);
return ret;
}
 
-- 
2.20.1



[PATCH] regulator: Simplify lp87565_buck_set_ramp_delay

2019-09-07 Thread Axel Lin
Use rdev->regmap/&rdev->dev instead of lp87565->regmap/lp87565->dev.
In additional, the lp87565->dev actually is the parent mfd device,
so the dev_err message is misleading here with lp87565->dev.

Signed-off-by: Axel Lin 
---
 drivers/regulator/lp87565-regulator.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/regulator/lp87565-regulator.c 
b/drivers/regulator/lp87565-regulator.c
index 0c440c5e2832..4ae12ac1f4c6 100644
--- a/drivers/regulator/lp87565-regulator.c
+++ b/drivers/regulator/lp87565-regulator.c
@@ -65,7 +65,6 @@ static int lp87565_buck_set_ramp_delay(struct regulator_dev 
*rdev,
   int ramp_delay)
 {
int id = rdev_get_id(rdev);
-   struct lp87565 *lp87565 = rdev_get_drvdata(rdev);
unsigned int reg;
int ret;
 
@@ -86,11 +85,11 @@ static int lp87565_buck_set_ramp_delay(struct regulator_dev 
*rdev,
else
reg = 0;
 
-   ret = regmap_update_bits(lp87565->regmap, regulators[id].ctrl2_reg,
+   ret = regmap_update_bits(rdev->regmap, regulators[id].ctrl2_reg,
 LP87565_BUCK_CTRL_2_SLEW_RATE,
 reg << __ffs(LP87565_BUCK_CTRL_2_SLEW_RATE));
if (ret) {
-   dev_err(lp87565->dev, "SLEW RATE write failed: %d\n", ret);
+   dev_err(&rdev->dev, "SLEW RATE write failed: %d\n", ret);
return ret;
}
 
-- 
2.20.1



[PATCH RESEND] regulator: lp87565: Fix probe failure for "ti,lp87565"

2019-07-23 Thread Axel Lin
The "ti,lp87565" compatible string is still in of_lp87565_match_table,
but current code will return -EINVAL because lp87565->dev_type is unknown.
This was working in earlier kernel versions, so fix it.

Fixes: 7ee63bd74750 ("regulator: lp87565: Add 4-phase lp87561 regulator 
support")
Signed-off-by: Axel Lin 
---
This patch was sent on https://lkml.org/lkml/2019/7/11/203
This resend re-generate the patch against regulator tree for-5.3 branch.

Note there is a conflict with commit f3f4363b1239 on Linus' tree which is 
merged from mfd tree.
("regulator: lp87565: Fix missing break in switch statement")

 drivers/regulator/lp87565-regulator.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/regulator/lp87565-regulator.c 
b/drivers/regulator/lp87565-regulator.c
index 993c11702083..0c440c5e2832 100644
--- a/drivers/regulator/lp87565-regulator.c
+++ b/drivers/regulator/lp87565-regulator.c
@@ -163,7 +163,7 @@ static int lp87565_regulator_probe(struct platform_device 
*pdev)
struct lp87565 *lp87565 = dev_get_drvdata(pdev->dev.parent);
struct regulator_config config = { };
struct regulator_dev *rdev;
-   int i, min_idx = LP87565_BUCK_0, max_idx = LP87565_BUCK_3;
+   int i, min_idx, max_idx;
 
platform_set_drvdata(pdev, lp87565);
 
@@ -180,10 +180,11 @@ static int lp87565_regulator_probe(struct platform_device 
*pdev)
case LP87565_DEVICE_TYPE_LP87561_Q1:
min_idx = LP87565_BUCK_3210;
max_idx = LP87565_BUCK_3210;
+   break;
default:
-   dev_err(lp87565->dev, "Invalid lp config %d\n",
-   lp87565->dev_type);
-   return -EINVAL;
+   min_idx = LP87565_BUCK_0;
+   max_idx = LP87565_BUCK_3;
+   break;
}
 
for (i = min_idx; i <= max_idx; i++) {
-- 
2.20.1



Re: [PATCH RFT] regulator: lp87565: Fix probe failure for "ti,lp87565"

2019-07-23 Thread Axel Lin
Mark Brown  於 2019年7月24日 週三 上午12:35寫道:
>
> On Tue, Jul 23, 2019 at 08:28:35PM +0800, Axel Lin wrote:
> > Mark Brown  於 2019年7月23日 週二 下午7:26寫道:
> > > On Thu, Jul 11, 2019 at 07:35:17PM +0800, Axel Lin wrote:
>
> > > > The "ti,lp87565" compatible string is still in of_lp87565_match_table,
> > > > but current code will return -EINVAL because lp87565->dev_type is 
> > > > unknown.
> > > > This was working in earlier kernel versions, so fix it.
>
> > > This doesn't seem to apply against current code, please check and
> > > resend.
>
> > I re-generate the patch but the new patch is exactly the same as this one.
> > It can be applied to both Linus and linux-next trees.
> > Did I miss something?
>
> It's a fix so I was trying to apply it on my for-5.3 branch.

The commit f3f4363b1239 ("regulator: lp87565: Fix missing break in
switch statement") from mfd tree has been merged to 5.3-rc1.
So I'm wondering if the better approach is rebase for-5.3 branch to 5.3-rc1.
Then you can apply this patch without conflict.

Anyway, I will resend the patch against regulator tree for-5.3.

Regards,
Axel


Re: [PATCH RFT] regulator: lp87565: Fix probe failure for "ti,lp87565"

2019-07-23 Thread Axel Lin
Mark Brown  於 2019年7月23日 週二 下午7:26寫道:
>
> On Thu, Jul 11, 2019 at 07:35:17PM +0800, Axel Lin wrote:
> > The "ti,lp87565" compatible string is still in of_lp87565_match_table,
> > but current code will return -EINVAL because lp87565->dev_type is unknown.
> > This was working in earlier kernel versions, so fix it.
>
> This doesn't seem to apply against current code, please check and
> resend.

I re-generate the patch but the new patch is exactly the same as this one.
It can be applied to both Linus and linux-next trees.
Did I miss something?


[PATCH] regulator: stm32-booster: Remove .min_uV and .list_voltage for fixed regulator

2019-07-22 Thread Axel Lin
Setting .n_voltages = 1 and .fixed_uV is enough for fixed regulator,
remove the redundant .min_uV and .list_voltage settings.

Signed-off-by: Axel Lin 
---
 drivers/regulator/stm32-booster.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/regulator/stm32-booster.c 
b/drivers/regulator/stm32-booster.c
index 2a897666c650..03f162ffd144 100644
--- a/drivers/regulator/stm32-booster.c
+++ b/drivers/regulator/stm32-booster.c
@@ -20,7 +20,6 @@
 #define STM32MP1_SYSCFG_EN_BOOSTER_MASKBIT(8)
 
 static const struct regulator_ops stm32h7_booster_ops = {
-   .list_voltage   = regulator_list_voltage_linear,
.enable = regulator_enable_regmap,
.disable= regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
@@ -31,7 +30,6 @@ static const struct regulator_desc stm32h7_booster_desc = {
.supply_name = "vdda",
.n_voltages = 1,
.type = REGULATOR_VOLTAGE,
-   .min_uV = 330,
.fixed_uV = 330,
.ramp_delay = 66000, /* up to 50us to stabilize */
.ops = &stm32h7_booster_ops,
@@ -53,7 +51,6 @@ static int stm32mp1_booster_disable(struct regulator_dev 
*rdev)
 }
 
 static const struct regulator_ops stm32mp1_booster_ops = {
-   .list_voltage   = regulator_list_voltage_linear,
.enable = stm32mp1_booster_enable,
.disable= stm32mp1_booster_disable,
.is_enabled = regulator_is_enabled_regmap,
@@ -64,7 +61,6 @@ static const struct regulator_desc stm32mp1_booster_desc = {
.supply_name = "vdda",
.n_voltages = 1,
.type = REGULATOR_VOLTAGE,
-   .min_uV = 330,
.fixed_uV = 330,
.ramp_delay = 66000,
.ops = &stm32mp1_booster_ops,
-- 
2.20.1



[PATCH] regulator: rk808: Return REGULATOR_MODE_INVALID for invalid mode

2019-07-11 Thread Axel Lin
-EINVAL is not a valid return value for .of_map_mode, return
REGULATOR_MODE_INVALID instead.

Signed-off-by: Axel Lin 
---
 drivers/regulator/rk808-regulator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/rk808-regulator.c 
b/drivers/regulator/rk808-regulator.c
index e7af0c53d449..61bd5ef0806c 100644
--- a/drivers/regulator/rk808-regulator.c
+++ b/drivers/regulator/rk808-regulator.c
@@ -606,7 +606,7 @@ static unsigned int rk8xx_regulator_of_map_mode(unsigned 
int mode)
case 2:
return REGULATOR_MODE_NORMAL;
default:
-   return -EINVAL;
+   return REGULATOR_MODE_INVALID;
}
 }
 
-- 
2.20.1



[PATCH] regulator: da9062: Simplify the code iterating all regulators

2019-07-11 Thread Axel Lin
It's more straightforward to use for statement here.

Signed-off-by: Axel Lin 
---
 drivers/regulator/da9062-regulator.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/regulator/da9062-regulator.c 
b/drivers/regulator/da9062-regulator.c
index 2ffc64622451..5ea8d58d28c5 100644
--- a/drivers/regulator/da9062-regulator.c
+++ b/drivers/regulator/da9062-regulator.c
@@ -966,8 +966,7 @@ static int da9062_regulator_probe(struct platform_device 
*pdev)
regulators->n_regulators = max_regulators;
platform_set_drvdata(pdev, regulators);
 
-   n = 0;
-   while (n < regulators->n_regulators) {
+   for (n = 0; n < regulators->n_regulators; n++) {
/* Initialise regulator structure */
regl = ®ulators->regulator[n];
regl->hw = chip;
@@ -1026,8 +1025,6 @@ static int da9062_regulator_probe(struct platform_device 
*pdev)
regl->desc.name);
return PTR_ERR(regl->rdev);
}
-
-   n++;
}
 
/* LDOs overcurrent event support */
-- 
2.20.1



[PATCH RFT] regulator: lp87565: Fix probe failure for "ti,lp87565"

2019-07-11 Thread Axel Lin
The "ti,lp87565" compatible string is still in of_lp87565_match_table,
but current code will return -EINVAL because lp87565->dev_type is unknown.
This was working in earlier kernel versions, so fix it.

Fixes: 7ee63bd74750 ("regulator: lp87565: Add 4-phase lp87561 regulator 
support")
Signed-off-by: Axel Lin 
---
Hi Keerthy,
The commit "regulator: lp87565: Add 4-phase lp87561 regulator support" does not
mention why it returns -EINVAL for "ti,lp87565" (The data field is not set for
.compatible = "ti,lp87565"), so I think the support for "ti,lp87565" was 
accidently
removed.
I don't have this h/w for test, maybe you can test it since you wrote this 
driver.

 drivers/regulator/lp87565-regulator.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/regulator/lp87565-regulator.c 
b/drivers/regulator/lp87565-regulator.c
index 5d067f7c2116..0c440c5e2832 100644
--- a/drivers/regulator/lp87565-regulator.c
+++ b/drivers/regulator/lp87565-regulator.c
@@ -163,7 +163,7 @@ static int lp87565_regulator_probe(struct platform_device 
*pdev)
struct lp87565 *lp87565 = dev_get_drvdata(pdev->dev.parent);
struct regulator_config config = { };
struct regulator_dev *rdev;
-   int i, min_idx = LP87565_BUCK_0, max_idx = LP87565_BUCK_3;
+   int i, min_idx, max_idx;
 
platform_set_drvdata(pdev, lp87565);
 
@@ -182,9 +182,9 @@ static int lp87565_regulator_probe(struct platform_device 
*pdev)
max_idx = LP87565_BUCK_3210;
break;
default:
-   dev_err(lp87565->dev, "Invalid lp config %d\n",
-   lp87565->dev_type);
-   return -EINVAL;
+   min_idx = LP87565_BUCK_0;
+   max_idx = LP87565_BUCK_3;
+   break;
}
 
for (i = min_idx; i <= max_idx; i++) {
-- 
2.20.1



Re: [RFT][PATCH 2/2] regulator: lm363x: Fix n_voltages setting for lm36274

2019-07-07 Thread Axel Lin
Axel Lin  於 2019年6月27日 週四 上午7:58寫道:
>
> > > With your current code where LM36274_LDO_VSEL_MAX and n_voltages is 0x34,
> > > the maximum voltage will become 40 + 5 * 0x34 = 6.6V which
> > > does not match the datasheet.
> >
> > Not sure how you get 6.6v the LDO max is 6.5v.
> >
> > After 0x32->0x7f maps to 6.5v
> >
> > 00 = 4 V
> > 01 = 4.05 V
> > :
> > 00 = 5.5 V (Default)
> > :
> > 110010 = 6.5 V
> >
> > 110011 to 11 map to 6.5 V <- Should never see 6.6v from LDO
> >
> > Page 7 of the Datasheet says range is 4v->6.5v
> Hi Dan,
>
> The device indeed can only support up to 6.5V, the point is you are using
> linear equation to calculate the voltage of each selecter.
> In your current code:
> #define LM36274_LDO_VSEL_MAX   0x34 (and it's .n_voltages)
> So it supports selector 0 ... 0x33.
> For selector 0x33 in the linear equation is
> 400 + 5 * 51 = 655 (i.e. 6.55V)
> i.e. The device actually only support up to 6.5V but the driver
> reports it support up to 6.55V
>  because regulator_list_voltage() will return 6.55V for selector 0x33.
> (I have off-by-one in my previous reply because when .n_voltages is
> 0x34, it supports up to 0x33)

Similar comment as I mentioned in another path.
Did you check regulator_list_voltage() output for the boundary case
with and without this patch?


Re: [RFT][PATCH 1/2] regulator: lm363x: Fix off-by-one n_voltages for lm3632 ldo_vpos/ldo_vneg

2019-07-07 Thread Axel Lin
Axel Lin  於 2019年6月26日 週三 下午11:12寫道:
>
> Dan Murphy  於 2019年6月26日 週三 下午11:07寫道:
> >
> > Hello
> >
> > On 6/26/19 8:26 AM, Axel Lin wrote:
> > > According to the datasheet https://www.ti.com/lit/ds/symlink/lm3632a.pdf
> > > Table 20. VPOS Bias Register Field Descriptions VPOS[5:0]
> > > Sets the Positive Display Bias (LDO) Voltage (50 mV per step)
> > > 00: 4 V
> > > 01: 4.05 V
> > > 10: 4.1 V
> > > 
> > > 011101: 5.45 V
> > > 00: 5.5 V (Default)
> > > 01: 5.55 V
> > > 
> > > 100111: 5.95 V
> > > 101000: 6 V
> > > Note: Codes 101001 to 11 map to 6 V
> > >
> > > The LM3632_LDO_VSEL_MAX should be 0b101000 (0x28), so the maximum voltage
> > > can match the datasheet.
> > >
> > > Fixes: 3a8d1a73a037 ("regulator: add LM363X driver")
> > > Signed-off-by: Axel Lin 
> > > ---
> > >   drivers/regulator/lm363x-regulator.c | 2 +-
> > >   1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/regulator/lm363x-regulator.c 
> > > b/drivers/regulator/lm363x-regulator.c
> > > index 5647e2f97ff8..e4a27d63bf90 100644
> > > --- a/drivers/regulator/lm363x-regulator.c
> > > +++ b/drivers/regulator/lm363x-regulator.c
> > > @@ -30,7 +30,7 @@
> > >
> > >   /* LM3632 */
> > >   #define LM3632_BOOST_VSEL_MAX   0x26
> > > -#define LM3632_LDO_VSEL_MAX  0x29
> > > +#define LM3632_LDO_VSEL_MAX  0x28
> >
> > Similar comment as I made on the LM36274
> >
> > These are 0 based registers so it is 28 + 1
> The code shows:  .n_voltages = LM3632_LDO_VSEL_MAX + 1
> so LM3632_LDO_VSEL_MAX needs to be 0x28.
>
> .name   = "ldo_vpos",
> .of_match   = "vpos",
> .id = LM3632_LDO_POS,
> .ops= &lm363x_regulator_voltage_table_ops,
> .n_voltages = LM3632_LDO_VSEL_MAX + 1,

Hi Dan,
I'm wondering if you read my previous reply.
You can try to call regulator_list_voltage() for selector 0x29 with
current code,
I believe it will return 6.05V which is wrong because the h/w only
support up to 6V.
And that is exactly the issue this patch try to fix.

BTW, you seem mixes the meaning of latest valid selector
(LM3632_LDO_VSEL_MAX) with n_voltage
since you mentioned it's 0 based registers.
>From the context all the LM3632_LDO_xxx_MAX are defined as latest
valid selector because you
can find the code: .n_voltages = LM3632_LDO_VSEL_MAX + 1.

Regards,
Axel


Re: [PATCH RESEND] mfd: hi655x-pmic: Fix missing return value check for devm_regmap_init_mmio_clk

2019-06-26 Thread Axel Lin
Hi Chen,

Chen Feng  於 2019年6月27日 週四 上午10:03寫道:
>
> Thanks
I assume this is an Ack.
If you can add your Acked-by in the reply, it's easier for maintainer to accept
the patch.

>
> On 2019/6/26 21:30, Axel Lin wrote:
> > Since devm_regmap_init_mmio_clk can fail, add return value checking.
> >
> > Signed-off-by: Axel Lin 
> > Acked-by: Chen Feng 
> > ---
> > This was sent on https://lkml.org/lkml/2019/3/6/904
> >
> >   drivers/mfd/hi655x-pmic.c | 2 ++
> >   1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/mfd/hi655x-pmic.c b/drivers/mfd/hi655x-pmic.c
> > index 96c07fa1802a..6693f74aa6ab 100644
> > --- a/drivers/mfd/hi655x-pmic.c
> > +++ b/drivers/mfd/hi655x-pmic.c
> > @@ -112,6 +112,8 @@ static int hi655x_pmic_probe(struct platform_device 
> > *pdev)
> >
> >   pmic->regmap = devm_regmap_init_mmio_clk(dev, NULL, base,
> >&hi655x_regmap_config);
> > + if (IS_ERR(pmic->regmap))
> > + return PTR_ERR(pmic->regmap);
> >
> >   regmap_read(pmic->regmap, HI655X_BUS_ADDR(HI655X_VER_REG), 
> > &pmic->ver);
> >   if ((pmic->ver < PMU_VER_START) || (pmic->ver > PMU_VER_END)) {
> >
>


Re: [RFT][PATCH 2/2] regulator: lm363x: Fix n_voltages setting for lm36274

2019-06-26 Thread Axel Lin
> > With your current code where LM36274_LDO_VSEL_MAX and n_voltages is 0x34,
> > the maximum voltage will become 40 + 5 * 0x34 = 6.6V which
> > does not match the datasheet.
>
> Not sure how you get 6.6v the LDO max is 6.5v.
>
> After 0x32->0x7f maps to 6.5v
>
> 00 = 4 V
> 01 = 4.05 V
> :
> 00 = 5.5 V (Default)
> :
> 110010 = 6.5 V
>
> 110011 to 11 map to 6.5 V <- Should never see 6.6v from LDO
>
> Page 7 of the Datasheet says range is 4v->6.5v
Hi Dan,

The device indeed can only support up to 6.5V, the point is you are using
linear equation to calculate the voltage of each selecter.
In your current code:
#define LM36274_LDO_VSEL_MAX   0x34 (and it's .n_voltages)
So it supports selector 0 ... 0x33.
For selector 0x33 in the linear equation is
400 + 5 * 51 = 655 (i.e. 6.55V)
i.e. The device actually only support up to 6.5V but the driver
reports it support up to 6.55V
 because regulator_list_voltage() will return 6.55V for selector 0x33.
(I have off-by-one in my previous reply because when .n_voltages is
0x34, it supports up to 0x33)

Regards,
AXel


Re: [RFT][PATCH 2/2] regulator: lm363x: Fix n_voltages setting for lm36274

2019-06-26 Thread Axel Lin
Dan Murphy  於 2019年6月26日 週三 下午11:07寫道:
>
> Hello
>
> On 6/26/19 8:26 AM, Axel Lin wrote:
> > According to the datasheet http://www.ti.com/lit/ds/symlink/lm36274.pdf:
> > Table 23. VPOS Bias Register Field Descriptions VPOS[5:0]:
> > VPOS voltage (50-mV steps): VPOS = 4 V + (Code × 50 mV), 6.5 V max
> > 00 = 4 V
> > 01 = 4.05 V
> > :
> > 00 = 5.5 V (Default)
> > :
> > 110010 = 6.5 V
> > 110011 to 11 map to 6.5 V
> >
> > So the LM36274_LDO_VSEL_MAX should be 0b110010 (0x32).
> > The valid selectors are 0 ... LM36274_LDO_VSEL_MAX, n_voltages should be
> > LM36274_LDO_VSEL_MAX + 1. Similarly, the n_voltages should be
> > LM36274_BOOST_VSEL_MAX + 1 for LM36274_BOOST.
> >
> > Fixes: bff5e8071533 ("regulator: lm363x: Add support for LM36274")
> > Signed-off-by: Axel Lin 
> > ---
> >   drivers/regulator/lm363x-regulator.c | 8 
> >   1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/regulator/lm363x-regulator.c 
> > b/drivers/regulator/lm363x-regulator.c
> > index e4a27d63bf90..4b9f618b07e9 100644
> > --- a/drivers/regulator/lm363x-regulator.c
> > +++ b/drivers/regulator/lm363x-regulator.c
> > @@ -36,7 +36,7 @@
> >
> >   /* LM36274 */
> >   #define LM36274_BOOST_VSEL_MAX  0x3f
> > -#define LM36274_LDO_VSEL_MAX 0x34
> > +#define LM36274_LDO_VSEL_MAX 0x32
>
> This does not seem correct the max number of voltages are 0x34.
>
> The register is zero based so you can have 33 voltage select levels and
> + 1 is 34 total selectors
>
> Liam/Mark correct me if I am incorrect.

>From the datasheet, the maximum voltage 110010 = 6.5 V, the 0b110010 is 0x32.
I know it is 0 based, so .n_voltages = LM36274_LDO_VSEL_MAX + 1,
(And that coding style is to match the original code.)

With your current code where LM36274_LDO_VSEL_MAX and n_voltages is 0x34,
the maximum voltage will become 40 + 5 * 0x34 = 6.6V which
does not match the datasheet.

Would you mind double check again?


Re: [RFT][PATCH 1/2] regulator: lm363x: Fix off-by-one n_voltages for lm3632 ldo_vpos/ldo_vneg

2019-06-26 Thread Axel Lin
Dan Murphy  於 2019年6月26日 週三 下午11:07寫道:
>
> Hello
>
> On 6/26/19 8:26 AM, Axel Lin wrote:
> > According to the datasheet https://www.ti.com/lit/ds/symlink/lm3632a.pdf
> > Table 20. VPOS Bias Register Field Descriptions VPOS[5:0]
> > Sets the Positive Display Bias (LDO) Voltage (50 mV per step)
> > 00: 4 V
> > 01: 4.05 V
> > 10: 4.1 V
> > 
> > 011101: 5.45 V
> > 00: 5.5 V (Default)
> > 01: 5.55 V
> > 
> > 100111: 5.95 V
> > 101000: 6 V
> > Note: Codes 101001 to 11 map to 6 V
> >
> > The LM3632_LDO_VSEL_MAX should be 0b101000 (0x28), so the maximum voltage
> > can match the datasheet.
> >
> > Fixes: 3a8d1a73a037 ("regulator: add LM363X driver")
> > Signed-off-by: Axel Lin 
> > ---
> >   drivers/regulator/lm363x-regulator.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/regulator/lm363x-regulator.c 
> > b/drivers/regulator/lm363x-regulator.c
> > index 5647e2f97ff8..e4a27d63bf90 100644
> > --- a/drivers/regulator/lm363x-regulator.c
> > +++ b/drivers/regulator/lm363x-regulator.c
> > @@ -30,7 +30,7 @@
> >
> >   /* LM3632 */
> >   #define LM3632_BOOST_VSEL_MAX   0x26
> > -#define LM3632_LDO_VSEL_MAX  0x29
> > +#define LM3632_LDO_VSEL_MAX  0x28
>
> Similar comment as I made on the LM36274
>
> These are 0 based registers so it is 28 + 1
The code shows:  .n_voltages = LM3632_LDO_VSEL_MAX + 1
so LM3632_LDO_VSEL_MAX needs to be 0x28.

.name   = "ldo_vpos",
.of_match   = "vpos",
.id = LM3632_LDO_POS,
.ops= &lm363x_regulator_voltage_table_ops,
.n_voltages = LM3632_LDO_VSEL_MAX + 1,


[PATCH RESEND] mfd: hi655x-pmic: Fix missing return value check for devm_regmap_init_mmio_clk

2019-06-26 Thread Axel Lin
Since devm_regmap_init_mmio_clk can fail, add return value checking.

Signed-off-by: Axel Lin 
Acked-by: Chen Feng 
---
This was sent on https://lkml.org/lkml/2019/3/6/904

 drivers/mfd/hi655x-pmic.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mfd/hi655x-pmic.c b/drivers/mfd/hi655x-pmic.c
index 96c07fa1802a..6693f74aa6ab 100644
--- a/drivers/mfd/hi655x-pmic.c
+++ b/drivers/mfd/hi655x-pmic.c
@@ -112,6 +112,8 @@ static int hi655x_pmic_probe(struct platform_device *pdev)
 
pmic->regmap = devm_regmap_init_mmio_clk(dev, NULL, base,
 &hi655x_regmap_config);
+   if (IS_ERR(pmic->regmap))
+   return PTR_ERR(pmic->regmap);
 
regmap_read(pmic->regmap, HI655X_BUS_ADDR(HI655X_VER_REG), &pmic->ver);
if ((pmic->ver < PMU_VER_START) || (pmic->ver > PMU_VER_END)) {
-- 
2.17.1



[RFT][PATCH 1/2] regulator: lm363x: Fix off-by-one n_voltages for lm3632 ldo_vpos/ldo_vneg

2019-06-26 Thread Axel Lin
According to the datasheet https://www.ti.com/lit/ds/symlink/lm3632a.pdf
Table 20. VPOS Bias Register Field Descriptions VPOS[5:0]
Sets the Positive Display Bias (LDO) Voltage (50 mV per step)
00: 4 V
01: 4.05 V
10: 4.1 V

011101: 5.45 V
00: 5.5 V (Default)
01: 5.55 V

100111: 5.95 V
101000: 6 V
Note: Codes 101001 to 11 map to 6 V

The LM3632_LDO_VSEL_MAX should be 0b101000 (0x28), so the maximum voltage
can match the datasheet.

Fixes: 3a8d1a73a037 ("regulator: add LM363X driver")
Signed-off-by: Axel Lin 
---
 drivers/regulator/lm363x-regulator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/lm363x-regulator.c 
b/drivers/regulator/lm363x-regulator.c
index 5647e2f97ff8..e4a27d63bf90 100644
--- a/drivers/regulator/lm363x-regulator.c
+++ b/drivers/regulator/lm363x-regulator.c
@@ -30,7 +30,7 @@
 
 /* LM3632 */
 #define LM3632_BOOST_VSEL_MAX  0x26
-#define LM3632_LDO_VSEL_MAX0x29
+#define LM3632_LDO_VSEL_MAX0x28
 #define LM3632_VBOOST_MIN  450
 #define LM3632_VLDO_MIN400
 
-- 
2.20.1



[RFT][PATCH 2/2] regulator: lm363x: Fix n_voltages setting for lm36274

2019-06-26 Thread Axel Lin
According to the datasheet http://www.ti.com/lit/ds/symlink/lm36274.pdf:
Table 23. VPOS Bias Register Field Descriptions VPOS[5:0]:
VPOS voltage (50-mV steps): VPOS = 4 V + (Code × 50 mV), 6.5 V max
00 = 4 V
01 = 4.05 V
:
00 = 5.5 V (Default)
:
110010 = 6.5 V
110011 to 11 map to 6.5 V

So the LM36274_LDO_VSEL_MAX should be 0b110010 (0x32).
The valid selectors are 0 ... LM36274_LDO_VSEL_MAX, n_voltages should be
LM36274_LDO_VSEL_MAX + 1. Similarly, the n_voltages should be
LM36274_BOOST_VSEL_MAX + 1 for LM36274_BOOST.

Fixes: bff5e8071533 ("regulator: lm363x: Add support for LM36274")
Signed-off-by: Axel Lin 
---
 drivers/regulator/lm363x-regulator.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/regulator/lm363x-regulator.c 
b/drivers/regulator/lm363x-regulator.c
index e4a27d63bf90..4b9f618b07e9 100644
--- a/drivers/regulator/lm363x-regulator.c
+++ b/drivers/regulator/lm363x-regulator.c
@@ -36,7 +36,7 @@
 
 /* LM36274 */
 #define LM36274_BOOST_VSEL_MAX 0x3f
-#define LM36274_LDO_VSEL_MAX   0x34
+#define LM36274_LDO_VSEL_MAX   0x32
 #define LM36274_VOLTAGE_MIN400
 
 /* Common */
@@ -226,7 +226,7 @@ static const struct regulator_desc lm363x_regulator_desc[] 
= {
.of_match   = "vboost",
.id = LM36274_BOOST,
.ops= &lm363x_boost_voltage_table_ops,
-   .n_voltages = LM36274_BOOST_VSEL_MAX,
+   .n_voltages = LM36274_BOOST_VSEL_MAX + 1,
.min_uV = LM36274_VOLTAGE_MIN,
.uV_step= LM363X_STEP_50mV,
.type   = REGULATOR_VOLTAGE,
@@ -239,7 +239,7 @@ static const struct regulator_desc lm363x_regulator_desc[] 
= {
.of_match   = "vpos",
.id = LM36274_LDO_POS,
.ops= &lm363x_regulator_voltage_table_ops,
-   .n_voltages = LM36274_LDO_VSEL_MAX,
+   .n_voltages = LM36274_LDO_VSEL_MAX + 1,
.min_uV = LM36274_VOLTAGE_MIN,
.uV_step= LM363X_STEP_50mV,
.type   = REGULATOR_VOLTAGE,
@@ -254,7 +254,7 @@ static const struct regulator_desc lm363x_regulator_desc[] 
= {
.of_match   = "vneg",
.id = LM36274_LDO_NEG,
.ops= &lm363x_regulator_voltage_table_ops,
-   .n_voltages = LM36274_LDO_VSEL_MAX,
+   .n_voltages = LM36274_LDO_VSEL_MAX + 1,
.min_uV = LM36274_VOLTAGE_MIN,
.uV_step= LM363X_STEP_50mV,
.type   = REGULATOR_VOLTAGE,
-- 
2.20.1



[PATCH 2/2] regulator: slg51000: Remove unneeded regl_pdata from struct slg51000

2019-05-24 Thread Axel Lin
Just use a local variable *ena_gpiod in slg51000_of_parse_cb instead.
With this change, the struct slg51000_pdata can be removed.

Signed-off-by: Axel Lin 
---
 drivers/regulator/slg51000-regulator.c | 17 ++---
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/regulator/slg51000-regulator.c 
b/drivers/regulator/slg51000-regulator.c
index a06a18f220e0..04b732991d69 100644
--- a/drivers/regulator/slg51000-regulator.c
+++ b/drivers/regulator/slg51000-regulator.c
@@ -35,14 +35,9 @@ enum slg51000_regulators {
SLG51000_MAX_REGULATORS,
 };
 
-struct slg51000_pdata {
-   struct gpio_desc *ena_gpiod;
-};
-
 struct slg51000 {
struct device *dev;
struct regmap *regmap;
-   struct slg51000_pdata regl_pdata[SLG51000_MAX_REGULATORS];
struct regulator_desc *rdesc[SLG51000_MAX_REGULATORS];
struct regulator_dev *rdev[SLG51000_MAX_REGULATORS];
struct gpio_desc *cs_gpiod;
@@ -204,14 +199,14 @@ static int slg51000_of_parse_cb(struct device_node *np,
struct regulator_config *config)
 {
struct slg51000 *chip = config->driver_data;
-   struct slg51000_pdata *rpdata = &chip->regl_pdata[desc->id];
+   struct gpio_desc *ena_gpiod;
enum gpiod_flags gflags = GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE;
 
-   rpdata->ena_gpiod = devm_gpiod_get_from_of_node(chip->dev, np,
-   "enable-gpios", 0,
-   gflags, "gpio-en-ldo");
-   if (rpdata->ena_gpiod) {
-   config->ena_gpiod = rpdata->ena_gpiod;
+   ena_gpiod = devm_gpiod_get_from_of_node(chip->dev, np,
+   "enable-gpios", 0,
+   gflags, "gpio-en-ldo");
+   if (ena_gpiod) {
+   config->ena_gpiod = ena_gpiod;
devm_gpiod_unhinge(chip->dev, config->ena_gpiod);
}
 
-- 
2.20.1



[PATCH 1/2] regulator: slg51000: Constify slg51000_regl_ops and slg51000_switch_ops

2019-05-24 Thread Axel Lin
These regulator_ops variables never need to be modified, make them const so
compiler can put them to .rodata.

Signed-off-by: Axel Lin 
---
 drivers/regulator/slg51000-regulator.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/slg51000-regulator.c 
b/drivers/regulator/slg51000-regulator.c
index 12e21d43030b..a06a18f220e0 100644
--- a/drivers/regulator/slg51000-regulator.c
+++ b/drivers/regulator/slg51000-regulator.c
@@ -183,7 +183,7 @@ static const struct regmap_config slg51000_regmap_config = {
.volatile_table = &slg51000_volatile_table,
 };
 
-static struct regulator_ops slg51000_regl_ops = {
+static const struct regulator_ops slg51000_regl_ops = {
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
@@ -193,7 +193,7 @@ static struct regulator_ops slg51000_regl_ops = {
.set_voltage_sel = regulator_set_voltage_sel_regmap,
 };
 
-static struct regulator_ops slg51000_switch_ops = {
+static const struct regulator_ops slg51000_switch_ops = {
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
-- 
2.20.1



Re: regulator: NULL-pointer dereference in tps6507x

2019-05-23 Thread Axel Lin
Bartosz Golaszewski  於 2019年5月23日 週四 下午5:28寫道:
>
> Hi Axel,
>
> commit f979c08f7624 ("regulator: tps6507x: Convert to regulator core's
> simplified DT parsing code") causes the following crash on da850-evm
> board with linux v5.2-rc1:

The fix is already in regulator tree and linux-next tree:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/drivers/regulator?id=7d293f56456120efa97c4e18250d86d2a05ad0bd

Regards,
Axel


Re: [PATCH] regulator: max77650: Move max77651_SBB1_desc's declaration down

2019-05-22 Thread Axel Lin
Nathan Chancellor  於 2019年5月23日 週四 上午9:27寫道:
>
> Clang warns:
>
> drivers/regulator/max77650-regulator.c:32:39: warning: tentative
> definition of variable with internal linkage has incomplete non-array
> type 'struct max77650_regulator_desc'
> [-Wtentative-definition-incomplete-type]
> static struct max77650_regulator_desc max77651_SBB1_desc;
>   ^
> drivers/regulator/max77650-regulator.c:32:15: note: forward declaration
> of 'struct max77650_regulator_desc'
> static struct max77650_regulator_desc max77651_SBB1_desc;
>   ^
> 1 warning generated.
>
> Move max77651_SBB1_desc's declaration below max77650_regulator_desc's
> definition so this warning does not happen.
>
> Fixes: 3df4235ac41c ("regulator: max77650: Convert MAX77651 SBB1 to pickable 
> linear range")
> Link: https://github.com/ClangBuiltLinux/linux/issues/491
> Signed-off-by: Nathan Chancellor 
Reviewed-by: Axel Lin 


[PATCH RFT] regulator: tps6507x: Fix boot regression due to testing wrong init_data pointer

2019-05-16 Thread Axel Lin
A NULL init_data once incremented will lead to oops, fix it.

Fixes: f979c08f7624 ("regulator: tps6507x: Convert to regulator core's 
simplified DT parsing code")
Reported-by: Sekhar Nori 
Signed-off-by: Axel Lin 
---
Hi Sekhar,
Please check if this patch works, thanks.
Axel
 drivers/regulator/tps6507x-regulator.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/regulator/tps6507x-regulator.c 
b/drivers/regulator/tps6507x-regulator.c
index a1b7fab91dd4..d2a8f69b2665 100644
--- a/drivers/regulator/tps6507x-regulator.c
+++ b/drivers/regulator/tps6507x-regulator.c
@@ -403,12 +403,12 @@ static int tps6507x_pmic_probe(struct platform_device 
*pdev)
/* common for all regulators */
tps->mfd = tps6507x_dev;
 
-   for (i = 0; i < TPS6507X_NUM_REGULATOR; i++, info++, init_data++) {
+   for (i = 0; i < TPS6507X_NUM_REGULATOR; i++, info++) {
/* Register the regulators */
tps->info[i] = info;
-   if (init_data && init_data->driver_data) {
+   if (init_data && init_data[i].driver_data) {
struct tps6507x_reg_platform_data *data =
-   init_data->driver_data;
+   init_data[i].driver_data;
info->defdcdc_default = data->defdcdc_default;
}
 
-- 
2.20.1



Re: [PATCH] spi: bitbang: Fix NULL pointer dereference in spi_unregister_master

2019-05-16 Thread Axel Lin
YueHaibing  於 2019年5月16日 週四 下午3:57寫道:
>
> If spi_register_master fails in spi_bitbang_start
> because device_add failure, We should return the
> error code other than 0, otherwise calling
> spi_bitbang_stop may trigger NULL pointer dereference
> like this:

Reviewed-by: Axel Lin 


[PATCH] regulator: core: Slightly improve readability of _regulator_get_enable_time

2019-05-03 Thread Axel Lin
The logic is equivalent, but it looks more straightforward this way:
If rdev->desc->ops->enable_time is set, call it.
Otherwise fallback to return rdev->desc->enable_time.

Signed-off-by: Axel Lin 
---
 drivers/regulator/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 7f467a0ca8f7..5a5f5ed064b2 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1650,9 +1650,9 @@ static int _regulator_get_enable_time(struct 
regulator_dev *rdev)
 {
if (rdev->constraints && rdev->constraints->enable_time)
return rdev->constraints->enable_time;
-   if (!rdev->desc->ops->enable_time)
-   return rdev->desc->enable_time;
-   return rdev->desc->ops->enable_time(rdev);
+   if (rdev->desc->ops->enable_time)
+   return rdev->desc->ops->enable_time(rdev);
+   return rdev->desc->enable_time;
 }
 
 static struct regulator_supply_alias *regulator_find_supply_alias(
-- 
2.20.1



[PATCH 2/2] regulator: da9xxx: Switch to SPDX identifier

2019-05-02 Thread Axel Lin
Convert Dialog Semiconductor DA9xxx regulator drivers to SPDX identifier.

Signed-off-by: Axel Lin 
---
 drivers/regulator/da903x.c   | 16 ++--
 drivers/regulator/da9052-regulator.c | 20 +++-
 drivers/regulator/da9055-regulator.c | 20 +++-
 drivers/regulator/da9062-regulator.c | 19 +--
 drivers/regulator/da9210-regulator.c | 23 ---
 drivers/regulator/da9210-regulator.h | 17 +
 drivers/regulator/da9211-regulator.c | 20 +---
 drivers/regulator/da9211-regulator.h | 11 +--
 8 files changed, 36 insertions(+), 110 deletions(-)

diff --git a/drivers/regulator/da903x.c b/drivers/regulator/da903x.c
index 33e8f3b8d2bd..5493c3a86426 100644
--- a/drivers/regulator/da903x.c
+++ b/drivers/regulator/da903x.c
@@ -1,13 +1,9 @@
-/*
- * Regulators driver for Dialog Semiconductor DA903x
- *
- * Copyright (C) 2006-2008 Marvell International Ltd.
- * Copyright (C) 2008 Compulab Ltd.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
+// SPDX-License-Identifier: GPL-2.0
+//
+// Regulators driver for Dialog Semiconductor DA903x
+//
+// Copyright (C) 2006-2008 Marvell International Ltd.
+// Copyright (C) 2008 Compulab Ltd.
 
 #include 
 #include 
diff --git a/drivers/regulator/da9052-regulator.c 
b/drivers/regulator/da9052-regulator.c
index b90a7ac3f3de..e18d291c7f21 100644
--- a/drivers/regulator/da9052-regulator.c
+++ b/drivers/regulator/da9052-regulator.c
@@ -1,16 +1,10 @@
-/*
-* da9052-regulator.c: Regulator driver for DA9052
-*
-* Copyright(c) 2011 Dialog Semiconductor Ltd.
-*
-* Author: David Dajun Chen 
-*
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-*/
+// SPDX-License-Identifier: GPL-2.0+
+//
+// da9052-regulator.c: Regulator driver for DA9052
+//
+// Copyright(c) 2011 Dialog Semiconductor Ltd.
+//
+// Author: David Dajun Chen 
 
 #include 
 #include 
diff --git a/drivers/regulator/da9055-regulator.c 
b/drivers/regulator/da9055-regulator.c
index bcbc2fbd7fea..c025ccb1a30a 100644
--- a/drivers/regulator/da9055-regulator.c
+++ b/drivers/regulator/da9055-regulator.c
@@ -1,16 +1,10 @@
-/*
-* Regulator driver for DA9055 PMIC
-*
-* Copyright(c) 2012 Dialog Semiconductor Ltd.
-*
-* Author: David Dajun Chen 
-*
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-*/
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Regulator driver for DA9055 PMIC
+//
+// Copyright(c) 2012 Dialog Semiconductor Ltd.
+//
+// Author: David Dajun Chen 
 
 #include 
 #include 
diff --git a/drivers/regulator/da9062-regulator.c 
b/drivers/regulator/da9062-regulator.c
index a7d929b7776a..a02e0488410f 100644
--- a/drivers/regulator/da9062-regulator.c
+++ b/drivers/regulator/da9062-regulator.c
@@ -1,17 +1,8 @@
-/*
- * Regulator device driver for DA9061 and DA9062.
- * Copyright (C) 2015-2017  Dialog Semiconductor
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Regulator device driver for DA9061 and DA9062.
+// Copyright (C) 2015-2017  Dialog Semiconductor
+
 #include 
 #include 
 #include 
diff --git a/drivers/regulator/da9210-regulator.c 
b/drivers/regulator/da9210-regulator.c
index 528303771723..f9448ed50e05 100644
--- a/drivers/regulator/da9210-regulator.c
+++ b/drivers/regulator/da9210-regulator.c
@@ -1,22 +1,7 @@
-/*
- * da9210-regulator.c - Regulator device driver for DA9210
- * Copyright (C) 2013  Dialog Semiconductor Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have

[PATCH 1/2] regulator: pv880x0: Switch to SPDX identifier

2019-05-02 Thread Axel Lin
Convert Powerventure Semiconductor PV88060/PV88080/PV88090 regulator
drivers to SPDX identifier.

Signed-off-by: Axel Lin 
---
 drivers/regulator/pv88060-regulator.c | 18 --
 drivers/regulator/pv88060-regulator.h | 11 +--
 drivers/regulator/pv88080-regulator.c | 18 --
 drivers/regulator/pv88080-regulator.h | 11 +--
 drivers/regulator/pv88090-regulator.c | 18 --
 drivers/regulator/pv88090-regulator.h | 11 +--
 6 files changed, 15 insertions(+), 72 deletions(-)

diff --git a/drivers/regulator/pv88060-regulator.c 
b/drivers/regulator/pv88060-regulator.c
index 810816e9df5d..3d3415839ba2 100644
--- a/drivers/regulator/pv88060-regulator.c
+++ b/drivers/regulator/pv88060-regulator.c
@@ -1,17 +1,7 @@
-/*
- * pv88060-regulator.c - Regulator device driver for PV88060
- * Copyright (C) 2015  Powerventure Semiconductor Ltd.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// pv88060-regulator.c - Regulator device driver for PV88060
+// Copyright (C) 2015  Powerventure Semiconductor Ltd.
 
 #include 
 #include 
diff --git a/drivers/regulator/pv88060-regulator.h 
b/drivers/regulator/pv88060-regulator.h
index 02ca9203a172..d333dbf3be94 100644
--- a/drivers/regulator/pv88060-regulator.h
+++ b/drivers/regulator/pv88060-regulator.h
@@ -1,16 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * pv88060-regulator.h - Regulator definitions for PV88060
  * Copyright (C) 2015 Powerventure Semiconductor Ltd.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
  */
 
 #ifndef __PV88060_REGISTERS_H__
diff --git a/drivers/regulator/pv88080-regulator.c 
b/drivers/regulator/pv88080-regulator.c
index 6279216fb254..a444f68af1a8 100644
--- a/drivers/regulator/pv88080-regulator.c
+++ b/drivers/regulator/pv88080-regulator.c
@@ -1,17 +1,7 @@
-/*
- * pv88080-regulator.c - Regulator device driver for PV88080
- * Copyright (C) 2016  Powerventure Semiconductor Ltd.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// pv88080-regulator.c - Regulator device driver for PV88080
+// Copyright (C) 2016  Powerventure Semiconductor Ltd.
 
 #include 
 #include 
diff --git a/drivers/regulator/pv88080-regulator.h 
b/drivers/regulator/pv88080-regulator.h
index ae25ff360e3d..7d7f8f11a75a 100644
--- a/drivers/regulator/pv88080-regulator.h
+++ b/drivers/regulator/pv88080-regulator.h
@@ -1,16 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * pv88080-regulator.h - Regulator definitions for PV88080
  * Copyright (C) 2016 Powerventure Semiconductor Ltd.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
  */
 
 #ifndef __PV88080_REGISTERS_H__
diff --git a/drivers/regulator/pv88090-regulator.c 
b/drivers/regulator/pv88090-regulator.c
index 90f4f907fb3f..b1d0d97ae935 100644
--- a/drivers/regulator/pv88090-regulator.c
+++ b/drivers/regulator/pv88090-regulator.c
@@ -1,17 +1,7 @@
-/*
- * pv88090-regulator.c - Regulator device driver for PV88090
- * Copyright (C) 2015  Powerventure Semiconductor Ltd.
- *
- * This program is free software; you can redistribute it and/or

[PATCH 2/2] regulator: ab3100: Set fixed_uV instead of min_uV for fixed regulators

2019-05-02 Thread Axel Lin
Slightly better readability by setting fixed_uV instead of min_uV.

Signed-off-by: Axel Lin 
---
 drivers/regulator/ab3100.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/regulator/ab3100.c b/drivers/regulator/ab3100.c
index edde907a7062..438509f55f05 100644
--- a/drivers/regulator/ab3100.c
+++ b/drivers/regulator/ab3100.c
@@ -354,7 +354,6 @@ static int ab3100_get_voltage_regulator_external(struct 
regulator_dev *reg)
 }
 
 static const struct regulator_ops regulator_ops_fixed = {
-   .list_voltage = regulator_list_voltage_linear,
.enable  = ab3100_enable_regulator,
.disable = ab3100_disable_regulator,
.is_enabled  = ab3100_is_enabled_regulator,
@@ -401,7 +400,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = {
.n_voltages = 1,
.type = REGULATOR_VOLTAGE,
.owner = THIS_MODULE,
-   .min_uV = LDO_A_VOLTAGE,
+   .fixed_uV = LDO_A_VOLTAGE,
.enable_time = 200,
},
{
@@ -411,7 +410,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = {
.n_voltages = 1,
.type = REGULATOR_VOLTAGE,
.owner = THIS_MODULE,
-   .min_uV = LDO_C_VOLTAGE,
+   .fixed_uV = LDO_C_VOLTAGE,
.enable_time = 200,
},
{
@@ -421,7 +420,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = {
.n_voltages = 1,
.type = REGULATOR_VOLTAGE,
.owner = THIS_MODULE,
-   .min_uV = LDO_D_VOLTAGE,
+   .fixed_uV = LDO_D_VOLTAGE,
.enable_time = 200,
},
{
-- 
2.20.1



[PATCH 1/2] regulator: ab3100: Constify regulator_ops and ab3100_regulator_desc

2019-05-02 Thread Axel Lin
These regulator_ops variables and ab3100_regulator_desc array never need
to be modified, make them const so compiler can put them to .rodata.

Signed-off-by: Axel Lin 
---
 drivers/regulator/ab3100.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/regulator/ab3100.c b/drivers/regulator/ab3100.c
index c92966a79a7e..edde907a7062 100644
--- a/drivers/regulator/ab3100.c
+++ b/drivers/regulator/ab3100.c
@@ -353,14 +353,14 @@ static int ab3100_get_voltage_regulator_external(struct 
regulator_dev *reg)
return 0;
 }
 
-static struct regulator_ops regulator_ops_fixed = {
+static const struct regulator_ops regulator_ops_fixed = {
.list_voltage = regulator_list_voltage_linear,
.enable  = ab3100_enable_regulator,
.disable = ab3100_disable_regulator,
.is_enabled  = ab3100_is_enabled_regulator,
 };
 
-static struct regulator_ops regulator_ops_variable = {
+static const struct regulator_ops regulator_ops_variable = {
.enable  = ab3100_enable_regulator,
.disable = ab3100_disable_regulator,
.is_enabled  = ab3100_is_enabled_regulator,
@@ -369,7 +369,7 @@ static struct regulator_ops regulator_ops_variable = {
.list_voltage = regulator_list_voltage_table,
 };
 
-static struct regulator_ops regulator_ops_variable_sleepable = {
+static const struct regulator_ops regulator_ops_variable_sleepable = {
.enable  = ab3100_enable_regulator,
.disable = ab3100_disable_regulator,
.is_enabled  = ab3100_is_enabled_regulator,
@@ -385,14 +385,14 @@ static struct regulator_ops 
regulator_ops_variable_sleepable = {
  * is an on/off switch plain an simple. The external
  * voltage is defined in the board set-up if any.
  */
-static struct regulator_ops regulator_ops_external = {
+static const struct regulator_ops regulator_ops_external = {
.enable  = ab3100_enable_regulator,
.disable = ab3100_disable_regulator,
.is_enabled  = ab3100_is_enabled_regulator,
.get_voltage = ab3100_get_voltage_regulator_external,
 };
 
-static struct regulator_desc
+static const struct regulator_desc
 ab3100_regulator_desc[AB3100_NUM_REGULATORS] = {
{
.name = "LDO_A",
@@ -499,7 +499,7 @@ static int ab3100_regulator_register(struct platform_device 
*pdev,
 struct device_node *np,
 unsigned long id)
 {
-   struct regulator_desc *desc;
+   const struct regulator_desc *desc;
struct ab3100_regulator *reg;
struct regulator_dev *rdev;
struct regulator_config config = { };
@@ -688,7 +688,7 @@ static int ab3100_regulators_probe(struct platform_device 
*pdev)
 
/* Register the regulators */
for (i = 0; i < AB3100_NUM_REGULATORS; i++) {
-   struct regulator_desc *desc = &ab3100_regulator_desc[i];
+   const struct regulator_desc *desc = &ab3100_regulator_desc[i];
 
err = ab3100_regulator_register(pdev, plfdata, NULL, NULL,
desc->id);
-- 
2.20.1



[PATCH] regulator: hi6xxx: Switch to SPDX identifier

2019-04-30 Thread Axel Lin
Convert HiSilicon hi6xxx PMIC drivers to SPDX identifier.

Signed-off-by: Axel Lin 
---
 drivers/regulator/hi6421-regulator.c | 24 +-
 drivers/regulator/hi6421v530-regulator.c | 26 ++--
 drivers/regulator/hi655x-regulator.c | 22 
 3 files changed, 30 insertions(+), 42 deletions(-)

diff --git a/drivers/regulator/hi6421-regulator.c 
b/drivers/regulator/hi6421-regulator.c
index 6c7ea4eb4bb0..5ac3d7c29725 100644
--- a/drivers/regulator/hi6421-regulator.c
+++ b/drivers/regulator/hi6421-regulator.c
@@ -1,17 +1,13 @@
-/*
- * Device driver for regulators in Hi6421 IC
- *
- * Copyright (c) <2011-2014> HiSilicon Technologies Co., Ltd.
- *  http://www.hisilicon.com
- * Copyright (c) <2013-2014> Linaro Ltd.
- *  http://www.linaro.org
- *
- * Author: Guodong Xu 
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
+// SPDX-License-Identifier: GPL-2.0
+//
+// Device driver for regulators in Hi6421 IC
+//
+// Copyright (c) <2011-2014> HiSilicon Technologies Co., Ltd.
+//  http://www.hisilicon.com
+// Copyright (c) <2013-2014> Linaro Ltd.
+//  http://www.linaro.org
+//
+// Author: Guodong Xu 
 
 #include 
 #include 
diff --git a/drivers/regulator/hi6421v530-regulator.c 
b/drivers/regulator/hi6421v530-regulator.c
index c09bc71538a5..06ae65199afd 100644
--- a/drivers/regulator/hi6421v530-regulator.c
+++ b/drivers/regulator/hi6421v530-regulator.c
@@ -1,18 +1,14 @@
-/*
- * Device driver for regulators in Hi6421V530 IC
- *
- * Copyright (c) <2017> HiSilicon Technologies Co., Ltd.
- *  http://www.hisilicon.com
- * Copyright (c) <2017> Linaro Ltd.
- *  http://www.linaro.org
- *
- * Author: Wang Xiaoyin 
- * Guodong Xu 
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
+// SPDX-License-Identifier: GPL-2.0
+//
+// Device driver for regulators in Hi6421V530 IC
+//
+// Copyright (c) <2017> HiSilicon Technologies Co., Ltd.
+//  http://www.hisilicon.com
+// Copyright (c) <2017> Linaro Ltd.
+//  http://www.linaro.org
+//
+// Author: Wang Xiaoyin 
+// Guodong Xu 
 
 #include 
 #include 
diff --git a/drivers/regulator/hi655x-regulator.c 
b/drivers/regulator/hi655x-regulator.c
index 6f6635daa026..ac2ee2030211 100644
--- a/drivers/regulator/hi655x-regulator.c
+++ b/drivers/regulator/hi655x-regulator.c
@@ -1,16 +1,12 @@
-/*
- * Device driver for regulators in Hi655x IC
- *
- * Copyright (c) 2016 Hisilicon.
- *
- * Authors:
- * Chen Feng 
- * Fei  Wang 
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
+// SPDX-License-Identifier: GPL-2.0
+//
+// Device driver for regulators in Hi655x IC
+//
+// Copyright (c) 2016 Hisilicon.
+//
+// Authors:
+// Chen Feng 
+// Fei  Wang 
 
 #include 
 #include 
-- 
2.17.1



[PATCH 2/2] regulator: stm32-pwr: Remove unneeded .min_uV and .list_volage

2019-04-30 Thread Axel Lin
For fixed regulator, setting .n_voltages = 1 and .fixed_uV is enough,
no need to set .min_uV and .list_volage.

Signed-off-by: Axel Lin 
---
 drivers/regulator/stm32-pwr.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/regulator/stm32-pwr.c b/drivers/regulator/stm32-pwr.c
index 8bd15e4d2cea..e0e627b0106e 100644
--- a/drivers/regulator/stm32-pwr.c
+++ b/drivers/regulator/stm32-pwr.c
@@ -102,7 +102,6 @@ static int stm32_pwr_reg_disable(struct regulator_dev *rdev)
 }
 
 static const struct regulator_ops stm32_pwr_reg_ops = {
-   .list_voltage   = regulator_list_voltage_linear,
.enable = stm32_pwr_reg_enable,
.disable= stm32_pwr_reg_disable,
.is_enabled = stm32_pwr_reg_is_enabled,
@@ -115,7 +114,6 @@ static const struct regulator_ops stm32_pwr_reg_ops = {
.of_match = of_match_ptr(_name), \
.n_voltages = 1, \
.type = REGULATOR_VOLTAGE, \
-   .min_uV = _volt, \
.fixed_uV = _volt, \
.ops = &stm32_pwr_reg_ops, \
.enable_mask = _en, \
-- 
2.17.1



[PATCH 1/2] regulator: stm32-pwr: Remove unneeded *desc from struct stm32_pwr_reg

2019-04-30 Thread Axel Lin
Just use rdev->desc instead.

Signed-off-by: Axel Lin 
---
 drivers/regulator/stm32-pwr.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/regulator/stm32-pwr.c b/drivers/regulator/stm32-pwr.c
index 7b39a41530d4..8bd15e4d2cea 100644
--- a/drivers/regulator/stm32-pwr.c
+++ b/drivers/regulator/stm32-pwr.c
@@ -40,7 +40,6 @@ static u32 ready_mask_table[STM32PWR_REG_NUM_REGS] = {
 
 struct stm32_pwr_reg {
void __iomem *base;
-   const struct regulator_desc *desc;
u32 ready_mask;
 };
 
@@ -61,7 +60,7 @@ static int stm32_pwr_reg_is_enabled(struct regulator_dev 
*rdev)
 
val = readl_relaxed(priv->base + REG_PWR_CR3);
 
-   return (val & priv->desc->enable_mask);
+   return (val & rdev->desc->enable_mask);
 }
 
 static int stm32_pwr_reg_enable(struct regulator_dev *rdev)
@@ -71,7 +70,7 @@ static int stm32_pwr_reg_enable(struct regulator_dev *rdev)
u32 val;
 
val = readl_relaxed(priv->base + REG_PWR_CR3);
-   val |= priv->desc->enable_mask;
+   val |= rdev->desc->enable_mask;
writel_relaxed(val, priv->base + REG_PWR_CR3);
 
/* use an arbitrary timeout of 20ms */
@@ -90,7 +89,7 @@ static int stm32_pwr_reg_disable(struct regulator_dev *rdev)
u32 val;
 
val = readl_relaxed(priv->base + REG_PWR_CR3);
-   val &= ~priv->desc->enable_mask;
+   val &= ~rdev->desc->enable_mask;
writel_relaxed(val, priv->base + REG_PWR_CR3);
 
/* use an arbitrary timeout of 20ms */
@@ -153,7 +152,6 @@ static int stm32_pwr_regulator_probe(struct platform_device 
*pdev)
if (!priv)
return -ENOMEM;
priv->base = base;
-   priv->desc = &stm32_pwr_desc[i];
priv->ready_mask = ready_mask_table[i];
config.driver_data = priv;
 
-- 
2.17.1



[PATCH 2/2] regulator: vexpress: Switch to SPDX identifier

2019-04-29 Thread Axel Lin
Signed-off-by: Axel Lin 
---
 drivers/regulator/vexpress-regulator.c | 15 +++
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/regulator/vexpress-regulator.c 
b/drivers/regulator/vexpress-regulator.c
index a15a1319436a..1235f46e633e 100644
--- a/drivers/regulator/vexpress-regulator.c
+++ b/drivers/regulator/vexpress-regulator.c
@@ -1,15 +1,6 @@
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * Copyright (C) 2012 ARM Limited
- */
+// SPDX-License-Identifier: GPL-2.0
+//
+// Copyright (C) 2012 ARM Limited
 
 #define DRVNAME "vexpress-regulator"
 #define pr_fmt(fmt) DRVNAME ": " fmt
-- 
2.20.1



[PATCH 1/2] regulator: vexpress: Get rid of struct vexpress_regulator

2019-04-29 Thread Axel Lin
The *regdev and *regmap can be replaced by local variables in probe().
Only desc of struct vexpress_regulator is really need, so just use
struct regulator_desc directly and remove struct vexpress_regulator.

Signed-off-by: Axel Lin 
---
 drivers/regulator/vexpress-regulator.c | 53 +++---
 1 file changed, 22 insertions(+), 31 deletions(-)

diff --git a/drivers/regulator/vexpress-regulator.c 
b/drivers/regulator/vexpress-regulator.c
index ca4230fe9e77..a15a1319436a 100644
--- a/drivers/regulator/vexpress-regulator.c
+++ b/drivers/regulator/vexpress-regulator.c
@@ -23,17 +23,10 @@
 #include 
 #include 
 
-struct vexpress_regulator {
-   struct regulator_desc desc;
-   struct regulator_dev *regdev;
-   struct regmap *regmap;
-};
-
 static int vexpress_regulator_get_voltage(struct regulator_dev *regdev)
 {
-   struct vexpress_regulator *reg = rdev_get_drvdata(regdev);
-   u32 uV;
-   int err = regmap_read(reg->regmap, 0, &uV);
+   unsigned int uV;
+   int err = regmap_read(regdev->regmap, 0, &uV);
 
return err ? err : uV;
 }
@@ -41,9 +34,7 @@ static int vexpress_regulator_get_voltage(struct 
regulator_dev *regdev)
 static int vexpress_regulator_set_voltage(struct regulator_dev *regdev,
int min_uV, int max_uV, unsigned *selector)
 {
-   struct vexpress_regulator *reg = rdev_get_drvdata(regdev);
-
-   return regmap_write(reg->regmap, 0, min_uV);
+   return regmap_write(regdev->regmap, 0, min_uV);
 }
 
 static const struct regulator_ops vexpress_regulator_ops_ro = {
@@ -57,44 +48,44 @@ static const struct regulator_ops vexpress_regulator_ops = {
 
 static int vexpress_regulator_probe(struct platform_device *pdev)
 {
-   struct vexpress_regulator *reg;
+   struct regulator_desc *desc;
struct regulator_init_data *init_data;
struct regulator_config config = { };
+   struct regulator_dev *rdev;
+   struct regmap *regmap;
 
-   reg = devm_kzalloc(&pdev->dev, sizeof(*reg), GFP_KERNEL);
-   if (!reg)
+   desc = devm_kzalloc(&pdev->dev, sizeof(*desc), GFP_KERNEL);
+   if (!desc)
return -ENOMEM;
 
-   reg->regmap = devm_regmap_init_vexpress_config(&pdev->dev);
-   if (IS_ERR(reg->regmap))
-   return PTR_ERR(reg->regmap);
+   regmap = devm_regmap_init_vexpress_config(&pdev->dev);
+   if (IS_ERR(regmap))
+   return PTR_ERR(regmap);
 
-   reg->desc.name = dev_name(&pdev->dev);
-   reg->desc.type = REGULATOR_VOLTAGE;
-   reg->desc.owner = THIS_MODULE;
-   reg->desc.continuous_voltage_range = true;
+   desc->name = dev_name(&pdev->dev);
+   desc->type = REGULATOR_VOLTAGE;
+   desc->owner = THIS_MODULE;
+   desc->continuous_voltage_range = true;
 
init_data = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node,
-  ®->desc);
+  desc);
if (!init_data)
return -EINVAL;
 
init_data->constraints.apply_uV = 0;
if (init_data->constraints.min_uV && init_data->constraints.max_uV)
-   reg->desc.ops = &vexpress_regulator_ops;
+   desc->ops = &vexpress_regulator_ops;
else
-   reg->desc.ops = &vexpress_regulator_ops_ro;
+   desc->ops = &vexpress_regulator_ops_ro;
 
+   config.regmap = regmap;
config.dev = &pdev->dev;
config.init_data = init_data;
-   config.driver_data = reg;
config.of_node = pdev->dev.of_node;
 
-   reg->regdev = devm_regulator_register(&pdev->dev, ®->desc, &config);
-   if (IS_ERR(reg->regdev))
-   return PTR_ERR(reg->regdev);
-
-   platform_set_drvdata(pdev, reg);
+   rdev = devm_regulator_register(&pdev->dev, desc, &config);
+   if (IS_ERR(rdev))
+   return PTR_ERR(rdev);
 
return 0;
 }
-- 
2.20.1



regulator: Several commits are disappear in regulator tree

2019-04-25 Thread Axel Lin
Hi Mark,

I found the commits between 2019-04-10 ~ 2019-04-17 are disappear
since linux-next 20190424:

linux-next 20190418:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/log/drivers/regulator?h=next-20190418

linux-next 20190424:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/log/drivers/regulator?h=next-20190424

I cannot find these missing commits in regulator tree now.

Regards,
Axel


[PATCH RESEND] regulator: max77620: Fix regulator info setting for max20024

2019-04-21 Thread Axel Lin
Current code always set pmic->rinfo[id] = &max77620_regs_info[id];
It should set to either max77620_regs_info or max20024_regs_info
depends on the chip_id.

Signed-off-by: Axel Lin 
---
This was sent on https://lkml.org/lkml/2019/2/23/482

 drivers/regulator/max77620-regulator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/max77620-regulator.c 
b/drivers/regulator/max77620-regulator.c
index 1607ac673e44..0ad91a7f9cb9 100644
--- a/drivers/regulator/max77620-regulator.c
+++ b/drivers/regulator/max77620-regulator.c
@@ -803,7 +803,7 @@ static int max77620_regulator_probe(struct platform_device 
*pdev)
continue;
 
rdesc = &rinfo[id].desc;
-   pmic->rinfo[id] = &max77620_regs_info[id];
+   pmic->rinfo[id] = &rinfo[id];
pmic->enable_power_mode[id] = MAX77620_POWER_MODE_NORMAL;
pmic->reg_pdata[id].active_fps_src = -1;
pmic->reg_pdata[id].active_fps_pd_slot = -1;
-- 
2.17.1



[PATCH] regulator: mt63xx: Switch to SPDX identifier

2019-04-20 Thread Axel Lin
Convert MediaTek mt63xx PMIC drivers to SPDX identifier.

Signed-off-by: Axel Lin 
---
 drivers/regulator/mt6311-regulator.c | 17 -
 drivers/regulator/mt6311-regulator.h | 10 +-
 drivers/regulator/mt6323-regulator.c | 12 
 drivers/regulator/mt6380-regulator.c | 17 -
 drivers/regulator/mt6397-regulator.c | 17 -
 5 files changed, 17 insertions(+), 56 deletions(-)

diff --git a/drivers/regulator/mt6311-regulator.c 
b/drivers/regulator/mt6311-regulator.c
index 01d69f43d2b0..af95449d3590 100644
--- a/drivers/regulator/mt6311-regulator.c
+++ b/drivers/regulator/mt6311-regulator.c
@@ -1,16 +1,7 @@
-/*
- * Copyright (c) 2015 MediaTek Inc.
- * Author: Henry Chen 
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
+// SPDX-License-Identifier: GPL-2.0
+//
+// Copyright (c) 2015 MediaTek Inc.
+// Author: Henry Chen 
 
 #include 
 #include 
diff --git a/drivers/regulator/mt6311-regulator.h 
b/drivers/regulator/mt6311-regulator.h
index 5218db46a798..4904d6751714 100644
--- a/drivers/regulator/mt6311-regulator.h
+++ b/drivers/regulator/mt6311-regulator.h
@@ -1,15 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  * Copyright (c) 2015 MediaTek Inc.
  * Author: Henry Chen 
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
  */
 
 #ifndef __MT6311_REGULATOR_H__
diff --git a/drivers/regulator/mt6323-regulator.c 
b/drivers/regulator/mt6323-regulator.c
index 25b002328910..893ea190788a 100644
--- a/drivers/regulator/mt6323-regulator.c
+++ b/drivers/regulator/mt6323-regulator.c
@@ -1,11 +1,7 @@
-/*
- * Copyright (c) 2016 MediaTek Inc.
- * Author: Chen Zhong 
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
+// SPDX-License-Identifier: GPL-2.0
+//
+// Copyright (c) 2016 MediaTek Inc.
+// Author: Chen Zhong 
 
 #include 
 #include 
diff --git a/drivers/regulator/mt6380-regulator.c 
b/drivers/regulator/mt6380-regulator.c
index 86bc332df3f2..b6aed090b5e0 100644
--- a/drivers/regulator/mt6380-regulator.c
+++ b/drivers/regulator/mt6380-regulator.c
@@ -1,16 +1,7 @@
-/*
- * Copyright (c) 2017 MediaTek Inc.
- * Author: Chenglin Xu 
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
+// SPDX-License-Identifier: GPL-2.0
+//
+// Copyright (c) 2017 MediaTek Inc.
+// Author: Chenglin Xu 
 
 #include 
 #include 
diff --git a/drivers/regulator/mt6397-regulator.c 
b/drivers/regulator/mt6397-regulator.c
index 3e6c8d99ec0f..fd9ed864a0c1 100644
--- a/drivers/regulator/mt6397-regulator.c
+++ b/drivers/regulator/mt6397-regulator.c
@@ -1,16 +1,7 @@
-/*
- * Copyright (c) 2014 MediaTek Inc.
- * Author: Flora Fu 
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
+// SPDX-License-Identifier: GPL-2.0
+//
+// Copyright (c) 2014 MediaTek Inc.
+// Author: Flora Fu 
 
 #include 
 #include 
-- 
2.17.1



[PATCH 1/2] regulator: sky81452: Constify sky81452_reg_ops

2019-04-20 Thread Axel Lin
sky81452_reg_ops is never changed, make it const.

Signed-off-by: Axel Lin 
---
 drivers/regulator/sky81452-regulator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/sky81452-regulator.c 
b/drivers/regulator/sky81452-regulator.c
index 647860611916..eb2b60968a1a 100644
--- a/drivers/regulator/sky81452-regulator.c
+++ b/drivers/regulator/sky81452-regulator.c
@@ -34,7 +34,7 @@
 #define SKY81452_LEN   0x40
 #define SKY81452_LOUT  0x1F
 
-static struct regulator_ops sky81452_reg_ops = {
+static const struct regulator_ops sky81452_reg_ops = {
.list_voltage = regulator_list_voltage_linear_range,
.map_voltage = regulator_map_voltage_linear_range,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
-- 
2.17.1



[PATCH 2/2] regulator: sky81452: Switch to SPDX identifier

2019-04-20 Thread Axel Lin
Signed-off-by: Axel Lin 
---
 drivers/regulator/sky81452-regulator.c | 24 ++--
 1 file changed, 6 insertions(+), 18 deletions(-)

diff --git a/drivers/regulator/sky81452-regulator.c 
b/drivers/regulator/sky81452-regulator.c
index eb2b60968a1a..177dede82a61 100644
--- a/drivers/regulator/sky81452-regulator.c
+++ b/drivers/regulator/sky81452-regulator.c
@@ -1,21 +1,9 @@
-/*
- * sky81452-regulator.cSKY81452 regulator driver
- *
- * Copyright 2014 Skyworks Solutions Inc.
- * Author : Gyungoh Yoo 
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, see <http://www.gnu.org/licenses/>.
- */
+// SPDX-License-Identifier: GPL-2.0
+//
+// sky81452-regulator.cSKY81452 regulator driver
+//
+// Copyright 2014 Skyworks Solutions Inc.
+// Author : Gyungoh Yoo 
 
 #include 
 #include 
-- 
2.17.1



[PATCH] regulator: sy8106a: Get rid of struct sy8106a

2019-04-19 Thread Axel Lin
All the fields in struct sy8106a are only used in sy8106a_i2c_probe(), so
use local variables instead.

Signed-off-by: Axel Lin 
---
 drivers/regulator/sy8106a-regulator.c | 40 +--
 1 file changed, 13 insertions(+), 27 deletions(-)

diff --git a/drivers/regulator/sy8106a-regulator.c 
b/drivers/regulator/sy8106a-regulator.c
index 65fbd1f0b612..42e03b2c10a0 100644
--- a/drivers/regulator/sy8106a-regulator.c
+++ b/drivers/regulator/sy8106a-regulator.c
@@ -22,12 +22,6 @@
  */
 #define SY8106A_GO_BIT BIT(7)
 
-struct sy8106a {
-   struct regulator_dev *rdev;
-   struct regmap *regmap;
-   u32 fixed_voltage;
-};
-
 static const struct regmap_config sy8106a_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
@@ -70,36 +64,32 @@ static const struct regulator_desc sy8106a_reg = {
 static int sy8106a_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
 {
-   struct sy8106a *chip;
struct device *dev = &i2c->dev;
-   struct regulator_dev *rdev = NULL;
+   struct regulator_dev *rdev;
struct regulator_config config = { };
+   struct regmap *regmap;
unsigned int reg, vsel;
+   u32 fixed_voltage;
int error;
 
-   chip = devm_kzalloc(&i2c->dev, sizeof(struct sy8106a), GFP_KERNEL);
-   if (!chip)
-   return -ENOMEM;
-
error = of_property_read_u32(dev->of_node, "silergy,fixed-microvolt",
-&chip->fixed_voltage);
+&fixed_voltage);
if (error)
return error;
 
-   if (chip->fixed_voltage < SY8106A_MIN_MV * 1000 ||
-   chip->fixed_voltage > SY8106A_MAX_MV * 1000)
+   if (fixed_voltage < SY8106A_MIN_MV * 1000 ||
+   fixed_voltage > SY8106A_MAX_MV * 1000)
return -EINVAL;
 
-   chip->regmap = devm_regmap_init_i2c(i2c, &sy8106a_regmap_config);
-   if (IS_ERR(chip->regmap)) {
-   error = PTR_ERR(chip->regmap);
+   regmap = devm_regmap_init_i2c(i2c, &sy8106a_regmap_config);
+   if (IS_ERR(regmap)) {
+   error = PTR_ERR(regmap);
dev_err(dev, "Failed to allocate register map: %d\n", error);
return error;
}
 
config.dev = &i2c->dev;
-   config.regmap = chip->regmap;
-   config.driver_data = chip;
+   config.regmap = regmap;
 
config.of_node = dev->of_node;
config.init_data = of_get_regulator_init_data(dev, dev->of_node,
@@ -109,15 +99,15 @@ static int sy8106a_i2c_probe(struct i2c_client *i2c,
return -ENOMEM;
 
/* Ensure GO_BIT is enabled when probing */
-   error = regmap_read(chip->regmap, SY8106A_REG_VOUT1_SEL, ®);
+   error = regmap_read(regmap, SY8106A_REG_VOUT1_SEL, ®);
if (error)
return error;
 
if (!(reg & SY8106A_GO_BIT)) {
-   vsel = (chip->fixed_voltage / 1000 - SY8106A_MIN_MV) /
+   vsel = (fixed_voltage / 1000 - SY8106A_MIN_MV) /
   SY8106A_STEP_MV;
 
-   error = regmap_write(chip->regmap, SY8106A_REG_VOUT1_SEL,
+   error = regmap_write(regmap, SY8106A_REG_VOUT1_SEL,
 vsel | SY8106A_GO_BIT);
if (error)
return error;
@@ -131,10 +121,6 @@ static int sy8106a_i2c_probe(struct i2c_client *i2c,
return error;
}
 
-   chip->rdev = rdev;
-
-   i2c_set_clientdata(i2c, chip);
-
return 0;
 }
 
-- 
2.17.1



[PATCH 1/2] regulator: fan53555: Clean up unneeded fields from struct fan53555_device_info

2019-04-18 Thread Axel Lin
The *regmap and *rdev can be replaced by local variables.
The slew_rate is no longer used since commit dd7e71fbeefe
("regulator: fan53555: use set_ramp_delay to set the ramp up slew rate").

Signed-off-by: Axel Lin 
---
 drivers/regulator/fan53555.c | 36 +---
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c
index 771a06d1900d..e2caf4173ab5 100644
--- a/drivers/regulator/fan53555.c
+++ b/drivers/regulator/fan53555.c
@@ -91,10 +91,8 @@ enum {
 
 struct fan53555_device_info {
enum fan53555_vendor vendor;
-   struct regmap *regmap;
struct device *dev;
struct regulator_desc desc;
-   struct regulator_dev *rdev;
struct regulator_init_data *regulator;
/* IC Type and Rev */
int chip_id;
@@ -106,8 +104,6 @@ struct fan53555_device_info {
unsigned int vsel_min;
unsigned int vsel_step;
unsigned int vsel_count;
-   /* Voltage slew rate limiting */
-   unsigned int slew_rate;
/* Mode */
unsigned int mode_reg;
unsigned int mode_mask;
@@ -125,7 +121,7 @@ static int fan53555_set_suspend_voltage(struct 
regulator_dev *rdev, int uV)
ret = regulator_map_voltage_linear(rdev, uV, uV);
if (ret < 0)
return ret;
-   ret = regmap_update_bits(di->regmap, di->sleep_reg,
+   ret = regmap_update_bits(rdev->regmap, di->sleep_reg,
 di->desc.vsel_mask, ret);
if (ret < 0)
return ret;
@@ -140,7 +136,7 @@ static int fan53555_set_suspend_enable(struct regulator_dev 
*rdev)
 {
struct fan53555_device_info *di = rdev_get_drvdata(rdev);
 
-   return regmap_update_bits(di->regmap, di->sleep_reg,
+   return regmap_update_bits(rdev->regmap, di->sleep_reg,
  VSEL_BUCK_EN, VSEL_BUCK_EN);
 }
 
@@ -148,7 +144,7 @@ static int fan53555_set_suspend_disable(struct 
regulator_dev *rdev)
 {
struct fan53555_device_info *di = rdev_get_drvdata(rdev);
 
-   return regmap_update_bits(di->regmap, di->sleep_reg,
+   return regmap_update_bits(rdev->regmap, di->sleep_reg,
  VSEL_BUCK_EN, 0);
 }
 
@@ -158,11 +154,11 @@ static int fan53555_set_mode(struct regulator_dev *rdev, 
unsigned int mode)
 
switch (mode) {
case REGULATOR_MODE_FAST:
-   regmap_update_bits(di->regmap, di->mode_reg,
+   regmap_update_bits(rdev->regmap, di->mode_reg,
   di->mode_mask, di->mode_mask);
break;
case REGULATOR_MODE_NORMAL:
-   regmap_update_bits(di->regmap, di->vol_reg, di->mode_mask, 0);
+   regmap_update_bits(rdev->regmap, di->vol_reg, di->mode_mask, 0);
break;
default:
return -EINVAL;
@@ -176,7 +172,7 @@ static unsigned int fan53555_get_mode(struct regulator_dev 
*rdev)
unsigned int val;
int ret = 0;
 
-   ret = regmap_read(di->regmap, di->mode_reg, &val);
+   ret = regmap_read(rdev->regmap, di->mode_reg, &val);
if (ret < 0)
return ret;
if (val & di->mode_mask)
@@ -213,7 +209,7 @@ static int fan53555_set_ramp(struct regulator_dev *rdev, 
int ramp)
return -EINVAL;
}
 
-   return regmap_update_bits(di->regmap, FAN53555_CONTROL,
+   return regmap_update_bits(rdev->regmap, FAN53555_CONTROL,
  CTL_SLEW_MASK, regval << CTL_SLEW_SHIFT);
 }
 
@@ -396,6 +392,7 @@ static int fan53555_regulator_register(struct 
fan53555_device_info *di,
struct regulator_config *config)
 {
struct regulator_desc *rdesc = &di->desc;
+   struct regulator_dev *rdev;
 
rdesc->name = "fan53555-reg";
rdesc->supply_name = "vin";
@@ -410,8 +407,8 @@ static int fan53555_regulator_register(struct 
fan53555_device_info *di,
rdesc->vsel_mask = di->vsel_count - 1;
rdesc->owner = THIS_MODULE;
 
-   di->rdev = devm_regulator_register(di->dev, &di->desc, config);
-   return PTR_ERR_OR_ZERO(di->rdev);
+   rdev = devm_regulator_register(di->dev, &di->desc, config);
+   return PTR_ERR_OR_ZERO(rdev);
 }
 
 static const struct regmap_config fan53555_regmap_config = {
@@ -466,6 +463,7 @@ static int fan53555_regulator_probe(struct i2c_client 
*client,
struct fan53555_device_info *di;
struct fan53555_platform_data *pdata;
struct regulator_config config = { };
+   struct regmap *regmap;
unsigned int val;
int ret;
 
@@ -502,22 +500,22 @@ static int fan53555_regulator_probe(struct i2c_client 
*client,
di->vendor = id-&

[PATCH 2/2] regulator: fan53555: Switch to SPDX identifier

2019-04-18 Thread Axel Lin
Signed-off-by: Axel Lin 
---
 drivers/regulator/fan53555.c | 24 ++--
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c
index e2caf4173ab5..dbe477da4e55 100644
--- a/drivers/regulator/fan53555.c
+++ b/drivers/regulator/fan53555.c
@@ -1,17 +1,13 @@
-/*
- * FAN53555 Fairchild Digitally Programmable TinyBuck Regulator Driver.
- *
- * Supported Part Numbers:
- * FAN53555UC00X/01X/03X/04X/05X
- *
- * Copyright (c) 2012 Marvell Technology Ltd.
- * Yunfan Zhang 
- *
- * This package is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- */
+// SPDX-License-Identifier: GPL-2.0
+//
+// FAN53555 Fairchild Digitally Programmable TinyBuck Regulator Driver.
+//
+// Supported Part Numbers:
+// FAN53555UC00X/01X/03X/04X/05X
+//
+// Copyright (c) 2012 Marvell Technology Ltd.
+// Yunfan Zhang 
+
 #include 
 #include 
 #include 
-- 
2.17.1



[PATCH 1/3] regulator: ltc3589: Convert to use simplified DT parsing

2019-04-18 Thread Axel Lin
Use regulator core's simplified DT parsing code to simplify the driver
implementation.

Signed-off-by: Axel Lin 
---
 drivers/regulator/ltc3589.c | 194 +++-
 1 file changed, 58 insertions(+), 136 deletions(-)

diff --git a/drivers/regulator/ltc3589.c b/drivers/regulator/ltc3589.c
index 75089b037b72..35741f476024 100644
--- a/drivers/regulator/ltc3589.c
+++ b/drivers/regulator/ltc3589.c
@@ -86,10 +86,6 @@ enum ltc3589_reg {
 
 struct ltc3589_regulator {
struct regulator_desc desc;
-
-   /* External feedback voltage divider */
-   unsigned int r1;
-   unsigned int r2;
 };
 
 struct ltc3589 {
@@ -196,11 +192,55 @@ static const struct regulator_ops 
ltc3589_table_regulator_ops = {
.get_voltage_sel = regulator_get_voltage_sel_regmap,
 };
 
+static inline unsigned int ltc3589_scale(unsigned int uV, u32 r1, u32 r2)
+{
+   uint64_t tmp;
+
+   if (uV == 0)
+   return 0;
+
+   tmp = (uint64_t)uV * r1;
+   do_div(tmp, r2);
+   return uV + (unsigned int)tmp;
+}
+
+static int ltc3589_of_parse_cb(struct device_node *np,
+  const struct regulator_desc *desc,
+  struct regulator_config *config)
+{
+   struct ltc3589 *ltc3589 = config->driver_data;
+   struct ltc3589_regulator *rdesc = <c3589->regulator_descs[desc->id];
+   u32 r[2];
+   int ret;
+
+   /* Parse feedback voltage dividers. LDO3 and LDO4 don't have them */
+   if (desc->id >= LTC3589_LDO3)
+   return 0;
+
+   ret = of_property_read_u32_array(np, "lltc,fb-voltage-divider", r, 2);
+   if (ret) {
+   dev_err(ltc3589->dev, "Failed to parse voltage divider: %d\n",
+   ret);
+   return ret;
+   }
+
+   if (!r[0] || !r[1])
+   return 0;
+
+   rdesc->desc.min_uV = ltc3589_scale(desc->min_uV, r[0], r[1]);
+   rdesc->desc.uV_step = ltc3589_scale(desc->uV_step, r[0], r[1]);
+   rdesc->desc.fixed_uV = ltc3589_scale(desc->fixed_uV, r[0], r[1]);
+
+   return 0;
+}
 
-#define LTC3589_REG(_name, _ops, en_bit, dtv1_reg, dtv_mask, go_bit)   \
+#define LTC3589_REG(_name, _of_name, _ops, en_bit, dtv1_reg, dtv_mask, go_bit)\
[LTC3589_ ## _name] = { \
.desc = {   \
.name = #_name, \
+   .of_match = of_match_ptr(#_of_name),\
+   .regulators_node = of_match_ptr("regulators"),  \
+   .of_parse_cb = ltc3589_of_parse_cb, \
.n_voltages = (dtv_mask) + 1,   \
.min_uV = (go_bit) ? 362500 : 0,\
.uV_step = (go_bit) ? 12500 : 0,\
@@ -219,109 +259,26 @@ static const struct regulator_ops 
ltc3589_table_regulator_ops = {
},  \
}
 
-#define LTC3589_LINEAR_REG(_name, _dtv1)   \
-   LTC3589_REG(_name, linear, LTC3589_OVEN_ ## _name,  \
+#define LTC3589_LINEAR_REG(_name, _of_name, _dtv1) \
+   LTC3589_REG(_name, _of_name, linear, LTC3589_OVEN_ ## _name,\
LTC3589_ ## _dtv1, 0x1f,\
LTC3589_VCCR_ ## _name ## _GO)
 
-#define LTC3589_FIXED_REG(_name) \
-   LTC3589_REG(_name, fixed, LTC3589_OVEN_ ## _name, 0, 0, 0)
+#define LTC3589_FIXED_REG(_name, _of_name) \
+   LTC3589_REG(_name, _of_name, fixed, LTC3589_OVEN_ ## _name, 0, 0, 0)
 
 static struct ltc3589_regulator ltc3589_regulators[LTC3589_NUM_REGULATORS] = {
-   LTC3589_LINEAR_REG(SW1, B1DTV1),
-   LTC3589_LINEAR_REG(SW2, B2DTV1),
-   LTC3589_LINEAR_REG(SW3, B3DTV1),
-   LTC3589_FIXED_REG(BB_OUT),
-   LTC3589_REG(LDO1, fixed_standby, 0, 0, 0, 0),
-   LTC3589_LINEAR_REG(LDO2, L2DTV1),
-   LTC3589_FIXED_REG(LDO3),
-   LTC3589_REG(LDO4, table, LTC3589_OVEN_LDO4, LTC3589_L2DTV2, 0x60, 0),
+   LTC3589_LINEAR_REG(SW1, sw1, B1DTV1),
+   LTC3589_LINEAR_REG(SW2, sw2, B2DTV1),
+   LTC3589_LINEAR_REG(SW3, sw3, B3DTV1),
+   LTC3589_FIXED_REG(BB_OUT, bb-out),
+   LTC3589_REG(LDO1, ldo1, fixed_standby, 0, 0, 0, 0),
+   LTC3589_LINEAR_REG(LDO2, ldo2, L2DTV1),
+   LTC3589_FIXED_REG(LDO3, ldo3),
+   LTC3589_REG(LDO4, ldo4, table, LTC3589_OVEN_LDO4, LTC3589_L2DTV2,
+   0x60, 0),
 };
 
-#ifdef CONFIG_OF
-static struct of_regulator_match ltc3589_matches[LTC3589_NUM_REGULATORS] = {
-   { .name = "sw1",},
-   { .name = "sw2",},
-   { .name = "sw3",},
-   { .name = &qu

[PATCH 3/3] regulator: ltc3589: Switch to SPDX identifier

2019-04-18 Thread Axel Lin
Signed-off-by: Axel Lin 
---
 drivers/regulator/ltc3589.c | 24 ++--
 1 file changed, 6 insertions(+), 18 deletions(-)

diff --git a/drivers/regulator/ltc3589.c b/drivers/regulator/ltc3589.c
index 077e73715514..9a037fdc5fc5 100644
--- a/drivers/regulator/ltc3589.c
+++ b/drivers/regulator/ltc3589.c
@@ -1,21 +1,9 @@
-/*
- * Linear Technology LTC3589,LTC3589-1 regulator support
- *
- * Copyright (c) 2014 Philipp Zabel , Pengutronix
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- */
+// SPDX-License-Identifier: GPL-2.0
+//
+// Linear Technology LTC3589,LTC3589-1 regulator support
+//
+// Copyright (c) 2014 Philipp Zabel , Pengutronix
+
 #include 
 #include 
 #include 
-- 
2.17.1



[PATCH 2/3] regulator: ltc3589: Get rid of struct ltc3589_regulator

2019-04-18 Thread Axel Lin
After converting to use simplified DT parsing, the struct ltc3589_regulator
only has a desc member. So let's remove struct ltc3589_regulator and use
struct regulator_desc instead.

Signed-off-by: Axel Lin 
---
 drivers/regulator/ltc3589.c | 69 +
 1 file changed, 31 insertions(+), 38 deletions(-)

diff --git a/drivers/regulator/ltc3589.c b/drivers/regulator/ltc3589.c
index 35741f476024..077e73715514 100644
--- a/drivers/regulator/ltc3589.c
+++ b/drivers/regulator/ltc3589.c
@@ -84,15 +84,11 @@ enum ltc3589_reg {
LTC3589_NUM_REGULATORS,
 };
 
-struct ltc3589_regulator {
-   struct regulator_desc desc;
-};
-
 struct ltc3589 {
struct regmap *regmap;
struct device *dev;
enum ltc3589_variant variant;
-   struct ltc3589_regulator regulator_descs[LTC3589_NUM_REGULATORS];
+   struct regulator_desc regulator_descs[LTC3589_NUM_REGULATORS];
struct regulator_dev *regulators[LTC3589_NUM_REGULATORS];
 };
 
@@ -209,7 +205,7 @@ static int ltc3589_of_parse_cb(struct device_node *np,
   struct regulator_config *config)
 {
struct ltc3589 *ltc3589 = config->driver_data;
-   struct ltc3589_regulator *rdesc = <c3589->regulator_descs[desc->id];
+   struct regulator_desc *rdesc = <c3589->regulator_descs[desc->id];
u32 r[2];
int ret;
 
@@ -227,36 +223,34 @@ static int ltc3589_of_parse_cb(struct device_node *np,
if (!r[0] || !r[1])
return 0;
 
-   rdesc->desc.min_uV = ltc3589_scale(desc->min_uV, r[0], r[1]);
-   rdesc->desc.uV_step = ltc3589_scale(desc->uV_step, r[0], r[1]);
-   rdesc->desc.fixed_uV = ltc3589_scale(desc->fixed_uV, r[0], r[1]);
+   rdesc->min_uV = ltc3589_scale(desc->min_uV, r[0], r[1]);
+   rdesc->uV_step = ltc3589_scale(desc->uV_step, r[0], r[1]);
+   rdesc->fixed_uV = ltc3589_scale(desc->fixed_uV, r[0], r[1]);
 
return 0;
 }
 
 #define LTC3589_REG(_name, _of_name, _ops, en_bit, dtv1_reg, dtv_mask, go_bit)\
[LTC3589_ ## _name] = { \
-   .desc = {   \
-   .name = #_name, \
-   .of_match = of_match_ptr(#_of_name),\
-   .regulators_node = of_match_ptr("regulators"),  \
-   .of_parse_cb = ltc3589_of_parse_cb, \
-   .n_voltages = (dtv_mask) + 1,   \
-   .min_uV = (go_bit) ? 362500 : 0,\
-   .uV_step = (go_bit) ? 12500 : 0,\
-   .ramp_delay = (go_bit) ? 1750 : 0,  \
-   .fixed_uV = (dtv_mask) ? 0 : 80,\
-   .ops = <c3589_ ## _ops ## _regulator_ops, \
-   .type = REGULATOR_VOLTAGE,  \
-   .id = LTC3589_ ## _name,\
-   .owner = THIS_MODULE,   \
-   .vsel_reg = (dtv1_reg), \
-   .vsel_mask = (dtv_mask),\
-   .apply_reg = (go_bit) ? LTC3589_VCCR : 0,   \
-   .apply_bit = (go_bit),  \
-   .enable_reg = (en_bit) ? LTC3589_OVEN : 0,  \
-   .enable_mask = (en_bit),\
-   },  \
+   .name = #_name, \
+   .of_match = of_match_ptr(#_of_name),\
+   .regulators_node = of_match_ptr("regulators"),  \
+   .of_parse_cb = ltc3589_of_parse_cb, \
+   .n_voltages = (dtv_mask) + 1,   \
+   .min_uV = (go_bit) ? 362500 : 0,\
+   .uV_step = (go_bit) ? 12500 : 0,\
+   .ramp_delay = (go_bit) ? 1750 : 0,  \
+   .fixed_uV = (dtv_mask) ? 0 : 80,\
+   .ops = <c3589_ ## _ops ## _regulator_ops, \
+   .type = REGULATOR_VOLTAGE,  \
+   .id = LTC3589_ ## _name,\
+   .owner = THIS_MODULE,   \
+   .vsel_reg = (dtv1_reg), \
+   .vsel_mask = (dtv_mask),\
+   .apply_reg = (go_bit) ? LTC3589_VCCR : 0,   \
+   .apply_bit = (go_bit), 

[PATCH 3/5] regulator: wm8350: Switch to SPDX identifier

2019-04-17 Thread Axel Lin
Signed-off-by: Axel Lin 
---
 drivers/regulator/wm8350-regulator.c | 21 -
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/regulator/wm8350-regulator.c 
b/drivers/regulator/wm8350-regulator.c
index 0eb3f3a33caa..56d6168a888d 100644
--- a/drivers/regulator/wm8350-regulator.c
+++ b/drivers/regulator/wm8350-regulator.c
@@ -1,16 +1,11 @@
-/*
- * wm8350.c  --  Voltage and current regulation for the Wolfson WM8350 PMIC
- *
- * Copyright 2007, 2008 Wolfson Microelectronics PLC.
- *
- * Author: Liam Girdwood
- * li...@wolfsonmicro.com
- *
- *  This program is free software; you can redistribute  it and/or modify it
- *  under  the terms of  the GNU General  Public License as published by the
- *  Free Software Foundation;  either version 2 of the  License, or (at your
- *  option) any later version.
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// wm8350.c  --  Voltage and current regulation for the Wolfson WM8350 PMIC
+//
+// Copyright 2007, 2008 Wolfson Microelectronics PLC.
+//
+// Author: Liam Girdwood
+// li...@wolfsonmicro.com
 
 #include 
 #include 
-- 
2.17.1



[PATCH 4/5] regulator: wm8400: Switch to SPDX identifier

2019-04-17 Thread Axel Lin
Signed-off-by: Axel Lin 
---
 drivers/regulator/wm8400-regulator.c | 20 +++-
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/regulator/wm8400-regulator.c 
b/drivers/regulator/wm8400-regulator.c
index 5ce86b92851b..6f331b51e479 100644
--- a/drivers/regulator/wm8400-regulator.c
+++ b/drivers/regulator/wm8400-regulator.c
@@ -1,16 +1,10 @@
-/*
- * Regulator support for WM8400
- *
- * Copyright 2008 Wolfson Microelectronics PLC.
- *
- * Author: Mark Brown 
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Regulator support for WM8400
+//
+// Copyright 2008 Wolfson Microelectronics PLC.
+//
+// Author: Mark Brown 
 
 #include 
 #include 
-- 
2.17.1



[PATCH 1/5] regulator: arizona: Switch to SPDX identifier

2019-04-17 Thread Axel Lin
Signed-off-by: Axel Lin 
---
 drivers/regulator/arizona-ldo1.c| 19 +++
 drivers/regulator/arizona-micsupp.c | 19 +++
 2 files changed, 14 insertions(+), 24 deletions(-)

diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c
index bf3ab405eed1..e4bc7b1e5ccd 100644
--- a/drivers/regulator/arizona-ldo1.c
+++ b/drivers/regulator/arizona-ldo1.c
@@ -1,15 +1,10 @@
-/*
- * arizona-ldo1.c  --  LDO1 supply for Arizona devices
- *
- * Copyright 2012 Wolfson Microelectronics PLC.
- *
- * Author: Mark Brown 
- *
- *  This program is free software; you can redistribute  it and/or modify it
- *  under  the terms of  the GNU General  Public License as published by the
- *  Free Software Foundation;  either version 2 of the  License, or (at your
- *  option) any later version.
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// arizona-ldo1.c  --  LDO1 supply for Arizona devices
+//
+// Copyright 2012 Wolfson Microelectronics PLC.
+//
+// Author: Mark Brown 
 
 #include 
 #include 
diff --git a/drivers/regulator/arizona-micsupp.c 
b/drivers/regulator/arizona-micsupp.c
index 120de94caf02..be0d46da51a1 100644
--- a/drivers/regulator/arizona-micsupp.c
+++ b/drivers/regulator/arizona-micsupp.c
@@ -1,15 +1,10 @@
-/*
- * arizona-micsupp.c  --  Microphone supply for Arizona devices
- *
- * Copyright 2012 Wolfson Microelectronics PLC.
- *
- * Author: Mark Brown 
- *
- *  This program is free software; you can redistribute  it and/or modify it
- *  under  the terms of  the GNU General  Public License as published by the
- *  Free Software Foundation;  either version 2 of the  License, or (at your
- *  option) any later version.
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// arizona-micsupp.c  --  Microphone supply for Arizona devices
+//
+// Copyright 2012 Wolfson Microelectronics PLC.
+//
+// Author: Mark Brown 
 
 #include 
 #include 
-- 
2.17.1



[PATCH 5/5] regulator: wm8994: Switch to SPDX identifier

2019-04-17 Thread Axel Lin
Signed-off-by: Axel Lin 
---
 drivers/regulator/wm8994-regulator.c | 19 +++
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/drivers/regulator/wm8994-regulator.c 
b/drivers/regulator/wm8994-regulator.c
index 38928cdcb6e6..cadea0344486 100644
--- a/drivers/regulator/wm8994-regulator.c
+++ b/drivers/regulator/wm8994-regulator.c
@@ -1,15 +1,10 @@
-/*
- * wm8994-regulator.c  --  Regulator driver for the WM8994
- *
- * Copyright 2009 Wolfson Microelectronics PLC.
- *
- * Author: Mark Brown 
- *
- *  This program is free software; you can redistribute  it and/or modify it
- *  under  the terms of  the GNU General  Public License as published by the
- *  Free Software Foundation;  either version 2 of the  License, or (at your
- *  option) any later version.
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// wm8994-regulator.c  --  Regulator driver for the WM8994
+//
+// Copyright 2009 Wolfson Microelectronics PLC.
+//
+// Author: Mark Brown 
 
 #include 
 #include 
-- 
2.17.1



[PATCH 2/5] regulator: wm831x: Switch to SPDX identifier

2019-04-17 Thread Axel Lin
Signed-off-by: Axel Lin 
---
 drivers/regulator/wm831x-dcdc.c  | 19 +++
 drivers/regulator/wm831x-isink.c | 19 +++
 drivers/regulator/wm831x-ldo.c   | 19 +++
 3 files changed, 21 insertions(+), 36 deletions(-)

diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c
index d1873f94bca7..8b607e21fc86 100644
--- a/drivers/regulator/wm831x-dcdc.c
+++ b/drivers/regulator/wm831x-dcdc.c
@@ -1,15 +1,10 @@
-/*
- * wm831x-dcdc.c  --  DC-DC buck convertor driver for the WM831x series
- *
- * Copyright 2009 Wolfson Microelectronics PLC.
- *
- * Author: Mark Brown 
- *
- *  This program is free software; you can redistribute  it and/or modify it
- *  under  the terms of  the GNU General  Public License as published by the
- *  Free Software Foundation;  either version 2 of the  License, or (at your
- *  option) any later version.
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// wm831x-dcdc.c  --  DC-DC buck converter driver for the WM831x series
+//
+// Copyright 2009 Wolfson Microelectronics PLC.
+//
+// Author: Mark Brown 
 
 #include 
 #include 
diff --git a/drivers/regulator/wm831x-isink.c b/drivers/regulator/wm831x-isink.c
index bdc521a6f048..ff3d2bf50410 100644
--- a/drivers/regulator/wm831x-isink.c
+++ b/drivers/regulator/wm831x-isink.c
@@ -1,15 +1,10 @@
-/*
- * wm831x-isink.c  --  Current sink driver for the WM831x series
- *
- * Copyright 2009 Wolfson Microelectronics PLC.
- *
- * Author: Mark Brown 
- *
- *  This program is free software; you can redistribute  it and/or modify it
- *  under  the terms of  the GNU General  Public License as published by the
- *  Free Software Foundation;  either version 2 of the  License, or (at your
- *  option) any later version.
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// wm831x-isink.c  --  Current sink driver for the WM831x series
+//
+// Copyright 2009 Wolfson Microelectronics PLC.
+//
+// Author: Mark Brown 
 
 #include 
 #include 
diff --git a/drivers/regulator/wm831x-ldo.c b/drivers/regulator/wm831x-ldo.c
index fcd038e7cd80..56754686c982 100644
--- a/drivers/regulator/wm831x-ldo.c
+++ b/drivers/regulator/wm831x-ldo.c
@@ -1,15 +1,10 @@
-/*
- * wm831x-ldo.c  --  LDO driver for the WM831x series
- *
- * Copyright 2009 Wolfson Microelectronics PLC.
- *
- * Author: Mark Brown 
- *
- *  This program is free software; you can redistribute  it and/or modify it
- *  under  the terms of  the GNU General  Public License as published by the
- *  Free Software Foundation;  either version 2 of the  License, or (at your
- *  option) any later version.
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// wm831x-ldo.c  --  LDO driver for the WM831x series
+//
+// Copyright 2009 Wolfson Microelectronics PLC.
+//
+// Author: Mark Brown 
 
 #include 
 #include 
-- 
2.17.1



[PATCH] regulator: stm32-pwr: Fix error checking for of_iomap

2019-04-17 Thread Axel Lin
of_iomap returns NULL on error.

Signed-off-by: Axel Lin 
---
 drivers/regulator/stm32-pwr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/stm32-pwr.c b/drivers/regulator/stm32-pwr.c
index 222d593d76a2..dd5c2b383e5b 100644
--- a/drivers/regulator/stm32-pwr.c
+++ b/drivers/regulator/stm32-pwr.c
@@ -140,9 +140,9 @@ static int stm32_pwr_regulator_probe(struct platform_device 
*pdev)
int i, ret = 0;
 
base = of_iomap(np, 0);
-   if (IS_ERR(base)) {
+   if (!base) {
dev_err(&pdev->dev, "Unable to map IO memory\n");
-   return PTR_ERR(base);
+   return -ENODEV;
}
 
config.dev = &pdev->dev;
-- 
2.17.1



[PATCH] regulator: stm32-pwr: Staticize local symbols

2019-04-17 Thread Axel Lin
These symbols are only used by this driver, make them static.

Signed-off-by: Axel Lin 
---
 drivers/regulator/stm32-pwr.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/regulator/stm32-pwr.c b/drivers/regulator/stm32-pwr.c
index e434b26d4c8b..222d593d76a2 100644
--- a/drivers/regulator/stm32-pwr.c
+++ b/drivers/regulator/stm32-pwr.c
@@ -32,7 +32,7 @@ enum {
STM32PWR_REG_NUM_REGS
 };
 
-u32 ready_mask_table[STM32PWR_REG_NUM_REGS] = {
+static u32 ready_mask_table[STM32PWR_REG_NUM_REGS] = {
[PWR_REG11] = REG_1_1_RDY,
[PWR_REG18] = REG_1_8_RDY,
[PWR_USB33] = USB_3_3_RDY,
@@ -44,7 +44,7 @@ struct stm32_pwr_reg {
u32 ready_mask;
 };
 
-int stm32_pwr_reg_is_ready(struct regulator_dev *rdev)
+static int stm32_pwr_reg_is_ready(struct regulator_dev *rdev)
 {
struct stm32_pwr_reg *priv = rdev_get_drvdata(rdev);
u32 val;
@@ -54,7 +54,7 @@ int stm32_pwr_reg_is_ready(struct regulator_dev *rdev)
return (val & priv->ready_mask);
 }
 
-int stm32_pwr_reg_is_enabled(struct regulator_dev *rdev)
+static int stm32_pwr_reg_is_enabled(struct regulator_dev *rdev)
 {
struct stm32_pwr_reg *priv = rdev_get_drvdata(rdev);
u32 val;
-- 
2.17.1



[PATCH 3/3] regulator: tps80031: Switch to SPDX identifier

2019-04-16 Thread Axel Lin
Signed-off-by: Axel Lin 
---
 drivers/regulator/tps80031-regulator.c | 34 --
 1 file changed, 10 insertions(+), 24 deletions(-)

diff --git a/drivers/regulator/tps80031-regulator.c 
b/drivers/regulator/tps80031-regulator.c
index 8e65a13e2ef5..85a6a8ca8c1b 100644
--- a/drivers/regulator/tps80031-regulator.c
+++ b/drivers/regulator/tps80031-regulator.c
@@ -1,27 +1,13 @@
-/*
- * tps80031-regulator.c -- TI TPS80031 regulator driver.
- *
- * Regulator driver for TI TPS80031/TPS80032 Fully Integrated Power
- * Management with Power Path and Battery Charger.
- *
- * Copyright (c) 2012, NVIDIA Corporation.
- *
- * Author: Laxman Dewangan 
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation version 2.
- *
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
- * whether express or implied; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- * 02111-1307, USA
- */
+// SPDX-License-Identifier: GPL-2.0
+//
+// tps80031-regulator.c -- TI TPS80031 regulator driver.
+//
+// Regulator driver for TI TPS80031/TPS80032 Fully Integrated Power
+// Management with Power Path and Battery Charger.
+//
+// Copyright (c) 2012, NVIDIA Corporation.
+//
+// Author: Laxman Dewangan 
 
 #include 
 #include 
-- 
2.17.1



[PATCH 2/3] regulator: tps80031: Constify regulator_ops and tps80031_dcdc_voltages array

2019-04-16 Thread Axel Lin
These regulator_ops variables and tps80031_dcdc_voltages array never need
to be modified, make them const so compiler can put them to .rodata.

Signed-off-by: Axel Lin 
---
 drivers/regulator/tps80031-regulator.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/regulator/tps80031-regulator.c 
b/drivers/regulator/tps80031-regulator.c
index d97cd55b6850..8e65a13e2ef5 100644
--- a/drivers/regulator/tps80031-regulator.c
+++ b/drivers/regulator/tps80031-regulator.c
@@ -154,7 +154,7 @@ static int tps80031_reg_disable(struct regulator_dev *rdev)
 }
 
 /* DCDC voltages for the selector of 58 to 63 */
-static int tps80031_dcdc_voltages[4][5] = {
+static const int tps80031_dcdc_voltages[4][5] = {
{ 1350, 1500, 1800, 1900, 2100},
{ 1350, 1500, 1800, 1900, 2100},
{ 2084, 2315, 2778, 2932, 3241},
@@ -377,7 +377,7 @@ static int tps80031_vbus_disable(struct regulator_dev *rdev)
return ret;
 }
 
-static struct regulator_ops tps80031_dcdc_ops = {
+static const struct regulator_ops tps80031_dcdc_ops = {
.list_voltage   = tps80031_dcdc_list_voltage,
.set_voltage_sel= tps80031_dcdc_set_voltage_sel,
.get_voltage_sel= tps80031_dcdc_get_voltage_sel,
@@ -386,7 +386,7 @@ static struct regulator_ops tps80031_dcdc_ops = {
.is_enabled = tps80031_reg_is_enabled,
 };
 
-static struct regulator_ops tps80031_ldo_ops = {
+static const struct regulator_ops tps80031_ldo_ops = {
.list_voltage   = tps80031_ldo_list_voltage,
.map_voltage= tps80031_ldo_map_voltage,
.set_voltage_sel= regulator_set_voltage_sel_regmap,
@@ -396,18 +396,18 @@ static struct regulator_ops tps80031_ldo_ops = {
.is_enabled = tps80031_reg_is_enabled,
 };
 
-static struct regulator_ops tps80031_vbus_sw_ops = {
+static const struct regulator_ops tps80031_vbus_sw_ops = {
.list_voltage   = regulator_list_voltage_linear,
.enable = tps80031_vbus_enable,
.disable= tps80031_vbus_disable,
.is_enabled = tps80031_vbus_is_enabled,
 };
 
-static struct regulator_ops tps80031_vbus_hw_ops = {
+static const struct regulator_ops tps80031_vbus_hw_ops = {
.list_voltage   = regulator_list_voltage_linear,
 };
 
-static struct regulator_ops tps80031_ext_reg_ops = {
+static const struct regulator_ops tps80031_ext_reg_ops = {
.list_voltage   = regulator_list_voltage_linear,
.enable = tps80031_reg_enable,
.disable= tps80031_reg_disable,
-- 
2.17.1



[PATCH 1/3] regulator: tps80031: Remove unused *rdev from struct tps80031_regulator

2019-04-16 Thread Axel Lin
The ri-rdev is assigend but not used, so remove it.

Signed-off-by: Axel Lin 
---
 drivers/regulator/tps80031-regulator.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/regulator/tps80031-regulator.c 
b/drivers/regulator/tps80031-regulator.c
index 1001147404c3..d97cd55b6850 100644
--- a/drivers/regulator/tps80031-regulator.c
+++ b/drivers/regulator/tps80031-regulator.c
@@ -85,7 +85,6 @@ struct tps80031_regulator_info {
 
 struct tps80031_regulator {
struct device   *dev;
-   struct regulator_dev*rdev;
struct tps80031_regulator_info  *rinfo;
 
u8  device_flags;
@@ -736,7 +735,6 @@ static int tps80031_regulator_probe(struct platform_device 
*pdev)
ri->rinfo->desc.name);
return PTR_ERR(rdev);
}
-   ri->rdev = rdev;
}
 
platform_set_drvdata(pdev, pmic);
-- 
2.17.1



[PATCH 2/2] regulator: max8998: Factor out struct voltage_map_desc

2019-04-14 Thread Axel Lin
The struct voltage_map_desc is used for storing min/max/step fileds, and
then setup the min_uV, uV_step and n_voltages fields for regulator_desc.
Introduce MAX8998_LINEAR_REG/MAX8998_OTHERS_REG macro to setup these filds
directly in regulator_desc to simplify the code.

Signed-off-by: Axel Lin 
---
 drivers/regulator/max8998.c | 294 +++-
 1 file changed, 56 insertions(+), 238 deletions(-)

diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c
index 43b69ebd086b..60599c3bb845 100644
--- a/drivers/regulator/max8998.c
+++ b/drivers/regulator/max8998.c
@@ -33,72 +33,6 @@ struct max8998_data {
unsigned intbuck2_idx;
 };
 
-struct voltage_map_desc {
-   int min;
-   int max;
-   int step;
-};
-
-/* Voltage maps in uV*/
-static const struct voltage_map_desc ldo23_voltage_map_desc = {
-   .min = 80,  .step = 5,  .max = 130,
-};
-static const struct voltage_map_desc ldo456711_voltage_map_desc = {
-   .min = 160, .step = 10, .max = 360,
-};
-static const struct voltage_map_desc ldo8_voltage_map_desc = {
-   .min = 300, .step = 10, .max = 360,
-};
-static const struct voltage_map_desc ldo9_voltage_map_desc = {
-   .min = 280, .step = 10, .max = 310,
-};
-static const struct voltage_map_desc ldo10_voltage_map_desc = {
-   .min = 95,  .step = 5,  .max = 130,
-};
-static const struct voltage_map_desc ldo1213_voltage_map_desc = {
-   .min = 80,  .step = 10, .max = 330,
-};
-static const struct voltage_map_desc ldo1415_voltage_map_desc = {
-   .min = 120, .step = 10, .max = 330,
-};
-static const struct voltage_map_desc ldo1617_voltage_map_desc = {
-   .min = 160, .step = 10, .max = 360,
-};
-static const struct voltage_map_desc buck12_voltage_map_desc = {
-   .min = 75,  .step = 25000,  .max = 1525000,
-};
-static const struct voltage_map_desc buck3_voltage_map_desc = {
-   .min = 160, .step = 10, .max = 360,
-};
-static const struct voltage_map_desc buck4_voltage_map_desc = {
-   .min = 80,  .step = 10, .max = 230,
-};
-
-static const struct voltage_map_desc *ldo_voltage_map[] = {
-   NULL,
-   NULL,
-   &ldo23_voltage_map_desc,/* LDO2 */
-   &ldo23_voltage_map_desc,/* LDO3 */
-   &ldo456711_voltage_map_desc,/* LDO4 */
-   &ldo456711_voltage_map_desc,/* LDO5 */
-   &ldo456711_voltage_map_desc,/* LDO6 */
-   &ldo456711_voltage_map_desc,/* LDO7 */
-   &ldo8_voltage_map_desc, /* LDO8 */
-   &ldo9_voltage_map_desc, /* LDO9 */
-   &ldo10_voltage_map_desc,/* LDO10 */
-   &ldo456711_voltage_map_desc,/* LDO11 */
-   &ldo1213_voltage_map_desc,  /* LDO12 */
-   &ldo1213_voltage_map_desc,  /* LDO13 */
-   &ldo1415_voltage_map_desc,  /* LDO14 */
-   &ldo1415_voltage_map_desc,  /* LDO15 */
-   &ldo1617_voltage_map_desc,  /* LDO16 */
-   &ldo1617_voltage_map_desc,  /* LDO17 */
-   &buck12_voltage_map_desc,   /* BUCK1 */
-   &buck12_voltage_map_desc,   /* BUCK2 */
-   &buck3_voltage_map_desc,/* BUCK3 */
-   &buck4_voltage_map_desc,/* BUCK4 */
-};
-
 static int max8998_get_enable_register(struct regulator_dev *rdev,
int *reg, int *shift)
 {
@@ -400,7 +334,6 @@ static int max8998_set_voltage_buck_time_sel(struct 
regulator_dev *rdev,
 {
struct max8998_data *max8998 = rdev_get_drvdata(rdev);
struct i2c_client *i2c = max8998->iodev->i2c;
-   const struct voltage_map_desc *desc;
int buck = rdev_get_id(rdev);
u8 val = 0;
int difference, ret;
@@ -408,8 +341,6 @@ static int max8998_set_voltage_buck_time_sel(struct 
regulator_dev *rdev,
if (buck < MAX8998_BUCK1 || buck > MAX8998_BUCK4)
return -EINVAL;
 
-   desc = ldo_voltage_map[buck];
-
/* Voltage stabilization */
ret = max8998_read_reg(i2c, MAX8998_REG_ONOFF4, &val);
if (ret)
@@ -420,7 +351,7 @@ static int max8998_set_voltage_buck_time_sel(struct 
regulator_dev *rdev,
if (max8998->iodev->type == TYPE_MAX8998 && !(val & MAX8998_ENRAMP))
return 0;
 
-   difference = (new_selector - old_selector) * desc->step / 1000;
+   difference = (new_selector - old_selector) * rdev->desc->uV_step / 1000;
if (difference > 0)
return DIV_ROUND_UP(difference, (val & 0x0f) + 1);
 
@@ -454,158 +385,53 @@ static const struct regulator_ops max8998_others_ops = {
.disable= max8998_ldo_disable,
 };
 
-static struct regulator_desc regulators[] = {
-   {
-   .name   = "LDO2",
-  

[PATCH 1/2] regulator: max8998: Constify regulator_ops

2019-04-14 Thread Axel Lin
These regulator_ops variables never need to be modified, make them const so
compiler can put them to .rodata.

Signed-off-by: Axel Lin 
---
 drivers/regulator/max8998.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c
index 271bb736f3f5..43b69ebd086b 100644
--- a/drivers/regulator/max8998.c
+++ b/drivers/regulator/max8998.c
@@ -427,7 +427,7 @@ static int max8998_set_voltage_buck_time_sel(struct 
regulator_dev *rdev,
return 0;
 }
 
-static struct regulator_ops max8998_ldo_ops = {
+static const struct regulator_ops max8998_ldo_ops = {
.list_voltage   = regulator_list_voltage_linear,
.map_voltage= regulator_map_voltage_linear,
.is_enabled = max8998_ldo_is_enabled,
@@ -437,7 +437,7 @@ static struct regulator_ops max8998_ldo_ops = {
.set_voltage_sel= max8998_set_voltage_ldo_sel,
 };
 
-static struct regulator_ops max8998_buck_ops = {
+static const struct regulator_ops max8998_buck_ops = {
.list_voltage   = regulator_list_voltage_linear,
.map_voltage= regulator_map_voltage_linear,
.is_enabled = max8998_ldo_is_enabled,
@@ -448,7 +448,7 @@ static struct regulator_ops max8998_buck_ops = {
.set_voltage_time_sel   = max8998_set_voltage_buck_time_sel,
 };
 
-static struct regulator_ops max8998_others_ops = {
+static const struct regulator_ops max8998_others_ops = {
.is_enabled = max8998_ldo_is_enabled,
.enable = max8998_ldo_enable,
.disable= max8998_ldo_disable,
-- 
2.17.1



[PATCH 2/2] regulator: tps6524x: Remove *rdev[N_REGULATORS] from struct tps6524x

2019-04-13 Thread Axel Lin
Current code is using devm_regulator_register() so we don't need to store
*rdev for clean up, use a local variable instead.

Signed-off-by: Axel Lin 
---
 drivers/regulator/tps6524x-regulator.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/regulator/tps6524x-regulator.c 
b/drivers/regulator/tps6524x-regulator.c
index c09223c34dbf..740aeccdfb1f 100644
--- a/drivers/regulator/tps6524x-regulator.c
+++ b/drivers/regulator/tps6524x-regulator.c
@@ -137,7 +137,6 @@ struct tps6524x {
struct spi_device   *spi;
struct mutexlock;
struct regulator_desc   desc[N_REGULATORS];
-   struct regulator_dev*rdev[N_REGULATORS];
 };
 
 static int __read_reg(struct tps6524x *hw, int reg)
@@ -584,6 +583,7 @@ static int pmic_probe(struct spi_device *spi)
const struct supply_info *info = supply_info;
struct regulator_init_data *init_data;
struct regulator_config config = { };
+   struct regulator_dev *rdev;
int i;
 
init_data = dev_get_platdata(dev);
@@ -616,10 +616,9 @@ static int pmic_probe(struct spi_device *spi)
config.init_data = init_data;
config.driver_data = hw;
 
-   hw->rdev[i] = devm_regulator_register(dev, &hw->desc[i],
- &config);
-   if (IS_ERR(hw->rdev[i]))
-   return PTR_ERR(hw->rdev[i]);
+   rdev = devm_regulator_register(dev, &hw->desc[i], &config);
+   if (IS_ERR(rdev))
+   return PTR_ERR(rdev);
}
 
return 0;
-- 
2.17.1



[PATCH 1/2] regulator: tps6524x: Constify regulator_ops

2019-04-13 Thread Axel Lin
The regulator_ops is never changed, make it const.

Signed-off-by: Axel Lin 
---
 drivers/regulator/tps6524x-regulator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/tps6524x-regulator.c 
b/drivers/regulator/tps6524x-regulator.c
index 67cac2682f50..c09223c34dbf 100644
--- a/drivers/regulator/tps6524x-regulator.c
+++ b/drivers/regulator/tps6524x-regulator.c
@@ -565,7 +565,7 @@ static int is_supply_enabled(struct regulator_dev *rdev)
return read_field(hw, &info->enable);
 }
 
-static struct regulator_ops regulator_ops = {
+static const struct regulator_ops regulator_ops = {
.is_enabled = is_supply_enabled,
.enable = enable_supply,
.disable= disable_supply,
-- 
2.17.1



[PATCH] regulator: tps65218: Convert to use regulator_get_current_limit_regmap

2019-04-12 Thread Axel Lin
Use regulator_get_current_limit_regmap helper to save some code.

Signed-off-by: Axel Lin 
---
 drivers/regulator/tps65218-regulator.c | 48 ++
 1 file changed, 19 insertions(+), 29 deletions(-)

diff --git a/drivers/regulator/tps65218-regulator.c 
b/drivers/regulator/tps65218-regulator.c
index 7aed3fbffecc..b72035610013 100644
--- a/drivers/regulator/tps65218-regulator.c
+++ b/drivers/regulator/tps65218-regulator.c
@@ -29,7 +29,8 @@
 #include 
 
 #define TPS65218_REGULATOR(_name, _of, _id, _type, _ops, _n, _vr, _vm, _er, \
-  _em, _cr, _cm, _lr, _nlr, _delay, _fuv, _sr, _sm) \
+  _em, _cr, _cm, _lr, _nlr, _delay, _fuv, _sr, _sm, \
+  _ct, _ncl) \
{   \
.name   = _name,\
.of_match   = _of,  \
@@ -42,6 +43,8 @@
.vsel_mask  = _vm,  \
.csel_reg   = _cr,  \
.csel_mask  = _cm,  \
+   .curr_table = _ct,  \
+   .n_current_limits   = _ncl, \
.enable_reg = _er,  \
.enable_mask= _em,  \
.volt_table = NULL, \
@@ -188,8 +191,7 @@ static const struct regulator_ops tps65218_ldo1_dcdc34_ops 
= {
.set_suspend_disable= tps65218_pmic_set_suspend_disable,
 };
 
-static const int ls3_currents[] = { 10, 20, 50, 100 };
-
+static const unsigned int ls3_currents[] = { 10, 20, 50, 100 };
 
 static int tps65218_pmic_set_input_current_lim(struct regulator_dev *dev,
   int lim_uA)
@@ -229,29 +231,13 @@ static int tps65218_pmic_set_current_limit(struct 
regulator_dev *dev,
 TPS65218_PROTECT_L1);
 }
 
-static int tps65218_pmic_get_current_limit(struct regulator_dev *dev)
-{
-   int retval;
-   unsigned int index;
-   struct tps65218 *tps = rdev_get_drvdata(dev);
-
-   retval = regmap_read(tps->regmap, dev->desc->csel_reg, &index);
-   if (retval < 0)
-   return retval;
-
-   index = (index & dev->desc->csel_mask) >>
-__builtin_ctz(dev->desc->csel_mask);
-
-   return ls3_currents[index];
-}
-
 static const struct regulator_ops tps65218_ls23_ops = {
.is_enabled = regulator_is_enabled_regmap,
.enable = tps65218_pmic_enable,
.disable= tps65218_pmic_disable,
.set_input_current_limit = tps65218_pmic_set_input_current_lim,
.set_current_limit  = tps65218_pmic_set_current_limit,
-   .get_current_limit  = tps65218_pmic_get_current_limit,
+   .get_current_limit  = regulator_get_current_limit_regmap,
 };
 
 /* Operations permitted on DCDC5, DCDC6 */
@@ -270,53 +256,57 @@ static const struct regulator_desc regulators[] = {
   TPS65218_CONTROL_DCDC1_MASK, TPS65218_REG_ENABLE1,
   TPS65218_ENABLE1_DC1_EN, 0, 0, dcdc1_dcdc2_ranges,
   2, 4000, 0, TPS65218_REG_SEQ3,
-  TPS65218_SEQ3_DC1_SEQ_MASK),
+  TPS65218_SEQ3_DC1_SEQ_MASK, NULL, 0),
TPS65218_REGULATOR("DCDC2", "regulator-dcdc2", TPS65218_DCDC_2,
   REGULATOR_VOLTAGE, tps65218_dcdc12_ops, 64,
   TPS65218_REG_CONTROL_DCDC2,
   TPS65218_CONTROL_DCDC2_MASK, TPS65218_REG_ENABLE1,
   TPS65218_ENABLE1_DC2_EN, 0, 0, dcdc1_dcdc2_ranges,
   2, 4000, 0, TPS65218_REG_SEQ3,
-  TPS65218_SEQ3_DC2_SEQ_MASK),
+  TPS65218_SEQ3_DC2_SEQ_MASK, NULL, 0),
TPS65218_REGULATOR("DCDC3", "regulator-dcdc3", TPS65218_DCDC_3,
   REGULATOR_VOLTAGE, tps65218_ldo1_dcdc34_ops, 64,
   TPS65218_REG_CONTROL_DCDC3,
   TPS65218_CONTROL_DCDC3_MASK, TPS65218_REG_ENABLE1,
   TPS65218_ENABLE1_DC3_EN, 0, 0, ldo1_dcdc3_ranges, 2,
-  0, 0, TPS65218_REG_SEQ4, TPS65218_SEQ4_DC3_SEQ_MASK),
+  0, 0, TPS65218_REG_SEQ4, TPS65218_SEQ4_DC3_SEQ_MASK,
+  NULL, 0),
TPS65218_REGULATOR("DCDC4", "regulator-dcdc4", TPS65218_DCDC_4,
   REGULATOR_VOLTAGE, tps65218_ldo1_dcdc34_ops, 53,
   TPS65218_REG_CONTROL_DCDC4,
   TPS65218_CONTROL_DCDC4_MAS

[PATCH 1/2] regulator: ab8500: Constify regulator_ops

2019-04-12 Thread Axel Lin
These regulator_ops variables never need to be modified, make them const so
compiler can put them to .rodata.

Signed-off-by: Axel Lin 
---
 drivers/regulator/ab8500.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
index 83dba3fbfe0c..6b9a3463f1fd 100644
--- a/drivers/regulator/ab8500.c
+++ b/drivers/regulator/ab8500.c
@@ -510,7 +510,7 @@ static int ab8500_regulator_set_voltage_sel(struct 
regulator_dev *rdev,
return ret;
 }
 
-static struct regulator_ops ab8500_regulator_volt_mode_ops = {
+static const struct regulator_ops ab8500_regulator_volt_mode_ops = {
.enable = ab8500_regulator_enable,
.disable= ab8500_regulator_disable,
.is_enabled = ab8500_regulator_is_enabled,
@@ -522,7 +522,7 @@ static struct regulator_ops ab8500_regulator_volt_mode_ops 
= {
.list_voltage   = regulator_list_voltage_table,
 };
 
-static struct regulator_ops ab8500_regulator_volt_ops = {
+static const struct regulator_ops ab8500_regulator_volt_ops = {
.enable = ab8500_regulator_enable,
.disable= ab8500_regulator_disable,
.is_enabled = ab8500_regulator_is_enabled,
@@ -531,7 +531,7 @@ static struct regulator_ops ab8500_regulator_volt_ops = {
.list_voltage   = regulator_list_voltage_table,
 };
 
-static struct regulator_ops ab8500_regulator_mode_ops = {
+static const struct regulator_ops ab8500_regulator_mode_ops = {
.enable = ab8500_regulator_enable,
.disable= ab8500_regulator_disable,
.is_enabled = ab8500_regulator_is_enabled,
@@ -541,14 +541,14 @@ static struct regulator_ops ab8500_regulator_mode_ops = {
.list_voltage   = regulator_list_voltage_table,
 };
 
-static struct regulator_ops ab8500_regulator_ops = {
+static const struct regulator_ops ab8500_regulator_ops = {
.enable = ab8500_regulator_enable,
.disable= ab8500_regulator_disable,
.is_enabled = ab8500_regulator_is_enabled,
.list_voltage   = regulator_list_voltage_table,
 };
 
-static struct regulator_ops ab8500_regulator_anamic_mode_ops = {
+static const struct regulator_ops ab8500_regulator_anamic_mode_ops = {
.enable = ab8500_regulator_enable,
.disable= ab8500_regulator_disable,
.is_enabled = ab8500_regulator_is_enabled,
-- 
2.17.1



[PATCH 2/2] regulator: ab8500: Remove *regulator from struct ab8500_regulator_info

2019-04-12 Thread Axel Lin
Current code is using devm_regulator_register() so we don't need to save
*regulator for clean up, use a local variable instead.

Signed-off-by: Axel Lin 
---
 drivers/regulator/ab8500.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
index 6b9a3463f1fd..3fcb4cbaab02 100644
--- a/drivers/regulator/ab8500.c
+++ b/drivers/regulator/ab8500.c
@@ -44,7 +44,6 @@ struct ab8500_shared_mode {
  * struct ab8500_regulator_info - ab8500 regulator information
  * @dev: device pointer
  * @desc: regulator description
- * @regulator_dev: regulator device
  * @shared_mode: used when mode is shared between two regulators
  * @load_lp_uA: maximum load in idle (low power) mode
  * @update_bank: bank to control on/off
@@ -65,7 +64,6 @@ struct ab8500_shared_mode {
 struct ab8500_regulator_info {
struct device   *dev;
struct regulator_desc   desc;
-   struct regulator_dev*regulator;
struct ab8500_shared_mode *shared_mode;
int load_lp_uA;
u8 update_bank;
@@ -1600,6 +1598,7 @@ static int ab8500_regulator_register(struct 
platform_device *pdev,
struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
struct ab8500_regulator_info *info = NULL;
struct regulator_config config = { };
+   struct regulator_dev *rdev;
 
/* assign per-regulator data */
info = &abx500_regulator.info[id];
@@ -1621,12 +1620,11 @@ static int ab8500_regulator_register(struct 
platform_device *pdev,
}
 
/* register regulator with framework */
-   info->regulator = devm_regulator_register(&pdev->dev, &info->desc,
-   &config);
-   if (IS_ERR(info->regulator)) {
+   rdev = devm_regulator_register(&pdev->dev, &info->desc, &config);
+   if (IS_ERR(rdev)) {
dev_err(&pdev->dev, "failed to register regulator %s\n",
info->desc.name);
-   return PTR_ERR(info->regulator);
+   return PTR_ERR(rdev);
}
 
return 0;
-- 
2.17.1



[PATCH 3/3] regulator: ab8500-ext: Convert to use simplified DT parsing

2019-04-12 Thread Axel Lin
Use regulator core's simplified DT parsing code to simplify the driver
implementation.

Signed-off-by: Axel Lin 
---
 drivers/regulator/ab8500-ext.c | 28 +---
 1 file changed, 5 insertions(+), 23 deletions(-)

diff --git a/drivers/regulator/ab8500-ext.c b/drivers/regulator/ab8500-ext.c
index 8e5365869c82..95704446d89e 100644
--- a/drivers/regulator/ab8500-ext.c
+++ b/drivers/regulator/ab8500-ext.c
@@ -733,6 +733,7 @@ static struct ab8500_ext_regulator_info
[AB8500_EXT_SUPPLY1] = {
.desc = {
.name   = "VEXTSUPPLY1",
+   .of_match   = of_match_ptr("ab8500_ext1"),
.ops= &ab8500_ext_regulator_ops,
.type   = REGULATOR_VOLTAGE,
.id = AB8500_EXT_SUPPLY1,
@@ -750,6 +751,7 @@ static struct ab8500_ext_regulator_info
[AB8500_EXT_SUPPLY2] = {
.desc = {
.name   = "VEXTSUPPLY2",
+   .of_match   = of_match_ptr("ab8500_ext2"),
.ops= &ab8500_ext_regulator_ops,
.type   = REGULATOR_VOLTAGE,
.id = AB8500_EXT_SUPPLY2,
@@ -767,6 +769,7 @@ static struct ab8500_ext_regulator_info
[AB8500_EXT_SUPPLY3] = {
.desc = {
.name   = "VEXTSUPPLY3",
+   .of_match   = of_match_ptr("ab8500_ext3"),
.ops= &ab8500_ext_regulator_ops,
.type   = REGULATOR_VOLTAGE,
.id = AB8500_EXT_SUPPLY3,
@@ -783,31 +786,13 @@ static struct ab8500_ext_regulator_info
},
 };
 
-static struct of_regulator_match ab8500_ext_regulator_match[] = {
-   { .name = "ab8500_ext1", .driver_data = (void *) AB8500_EXT_SUPPLY1, },
-   { .name = "ab8500_ext2", .driver_data = (void *) AB8500_EXT_SUPPLY2, },
-   { .name = "ab8500_ext3", .driver_data = (void *) AB8500_EXT_SUPPLY3, },
-};
-
 static int ab8500_ext_regulator_probe(struct platform_device *pdev)
 {
struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
struct ab8500_regulator_platform_data *pdata = 
&ab8500_regulator_plat_data;
-   struct device_node *np = pdev->dev.of_node;
struct regulator_config config = { };
struct regulator_dev *rdev;
-   int i, err;
-
-   if (np) {
-   err = of_regulator_match(&pdev->dev, np,
-ab8500_ext_regulator_match,
-
ARRAY_SIZE(ab8500_ext_regulator_match));
-   if (err < 0) {
-   dev_err(&pdev->dev,
-   "Error parsing regulator init data: %d\n", err);
-   return err;
-   }
-   }
+   int i;
 
if (!ab8500) {
dev_err(&pdev->dev, "null mfd parent\n");
@@ -843,10 +828,7 @@ static int ab8500_ext_regulator_probe(struct 
platform_device *pdev)
 
config.dev = &pdev->dev;
config.driver_data = info;
-   config.of_node = ab8500_ext_regulator_match[i].of_node;
-   config.init_data = (np) ?
-   ab8500_ext_regulator_match[i].init_data :
-   &pdata->ext_regulator[i];
+   config.init_data = &pdata->ext_regulator[i];
 
/* register regulator with framework */
rdev = devm_regulator_register(&pdev->dev, &info->desc,
-- 
2.17.1



[PATCH 2/3] regulator: ab8500-ext: Remove *rdev from struct ab8500_ext_regulator_info

2019-04-12 Thread Axel Lin
Current code is using devm_regulator_register() so we don't need to save
*rdev for clean up, use a local variable instead.

Signed-off-by: Axel Lin 
---
 drivers/regulator/ab8500-ext.c | 19 ---
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/regulator/ab8500-ext.c b/drivers/regulator/ab8500-ext.c
index 2268c934d6be..8e5365869c82 100644
--- a/drivers/regulator/ab8500-ext.c
+++ b/drivers/regulator/ab8500-ext.c
@@ -479,7 +479,6 @@ static struct ab8500_regulator_platform_data 
ab8500_regulator_plat_data = {
  * struct ab8500_ext_regulator_info - ab8500 regulator information
  * @dev: device pointer
  * @desc: regulator description
- * @rdev: regulator device
  * @cfg: regulator configuration (extension of regulator FW configuration)
  * @update_bank: bank to control on/off
  * @update_reg: register to control on/off
@@ -495,7 +494,6 @@ static struct ab8500_regulator_platform_data 
ab8500_regulator_plat_data = {
 struct ab8500_ext_regulator_info {
struct device *dev;
struct regulator_desc desc;
-   struct regulator_dev *rdev;
struct ab8500_ext_regulator_cfg *cfg;
u8 update_bank;
u8 update_reg;
@@ -530,7 +528,7 @@ static int ab8500_ext_regulator_enable(struct regulator_dev 
*rdev)
info->update_bank, info->update_reg,
info->update_mask, regval);
if (ret < 0) {
-   dev_err(rdev_get_dev(info->rdev),
+   dev_err(rdev_get_dev(rdev),
"couldn't set enable bits for regulator\n");
return ret;
}
@@ -566,7 +564,7 @@ static int ab8500_ext_regulator_disable(struct 
regulator_dev *rdev)
info->update_bank, info->update_reg,
info->update_mask, regval);
if (ret < 0) {
-   dev_err(rdev_get_dev(info->rdev),
+   dev_err(rdev_get_dev(rdev),
"couldn't set disable bits for regulator\n");
return ret;
}
@@ -797,6 +795,7 @@ static int ab8500_ext_regulator_probe(struct 
platform_device *pdev)
struct ab8500_regulator_platform_data *pdata = 
&ab8500_regulator_plat_data;
struct device_node *np = pdev->dev.of_node;
struct regulator_config config = { };
+   struct regulator_dev *rdev;
int i, err;
 
if (np) {
@@ -850,17 +849,15 @@ static int ab8500_ext_regulator_probe(struct 
platform_device *pdev)
&pdata->ext_regulator[i];
 
/* register regulator with framework */
-   info->rdev = devm_regulator_register(&pdev->dev, &info->desc,
-&config);
-   if (IS_ERR(info->rdev)) {
-   err = PTR_ERR(info->rdev);
+   rdev = devm_regulator_register(&pdev->dev, &info->desc,
+  &config);
+   if (IS_ERR(rdev)) {
dev_err(&pdev->dev, "failed to register regulator %s\n",
info->desc.name);
-   return err;
+   return PTR_ERR(rdev);
}
 
-   dev_dbg(rdev_get_dev(info->rdev),
-   "%s-probed\n", info->desc.name);
+   dev_dbg(&pdev->dev, "%s-probed\n", info->desc.name);
}
 
return 0;
-- 
2.17.1



[PATCH 1/3] regulator: ab8500-ext: Constify ab8500_ext_regulator_ops

2019-04-12 Thread Axel Lin
ab8500_ext_regulator_ops never need to be modified, make it const so
compiler can put it to .rodata.

Signed-off-by: Axel Lin 
---
 drivers/regulator/ab8500-ext.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/ab8500-ext.c b/drivers/regulator/ab8500-ext.c
index 2ca00045eb99..2268c934d6be 100644
--- a/drivers/regulator/ab8500-ext.c
+++ b/drivers/regulator/ab8500-ext.c
@@ -720,7 +720,7 @@ static int ab8500_ext_list_voltage(struct regulator_dev 
*rdev,
return -EINVAL;
 }
 
-static struct regulator_ops ab8500_ext_regulator_ops = {
+static const struct regulator_ops ab8500_ext_regulator_ops = {
.enable = ab8500_ext_regulator_enable,
.disable= ab8500_ext_regulator_disable,
.is_enabled = ab8500_ext_regulator_is_enabled,
-- 
2.17.1



regulator: ab8500: Question about AB8505_LDO_USB

2019-04-12 Thread Axel Lin
Hi Lee,
In ab8500 regulator driver code, I found the AB8505_LDO_USB entry does
not has corresponding entry in ab8505_regulator_match.

ab8505 support is added by below commit:
547f384f33dbd6171607f925ab246e25e315961e regulator: ab8500: add
support for ab8505

For ab8505, I'm wondering if it make sense to remove AB8505_LDO_USB
entry from ab8505_regulator_info?
Since it's not in the ab8505_regulator_match, it won't be registered anyway.
For ab8500, you removed the USB regulator by
41a06aa738ad889cf96f56024ddf84ecf4a18a6f regulator: ab8500: Remove USB regulator
So I'm wondering if AB8505_LDO_USB is similar case.

Or does it make sense to add the corresponding entry to ab8505_regulator_match?

Thanks,
Axel


[PATCH 2/3] regulator: db8500-prcmu: Convert to use simplified DT parsing

2019-04-11 Thread Axel Lin
Use regulator core's simplified DT parsing code to simplify the driver
implementation.

Signed-off-by: Axel Lin 
---
 drivers/regulator/db8500-prcmu.c | 139 ++-
 1 file changed, 42 insertions(+), 97 deletions(-)

diff --git a/drivers/regulator/db8500-prcmu.c b/drivers/regulator/db8500-prcmu.c
index 863bd3de42a7..c2a3ccfc510e 100644
--- a/drivers/regulator/db8500-prcmu.c
+++ b/drivers/regulator/db8500-prcmu.c
@@ -214,6 +214,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_VAPE] = {
.desc = {
.name   = "db8500-vape",
+   .of_match = of_match_ptr("db8500_vape"),
.id = DB8500_REGULATOR_VAPE,
.ops= &db8500_regulator_ops,
.type   = REGULATOR_VOLTAGE,
@@ -223,6 +224,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_VARM] = {
.desc = {
.name   = "db8500-varm",
+   .of_match = of_match_ptr("db8500_varm"),
.id = DB8500_REGULATOR_VARM,
.ops= &db8500_regulator_ops,
.type   = REGULATOR_VOLTAGE,
@@ -232,6 +234,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_VMODEM] = {
.desc = {
.name   = "db8500-vmodem",
+   .of_match = of_match_ptr("db8500_vmodem"),
.id = DB8500_REGULATOR_VMODEM,
.ops= &db8500_regulator_ops,
.type   = REGULATOR_VOLTAGE,
@@ -241,6 +244,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_VPLL] = {
.desc = {
.name   = "db8500-vpll",
+   .of_match = of_match_ptr("db8500_vpll"),
.id = DB8500_REGULATOR_VPLL,
.ops= &db8500_regulator_ops,
.type   = REGULATOR_VOLTAGE,
@@ -250,6 +254,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_VSMPS1] = {
.desc = {
.name   = "db8500-vsmps1",
+   .of_match = of_match_ptr("db8500_vsmps1"),
.id = DB8500_REGULATOR_VSMPS1,
.ops= &db8500_regulator_ops,
.type   = REGULATOR_VOLTAGE,
@@ -259,6 +264,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_VSMPS2] = {
.desc = {
.name   = "db8500-vsmps2",
+   .of_match = of_match_ptr("db8500_vsmps2"),
.id = DB8500_REGULATOR_VSMPS2,
.ops= &db8500_regulator_ops,
.type   = REGULATOR_VOLTAGE,
@@ -271,6 +277,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_VSMPS3] = {
.desc = {
.name   = "db8500-vsmps3",
+   .of_match = of_match_ptr("db8500_vsmps3"),
.id = DB8500_REGULATOR_VSMPS3,
.ops= &db8500_regulator_ops,
.type   = REGULATOR_VOLTAGE,
@@ -280,6 +287,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_VRF1] = {
.desc = {
.name   = "db8500-vrf1",
+   .of_match = of_match_ptr("db8500_vrf1"),
.id = DB8500_REGULATOR_VRF1,
.ops= &db8500_regulator_ops,
.type   = REGULATOR_VOLTAGE,
@@ -289,6 +297,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_SWITCH_SVAMMDSP] = {
.desc = {
.name   = "db8500-sva-mmdsp",
+   .of_match = of_match_ptr("db8500_sva_mmdsp"),
.id = DB8500_REGULATOR_SWITCH_SVAMMDSP,
.ops= &db8500_regulator_switch_ops,
.type   = REGULATOR_VOLTAGE,
@@ -299,6 +308,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_SWITCH_SVAMMDSPRET] = {
.desc = {
.name   = "db8500-sva-mmdsp-ret",
+   .of_match = of_match_ptr("db8500_sva_mmdsp_ret"),
.id = DB8500_REGULATOR_SWITCH_SVAMMDSPRET,
.ops= &db8500_regulator_switch_ops,
.type   = REGULATOR_VOLTAGE,
@@ -310,6 +320,7 @@ dbx500_regulator_info[DB8

[PATCH 3/3] regulator: dbx500-prcmu: Remove unused fields from struct dbx500_regulator_info

2019-04-11 Thread Axel Lin
The *dev is assigned but not used, remove it.
Current driver is using devm_regulator_register(), so no neeed to save
*rdev for clean up. Use a local variable instead.

Signed-off-by: Axel Lin 
---
 drivers/regulator/db8500-prcmu.c | 10 +-
 drivers/regulator/dbx500-prcmu.h |  4 
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/regulator/db8500-prcmu.c b/drivers/regulator/db8500-prcmu.c
index c2a3ccfc510e..eb317663f875 100644
--- a/drivers/regulator/db8500-prcmu.c
+++ b/drivers/regulator/db8500-prcmu.c
@@ -439,6 +439,7 @@ static int db8500_regulator_probe(struct platform_device 
*pdev)
struct regulator_init_data *db8500_init_data;
struct dbx500_regulator_info *info;
struct regulator_config config = { };
+   struct regulator_dev *rdev;
int err, i;
 
db8500_init_data = dev_get_platdata(&pdev->dev);
@@ -446,17 +447,16 @@ static int db8500_regulator_probe(struct platform_device 
*pdev)
for (i = 0; i < ARRAY_SIZE(dbx500_regulator_info); i++) {
/* assign per-regulator data */
info = &dbx500_regulator_info[i];
-   info->dev = &pdev->dev;
 
config.driver_data = info;
config.dev = &pdev->dev;
if (db8500_init_data)
config.init_data = &db8500_init_data[i];
 
-   info->rdev = devm_regulator_register(&pdev->dev, &info->desc,
-&config);
-   if (IS_ERR(info->rdev)) {
-   err = PTR_ERR(info->rdev);
+   rdev = devm_regulator_register(&pdev->dev, &info->desc,
+  &config);
+   if (IS_ERR(rdev)) {
+   err = PTR_ERR(rdev);
dev_err(&pdev->dev, "failed to register %s: err %i\n",
info->desc.name, err);
return err;
diff --git a/drivers/regulator/dbx500-prcmu.h b/drivers/regulator/dbx500-prcmu.h
index c8e51ace9f06..6e20dab611ac 100644
--- a/drivers/regulator/dbx500-prcmu.h
+++ b/drivers/regulator/dbx500-prcmu.h
@@ -15,18 +15,14 @@
 
 /**
  * struct dbx500_regulator_info - dbx500 regulator information
- * @dev: device pointer
  * @desc: regulator description
- * @rdev: regulator device pointer
  * @is_enabled: status of the regulator
  * @epod_id: id for EPOD (power domain)
  * @is_ramret: RAM retention switch for EPOD (power domain)
  *
  */
 struct dbx500_regulator_info {
-   struct device *dev;
struct regulator_desc desc;
-   struct regulator_dev *rdev;
bool is_enabled;
u16 epod_id;
bool is_ramret;
-- 
2.17.1



[PATCH 1/3] regulator: db8500-prcmu: Constify regulator_ops

2019-04-11 Thread Axel Lin
These regulator_ops variables never need to be modified, make them const so
compiler can put them to .rodata.

Signed-off-by: Axel Lin 
---
 drivers/regulator/db8500-prcmu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/db8500-prcmu.c b/drivers/regulator/db8500-prcmu.c
index 7cec535cf0bc..863bd3de42a7 100644
--- a/drivers/regulator/db8500-prcmu.c
+++ b/drivers/regulator/db8500-prcmu.c
@@ -75,7 +75,7 @@ static int db8500_regulator_is_enabled(struct regulator_dev 
*rdev)
 }
 
 /* db8500 regulator operations */
-static struct regulator_ops db8500_regulator_ops = {
+static const struct regulator_ops db8500_regulator_ops = {
.enable = db8500_regulator_enable,
.disable= db8500_regulator_disable,
.is_enabled = db8500_regulator_is_enabled,
@@ -200,7 +200,7 @@ static int db8500_regulator_switch_is_enabled(struct 
regulator_dev *rdev)
return info->is_enabled;
 }
 
-static struct regulator_ops db8500_regulator_switch_ops = {
+static const struct regulator_ops db8500_regulator_switch_ops = {
.enable = db8500_regulator_switch_enable,
.disable= db8500_regulator_switch_disable,
.is_enabled = db8500_regulator_switch_is_enabled,
-- 
2.17.1



[PATCH 2/2] regulator: mcp16502: Remove setup_regulators function

2019-04-10 Thread Axel Lin
It seems a little bit odd current code pass struct regulator_config rather
than a pointer to setup_regulators. The setup_regulators is so simple and
only has one caller, so remove it.

Signed-off-by: Axel Lin 
---
 drivers/regulator/mcp16502.c | 37 +++-
 1 file changed, 11 insertions(+), 26 deletions(-)

diff --git a/drivers/regulator/mcp16502.c b/drivers/regulator/mcp16502.c
index 9292ab8736c7..e5a02711cb46 100644
--- a/drivers/regulator/mcp16502.c
+++ b/drivers/regulator/mcp16502.c
@@ -427,36 +427,15 @@ static const struct regmap_config mcp16502_regmap_config 
= {
.wr_table   = &mcp16502_yes_reg_table,
 };
 
-/*
- * set_up_regulators() - initialize all regulators
- */
-static int setup_regulators(struct mcp16502 *mcp, struct device *dev,
-   struct regulator_config config)
-{
-   struct regulator_dev *rdev;
-   int i;
-
-   for (i = 0; i < NUM_REGULATORS; i++) {
-   rdev = devm_regulator_register(dev, &mcp16502_desc[i], &config);
-   if (IS_ERR(rdev)) {
-   dev_err(dev,
-   "failed to register %s regulator %ld\n",
-   mcp16502_desc[i].name, PTR_ERR(rdev));
-   return PTR_ERR(rdev);
-   }
-   }
-
-   return 0;
-}
-
 static int mcp16502_probe(struct i2c_client *client,
  const struct i2c_device_id *id)
 {
struct regulator_config config = { };
+   struct regulator_dev *rdev;
struct device *dev;
struct mcp16502 *mcp;
struct regmap *rmap;
-   int ret = 0;
+   int i, ret;
 
dev = &client->dev;
config.dev = dev;
@@ -482,9 +461,15 @@ static int mcp16502_probe(struct i2c_client *client,
return PTR_ERR(mcp->lpm);
}
 
-   ret = setup_regulators(mcp, dev, config);
-   if (ret != 0)
-   return ret;
+   for (i = 0; i < NUM_REGULATORS; i++) {
+   rdev = devm_regulator_register(dev, &mcp16502_desc[i], &config);
+   if (IS_ERR(rdev)) {
+   dev_err(dev,
+   "failed to register %s regulator %ld\n",
+   mcp16502_desc[i].name, PTR_ERR(rdev));
+   return PTR_ERR(rdev);
+   }
+   }
 
mcp16502_gpio_set_mode(mcp, MCP16502_OPMODE_ACTIVE);
 
-- 
2.17.1



[PATCH 1/2] regulator: mcp16502: Remove unneeded fields from struct mcp16502

2019-04-10 Thread Axel Lin
At the context with rdev, we can use rdev->regmap instead of mcp->rmap.
The *rdev[NUM_REGULATORS] is not required because current code uses
devm_regulator_register() so we don't need to store *rdev for clean up
paths.

Signed-off-by: Axel Lin 
---
 drivers/regulator/mcp16502.c | 40 +++-
 1 file changed, 16 insertions(+), 24 deletions(-)

diff --git a/drivers/regulator/mcp16502.c b/drivers/regulator/mcp16502.c
index 3a8004abe044..9292ab8736c7 100644
--- a/drivers/regulator/mcp16502.c
+++ b/drivers/regulator/mcp16502.c
@@ -119,8 +119,6 @@ enum {
  * @lpm: LPM GPIO descriptor
  */
 struct mcp16502 {
-   struct regulator_dev *rdev[NUM_REGULATORS];
-   struct regmap *rmap;
struct gpio_desc *lpm;
 };
 
@@ -179,13 +177,12 @@ static unsigned int mcp16502_get_mode(struct 
regulator_dev *rdev)
 {
unsigned int val;
int ret, reg;
-   struct mcp16502 *mcp = rdev_get_drvdata(rdev);
 
reg = mcp16502_get_reg(rdev, MCP16502_OPMODE_ACTIVE);
if (reg < 0)
return reg;
 
-   ret = regmap_read(mcp->rmap, reg, &val);
+   ret = regmap_read(rdev->regmap, reg, &val);
if (ret)
return ret;
 
@@ -211,7 +208,6 @@ static int _mcp16502_set_mode(struct regulator_dev *rdev, 
unsigned int mode,
 {
int val;
int reg;
-   struct mcp16502 *mcp = rdev_get_drvdata(rdev);
 
reg = mcp16502_get_reg(rdev, op_mode);
if (reg < 0)
@@ -228,7 +224,7 @@ static int _mcp16502_set_mode(struct regulator_dev *rdev, 
unsigned int mode,
return -EINVAL;
}
 
-   reg = regmap_update_bits(mcp->rmap, reg, MCP16502_MODE, val);
+   reg = regmap_update_bits(rdev->regmap, reg, MCP16502_MODE, val);
return reg;
 }
 
@@ -247,9 +243,8 @@ static int mcp16502_get_status(struct regulator_dev *rdev)
 {
int ret;
unsigned int val;
-   struct mcp16502 *mcp = rdev_get_drvdata(rdev);
 
-   ret = regmap_read(mcp->rmap, MCP16502_STAT_BASE(rdev_get_id(rdev)),
+   ret = regmap_read(rdev->regmap, MCP16502_STAT_BASE(rdev_get_id(rdev)),
  &val);
if (ret)
return ret;
@@ -290,7 +285,6 @@ static int mcp16502_suspend_get_target_reg(struct 
regulator_dev *rdev)
  */
 static int mcp16502_set_suspend_voltage(struct regulator_dev *rdev, int uV)
 {
-   struct mcp16502 *mcp = rdev_get_drvdata(rdev);
int sel = regulator_map_voltage_linear_range(rdev, uV, uV);
int reg = mcp16502_suspend_get_target_reg(rdev);
 
@@ -300,7 +294,7 @@ static int mcp16502_set_suspend_voltage(struct 
regulator_dev *rdev, int uV)
if (reg < 0)
return reg;
 
-   return regmap_update_bits(mcp->rmap, reg, MCP16502_VSEL, sel);
+   return regmap_update_bits(rdev->regmap, reg, MCP16502_VSEL, sel);
 }
 
 /*
@@ -328,13 +322,12 @@ static int mcp16502_set_suspend_mode(struct regulator_dev 
*rdev,
  */
 static int mcp16502_set_suspend_enable(struct regulator_dev *rdev)
 {
-   struct mcp16502 *mcp = rdev_get_drvdata(rdev);
int reg = mcp16502_suspend_get_target_reg(rdev);
 
if (reg < 0)
return reg;
 
-   return regmap_update_bits(mcp->rmap, reg, MCP16502_EN, MCP16502_EN);
+   return regmap_update_bits(rdev->regmap, reg, MCP16502_EN, MCP16502_EN);
 }
 
 /*
@@ -342,13 +335,12 @@ static int mcp16502_set_suspend_enable(struct 
regulator_dev *rdev)
  */
 static int mcp16502_set_suspend_disable(struct regulator_dev *rdev)
 {
-   struct mcp16502 *mcp = rdev_get_drvdata(rdev);
int reg = mcp16502_suspend_get_target_reg(rdev);
 
if (reg < 0)
return reg;
 
-   return regmap_update_bits(mcp->rmap, reg, MCP16502_EN, 0);
+   return regmap_update_bits(rdev->regmap, reg, MCP16502_EN, 0);
 }
 #endif /* CONFIG_SUSPEND */
 
@@ -441,17 +433,16 @@ static const struct regmap_config mcp16502_regmap_config 
= {
 static int setup_regulators(struct mcp16502 *mcp, struct device *dev,
struct regulator_config config)
 {
+   struct regulator_dev *rdev;
int i;
 
for (i = 0; i < NUM_REGULATORS; i++) {
-   mcp->rdev[i] = devm_regulator_register(dev,
-  &mcp16502_desc[i],
-  &config);
-   if (IS_ERR(mcp->rdev[i])) {
+   rdev = devm_regulator_register(dev, &mcp16502_desc[i], &config);
+   if (IS_ERR(rdev)) {
dev_err(dev,
"failed to register %s regulator %ld\n",
-   mcp16502_desc[i].name, PTR_ERR(mcp->rdev[i]));
-   return PTR_ERR(mcp->rdev[i]);
+   mcp16502_desc[i].name, PTR_ERR(rdev));
+   return P

[PATCH] regulator: vexpress: Constify regulator_ops

2019-04-10 Thread Axel Lin
vexpress_regulator_ops_ro and vexpress_regulator_ops are never changed,
make them const.

Signed-off-by: Axel Lin 
---
 drivers/regulator/vexpress-regulator.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/vexpress-regulator.c 
b/drivers/regulator/vexpress-regulator.c
index c810cbbd463f..ca4230fe9e77 100644
--- a/drivers/regulator/vexpress-regulator.c
+++ b/drivers/regulator/vexpress-regulator.c
@@ -46,11 +46,11 @@ static int vexpress_regulator_set_voltage(struct 
regulator_dev *regdev,
return regmap_write(reg->regmap, 0, min_uV);
 }
 
-static struct regulator_ops vexpress_regulator_ops_ro = {
+static const struct regulator_ops vexpress_regulator_ops_ro = {
.get_voltage = vexpress_regulator_get_voltage,
 };
 
-static struct regulator_ops vexpress_regulator_ops = {
+static const struct regulator_ops vexpress_regulator_ops = {
.get_voltage = vexpress_regulator_get_voltage,
.set_voltage = vexpress_regulator_set_voltage,
 };
-- 
2.17.1



  1   2   3   4   5   6   7   8   9   10   >