* [PATCH v2 0/2] Staging: rts5208: rtsx_reset_chip style clean up
@ 2014-10-19 19:30 Fabio Falzoi
2014-10-19 19:30 ` [PATCH v2 1/2] Staging: rts5208: helper function to manage aspm during reset Fabio Falzoi
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Fabio Falzoi @ 2014-10-19 19:30 UTC (permalink / raw)
To: gregkh
Cc: micky_ching, joe, giedrius.statkevicius, devel, linux-kernel,
Fabio Falzoi
Clean up the code in rtsx_reset_chip function defining two new helper
functions rtsx_reset_aspm and rtsx_enable_pcie_intr.
Specifically, the following checkpatch warnings are corrected:
* PARENTHESIS_ALIGNMENT at rows 271, 302, 343 and 346
* LONG_LINE at rows 294, 313 and 315
* BRACES at rowa 320 and 351
This patch is inspired by the following post on LKML regarding another
clean up for rts5208 module:
http://www.spinics.net/lists/linux-driver-devel/msg55038.html
Changes in v2:
* rebased against staging-testing branch of staging driver development
tree
Fabio Falzoi (2):
Staging: rts5208: helper function to manage aspm during reset
Staging: rts5208: helper function to enable interrupts during reset
drivers/staging/rts5208/rtsx_chip.c | 165 +++++++++++++++++++-----------------
1 file changed, 87 insertions(+), 78 deletions(-)
--
2.1.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 1/2] Staging: rts5208: helper function to manage aspm during reset
2014-10-19 19:30 [PATCH v2 0/2] Staging: rts5208: rtsx_reset_chip style clean up Fabio Falzoi
@ 2014-10-19 19:30 ` Fabio Falzoi
2014-10-19 19:30 ` [PATCH v2 2/2] Staging: rts5208: helper function to enable interrupts " Fabio Falzoi
2014-10-20 10:02 ` [PATCH v2 0/2] Staging: rts5208: rtsx_reset_chip style clean up Dan Carpenter
2 siblings, 0 replies; 4+ messages in thread
From: Fabio Falzoi @ 2014-10-19 19:30 UTC (permalink / raw)
To: gregkh
Cc: micky_ching, joe, giedrius.statkevicius, devel, linux-kernel,
Fabio Falzoi
Define the helper function rtsx_reset_aspm to shorten the
rtsx_reset_chip code and get rid of the LONG_LINE checkpatch warnings.
Signed-off-by: Fabio Falzoi <fabio.falzoi84@gmail.com>
---
drivers/staging/rts5208/rtsx_chip.c | 70 +++++++++++++++++++++----------------
1 file changed, 39 insertions(+), 31 deletions(-)
diff --git a/drivers/staging/rts5208/rtsx_chip.c b/drivers/staging/rts5208/rtsx_chip.c
index ffcf5de..ea6cfd1 100644
--- a/drivers/staging/rts5208/rtsx_chip.c
+++ b/drivers/staging/rts5208/rtsx_chip.c
@@ -227,6 +227,42 @@ static int rtsx_pre_handle_sdio_new(struct rtsx_chip *chip)
}
#endif
+static int rtsx_reset_aspm(struct rtsx_chip *chip)
+{
+ int ret;
+
+ if (chip->dynamic_aspm) {
+ if (!CHK_SDIO_EXIST(chip) || !CHECK_PID(chip, 0x5288))
+ return STATUS_SUCCESS;
+
+ ret = rtsx_write_cfg_dw(chip, 2, 0xC0, 0xFF,
+ chip->aspm_l0s_l1_en);
+ if (ret != STATUS_SUCCESS)
+ TRACE_RET(chip, STATUS_FAIL);
+
+ return STATUS_SUCCESS;
+ }
+
+ if (CHECK_PID(chip, 0x5208))
+ RTSX_WRITE_REG(chip, ASPM_FORCE_CTL, 0xFF, 0x3F);
+ ret = rtsx_write_config_byte(chip, LCTLR, chip->aspm_l0s_l1_en);
+ if (ret != 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;
+ ret = rtsx_write_cfg_dw(chip, CHECK_PID(chip, 0x5288) ? 2 : 1,
+ 0xC0, 0xFF, chip->aspm_l0s_l1_en);
+ if (ret != STATUS_SUCCESS)
+ TRACE_RET(chip, STATUS_FAIL);
+ }
+
+ chip->aspm_enabled = 1;
+
+ return STATUS_SUCCESS;
+}
+
int rtsx_reset_chip(struct rtsx_chip *chip)
{
int retval;
@@ -289,37 +325,9 @@ 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) && 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;
- retval = rtsx_write_cfg_dw(chip,
- CHECK_PID(chip, 0x5288) ? 2 : 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);
+ if (retval != STATUS_SUCCESS)
+ TRACE_RET(chip, STATUS_FAIL);
} else {
if (chip->asic_code && CHECK_PID(chip, 0x5208)) {
retval = rtsx_write_phy_register(chip, 0x07, 0x0129);
--
2.1.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] Staging: rts5208: helper function to enable interrupts during reset
2014-10-19 19:30 [PATCH v2 0/2] Staging: rts5208: rtsx_reset_chip style clean up Fabio Falzoi
2014-10-19 19:30 ` [PATCH v2 1/2] Staging: rts5208: helper function to manage aspm during reset Fabio Falzoi
@ 2014-10-19 19:30 ` Fabio Falzoi
2014-10-20 10:02 ` [PATCH v2 0/2] Staging: rts5208: rtsx_reset_chip style clean up Dan Carpenter
2 siblings, 0 replies; 4+ messages in thread
From: Fabio Falzoi @ 2014-10-19 19:30 UTC (permalink / raw)
To: gregkh
Cc: micky_ching, joe, giedrius.statkevicius, devel, linux-kernel,
Fabio Falzoi
Define the helper function rtsx_enable_pcie_intr to shorten the
rtsx_reset_chip code and get rid of the LONG_LINE checkpatch warnings.
Signed-off-by: Fabio Falzoi <fabio.falzoi84@gmail.com>
---
drivers/staging/rts5208/rtsx_chip.c | 95 +++++++++++++++++++------------------
1 file changed, 48 insertions(+), 47 deletions(-)
diff --git a/drivers/staging/rts5208/rtsx_chip.c b/drivers/staging/rts5208/rtsx_chip.c
index ea6cfd1..9593d81 100644
--- a/drivers/staging/rts5208/rtsx_chip.c
+++ b/drivers/staging/rts5208/rtsx_chip.c
@@ -263,6 +263,51 @@ static int rtsx_reset_aspm(struct rtsx_chip *chip)
return STATUS_SUCCESS;
}
+static int rtsx_enable_pcie_intr(struct rtsx_chip *chip)
+{
+ int ret;
+
+ if (!chip->asic_code || !CHECK_PID(chip, 0x5208)) {
+ rtsx_enable_bus_int(chip);
+ return STATUS_SUCCESS;
+ }
+
+ if (chip->phy_debug_mode) {
+ RTSX_WRITE_REG(chip, CDRESUMECTL, 0x77, 0);
+ rtsx_disable_bus_int(chip);
+ } else {
+ rtsx_enable_bus_int(chip);
+ }
+
+ if (chip->ic_version >= IC_VER_D) {
+ u16 reg;
+
+ ret = rtsx_read_phy_register(chip, 0x00, ®);
+ if (ret != STATUS_SUCCESS)
+ TRACE_RET(chip, STATUS_FAIL);
+
+ reg &= 0xFE7F;
+ reg |= 0x80;
+ ret = rtsx_write_phy_register(chip, 0x00, reg);
+ if (ret != STATUS_SUCCESS)
+ TRACE_RET(chip, STATUS_FAIL);
+
+ ret = rtsx_read_phy_register(chip, 0x1C, ®);
+ if (ret != STATUS_SUCCESS)
+ TRACE_RET(chip, STATUS_FAIL);
+
+ reg &= 0xFFF7;
+ ret = rtsx_write_phy_register(chip, 0x1C, reg);
+ if (ret != STATUS_SUCCESS)
+ TRACE_RET(chip, STATUS_FAIL);
+ }
+
+ if (chip->driver_first_load && (chip->ic_version < IC_VER_C))
+ rtsx_calibration(chip);
+
+ return STATUS_SUCCESS;
+}
+
int rtsx_reset_chip(struct rtsx_chip *chip)
{
int retval;
@@ -367,53 +412,9 @@ int rtsx_reset_chip(struct rtsx_chip *chip)
RTSX_WRITE_REG(chip, PERST_GLITCH_WIDTH, 0xFF, 0x80);
- /* Enable PCIE interrupt */
- if (chip->asic_code) {
- if (CHECK_PID(chip, 0x5208)) {
- if (chip->phy_debug_mode) {
- RTSX_WRITE_REG(chip, CDRESUMECTL, 0x77, 0);
- rtsx_disable_bus_int(chip);
- } else {
- rtsx_enable_bus_int(chip);
- }
-
- if (chip->ic_version >= IC_VER_D) {
- u16 reg;
-
- retval = rtsx_read_phy_register(chip, 0x00,
- ®);
- if (retval != STATUS_SUCCESS)
- TRACE_RET(chip, STATUS_FAIL);
-
- reg &= 0xFE7F;
- reg |= 0x80;
- retval = rtsx_write_phy_register(chip, 0x00,
- reg);
- if (retval != STATUS_SUCCESS)
- TRACE_RET(chip, STATUS_FAIL);
-
- retval = rtsx_read_phy_register(chip, 0x1C,
- ®);
- if (retval != STATUS_SUCCESS)
- TRACE_RET(chip, STATUS_FAIL);
-
- reg &= 0xFFF7;
- retval = rtsx_write_phy_register(chip, 0x1C,
- reg);
- if (retval != STATUS_SUCCESS)
- TRACE_RET(chip, STATUS_FAIL);
- }
-
- if (chip->driver_first_load &&
- (chip->ic_version < IC_VER_C))
- rtsx_calibration(chip);
-
- } else {
- rtsx_enable_bus_int(chip);
- }
- } else {
- rtsx_enable_bus_int(chip);
- }
+ retval = rtsx_enable_pcie_intr(chip);
+ if (retval != STATUS_SUCCESS)
+ TRACE_RET(chip, STATUS_FAIL);
chip->need_reset = 0;
--
2.1.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 0/2] Staging: rts5208: rtsx_reset_chip style clean up
2014-10-19 19:30 [PATCH v2 0/2] Staging: rts5208: rtsx_reset_chip style clean up Fabio Falzoi
2014-10-19 19:30 ` [PATCH v2 1/2] Staging: rts5208: helper function to manage aspm during reset Fabio Falzoi
2014-10-19 19:30 ` [PATCH v2 2/2] Staging: rts5208: helper function to enable interrupts " Fabio Falzoi
@ 2014-10-20 10:02 ` Dan Carpenter
2 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2014-10-20 10:02 UTC (permalink / raw)
To: Fabio Falzoi; +Cc: gregkh, devel, linux-kernel, joe
These look good to me.
Reviewed-by: Dan Carpenter <dan.carpente@oracle.com>
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-10-20 10:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-19 19:30 [PATCH v2 0/2] Staging: rts5208: rtsx_reset_chip style clean up Fabio Falzoi
2014-10-19 19:30 ` [PATCH v2 1/2] Staging: rts5208: helper function to manage aspm during reset Fabio Falzoi
2014-10-19 19:30 ` [PATCH v2 2/2] Staging: rts5208: helper function to enable interrupts " Fabio Falzoi
2014-10-20 10:02 ` [PATCH v2 0/2] Staging: rts5208: rtsx_reset_chip style clean up Dan Carpenter
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.