* Re: [PATCH 1/2] extcon: max14577: Use common error handling code in max14577_muic_set_path() [not found] ` <20171022185941.mzplggaick742ylf@kozik-lap> @ 2017-10-22 20:15 ` SF Markus Elfring 0 siblings, 0 replies; 6+ messages in thread From: SF Markus Elfring @ 2017-10-22 20:15 UTC (permalink / raw) To: Krzysztof Kozlowski, kernel-janitors Cc: Bartlomiej Zolnierkiewicz, Chanwoo Choi, MyungJoo Ham, LKML >> From: Markus Elfring <elfring@users.sourceforge.net> >> Date: Sun, 22 Oct 2017 19:33:58 +0200 >> >> Add a jump target so that a bit of exception handling can be better reused >> at the end of this function. >> >> This issue was detected by using the Coccinelle software. >> >> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> >> --- >> drivers/extcon/extcon-max14577.c | 22 ++++++++++------------ >> 1 file changed, 10 insertions(+), 12 deletions(-) >> >> diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c >> index f6414b7fa5bc..3d4bf5d23236 100644 >> --- a/drivers/extcon/extcon-max14577.c >> +++ b/drivers/extcon/extcon-max14577.c >> @@ -211,10 +211,8 @@ static int max14577_muic_set_path(struct max14577_muic_info *info, >> ret = max14577_update_reg(info->max14577->regmap, >> MAX14577_MUIC_REG_CONTROL1, >> CLEAR_IDBEN_MICEN_MASK, CTRL1_SW_OPEN); >> - if (ret < 0) { >> - dev_err(info->dev, "failed to update MUIC register\n"); >> - return ret; >> - } >> + if (ret < 0) >> + goto report_failure; > > No, one exit path just to report error does not seem to be more readable. I got an other development opinion on this aspect. > Instead printing error after the register access looks to me > as common pattern, easy to maintain. Do you care if corresponding messages are different? > This patch does not bring improvement, in my opinion. How do you generally think about the change possibility for a bit of code reduction? >> >> if (attached) >> ctrl1 = val; >> @@ -224,10 +222,8 @@ static int max14577_muic_set_path(struct max14577_muic_info *info, >> ret = max14577_update_reg(info->max14577->regmap, >> MAX14577_MUIC_REG_CONTROL1, >> CLEAR_IDBEN_MICEN_MASK, ctrl1); >> - if (ret < 0) { >> - dev_err(info->dev, "failed to update MUIC register\n"); >> - return ret; >> - } >> + if (ret < 0) >> + goto report_failure; >> >> if (attached) >> ctrl2 |= CTRL2_CPEN_MASK; /* LowPwr=0, CPEn=1 */ >> @@ -237,16 +233,18 @@ static int max14577_muic_set_path(struct max14577_muic_info *info, >> ret = max14577_update_reg(info->max14577->regmap, >> MAX14577_REG_CONTROL2, >> CTRL2_LOWPWR_MASK | CTRL2_CPEN_MASK, ctrl2); >> - if (ret < 0) { >> - dev_err(info->dev, "failed to update MUIC register\n"); >> - return ret; >> - } >> + if (ret < 0) >> + goto report_failure; >> >> dev_dbg(info->dev, >> "CONTROL1 : 0x%02x, CONTROL2 : 0x%02x, state : %s\n", >> ctrl1, ctrl2, attached ? "attached" : "detached"); >> >> return 0; >> + >> +report_failure: >> + dev_err(info->dev, "failed to update MUIC register\n"); >> + return ret; >> } >> >> /* >> -- >> 2.14.2 >> Would you like to take another look at remaining open issues in source files from the pattern “extcon-max…”? Regards, Markus ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <59ED3E72.7010401@samsung.com>]
* Re: [PATCH 1/2] extcon: max14577: Use common error handling code in max14577_muic_set_path() [not found] ` <59ED3E72.7010401@samsung.com> @ 2017-10-23 5:45 ` SF Markus Elfring 2017-10-23 5:54 ` Chanwoo Choi 0 siblings, 1 reply; 6+ messages in thread From: SF Markus Elfring @ 2017-10-23 5:45 UTC (permalink / raw) To: Chanwoo Choi, kernel-janitors Cc: Bartlomiej Zolnierkiewicz, Krzysztof Kozlowski, MyungJoo Ham, LKML > As you commented, this patch might remove the redundant error message. > But, it makes the code more complicated in side of readability. Do you try to avoid duplicated code any more in other circumstances? Regards, Markus ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] extcon: max14577: Use common error handling code in max14577_muic_set_path() 2017-10-23 5:45 ` SF Markus Elfring @ 2017-10-23 5:54 ` Chanwoo Choi 2017-10-23 5:57 ` SF Markus Elfring 0 siblings, 1 reply; 6+ messages in thread From: Chanwoo Choi @ 2017-10-23 5:54 UTC (permalink / raw) To: SF Markus Elfring, kernel-janitors Cc: Bartlomiej Zolnierkiewicz, Krzysztof Kozlowski, MyungJoo Ham, LKML On 2017년 10월 23일 14:45, SF Markus Elfring wrote: >> As you commented, this patch might remove the redundant error message. >> But, it makes the code more complicated in side of readability. > > Do you try to avoid duplicated code any more in other circumstances? I usually used the goto statement on following cases: - Return the value (error number if fail or 0 if success) - Do free or unregister or remove operations when error happen. I think that there is any benefit of this patch. Also, as I commented, it make the code more complicated. -- Best Regards, Chanwoo Choi Samsung Electronics ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: extcon: max14577: Use common error handling code in max14577_muic_set_path() 2017-10-23 5:54 ` Chanwoo Choi @ 2017-10-23 5:57 ` SF Markus Elfring 2017-10-23 6:03 ` Chanwoo Choi 0 siblings, 1 reply; 6+ messages in thread From: SF Markus Elfring @ 2017-10-23 5:57 UTC (permalink / raw) To: Chanwoo Choi, kernel-janitors Cc: Bartlomiej Zolnierkiewicz, Krzysztof Kozlowski, MyungJoo Ham, LKML > I think that there is any benefit of this patch. > Also, as I commented, it make the code more complicated. We have got different software development opinions about the shown change possibilities then. Regards, Markus ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: extcon: max14577: Use common error handling code in max14577_muic_set_path() 2017-10-23 5:57 ` SF Markus Elfring @ 2017-10-23 6:03 ` Chanwoo Choi 2017-10-23 6:08 ` SF Markus Elfring 0 siblings, 1 reply; 6+ messages in thread From: Chanwoo Choi @ 2017-10-23 6:03 UTC (permalink / raw) To: SF Markus Elfring, kernel-janitors Cc: Bartlomiej Zolnierkiewicz, Krzysztof Kozlowski, MyungJoo Ham, LKML On 2017년 10월 23일 14:57, SF Markus Elfring wrote: >> I think that there is any benefit of this patch. >> Also, as I commented, it make the code more complicated. > > We have got different software development opinions about I agree absolutely. So, anyone can suggest the opinion and send patches. But, all patches have to get the review from maintainer, reviewer or the mailing-list developer. (Please don't remove the part of my comment when you reply.) > the shown change possibilities then. -- Best Regards, Chanwoo Choi Samsung Electronics ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: extcon: max14577: Use common error handling code in max14577_muic_set_path() 2017-10-23 6:03 ` Chanwoo Choi @ 2017-10-23 6:08 ` SF Markus Elfring 0 siblings, 0 replies; 6+ messages in thread From: SF Markus Elfring @ 2017-10-23 6:08 UTC (permalink / raw) To: Chanwoo Choi, kernel-janitors Cc: Bartlomiej Zolnierkiewicz, Krzysztof Kozlowski, MyungJoo Ham, LKML >>> I think that there is any benefit of this patch. >>> Also, as I commented, it make the code more complicated. >> >> We have got different software development opinions about > > I agree absolutely. So, anyone can suggest the opinion and send patches. > But, all patches have to get the review from maintainer, reviewer > or the mailing-list developer. Can an other change acceptance evolve over time? > (Please don't remove the part of my comment when you reply.) > >> the shown change possibilities then. Do you find similar updates more useful for any other software modules? Regards, Markus ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-10-23 6:08 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <d08cbbf6-015a-ab76-6491-126901d1dda6@users.sourceforge.net>
[not found] ` <5cdefd84-066d-5379-43c8-76f5d3b8f7c4@users.sourceforge.net>
[not found] ` <20171022185941.mzplggaick742ylf@kozik-lap>
2017-10-22 20:15 ` [PATCH 1/2] extcon: max14577: Use common error handling code in max14577_muic_set_path() SF Markus Elfring
[not found] ` <59ED3E72.7010401@samsung.com>
2017-10-23 5:45 ` SF Markus Elfring
2017-10-23 5:54 ` Chanwoo Choi
2017-10-23 5:57 ` SF Markus Elfring
2017-10-23 6:03 ` Chanwoo Choi
2017-10-23 6:08 ` SF Markus Elfring
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox