From 91a024e80336528d12b67b5a2e636b9e4467d3ec Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Mon, 10 Jul 2017 16:33:39 +0200 Subject: [PATCH 1/7] regulator: cpcap: Fix standby mode The original patch from Tony uses standby mode bit inverted, which is not correct. This fixes all instances in the driver code for get & set mode. This did not yet make problems, since mode has not been changed by any mainline driver so far. Fixes: 0ad4c07edd41 ("regulator: cpcap: Add basic regulator support") Acked-by: Tony Lindgren Signed-off-by: Sebastian Reichel Signed-off-by: Mark Brown Cc: stable@vger.kernel.org --- drivers/regulator/cpcap-regulator.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/regulator/cpcap-regulator.c b/drivers/regulator/cpcap-regulator.c index cc98aceed1c1..ce1cab320f6f 100644 --- a/drivers/regulator/cpcap-regulator.c +++ b/drivers/regulator/cpcap-regulator.c @@ -77,6 +77,8 @@ #define CPCAP_BIT_VAUDIO_MODE0 BIT(1) #define CPCAP_BIT_V_AUDIO_EN BIT(0) +#define CPCAP_BIT_AUDIO_NORMAL_MODE 0x00 + /* * Off mode configuration bit. Used currently only by SW5 on omap4. There's * the following comment in Motorola Linux kernel tree for it: @@ -217,7 +219,7 @@ static unsigned int cpcap_regulator_get_mode(struct regulator_dev *rdev) regmap_read(rdev->regmap, rdev->desc->enable_reg, &value); - if (!(value & CPCAP_BIT_AUDIO_LOW_PWR)) + if (value & CPCAP_BIT_AUDIO_LOW_PWR) return REGULATOR_MODE_STANDBY; return REGULATOR_MODE_NORMAL; @@ -230,10 +232,10 @@ static int cpcap_regulator_set_mode(struct regulator_dev *rdev, switch (mode) { case REGULATOR_MODE_NORMAL: - value = CPCAP_BIT_AUDIO_LOW_PWR; + value = CPCAP_BIT_AUDIO_NORMAL_MODE; break; case REGULATOR_MODE_STANDBY: - value = 0; + value = CPCAP_BIT_AUDIO_LOW_PWR; break; default: return -EINVAL; From 74ff8e06510196dfa31679010d9a05c5cdc39754 Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Mon, 10 Jul 2017 16:33:40 +0200 Subject: [PATCH 2/7] regulator: cpcap: Add OF mode mapping Add device tree mode mapping capabilities to the cpcap driver. Acked-by: Tony Lindgren Signed-off-by: Sebastian Reichel Signed-off-by: Mark Brown --- drivers/regulator/cpcap-regulator.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/regulator/cpcap-regulator.c b/drivers/regulator/cpcap-regulator.c index ce1cab320f6f..f541b80f1b54 100644 --- a/drivers/regulator/cpcap-regulator.c +++ b/drivers/regulator/cpcap-regulator.c @@ -123,6 +123,7 @@ struct cpcap_regulator { .enable_val = (mode_val), \ .disable_val = (off_val), \ .ramp_delay = (volt_trans_time), \ + .of_map_mode = cpcap_map_mode, \ }, \ .assign_reg = (assignment_reg), \ .assign_mask = (assignment_mask), \ @@ -213,6 +214,18 @@ static int cpcap_regulator_disable(struct regulator_dev *rdev) return error; } +static unsigned int cpcap_map_mode(unsigned int mode) +{ + switch (mode) { + case CPCAP_BIT_AUDIO_NORMAL_MODE: + return REGULATOR_MODE_NORMAL; + case CPCAP_BIT_AUDIO_LOW_PWR: + return REGULATOR_MODE_STANDBY; + default: + return -EINVAL; + } +} + static unsigned int cpcap_regulator_get_mode(struct regulator_dev *rdev) { int value; From 7799167b7a14feb17c258fb33a02c61eb54f67d1 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Tue, 18 Jul 2017 16:43:26 -0500 Subject: [PATCH 3/7] regulator: Convert to using %pOF instead of full_name Now that we have a custom printf format specifier, convert users of full_name to use %pOF instead. This is preparation to remove storing of the full path string for each node. Signed-off-by: Rob Herring Reviewed-by: Krzysztof Kozlowski Reviewed-by: Philipp Zabel Signed-off-by: Mark Brown --- drivers/regulator/core.c | 4 ++-- drivers/regulator/max1586.c | 2 +- drivers/regulator/s5m8767.c | 4 ++-- drivers/reset/reset-socfpga.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index e567fa54980b..d79ba9af9352 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -204,8 +204,8 @@ static struct device_node *of_get_regulator(struct device *dev, const char *supp regnode = of_parse_phandle(dev->of_node, prop_name, 0); if (!regnode) { - dev_dbg(dev, "Looking up %s property in node %s failed\n", - prop_name, dev->of_node->full_name); + dev_dbg(dev, "Looking up %s property in node %pOF failed\n", + prop_name, dev->of_node); return NULL; } return regnode; diff --git a/drivers/regulator/max1586.c b/drivers/regulator/max1586.c index 6779c2b53674..66bbaa999433 100644 --- a/drivers/regulator/max1586.c +++ b/drivers/regulator/max1586.c @@ -169,7 +169,7 @@ static int of_get_max1586_platform_data(struct device *dev, if (of_property_read_u32(np, "v3-gain", &pdata->v3_gain) < 0) { - dev_err(dev, "%s has no 'v3-gain' property\n", np->full_name); + dev_err(dev, "%pOF has no 'v3-gain' property\n", np); return -EINVAL; } diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index 383cd7533721..4836947e1521 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c @@ -590,8 +590,8 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, if (of_property_read_u32(reg_np, "op_mode", &rmode->mode)) { dev_warn(iodev->dev, - "no op_mode property property at %s\n", - reg_np->full_name); + "no op_mode property property at %pOF\n", + reg_np); rmode->mode = S5M8767_OPMODE_NORMAL_MODE; } diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c index 07224c019892..c60904ff40b8 100644 --- a/drivers/reset/reset-socfpga.c +++ b/drivers/reset/reset-socfpga.c @@ -109,8 +109,8 @@ static int socfpga_reset_probe(struct platform_device *pdev) * Do not continue, when we encounter an old DT. */ if (!of_find_property(pdev->dev.of_node, "#reset-cells", NULL)) { - dev_err(&pdev->dev, "%s missing #reset-cells property\n", - pdev->dev.of_node->full_name); + dev_err(&pdev->dev, "%pOF missing #reset-cells property\n", + pdev->dev.of_node); return -EINVAL; } From d110e3e921742980a54c27f16086dc5a6c1aecd7 Mon Sep 17 00:00:00 2001 From: Jisheng Zhang Date: Thu, 20 Jul 2017 16:42:17 +0800 Subject: [PATCH 4/7] regulator: fan53555: Use of_device_get_match_data() to simplify probe if fan53555_regulator_probe() is called and the "client->dev.of_node" isn't NULL, it means OF registered a device with a valid compatible string, so match cannot be NULL. Use of_device_get_match_data() to retrieve the drvdata pointer. No functional change intended. Signed-off-by: Jisheng Zhang Signed-off-by: Mark Brown --- drivers/regulator/fan53555.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c index 60f431831582..6b1c0e4672a2 100644 --- a/drivers/regulator/fan53555.c +++ b/drivers/regulator/fan53555.c @@ -407,14 +407,8 @@ static int fan53555_regulator_probe(struct i2c_client *client, di->regulator = pdata->regulator; if (client->dev.of_node) { - const struct of_device_id *match; - - match = of_match_device(of_match_ptr(fan53555_dt_ids), - &client->dev); - if (!match) - return -ENODEV; - - di->vendor = (unsigned long) match->data; + di->vendor = + (unsigned long)of_device_get_match_data(&client->dev); } else { /* if no ramp constraint set, get the pdata ramp_delay */ if (!di->regulator->constraints.ramp_delay) { From fc1111b885437f374ed54aadda44d8b241ebd2a3 Mon Sep 17 00:00:00 2001 From: Guillaume Tucker Date: Mon, 21 Aug 2017 13:47:43 +0100 Subject: [PATCH 5/7] regulator: fan53555: fix I2C device ids The device tree nodes all correctly describe the regulators as syr827 or syr828, but the I2C device id is currently set to the wildcard value of syr82x in the driver. This causes udev to fail to match the driver module with the modalias data from sysfs. Fix this by replacing the I2C device ids with ones that match the device tree descriptions, with syr827 and syr828. Tested on Firefly rk3288 board. The syr82x id was not used anywhere. Fixes: e80c47bd738b (regulator: fan53555: Export I2C module alias information) Signed-off-by: Guillaume Tucker Signed-off-by: Mark Brown --- drivers/regulator/fan53555.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c index 6b1c0e4672a2..a3bc8037153e 100644 --- a/drivers/regulator/fan53555.c +++ b/drivers/regulator/fan53555.c @@ -470,7 +470,10 @@ static const struct i2c_device_id fan53555_id[] = { .name = "fan53555", .driver_data = FAN53555_VENDOR_FAIRCHILD }, { - .name = "syr82x", + .name = "syr827", + .driver_data = FAN53555_VENDOR_SILERGY + }, { + .name = "syr828", .driver_data = FAN53555_VENDOR_SILERGY }, { }, From 6d284bb11c302a4db4d169ca13d48dbb4d9b5cbe Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 21 Aug 2017 22:21:08 +0530 Subject: [PATCH 6/7] regulator: ltc3589: constify i2c_device_id i2c_device_id are not supposed to change at runtime. All functions working with i2c_device_id provided by work with const i2c_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Mark Brown --- drivers/regulator/ltc3589.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/ltc3589.c b/drivers/regulator/ltc3589.c index 853a06ad86d6..18d5b01ddcb2 100644 --- a/drivers/regulator/ltc3589.c +++ b/drivers/regulator/ltc3589.c @@ -539,7 +539,7 @@ static int ltc3589_probe(struct i2c_client *client, return 0; } -static struct i2c_device_id ltc3589_i2c_id[] = { +static const struct i2c_device_id ltc3589_i2c_id[] = { { "ltc3589", LTC3589 }, { "ltc3589-1", LTC3589_1 }, { "ltc3589-2", LTC3589_2 }, From b6615659827839f3031c6bd4c1599c3c705778ac Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 30 Aug 2017 17:03:58 +0300 Subject: [PATCH 7/7] regulator: da9063: Return an error code on probe failure If "regl_pdata->n_regulators == 0" is true then we accidentally return PTR_ERR() instead of an error code. I've changed it to return -ENODEV instead. Fixes: 69ca3e58d178 ("regulator: da9063: Add Dialog DA9063 voltage regulators support.") Signed-off-by: Dan Carpenter Signed-off-by: Mark Brown --- drivers/regulator/da9063-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/da9063-regulator.c b/drivers/regulator/da9063-regulator.c index c6af343f54ea..6a8f9cd69f52 100644 --- a/drivers/regulator/da9063-regulator.c +++ b/drivers/regulator/da9063-regulator.c @@ -736,7 +736,7 @@ static int da9063_regulator_probe(struct platform_device *pdev) if (IS_ERR(regl_pdata) || regl_pdata->n_regulators == 0) { dev_err(&pdev->dev, "No regulators defined for the platform\n"); - return PTR_ERR(regl_pdata); + return -ENODEV; } /* Find regulators set for particular device model */