* [PATCH v2 1/2] extcon: axp288: Add missed error check
@ 2019-07-26 12:18 ` Andy Shevchenko
2019-07-26 12:18 ` [PATCH v2 2/2] extcon: axp288: Use for_each_set_bit() in axp288_extcon_log_rsi() Andy Shevchenko
2019-07-29 1:25 ` [PATCH v2 1/2] extcon: axp288: Add missed error check Chanwoo Choi
0 siblings, 2 replies; 4+ messages in thread
From: Andy Shevchenko @ 2019-07-26 12:18 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>
---
- added error message (Chanwoo)
drivers/extcon/extcon-axp288.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/extcon/extcon-axp288.c b/drivers/extcon/extcon-axp288.c
index 7254852e6ec0..694a8d4a57ff 100644
--- a/drivers/extcon/extcon-axp288.c
+++ b/drivers/extcon/extcon-axp288.c
@@ -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);
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] extcon: axp288: Use for_each_set_bit() in axp288_extcon_log_rsi()
2019-07-26 12:18 ` [PATCH v2 1/2] extcon: axp288: Add missed error check Andy Shevchenko
@ 2019-07-26 12:18 ` Andy Shevchenko
2019-07-29 1:25 ` Chanwoo Choi
2019-07-29 1:25 ` [PATCH v2 1/2] extcon: axp288: Add missed error check Chanwoo Choi
1 sibling, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2019-07-26 12:18 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 694a8d4a57ff..415afaf479e7 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,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);
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/2] extcon: axp288: Add missed error check
2019-07-26 12:18 ` [PATCH v2 1/2] extcon: axp288: Add missed error check Andy Shevchenko
2019-07-26 12:18 ` [PATCH v2 2/2] extcon: axp288: Use for_each_set_bit() in axp288_extcon_log_rsi() Andy Shevchenko
@ 2019-07-29 1:25 ` Chanwoo Choi
1 sibling, 0 replies; 4+ messages in thread
From: Chanwoo Choi @ 2019-07-29 1:25 UTC (permalink / raw)
To: Andy Shevchenko, MyungJoo Ham, linux-kernel, Hans de Goede, Chen-Yu Tsai
Cc: Ramakrishna Pallala
On 19. 7. 26. 오후 9:18, Andy Shevchenko wrote:
> 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>
> ---
> - added error message (Chanwoo)
> drivers/extcon/extcon-axp288.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/extcon/extcon-axp288.c b/drivers/extcon/extcon-axp288.c
> index 7254852e6ec0..694a8d4a57ff 100644
> --- a/drivers/extcon/extcon-axp288.c
> +++ b/drivers/extcon/extcon-axp288.c
> @@ -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);
>
Applied it. Thanks.
--
Best Regards,
Chanwoo Choi
Samsung Electronics
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 2/2] extcon: axp288: Use for_each_set_bit() in axp288_extcon_log_rsi()
2019-07-26 12:18 ` [PATCH v2 2/2] extcon: axp288: Use for_each_set_bit() in axp288_extcon_log_rsi() Andy Shevchenko
@ 2019-07-29 1:25 ` Chanwoo Choi
0 siblings, 0 replies; 4+ messages in thread
From: Chanwoo Choi @ 2019-07-29 1:25 UTC (permalink / raw)
To: Andy Shevchenko, MyungJoo Ham, linux-kernel, Hans de Goede, Chen-Yu Tsai
On 19. 7. 26. 오후 9:18, 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 694a8d4a57ff..415afaf479e7 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,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);
>
Applied it. Thanks.
--
Best Regards,
Chanwoo Choi
Samsung Electronics
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-07-29 1:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20190726121827epcas5p36e03788323eb0c805f9c340f7c6f7944@epcas5p3.samsung.com>
2019-07-26 12:18 ` [PATCH v2 1/2] extcon: axp288: Add missed error check Andy Shevchenko
2019-07-26 12:18 ` [PATCH v2 2/2] extcon: axp288: Use for_each_set_bit() in axp288_extcon_log_rsi() Andy Shevchenko
2019-07-29 1:25 ` Chanwoo Choi
2019-07-29 1:25 ` [PATCH v2 1/2] extcon: axp288: Add missed error check Chanwoo Choi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).