MMC: Add Extended CSD as a device attribute
PATCH 1/1 MMC: Add Extended CSD as a device attribute
---drivers/mmc/core/mmc.c | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
drivers/mmc/core/mmc.c +0 -0
@@ -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,
};
Signature · 1 line
1.5.4.3
Quoted 2 lines · On Wed, 14 Jan 2009 18:23:35 +0200 Adrian Hunter <[email protected]>…
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?
Quoted 2 lines
Signed-off-by Adrian Hunter <[email protected]>
It would take only 30 seconds to write a changelog for this patch :(
Quoted 19 lines
drivers/mmc/core/mmc.c | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-)drivers/mmc/core/mmc.c +8
-0@@ -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 );
drivers/mmc/core/mmc.c MMC_DEV_ATTR(name, "%s\n", card->cid.prod_name); · line 279
Quoted 10 lines
drivers/mmc/core/mmc.c +10
-0+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.
Quoted 20 lines
drivers/mmc/core/mmc.c +11
-0+ 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, };
From: Adrian Hunter <[email protected]>
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.
---drivers/mmc/core/mmc.c | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
drivers/mmc/core/mmc.c +0 -0
@@ -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,
};
Signature · 1 line
1.5.4.3
Quoted 11 lines · On Fri, 16 Jan 2009 12:41:50 +0200 Adrian Hunter <[email protected]>…
From: Adrian Hunter <[email protected]>
Date: Wed, 14 Jan 2009 17:45:53 +0200
Subject: [PATCH] MMC: Add Extended CSD as a device attributeExtended 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.
Quoted 2 lines
Signed-off-by Adrian Hunter <[email protected]>---
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
Signature · 9 lines
-- 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.
Quoted 14 lines · Pierre Ossman
Quoted 11 lines · On Fri, 16 Jan 2009 12:41:50 +0200 Adrian Hunter <[email protected]>…
From: Adrian Hunter <[email protected]>
Date: Wed, 14 Jan 2009 17:45:53 +0200
Subject: [PATCH] MMC: Add Extended CSD as a device attributeExtended 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.
Quoted 5 lines
Quoted 2 lines
Signed-off-by Adrian Hunter <[email protected]>---
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?
Quoted 5 lines · On Mon, 26 Jan 2009 11:16:36 +0200 Adrian Hunter <[email protected]>…
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_DEBUGor debugfs?
debugfs if it's not too much trouble. Noone can claim they didn't understand it was only for debugging there. :)
Signature · 9 lines
-- 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.