public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: wwang <wei_wang@realsil.com.cn>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: "devel@linuxdriverproject.org" <devel@linuxdriverproject.org>,
	"gregkh@suse.de" <gregkh@suse.de>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] staging:rts_pstor:Fix SDIO issue
Date: Mon, 10 Oct 2011 09:51:03 +0800	[thread overview]
Message-ID: <4E924F87.3080102@realsil.com.cn> (raw)
In-Reply-To: <20111009135745.GO18470@longonot.mountain>

Dear Carpenter:

I will resend the patch

Best Regards,
wwang


于 2011年10月09日 21:57, Dan Carpenter 写道:
> What I'm saying is, it's confusing to add another variable which is
> only subtly different from retval.  Here is what it looks like after
> we apply the patch.
>
> 	int reset_pass = 0;
>
> 	/* skip 45 lines */
>
> 	retval = sd_change_bank_voltage(chip, SD_IO_3V3);
> 	if (retval != STATUS_SUCCESS) {
> 		TRACE_RET(chip, STATUS_FAIL);
> 	}
>
> 	/* skip 30 lines */
>
> 	if (!reset_pass)
> 		TRACE_RET(chip, STATUS_FAIL);
>
> The reviewer would have to read through 80 lines of code to find that
> we don't care about the return value from sd_change_bank_voltage().
> Don't do it that way.
>
> Here is how I would write what it.  I can't actually test this since
> I don't have the hardware...
>
> diff --git a/drivers/staging/rts_pstor/sd.c b/drivers/staging/rts_pstor/sd.c
> index fb62eaf..46bf0e1 100644
> --- a/drivers/staging/rts_pstor/sd.c
> +++ b/drivers/staging/rts_pstor/sd.c
> @@ -3134,39 +3134,36 @@ int reset_sd_card(struct rtsx_chip *chip)
>  
>  	if (chip->sd_ctl & RESET_MMC_FIRST) {
>  		retval = reset_mmc(chip);
> -		if ((retval != STATUS_SUCCESS) && !sd_check_err_code(chip, SD_NO_CARD)) {
> +		if (retval != STATUS_SUCCESS) {
> +			if (sd_check_err_code(chip, SD_NO_CARD))
> +				TRACE_RET(chip, STATUS_FAIL);
> +
>  			retval = reset_sd(chip);
>  			if (retval != STATUS_SUCCESS) {
> -				if (CHECK_PID(chip, 0x5209)) {
> -					retval = sd_change_bank_voltage(chip, SD_IO_3V3);
> -					if (retval != STATUS_SUCCESS) {
> -						TRACE_RET(chip, STATUS_FAIL);
> -					}
> -				}
> +				if (CHECK_PID(chip, 0x5209))
> +					sd_change_bank_voltage(chip, SD_IO_3V3);
> +				TRACE_RET(chip, STATUS_FAIL);
>  			}
>  		}
>  	} else {
>  		retval = reset_sd(chip);
>  		if (retval != STATUS_SUCCESS) {
> -			if (sd_check_err_code(chip, SD_NO_CARD)) {
> +			if (sd_check_err_code(chip, SD_NO_CARD))
>  				TRACE_RET(chip, STATUS_FAIL);
> -			}
>  
>  			if (CHECK_PID(chip, 0x5209)) {
>  				retval = sd_change_bank_voltage(chip, SD_IO_3V3);
> -				if (retval != STATUS_SUCCESS) {
> +				if (retval != STATUS_SUCCESS)
>  					TRACE_RET(chip, STATUS_FAIL);
> -				}
>  			}
>  
> -			if (!chip->sd_io) {
> -				retval = reset_mmc(chip);
> -			}
> -		}
> -	}
> +			if (chip->sd_io)
> +				TRACE_RET(chip, STATUS_FAIL);
>  
> -	if (retval != STATUS_SUCCESS) {
> -		TRACE_RET(chip, STATUS_FAIL);
> +			retval = reset_mmc(chip);
> +			if (retval != STATUS_SUCCESS)
> +				TRACE_RET(chip, STATUS_FAIL);
> +		}
>  	}
>  
>  	retval = sd_set_clock_divider(chip, SD_CLK_DIVIDE_0);


  reply	other threads:[~2011-10-10  1:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-09  2:03 [PATCH] staging:rts_pstor:Fix SDIO issue wei_wang
2011-10-09  6:06 ` Dan Carpenter
2011-10-09  6:48   ` wwang
2011-10-09 13:57     ` Dan Carpenter
2011-10-10  1:51       ` wwang [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-10-10  1:51 wei_wang
2011-10-10  6:12 ` Dan Carpenter
2011-10-10  6:47 wei_wang
2011-10-10  7:55 ` Dan Carpenter

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=4E924F87.3080102@realsil.com.cn \
    --to=wei_wang@realsil.com.cn \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@linuxdriverproject.org \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    /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