* [PATCH v1 1/2] extcon: axp288: Add missed error check @ 2019-07-25 20:34 ` Andy Shevchenko 2019-07-25 20:34 ` [PATCH v1 2/2] extcon: axp288: Use for_each_set_bit() in axp288_extcon_log_rsi() Andy Shevchenko [not found] ` <bf2b9870-8504-17da-50b8-b1414b7d9b39@samsung.com> 0 siblings, 2 replies; 4+ messages in thread From: Andy Shevchenko @ 2019-07-25 20:34 UTC (permalink / raw) To: MyungJoo Ham, Chanwoo Choi, linux-kernel, Hans de Goede, Chen-Yu Tsai Cc: Andy Shevchenko, Ramakrishna Pallala It seems from the very beginning the error check has been missed in axp288_extcon_log_rsi(). Add it here. Cc: Ramakrishna Pallala <ramakrishna.pallala@intel.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- drivers/extcon/extcon-axp288.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/extcon/extcon-axp288.c b/drivers/extcon/extcon-axp288.c index 7254852e6ec0..4cbcc3b1aa6b 100644 --- a/drivers/extcon/extcon-axp288.c +++ b/drivers/extcon/extcon-axp288.c @@ -135,6 +135,9 @@ 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) + return; + for (i = 0, rsi = axp288_pwr_up_down_info; *rsi; rsi++, i++) { if (val & BIT(i)) { dev_dbg(info->dev, "%s\n", *rsi); -- 2.20.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v1 2/2] extcon: axp288: Use for_each_set_bit() in axp288_extcon_log_rsi() 2019-07-25 20:34 ` [PATCH v1 1/2] extcon: axp288: Add missed error check Andy Shevchenko @ 2019-07-25 20:34 ` Andy Shevchenko 2019-07-26 2:20 ` Chanwoo Choi [not found] ` <bf2b9870-8504-17da-50b8-b1414b7d9b39@samsung.com> 1 sibling, 1 reply; 4+ messages in thread From: Andy Shevchenko @ 2019-07-25 20:34 UTC (permalink / raw) To: MyungJoo Ham, Chanwoo Choi, linux-kernel, Hans de Goede, Chen-Yu Tsai Cc: Andy Shevchenko This simplifies and standardizes axp288_extcon_log_rsi() by using for_each_set_bit() library function. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- drivers/extcon/extcon-axp288.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/extcon/extcon-axp288.c b/drivers/extcon/extcon-axp288.c index 4cbcc3b1aa6b..670334c362ac 100644 --- a/drivers/extcon/extcon-axp288.c +++ b/drivers/extcon/extcon-axp288.c @@ -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,20 +129,18 @@ 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); if (ret < 0) 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); -- 2.20.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1 2/2] extcon: axp288: Use for_each_set_bit() in axp288_extcon_log_rsi() 2019-07-25 20:34 ` [PATCH v1 2/2] extcon: axp288: Use for_each_set_bit() in axp288_extcon_log_rsi() Andy Shevchenko @ 2019-07-26 2:20 ` Chanwoo Choi 0 siblings, 0 replies; 4+ messages in thread From: Chanwoo Choi @ 2019-07-26 2:20 UTC (permalink / raw) To: Andy Shevchenko, MyungJoo Ham, linux-kernel, Hans de Goede, Chen-Yu Tsai On 19. 7. 26. 오전 5:34, Andy Shevchenko wrote: > This simplifies and standardizes axp288_extcon_log_rsi() > by using for_each_set_bit() library function. > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > --- > drivers/extcon/extcon-axp288.c | 13 +++++-------- > 1 file changed, 5 insertions(+), 8 deletions(-) > > diff --git a/drivers/extcon/extcon-axp288.c b/drivers/extcon/extcon-axp288.c > index 4cbcc3b1aa6b..670334c362ac 100644 > --- a/drivers/extcon/extcon-axp288.c > +++ b/drivers/extcon/extcon-axp288.c > @@ -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,20 +129,18 @@ 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); > if (ret < 0) > 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); > Acked-by: Chanwoo Choi <cw00.choi@samsung.com> -- Best Regards, Chanwoo Choi Samsung Electronics ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <bf2b9870-8504-17da-50b8-b1414b7d9b39@samsung.com>]
* Re: [PATCH v1 1/2] extcon: axp288: Add missed error check [not found] ` <bf2b9870-8504-17da-50b8-b1414b7d9b39@samsung.com> @ 2019-07-26 12:12 ` Andy Shevchenko 0 siblings, 0 replies; 4+ messages in thread From: Andy Shevchenko @ 2019-07-26 12:12 UTC (permalink / raw) To: Chanwoo Choi, MyungJoo Ham, linux-kernel, Hans de Goede, Chen-Yu Tsai Cc: Ramakrishna Pallala On Fri, Jul 26, 2019 at 10:15:30AM +0900, Chanwoo Choi wrote: > On 19. 7. 26. 오전 5:34, Andy Shevchenko wrote: > > It seems from the very beginning the error check has been missed > > in axp288_extcon_log_rsi(). Add it here. > > ret = regmap_read(info->regmap, AXP288_PS_BOOT_REASON_REG, &val); > > + if (ret < 0) > > + return; > > It need to print error log because axp288_extcon_log_rsi() has the void' > return type if there is no any error log, it is not possible to check > the error status. Makes sense. Will add in v2. P.S. You answered privately, I had returned Cc list back. -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-07-26 12:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20190725203413epcas5p115dbc8d8119e17e39c38e5fb847d3ac5@epcas5p1.samsung.com>
2019-07-25 20:34 ` [PATCH v1 1/2] extcon: axp288: Add missed error check Andy Shevchenko
2019-07-25 20:34 ` [PATCH v1 2/2] extcon: axp288: Use for_each_set_bit() in axp288_extcon_log_rsi() Andy Shevchenko
2019-07-26 2:20 ` Chanwoo Choi
[not found] ` <bf2b9870-8504-17da-50b8-b1414b7d9b39@samsung.com>
2019-07-26 12:12 ` [PATCH v1 1/2] extcon: axp288: Add missed error check Andy Shevchenko
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
Powered by JetHome