extcon: axp288: Add missed error check
Subsystems (3)
PATCH v2 1/2 extcon: axp288: Add missed error check
It seems from the very beginning the error check has been missed in axp288_extcon_log_rsi(). Add it here.
---
- added error message (Chanwoo)
drivers/extcon/extcon-axp288.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/extcon/extcon-axp288.c +5 -0
@@ -135,6 +135,11 @@ static void axp288_extcon_log_rsi(struct axp288_extcon_info *info)int ret; ret =regmap_read (info->regmap,AXP288_PS_BOOT_REASON_REG , &val); +if (ret <0 ) { +dev_err (info->dev,"failed to read reset source indicator\n" ); +return ; + } +for (i =0 , rsi = axp288_pwr_up_down_info; *rsi; rsi++, i++) {if (val &BIT (i)) {dev_dbg (info->dev,"%s\n" , *rsi);
Signature · 1 line
2.20.1
PATCH v2 2/2 extcon: axp288: Use for_each_set_bit() in axp288_extcon_log_rsi()
This simplifies and standardizes axp288_extcon_log_rsi() by using for_each_set_bit() library function.
--- drivers/extcon/extcon-axp288.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/extcon/extcon-axp288.c +5 -8
@@ -121,7 +121,6 @@ static const char * const axp288_pwr_up_down_info[] = {"Last shutdown caused by PMIC UVLO threshold" ,"Last shutdown caused by SOC initiated cold off" , "Last shutdown caused by user pressing the power button", - NULL, };/*
@@ -130,8 +129,8 @@ static const char * const axp288_pwr_up_down_info[] = {*/ static void axp288_extcon_log_rsi (struct axp288_extcon_info *info) { -const char *const *rsi;unsigned int val, i, clear_mask =0 ; +unsigned long bits;int ret; ret =regmap_read (info->regmap,AXP288_PS_BOOT_REASON_REG , &val);
@@ -140,12 +139,10 @@ static void axp288_extcon_log_rsi(struct axp288_extcon_info *info)return ; } -for (i =0 , rsi = axp288_pwr_up_down_info; *rsi; rsi++, i++) { -if (val &BIT (i)) { -dev_dbg (info->dev,"%s\n" , *rsi); - clear_mask |=BIT (i); - } - } + bits = val &GENMASK (ARRAY_SIZE (axp288_pwr_up_down_info) -1 ,0 ); +for_each_set_bit (i, &bits,ARRAY_SIZE (axp288_pwr_up_down_info)) +dev_dbg (info->dev,"%s\n" , axp288_pwr_up_down_info[i]); + clear_mask = bits;/* Clear the register value for next reboot (write 1 to clear bit) */ regmap_write (info->regmap,AXP288_PS_BOOT_REASON_REG , clear_mask);
Signature · 1 line
2.20.1
Re: [PATCH v2 2/2] extcon: axp288: Use for_each_set_bit() in axp288_extcon_log_rsi()
Quoted 38 lines · Andy Shevchenko
This simplifies and standardizes
axp288_extcon_log_rsi()by usingfor_each_set_bit()library function.Signed-off-by Andy Shevchenko <[email protected]>--- drivers/extcon/extcon-axp288.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)drivers/extcon/extcon-axp288.c +1
-5@@ -121,7 +121,6 @@ static const char * const axp288_pwr_up_down_info[] = {"Last shutdown caused by PMIC UVLO threshold" ,"Last shutdown caused by SOC initiated cold off" , "Last shutdown caused by user pressing the power button", - NULL, };/* @@ -130,8 +129,8 @@ static const char * const axp288_pwr_up_down_info[] = {*/ static void axp288_extcon_log_rsi (struct axp288_extcon_info *info) { -const char *const *rsi;unsigned int val, i, clear_mask =0 ; +unsigned long bits;int ret; ret =regmap_read (info->regmap,AXP288_PS_BOOT_REASON_REG , &val);@@ -140,12 +139,10 @@ static void axp288_extcon_log_rsi(struct axp288_extcon_info *info)return ; } -for (i =0 , rsi = axp288_pwr_up_down_info; *rsi; rsi++, i++) { -if (val &BIT (i)) { -dev_dbg (info->dev,"%s\n" , *rsi);
drivers/extcon/extcon-axp288.c static void axp288_extcon_log_rsi(struct axp288_extcon_info *info) · line 148
Quoted 10 lines
drivers/extcon/extcon-axp288.c +4
-3- clear_mask |=BIT (i); - } - } + bits = val &GENMASK (ARRAY_SIZE (axp288_pwr_up_down_info) -1 ,0 ); +for_each_set_bit (i, &bits,ARRAY_SIZE (axp288_pwr_up_down_info)) +dev_dbg (info->dev,"%s\n" , axp288_pwr_up_down_info[i]); + clear_mask = bits;/* Clear the register value for next reboot (write 1 to clear bit) */ regmap_write (info->regmap,AXP288_PS_BOOT_REASON_REG , clear_mask);
Applied it. Thanks.
Signature · 3 lines
Best Regards, Chanwoo Choi Samsung Electronics
Quoted 17 lines · Andy Shevchenko
It seems from the very beginning the error check has been missed in
axp288_extcon_log_rsi(). Add it here.Cc Ramakrishna Pallala <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>---
- added error message (Chanwoo)drivers/extcon/extcon-axp288.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/extcon/extcon-axp288.c +0
-0@@ -135,6 +135,11 @@ static void axp288_extcon_log_rsi(struct axp288_extcon_info *info)int ret;
drivers/extcon/extcon-axp288.c static void axp288_extcon_log_rsi(struct axp288_extcon_info *info) · line 145
Quoted 10 lines
drivers/extcon/extcon-axp288.c +5
-0ret =regmap_read (info->regmap,AXP288_PS_BOOT_REASON_REG , &val); +if (ret <0 ) { +dev_err (info->dev,"failed to read reset source indicator\n" ); +return ; + } +for (i =0 , rsi = axp288_pwr_up_down_info; *rsi; rsi++, i++) {if (val &BIT (i)) {dev_dbg (info->dev,"%s\n" , *rsi);
Applied it. Thanks.
Signature · 3 lines
Best Regards, Chanwoo Choi Samsung Electronics