* [PATCH] MMC: Add Extended CSD as a device attribute
@ 2009-01-14 16:23 Adrian Hunter
2009-01-16 0:05 ` Andrew Morton
0 siblings, 1 reply; 6+ messages in thread
From: Adrian Hunter @ 2009-01-14 16:23 UTC (permalink / raw)
To: Pierre Ossman; +Cc: LKML
Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
---
drivers/mmc/core/mmc.c | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 3f5b089..29291de 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -259,6 +259,34 @@ MMC_DEV_ATTR(name, "%s\n", card->cid.prod_name);
MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid);
MMC_DEV_ATTR(serial, "0x%08x\n", card->cid.serial);
+static ssize_t mmc_ext_csd_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ struct mmc_card *card = container_of(dev, struct mmc_card, dev);
+ ssize_t n = 0;
+ u8 *ext_csd;
+ int err, i;
+
+ ext_csd = kmalloc(512, GFP_KERNEL);
+ if (!ext_csd)
+ return 0;
+
+ mmc_claim_host(card->host);
+ err = mmc_send_ext_csd(card, ext_csd);
+ mmc_release_host(card->host);
+
+ if (!err) {
+ for (i = 511; i >= 0; i--)
+ n += sprintf(buf + n, "%02x", (unsigned)ext_csd[i]);
+ n += sprintf(buf + n, "\n");
+ }
+
+ kfree(ext_csd);
+
+ return n;
+}
+
+static DEVICE_ATTR(ext_csd, S_IRUGO, mmc_ext_csd_show, NULL);
+
static struct attribute *mmc_std_attrs[] = {
&dev_attr_cid.attr,
&dev_attr_csd.attr,
@@ -269,6 +297,7 @@ static struct attribute *mmc_std_attrs[] = {
&dev_attr_name.attr,
&dev_attr_oemid.attr,
&dev_attr_serial.attr,
+ &dev_attr_ext_csd.attr,
NULL,
};
--
1.5.4.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] MMC: Add Extended CSD as a device attribute
2009-01-14 16:23 [PATCH] MMC: Add Extended CSD as a device attribute Adrian Hunter
@ 2009-01-16 0:05 ` Andrew Morton
2009-01-16 10:41 ` Adrian Hunter
0 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2009-01-16 0:05 UTC (permalink / raw)
To: Adrian Hunter; +Cc: drzeus-mmc, linux-kernel
On Wed, 14 Jan 2009 18:23:35 +0200
Adrian Hunter <ext-adrian.hunter@nokia.com> wrote:
>
> Subject: [PATCH] MMC: Add Extended CSD as a device attribute
Why? There must be some *reason* for making this change. Presumably
that reason is obvious to yourself and Pierre, but what about the rest
of us?
>
> Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
It would take only 30 seconds to write a changelog for this patch :(
> drivers/mmc/core/mmc.c | 29 +++++++++++++++++++++++++++++
> 1 files changed, 29 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index 3f5b089..29291de 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -259,6 +259,34 @@ MMC_DEV_ATTR(name, "%s\n", card->cid.prod_name);
> MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid);
> MMC_DEV_ATTR(serial, "0x%08x\n", card->cid.serial);
>
> +static ssize_t mmc_ext_csd_show(struct device *dev, struct device_attribute *attr, char *buf)
> +{
> + struct mmc_card *card = container_of(dev, struct mmc_card, dev);
> + ssize_t n = 0;
> + u8 *ext_csd;
> + int err, i;
> +
> + ext_csd = kmalloc(512, GFP_KERNEL);
> + if (!ext_csd)
> + return 0;
> +
> + mmc_claim_host(card->host);
> + err = mmc_send_ext_csd(card, ext_csd);
> + mmc_release_host(card->host);
> +
> + if (!err) {
> + for (i = 511; i >= 0; i--)
> + n += sprintf(buf + n, "%02x", (unsigned)ext_csd[i]);
The cast isn't actually needed.
> + n += sprintf(buf + n, "\n");
> + }
> +
> + kfree(ext_csd);
> +
> + return n;
> +}
> +
> +static DEVICE_ATTR(ext_csd, S_IRUGO, mmc_ext_csd_show, NULL);
> +
> static struct attribute *mmc_std_attrs[] = {
> &dev_attr_cid.attr,
> &dev_attr_csd.attr,
> @@ -269,6 +297,7 @@ static struct attribute *mmc_std_attrs[] = {
> &dev_attr_name.attr,
> &dev_attr_oemid.attr,
> &dev_attr_serial.attr,
> + &dev_attr_ext_csd.attr,
> NULL,
> };
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] MMC: Add Extended CSD as a device attribute
2009-01-16 0:05 ` Andrew Morton
@ 2009-01-16 10:41 ` Adrian Hunter
2009-01-24 20:45 ` Pierre Ossman
0 siblings, 1 reply; 6+ messages in thread
From: Adrian Hunter @ 2009-01-16 10:41 UTC (permalink / raw)
To: Andrew Morton; +Cc: drzeus-mmc, linux-kernel
From: Adrian Hunter <ext-adrian.hunter@nokia.com>
Date: Wed, 14 Jan 2009 17:45:53 +0200
Subject: [PATCH] MMC: Add Extended CSD as a device attribute
Extended CSD is a MMC card register. The Card Identification
(CID) register and the Card-Specific Data (CSD) register are
already device attributes. As increasingly interesting
fields are being added to Extended CSD, it seems reasonable to
add it too. Note that SD cards do not have an Extended CSD
register, so it is MMC only.
Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
---
drivers/mmc/core/mmc.c | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 3f5b089..4eadba6 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -259,6 +259,34 @@ MMC_DEV_ATTR(name, "%s\n", card->cid.prod_name);
MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid);
MMC_DEV_ATTR(serial, "0x%08x\n", card->cid.serial);
+static ssize_t mmc_ext_csd_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ struct mmc_card *card = container_of(dev, struct mmc_card, dev);
+ ssize_t n = 0;
+ u8 *ext_csd;
+ int err, i;
+
+ ext_csd = kmalloc(512, GFP_KERNEL);
+ if (!ext_csd)
+ return 0;
+
+ mmc_claim_host(card->host);
+ err = mmc_send_ext_csd(card, ext_csd);
+ mmc_release_host(card->host);
+
+ if (!err) {
+ for (i = 511; i >= 0; i--)
+ n += sprintf(buf + n, "%02x", ext_csd[i]);
+ n += sprintf(buf + n, "\n");
+ }
+
+ kfree(ext_csd);
+
+ return n;
+}
+
+static DEVICE_ATTR(ext_csd, S_IRUGO, mmc_ext_csd_show, NULL);
+
static struct attribute *mmc_std_attrs[] = {
&dev_attr_cid.attr,
&dev_attr_csd.attr,
@@ -269,6 +297,7 @@ static struct attribute *mmc_std_attrs[] = {
&dev_attr_name.attr,
&dev_attr_oemid.attr,
&dev_attr_serial.attr,
+ &dev_attr_ext_csd.attr,
NULL,
};
--
1.5.4.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] MMC: Add Extended CSD as a device attribute
2009-01-16 10:41 ` Adrian Hunter
@ 2009-01-24 20:45 ` Pierre Ossman
2009-01-26 9:16 ` Adrian Hunter
0 siblings, 1 reply; 6+ messages in thread
From: Pierre Ossman @ 2009-01-24 20:45 UTC (permalink / raw)
To: Adrian Hunter; +Cc: Andrew Morton, linux-kernel
On Fri, 16 Jan 2009 12:41:50 +0200
Adrian Hunter <ext-adrian.hunter@nokia.com> wrote:
> From: Adrian Hunter <ext-adrian.hunter@nokia.com>
> Date: Wed, 14 Jan 2009 17:45:53 +0200
> Subject: [PATCH] MMC: Add Extended CSD as a device attribute
>
> Extended CSD is a MMC card register. The Card Identification
> (CID) register and the Card-Specific Data (CSD) register are
> already device attributes. As increasingly interesting
> fields are being added to Extended CSD, it seems reasonable to
> add it too. Note that SD cards do not have an Extended CSD
> register, so it is MMC only.
>
> Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
> ---
Well, this might be interesting for debugging, but I don't see anything
of general interest for user space in there. What's your use case?
Rgds
--
-- Pierre Ossman
Linux kernel, MMC maintainer http://www.kernel.org
rdesktop, core developer http://www.rdesktop.org
WARNING: This correspondence is being monitored by the
Swedish government. Make sure your server uses encryption
for SMTP traffic and consider using PGP for end-to-end
encryption.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] MMC: Add Extended CSD as a device attribute
2009-01-24 20:45 ` Pierre Ossman
@ 2009-01-26 9:16 ` Adrian Hunter
2009-02-02 19:26 ` Pierre Ossman
0 siblings, 1 reply; 6+ messages in thread
From: Adrian Hunter @ 2009-01-26 9:16 UTC (permalink / raw)
To: Pierre Ossman; +Cc: Andrew Morton, linux-kernel
Pierre Ossman wrote:
> On Fri, 16 Jan 2009 12:41:50 +0200
> Adrian Hunter <ext-adrian.hunter@nokia.com> wrote:
>
>> From: Adrian Hunter <ext-adrian.hunter@nokia.com>
>> Date: Wed, 14 Jan 2009 17:45:53 +0200
>> Subject: [PATCH] MMC: Add Extended CSD as a device attribute
>>
>> Extended CSD is a MMC card register. The Card Identification
>> (CID) register and the Card-Specific Data (CSD) register are
>> already device attributes. As increasingly interesting
>> fields are being added to Extended CSD, it seems reasonable to
>> add it too. Note that SD cards do not have an Extended CSD
>> register, so it is MMC only.
>>
>> Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
>> ---
>
> Well, this might be interesting for debugging, but I don't see anything
> of general interest for user space in there. What's your use case?
Yes it is mainly just debugging. It was done as a device attribute for
consistency with the other card registers CID and CSD.
Would you prefer #ifdef CONFIG_MMC_DEBUG or debugfs?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] MMC: Add Extended CSD as a device attribute
2009-01-26 9:16 ` Adrian Hunter
@ 2009-02-02 19:26 ` Pierre Ossman
0 siblings, 0 replies; 6+ messages in thread
From: Pierre Ossman @ 2009-02-02 19:26 UTC (permalink / raw)
To: Adrian Hunter; +Cc: Andrew Morton, linux-kernel
On Mon, 26 Jan 2009 11:16:36 +0200
Adrian Hunter <ext-adrian.hunter@nokia.com> wrote:
>
> Yes it is mainly just debugging. It was done as a device attribute for
> consistency with the other card registers CID and CSD.
>
> Would you prefer #ifdef CONFIG_MMC_DEBUG or debugfs?
debugfs if it's not too much trouble. Noone can claim they didn't
understand it was only for debugging there. :)
--
-- Pierre Ossman
Linux kernel, MMC maintainer http://www.kernel.org
rdesktop, core developer http://www.rdesktop.org
WARNING: This correspondence is being monitored by the
Swedish government. Make sure your server uses encryption
for SMTP traffic and consider using PGP for end-to-end
encryption.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-02-02 19:26 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-14 16:23 [PATCH] MMC: Add Extended CSD as a device attribute Adrian Hunter
2009-01-16 0:05 ` Andrew Morton
2009-01-16 10:41 ` Adrian Hunter
2009-01-24 20:45 ` Pierre Ossman
2009-01-26 9:16 ` Adrian Hunter
2009-02-02 19:26 ` Pierre Ossman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox