public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pierre Ossman <drzeus-list@drzeus.cx>
To: Philip Langdale <plangdale@vmware.com>
Cc: linux-kernel@vger.kernel.org, John Gilmore <gnu@toad.com>
Subject: Re: [PATCH 2.6.19] mmc: Add support for SDHC cards
Date: Sun, 31 Dec 2006 12:46:47 +0100	[thread overview]
Message-ID: <4597A327.8030408@drzeus.cx> (raw)
In-Reply-To: <458C22C0.1080307@vmware.com>

Philip Langdale wrote:
> Hi all,
>
>
>   

*snip*

> Signed-off-by: Philipl Langdale <philipl@overt.org>
>   

When you have a commit message larger than the patch, you know there is
something wrong. ;)

Please skip the part about MMC at least.

> @@ -588,12 +591,15 @@
>
>  	if (mmc_card_sd(card)) {
>  		csd_struct = UNSTUFF_BITS(resp, 126, 2);
> -		if (csd_struct != 0) {
> +		if (csd_struct != 0 && csd_struct != 1) {
>  			printk("%s: unrecognised CSD structure version %d\n",
>  				mmc_hostname(card->host), csd_struct);
>  			mmc_card_set_bad(card);
>  			return;
>  		}
> +		if (csd_struct == 1) {
> +			mmc_card_set_blockaddr(card);
> +		}
>
>  		m = UNSTUFF_BITS(resp, 115, 4);
>  		e = UNSTUFF_BITS(resp, 112, 3);
>   

Actually, the way the spec describes version 2.0 of the CSD leaves my
stomach a bit upset. I think we will find cards that put bogus values in
the fields, expecting most hosts to use the well defined values. So I'd
prefer a switch statement here, where csd_struct == 1 results in hard
coded values for many fields.

> @@ -824,6 +835,25 @@
>  {
>  	struct mmc_command cmd;
>  	int i, err = 0;
> +	static const u8 test_pattern = 0xAA;
> +
> +	/*
> +	 * To support SD 2.0 cards, we must always invoke SD_SEND_IF_COND
> +	 * before SD_APP_OP_COND. This command will harmlessly fail for
> +	 * SD 1.0 and MMC cards (fortunately including MMC 4 cards).
> +	 */
> +	cmd.opcode = SD_SEND_IF_COND;
> +	cmd.arg = ((host->ocr_avail & 0xFF8000) != 0) << 8 | test_pattern;
> +	cmd.flags = MMC_RSP_R7 | MMC_CMD_BCR;
> +
> +	err = mmc_wait_for_cmd(host, &cmd, 0);
> +	if (err == MMC_ERR_NONE) {
> +		if ((cmd.resp[0] & 0xFF) != test_pattern) {
> +			return MMC_ERR_FAILED;
> +		} else if (ocr != 0) {
> +			ocr |= 1 << 30;
> +		}
> +	}
>
>  	cmd.opcode = SD_APP_OP_COND;
>  	cmd.arg = ocr;
>   

Put this in mmc_setup() with the rest of the initialisation. Hiding in
here just confuses things.

Also, please add a comment about why you manipulate the ocr.

> @@ -43,6 +43,7 @@
>  #define MMC_RSP_R2	(MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC)
>  #define MMC_RSP_R3	(MMC_RSP_PRESENT)
>  #define MMC_RSP_R6	(MMC_RSP_PRESENT|MMC_RSP_CRC)
> +#define MMC_RSP_R7	(MMC_RSP_PRESENT|MMC_RSP_CRC)
>
>  #define mmc_resp_type(cmd)	((cmd)->flags & (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC|MMC_RSP_BUSY|MMC_RSP_OPCODE))
>
>   

Wrong. R7 is defined as MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE.

(So is R6 btw, wonder why that is...)

Rgds

-- 
     -- Pierre Ossman

  Linux kernel, MMC maintainer        http://www.kernel.org
  PulseAudio, core developer          http://pulseaudio.org
  rdesktop, core developer          http://www.rdesktop.org


  parent reply	other threads:[~2006-12-31 11:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-22 18:24 [PATCH 2.6.19] mmc: Add support for SDHC cards Philip Langdale
2006-12-22 18:50 ` Philip Langdale
2006-12-28 13:36   ` Pavel Machek
2007-01-01 17:49     ` Pierre Ossman
2006-12-31 11:46 ` Pierre Ossman [this message]
2007-01-01 15:20   ` Philip Langdale
2007-01-03 21:05     ` Pierre Ossman

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=4597A327.8030408@drzeus.cx \
    --to=drzeus-list@drzeus.cx \
    --cc=gnu@toad.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=plangdale@vmware.com \
    /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