From: Joe Perches <joe@perches.com>
To: Giedrius Statkevicius <giedrius.statkevicius@gmail.com>
Cc: gregkh@linuxfoundation.org, micky_ching@realsil.com.cn,
fabio.falzoi84@gmail.com, mahati.chamarthy@gmail.com,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] staging: rts5208: Clean up coding style in rtsx_chip.c to get rid of checkpatch.pl warnings and combine two ifs into one
Date: Thu, 02 Oct 2014 04:45:49 -0700 [thread overview]
Message-ID: <1412250349.3247.44.camel@joe-AO725> (raw)
In-Reply-To: <542D336A.1050401@gmail.com>
On Thu, 2014-10-02 at 14:13 +0300, Giedrius Statkevicius wrote:
> Fix 10 occurences of coding style errors where the line exceeds 80 characters by breaking them into more lines.
> Checkpatch.pl reports these errors as: 'WARNING: line over 80 characters'
> Also, removes unnecessary returns in two void functions by removing the return statements.
> Checkpatch.pl reports these errors as: 'WARNING: void function return statements are not generally useful'
> Lastly it combines two if statements into one in rtsx_reset_chip()
Another way to reduce indentation is to write another
utility function like the suggested patch at the end
of this email.
Also, changing:
if (foo) {
[short code block...]
} else
[long code block...]
}
return bar;
to:
if (foo) {
[short code block...]
return bar;
}
[long code block...]
return bar;
reduces indentation.
Al Viro once gave good advice about indentation here:
https://lkml.org/lkml/2013/3/20/345
Using ternaries can also reduce line count and
indentation:
if (something)
foo(bar, 1, ...);
else
foo(bar, 2, ...);
can be written
foo(bar, something ? 1 : 2, ...)
Here's a suggestion:
---
drivers/staging/rts5208/rtsx_chip.c | 71 ++++++++++++++++++++-----------------
1 file changed, 38 insertions(+), 33 deletions(-)
diff --git a/drivers/staging/rts5208/rtsx_chip.c b/drivers/staging/rts5208/rtsx_chip.c
index 1411471..85d670d 100644
--- a/drivers/staging/rts5208/rtsx_chip.c
+++ b/drivers/staging/rts5208/rtsx_chip.c
@@ -226,6 +226,43 @@ static int rtsx_pre_handle_sdio_new(struct rtsx_chip *chip)
}
#endif
+static int rtsx_reset_aspm(struct rtsx_chip *chip)
+{
+ int rtn = STATUS_SUCCESS;
+
+ if (chip->dynamic_aspm) {
+ if (CHK_SDIO_EXIST(chip) && CHECK_PID(chip, 0x5288)) {
+ rtn = rtsx_write_cfg_dw(chip, 2, 0xC0, 0xFF,
+ chip->aspm_l0s_l1_en);
+ if (rtn != STATUS_SUCCESS)
+ TRACE_RET(chip, STATUS_FAIL);
+ }
+ return rtn;
+ }
+
+ if (CHECK_PID(chip, 0x5208))
+ RTSX_WRITE_REG(chip, ASPM_FORCE_CTL, 0xFF, 0x3F);
+
+ rtn = rtsx_write_config_byte(chip, LCTLR, chip->aspm_l0s_l1_en);
+ if (rtn != STATUS_SUCCESS)
+ TRACE_RET(chip, STATUS_FAIL);
+
+ chip->aspm_level[0] = chip->aspm_l0s_l1_en;
+
+ if (CHK_SDIO_EXIST(chip)) {
+ chip->aspm_level[1] = chip->aspm_l0s_l1_en;
+ rtn = rtsx_write_cfg_dw(chip,
+ CHECK_PID(chip, 0x5288) ? 2 : 1,
+ 0xC0, 0xFF, chip->aspm_l0s_l1_en);
+ if (rtn != STATUS_SUCCESS)
+ TRACE_RET(chip, STATUS_FAIL);
+ }
+
+ chip->aspm_enabled = 1;
+
+ return rtn;
+}
+
int rtsx_reset_chip(struct rtsx_chip *chip)
{
int retval;
@@ -288,39 +325,7 @@ int rtsx_reset_chip(struct rtsx_chip *chip)
/* Enable ASPM */
if (chip->aspm_l0s_l1_en) {
- if (chip->dynamic_aspm) {
- if (CHK_SDIO_EXIST(chip)) {
- if (CHECK_PID(chip, 0x5288)) {
- retval = rtsx_write_cfg_dw(chip, 2, 0xC0, 0xFF, chip->aspm_l0s_l1_en);
- if (retval != STATUS_SUCCESS)
- TRACE_RET(chip, STATUS_FAIL);
- }
- }
- } else {
- if (CHECK_PID(chip, 0x5208))
- RTSX_WRITE_REG(chip, ASPM_FORCE_CTL,
- 0xFF, 0x3F);
-
- retval = rtsx_write_config_byte(chip, LCTLR,
- chip->aspm_l0s_l1_en);
- if (retval != STATUS_SUCCESS)
- TRACE_RET(chip, STATUS_FAIL);
-
- chip->aspm_level[0] = chip->aspm_l0s_l1_en;
- if (CHK_SDIO_EXIST(chip)) {
- chip->aspm_level[1] = chip->aspm_l0s_l1_en;
- if (CHECK_PID(chip, 0x5288))
- retval = rtsx_write_cfg_dw(chip, 2, 0xC0, 0xFF, chip->aspm_l0s_l1_en);
- else
- retval = rtsx_write_cfg_dw(chip, 1, 0xC0, 0xFF, chip->aspm_l0s_l1_en);
-
- if (retval != STATUS_SUCCESS)
- TRACE_RET(chip, STATUS_FAIL);
-
- }
-
- chip->aspm_enabled = 1;
- }
+ retval = rtsx_reset_aspm(chip);
} else {
if (chip->asic_code && CHECK_PID(chip, 0x5208)) {
retval = rtsx_write_phy_register(chip, 0x07, 0x0129);
next prev parent reply other threads:[~2014-10-02 11:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-02 11:13 Giedrius Statkevicius
2014-10-02 11:45 ` Joe Perches [this message]
2014-10-02 15:25 ` Giedrius Statkevicius
2014-10-02 16:39 ` Joe Perches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1412250349.3247.44.camel@joe-AO725 \
--to=joe@perches.com \
--cc=devel@driverdev.osuosl.org \
--cc=fabio.falzoi84@gmail.com \
--cc=giedrius.statkevicius@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mahati.chamarthy@gmail.com \
--cc=micky_ching@realsil.com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®