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]>
---
Compile tested.
Changes since v1:
* converted dev_err and return to dev_warn as suggested by Lee Jones.
---
drivers/power/ab8500_charger.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c
index a4c4a10..0d355a9 100644
--- a/drivers/power/ab8500_charger.c
+++ b/drivers/power/ab8500_charger.c
@@ -1387,8 +1387,14 @@ 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);
- di->vddadc_en_ac = true;
+ ret = regulator_enable(di->regu);
+ if (ret) {
+ dev_warn(di->dev,
+ "Failed to enable regulator\n");
+ di->vddadc_en_ac = false;
+ } else {
+ di->vddadc_en_ac = true;
+ }
}
/* Check if the requested voltage or current is valid */
@@ -1556,8 +1562,14 @@ 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);
- di->vddadc_en_usb = true;
+ ret = regulator_enable(di->regu);
+ if (ret) {
+ dev_warn(di->dev,
+ "Failed to enable regulator\n");
+ di->vddadc_en_usb = false;
+ } else {
+ di->vddadc_en_usb = true;
+ }
}
/* Enable USB charging */
--
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]>
---
No changes since v1.
---
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 0d355a9..453141e 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
pm2xxx_charger_die_therm_mngt is used only in this file.
Make it static.
Signed-off-by: Sachin Kamat <[email protected]>
Acked-by: Lee Jones <[email protected]>
---
No changes since v1.
---
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 e55d809..b871ba4 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
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]>
---
Compile tested.
Changes since v1:
* converted dev_err and return to dev_warn as suggested by Lee Jones.
---
drivers/power/pm2301_charger.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/power/pm2301_charger.c b/drivers/power/pm2301_charger.c
index ffa10ed..e55d809 100644
--- a/drivers/power/pm2301_charger.c
+++ b/drivers/power/pm2301_charger.c
@@ -722,8 +722,14 @@ 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);
- pm2->vddadc_en_ac = true;
+ ret = regulator_enable(pm2->regu);
+ if (ret) {
+ dev_warn(pm2->dev,
+ "Failed to enable vddadc regulator\n");
+ pm2->vddadc_en_ac = false;
+ } else {
+ pm2->vddadc_en_ac = true;
+ }
}
ret = pm2xxx_charging_init(pm2);
--
1.7.9.5
On Fri, 06 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]
>
> Signed-off-by: Sachin Kamat <[email protected]>
> Cc: Lee Jones <[email protected]>
> ---
> Compile tested.
> Changes since v1:
> * converted dev_err and return to dev_warn as suggested by Lee Jones.
> ---
> drivers/power/ab8500_charger.c | 20 ++++++++++++++++----
> 1 file changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c
> index a4c4a10..0d355a9 100644
> --- a/drivers/power/ab8500_charger.c
> +++ b/drivers/power/ab8500_charger.c
> @@ -1387,8 +1387,14 @@ 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);
> - di->vddadc_en_ac = true;
> + ret = regulator_enable(di->regu);
> + if (ret) {
> + dev_warn(di->dev,
> + "Failed to enable regulator\n");
> + di->vddadc_en_ac = false;
Isn't di->vddadc_en_ac already false?
Or you wouldn't have made it into the if().
> + } else {
> + di->vddadc_en_ac = true;
> + }
> }
>
> /* Check if the requested voltage or current is valid */
> @@ -1556,8 +1562,14 @@ 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);
> - di->vddadc_en_usb = true;
> + ret = regulator_enable(di->regu);
> + if (ret) {
> + dev_warn(di->dev,
> + "Failed to enable regulator\n");
> + di->vddadc_en_usb = false;
Same thing here.
> + } else {
> + di->vddadc_en_usb = true;
> + }
> }
>
> /* Enable USB charging */
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
On Fri, 06 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]
>
> Signed-off-by: Sachin Kamat <[email protected]>
> Cc: Lee Jones <[email protected]>
> ---
> Compile tested.
> Changes since v1:
> * converted dev_err and return to dev_warn as suggested by Lee Jones.
> ---
> drivers/power/pm2301_charger.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/power/pm2301_charger.c b/drivers/power/pm2301_charger.c
> index ffa10ed..e55d809 100644
> --- a/drivers/power/pm2301_charger.c
> +++ b/drivers/power/pm2301_charger.c
> @@ -722,8 +722,14 @@ 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);
> - pm2->vddadc_en_ac = true;
> + ret = regulator_enable(pm2->regu);
> + if (ret) {
> + dev_warn(pm2->dev,
> + "Failed to enable vddadc regulator\n");
> + pm2->vddadc_en_ac = false;
pm2->vddadc_en_ac is already false.
> + } else {
> + pm2->vddadc_en_ac = true;
> + }
> }
>
> ret = pm2xxx_charging_init(pm2);
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
On Fri, 06 Sep 2013, Sachin Kamat wrote:
> Each of the if-else blocks has a break statement.
> Remove the additional one which is unreachable.
>
> Signed-off-by: Sachin Kamat <[email protected]>
> ---
> No changes since v1.
> ---
> drivers/power/ab8500_charger.c | 1 -
> 1 file changed, 1 deletion(-)
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 6 September 2013 12:32, Lee Jones <[email protected]> wrote:
> On Fri, 06 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]
>>
>> Signed-off-by: Sachin Kamat <[email protected]>
>> Cc: Lee Jones <[email protected]>
>> ---
>> Compile tested.
>> Changes since v1:
>> * converted dev_err and return to dev_warn as suggested by Lee Jones.
>> ---
>> drivers/power/ab8500_charger.c | 20 ++++++++++++++++----
>> 1 file changed, 16 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c
>> index a4c4a10..0d355a9 100644
>> --- a/drivers/power/ab8500_charger.c
>> +++ b/drivers/power/ab8500_charger.c
>> @@ -1387,8 +1387,14 @@ 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);
>> - di->vddadc_en_ac = true;
>> + ret = regulator_enable(di->regu);
>> + if (ret) {
>> + dev_warn(di->dev,
>> + "Failed to enable regulator\n");
>> + di->vddadc_en_ac = false;
>
> Isn't di->vddadc_en_ac already false?
>
> Or you wouldn't have made it into the if().
Yes you are right. This and other similar statements are redundant.
--
With warm regards,
Sachin