Check the return value of regulator_enable to silence the following
type of warnings:
drivers/power/ab8500_charger.c:1390:20: warning: ignoring return value
of ‘regulator_enable’, declared with attribute warn_unused_result
[-Wunused-result]
Signed-off-by: Sachin Kamat <[email protected]>
Cc: Lee Jones <[email protected]>
---
drivers/power/ab8500_charger.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c
index a4c4a10..fec0546 100644
--- a/drivers/power/ab8500_charger.c
+++ b/drivers/power/ab8500_charger.c
@@ -1387,7 +1387,12 @@ static int ab8500_charger_ac_en(struct ux500_charger *charger,
* the GPADC module independant of the AB8500 chargers
*/
if (!di->vddadc_en_ac) {
- regulator_enable(di->regu);
+ ret = regulator_enable(di->regu);
+ if (ret) {
+ dev_err(di->dev,
+ "Failed to enable regulator\n");
+ return ret;
+ }
di->vddadc_en_ac = true;
}
@@ -1556,7 +1561,12 @@ static int ab8500_charger_usb_en(struct ux500_charger *charger,
* the GPADC module independant of the AB8500 chargers
*/
if (!di->vddadc_en_usb) {
- regulator_enable(di->regu);
+ ret = regulator_enable(di->regu);
+ if (ret) {
+ dev_err(di->dev,
+ "Failed to enable regulator\n");
+ return ret;
+ }
di->vddadc_en_usb = true;
}
--
1.7.9.5
Each of the if-else blocks has a break statement.
Remove the additional one which is unreachable.
Signed-off-by: Sachin Kamat <[email protected]>
---
drivers/power/ab8500_charger.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c
index fec0546..608b63e 100644
--- a/drivers/power/ab8500_charger.c
+++ b/drivers/power/ab8500_charger.c
@@ -766,7 +766,6 @@ static int ab8500_charger_max_usb_curr(struct ab8500_charger *di,
ret = -ENXIO;
break;
}
- break;
case USB_STAT_CARKIT_1:
case USB_STAT_CARKIT_2:
case USB_STAT_ACA_DOCK_CHARGER:
--
1.7.9.5
Check the return value of regulator_enable to silence the following
warning:
drivers/power/pm2301_charger.c:725:20: warning:
ignoring return value of ‘regulator_enable’, declared with
attribute warn_unused_result [-Wunused-result]
Signed-off-by: Sachin Kamat <[email protected]>
Cc: Lee Jones <[email protected]>
---
drivers/power/pm2301_charger.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/power/pm2301_charger.c b/drivers/power/pm2301_charger.c
index ffa10ed..ab87d1a 100644
--- a/drivers/power/pm2301_charger.c
+++ b/drivers/power/pm2301_charger.c
@@ -722,7 +722,12 @@ static int pm2xxx_charger_ac_en(struct ux500_charger *charger,
dev_dbg(pm2->dev, "Enable AC: %dmV %dmA\n", vset, iset);
if (!pm2->vddadc_en_ac) {
- regulator_enable(pm2->regu);
+ ret = regulator_enable(pm2->regu);
+ if (ret) {
+ dev_err(pm2->dev,
+ "Failed to enable regulator\n");
+ goto error_occured;
+ }
pm2->vddadc_en_ac = true;
}
--
1.7.9.5
pm2xxx_charger_die_therm_mngt is used only in this file.
Make it static.
Signed-off-by: Sachin Kamat <[email protected]>
Cc: Lee Jones <[email protected]>
---
drivers/power/pm2301_charger.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/power/pm2301_charger.c b/drivers/power/pm2301_charger.c
index ab87d1a..b9e1ef7 100644
--- a/drivers/power/pm2301_charger.c
+++ b/drivers/power/pm2301_charger.c
@@ -205,7 +205,7 @@ static int pm2xxx_charger_batt_therm_mngt(struct pm2xxx_charger *pm2, int val)
}
-int pm2xxx_charger_die_therm_mngt(struct pm2xxx_charger *pm2, int val)
+static int pm2xxx_charger_die_therm_mngt(struct pm2xxx_charger *pm2, int val)
{
queue_work(pm2->charger_wq, &pm2->check_main_thermal_prot_work);
--
1.7.9.5
On Mon, 02 Sep 2013, Sachin Kamat wrote:
> Check the return value of regulator_enable to silence the following
> type of warnings:
> drivers/power/ab8500_charger.c:1390:20: warning: ignoring return value
> of ‘regulator_enable’, declared with attribute warn_unused_result
> [-Wunused-result]
I think I remember something about it being okay for the regulators to
fail, but that may have been something else. I think I'd be more
comfortable if we just raised a dev_warn() and didn't return early in
the error case.
> Signed-off-by: Sachin Kamat <[email protected]>
> Cc: Lee Jones <[email protected]>
> ---
> drivers/power/ab8500_charger.c | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c
> index a4c4a10..fec0546 100644
> --- a/drivers/power/ab8500_charger.c
> +++ b/drivers/power/ab8500_charger.c
> @@ -1387,7 +1387,12 @@ static int ab8500_charger_ac_en(struct ux500_charger *charger,
> * the GPADC module independant of the AB8500 chargers
> */
> if (!di->vddadc_en_ac) {
> - regulator_enable(di->regu);
> + ret = regulator_enable(di->regu);
> + if (ret) {
> + dev_err(di->dev,
> + "Failed to enable regulator\n");
> + return ret;
> + }
> di->vddadc_en_ac = true;
> }
>
> @@ -1556,7 +1561,12 @@ static int ab8500_charger_usb_en(struct ux500_charger *charger,
> * the GPADC module independant of the AB8500 chargers
> */
> if (!di->vddadc_en_usb) {
> - regulator_enable(di->regu);
> + ret = regulator_enable(di->regu);
> + if (ret) {
> + dev_err(di->dev,
> + "Failed to enable regulator\n");
> + return ret;
> + }
> di->vddadc_en_usb = true;
> }
>
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
On Mon, 02 Sep 2013, Sachin Kamat wrote:
> Check the return value of regulator_enable to silence the following
> warning:
> drivers/power/pm2301_charger.c:725:20: warning:
> ignoring return value of ‘regulator_enable’, declared with
> attribute warn_unused_result [-Wunused-result]
Same thing here.
> Signed-off-by: Sachin Kamat <[email protected]>
> Cc: Lee Jones <[email protected]>
> ---
> drivers/power/pm2301_charger.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/power/pm2301_charger.c b/drivers/power/pm2301_charger.c
> index ffa10ed..ab87d1a 100644
> --- a/drivers/power/pm2301_charger.c
> +++ b/drivers/power/pm2301_charger.c
> @@ -722,7 +722,12 @@ static int pm2xxx_charger_ac_en(struct ux500_charger *charger,
>
> dev_dbg(pm2->dev, "Enable AC: %dmV %dmA\n", vset, iset);
> if (!pm2->vddadc_en_ac) {
> - regulator_enable(pm2->regu);
> + ret = regulator_enable(pm2->regu);
> + if (ret) {
> + dev_err(pm2->dev,
> + "Failed to enable regulator\n");
> + goto error_occured;
> + }
> pm2->vddadc_en_ac = true;
> }
>
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
On Mon, 02 Sep 2013, Sachin Kamat wrote:
> pm2xxx_charger_die_therm_mngt is used only in this file.
> Make it static.
>
> Signed-off-by: Sachin Kamat <[email protected]>
> Cc: Lee Jones <[email protected]>
> ---
> drivers/power/pm2301_charger.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/power/pm2301_charger.c b/drivers/power/pm2301_charger.c
> index ab87d1a..b9e1ef7 100644
> --- a/drivers/power/pm2301_charger.c
> +++ b/drivers/power/pm2301_charger.c
> @@ -205,7 +205,7 @@ static int pm2xxx_charger_batt_therm_mngt(struct pm2xxx_charger *pm2, int val)
> }
>
>
> -int pm2xxx_charger_die_therm_mngt(struct pm2xxx_charger *pm2, int val)
> +static int pm2xxx_charger_die_therm_mngt(struct pm2xxx_charger *pm2, int val)
> {
> queue_work(pm2->charger_wq, &pm2->check_main_thermal_prot_work);
>
Acked-by: Lee Jones <[email protected]>
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
On 4 September 2013 15:11, Lee Jones <[email protected]> wrote:
> On Mon, 02 Sep 2013, Sachin Kamat wrote:
>
>> Check the return value of regulator_enable to silence the following
>> type of warnings:
>> drivers/power/ab8500_charger.c:1390:20: warning: ignoring return value
>> of ?regulator_enable?, declared with attribute warn_unused_result
>> [-Wunused-result]
>
> I think I remember something about it being okay for the regulators to
> fail, but that may have been something else. I think I'd be more
> comfortable if we just raised a dev_warn() and didn't return early in
> the error case.
In this particular case the regulator seems to be mandatory as they error out if
regulator_get() fails. Also, the comment above regulator_enable() said
the enabling
was done to fix some bug. Hence I wasn't sure if we could just print a
warning message
and continue further upon failure. I will change it as per your
suggestion and re-spin the patches.
--
With warm regards,
Sachin