From: Adrian Hunter <adrian.hunter@nokia.com>
To: "Ghorai, Sukumar" <s-ghorai@ti.com>
Cc: "linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] mmc: add device class attribute for ext_csd
Date: Mon, 26 Jul 2010 15:42:48 +0300 [thread overview]
Message-ID: <4C4D82C8.3040307@nokia.com> (raw)
In-Reply-To: <2A3DCF3DA181AD40BDE86A3150B27B6B030E4176E6@dbde02.ent.ti.com>
Ghorai, Sukumar wrote:
> All,
> EXT_CSD is 512byte information (read using CMD8) for the MMC (eMMC) device.
> And for the latest and upcoming specification, ext_csd are much relevant then past.
>
> So please let me know your idea to add and get the same ext_csd as MMC device attribute. This is the same way currently available for csd, cid, src, etc.
> (# cat /sys/class/mmc_host/mmc1/mmc1\:0001/ext_csd)
Some of the values in Extended CSD can change so storing
it could cause incorrect values to be reported.
Note that Extended CSD is available via debugfs
e.g. for device mmc0:0001 with debugfs mounted on /sys/kernel/debug
cat /sys/kernel/debug/mmc0/mmc0\:0001/ext_csd
>
> Regards,
> Sukumar Ghorai
>
> From: Sukumar Ghorai <s-ghorai@ti.com>
> Date: Mon, 26 Jul 2010 10:47:12 +0530
> Subject: [PATCH] mmc: add device class attribute for ext_csd
>
> ext_csd is getting more informative form eMMC 4.4 onwards and better to
> have this in device information as currently available for csd, cid, src.
>
> Signed-off-by: Sukumar Ghorai <s-ghorai@ti.com>
> ---
> drivers/mmc/core/bus.c | 1 +
> drivers/mmc/core/mmc.c | 23 +++++++++++++++++------
> include/linux/mmc/card.h | 1 +
> 3 files changed, 19 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
> index 49d9dca..57d035e 100644
> --- a/drivers/mmc/core/bus.c
> +++ b/drivers/mmc/core/bus.c
> @@ -191,6 +191,7 @@ static void mmc_release_card(struct device *dev)
> if (card->info)
> kfree(card->info);
>
> + kfree(card->raw_ext_csd);
> kfree(card);
> }
>
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index 89f7a25..23b1813 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -167,10 +167,6 @@ static int mmc_read_ext_csd(struct mmc_card *card)
> if (card->csd.mmca_vsn < CSD_SPEC_VER_4)
> return 0;
>
> - /*
> - * As the ext_csd is so large and mostly unused, we don't store the
> - * raw block in mmc_card.
> - */
> ext_csd = kmalloc(512, GFP_KERNEL);
> if (!ext_csd) {
> printk(KERN_ERR "%s: could not allocate a buffer to "
> @@ -250,11 +246,25 @@ static int mmc_read_ext_csd(struct mmc_card *card)
> }
>
> out:
> - kfree(ext_csd);
> -
> + card->raw_ext_csd = ext_csd;
> return err;
> }
>
> +static ssize_t mmc_ext_csd_show(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> +int i;
> +struct mmc_card *card = container_of(dev, struct mmc_card, dev);
> +
> + for (i = 0; i < 512; i++)
> + buf += sprintf(buf, "%02x", card->raw_ext_csd[i]);
> +
> + buf -= 512;
> + return 512;
> +}
> +
> +static DEVICE_ATTR(ext_csd, S_IRUGO, mmc_ext_csd_show, NULL);
> +
> MMC_DEV_ATTR(cid, "%08x%08x%08x%08x\n", card->raw_cid[0], card->raw_cid[1],
> card->raw_cid[2], card->raw_cid[3]);
> MMC_DEV_ATTR(csd, "%08x%08x%08x%08x\n", card->raw_csd[0], card->raw_csd[1],
> @@ -270,6 +280,7 @@ MMC_DEV_ATTR(serial, "0x%08x\n", card->cid.serial);
> static struct attribute *mmc_std_attrs[] = {
> &dev_attr_cid.attr,
> &dev_attr_csd.attr,
> + &dev_attr_ext_csd.attr,
> &dev_attr_date.attr,
> &dev_attr_fwrev.attr,
> &dev_attr_hwrev.attr,
> diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
> index d02d2c6..00332ca 100644
> --- a/include/linux/mmc/card.h
> +++ b/include/linux/mmc/card.h
> @@ -105,6 +105,7 @@ struct mmc_card {
> u32 raw_cid[4]; /* raw card CID */
> u32 raw_csd[4]; /* raw card CSD */
> u32 raw_scr[2]; /* raw card SCR */
> + u8 *raw_ext_csd; /* raw card EXT CSD for MMC */
> struct mmc_cid cid; /* card identification */
> struct mmc_csd csd; /* card specific */
> struct mmc_ext_csd ext_csd; /* mmc v4 extended card specific */
next prev parent reply other threads:[~2010-07-26 12:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-26 10:09 [PATCH] Fix mmc_test build order Kyungmin Park
2010-07-26 11:05 ` Adrian Hunter
2010-07-26 12:27 ` [PATCH] mmc: add device class attribute for ext_csd Ghorai, Sukumar
2010-07-26 12:42 ` Adrian Hunter [this message]
2010-07-26 15:00 ` Ghorai, Sukumar
2010-07-27 7:51 ` Adrian Hunter
2010-07-27 10:50 ` Ghorai, Sukumar
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=4C4D82C8.3040307@nokia.com \
--to=adrian.hunter@nokia.com \
--cc=akpm@linux-foundation.org \
--cc=linux-mmc@vger.kernel.org \
--cc=s-ghorai@ti.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;
as well as URLs for NNTP newsgroup(s).