mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mmc: core: Extend sysfs with DSR register
@ 2016-07-12 12:56 Bojan Prtvar
  2016-07-18 11:20 ` Ulf Hansson
  0 siblings, 1 reply; 2+ messages in thread
From: Bojan Prtvar @ 2016-07-12 12:56 UTC (permalink / raw)
  To: linux-mmc
  Cc: Jonathan Corbet, Ulf Hansson, Linus Walleij, Adrian Hunter,
	Dong Aisheng, Wolfram Sang, Gwendal Grignou, Chaotian Jing,
	linux-doc, linux-kernel

Export DSR register through sysfs same as we did for the CID, CSD and OCR registers.

Signed-off-by: Bojan Prtvar <prtvar.b@gmail.com>
---
 Documentation/mmc/mmc-dev-attrs.txt |  1 +
 drivers/mmc/core/mmc.c              | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/Documentation/mmc/mmc-dev-attrs.txt b/Documentation/mmc/mmc-dev-attrs.txt
index 8163eca..404a0e9 100644
--- a/Documentation/mmc/mmc-dev-attrs.txt
+++ b/Documentation/mmc/mmc-dev-attrs.txt
@@ -29,6 +29,7 @@ All attributes are read-only.
 	raw_rpmb_size_mult	RPMB partition size
 	rel_sectors		Reliable write sector count
 	ocr 			Operation Conditions Register
+	dsr			Driver Stage Register
 
 Note on Erase Size and Preferred Erase Size:
 
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 1848334..4363fdc 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -745,6 +745,22 @@ static ssize_t mmc_fwrev_show(struct device *dev,
 
 static DEVICE_ATTR(fwrev, S_IRUGO, mmc_fwrev_show, NULL);
 
+static ssize_t mmc_dsr_show(struct device *dev,
+			    struct device_attribute *attr,
+			    char *buf)
+{
+	struct mmc_card *card = mmc_dev_to_card(dev);
+	struct mmc_host *host = card->host;
+
+	if (card->csd.dsr_imp && host->dsr_req)
+		return sprintf(buf, "0x%x\n", host->dsr);
+	else
+		/* return default DSR value */
+		return sprintf(buf, "0x%x\n", 0x404);
+}
+
+static DEVICE_ATTR(dsr, S_IRUGO, mmc_dsr_show, NULL);
+
 static struct attribute *mmc_std_attrs[] = {
 	&dev_attr_cid.attr,
 	&dev_attr_csd.attr,
@@ -764,6 +780,7 @@ static struct attribute *mmc_std_attrs[] = {
 	&dev_attr_raw_rpmb_size_mult.attr,
 	&dev_attr_rel_sectors.attr,
 	&dev_attr_ocr.attr,
+	&dev_attr_dsr.attr,
 	NULL,
 };
 ATTRIBUTE_GROUPS(mmc_std);
-- 
2.8.0.GIT

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] mmc: core: Extend sysfs with DSR register
  2016-07-12 12:56 [PATCH] mmc: core: Extend sysfs with DSR register Bojan Prtvar
@ 2016-07-18 11:20 ` Ulf Hansson
  0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2016-07-18 11:20 UTC (permalink / raw)
  To: Bojan Prtvar
  Cc: linux-mmc, Jonathan Corbet, Linus Walleij, Adrian Hunter,
	Dong Aisheng, Wolfram Sang, Gwendal Grignou, Chaotian Jing,
	linux-doc, linux-kernel

On 12 July 2016 at 14:56, Bojan Prtvar <prtvar.b@gmail.com> wrote:
> Export DSR register through sysfs same as we did for the CID, CSD and OCR registers.
>
> Signed-off-by: Bojan Prtvar <prtvar.b@gmail.com>
> ---
>  Documentation/mmc/mmc-dev-attrs.txt |  1 +
>  drivers/mmc/core/mmc.c              | 17 +++++++++++++++++
>  2 files changed, 18 insertions(+)
>
> diff --git a/Documentation/mmc/mmc-dev-attrs.txt b/Documentation/mmc/mmc-dev-attrs.txt
> index 8163eca..404a0e9 100644
> --- a/Documentation/mmc/mmc-dev-attrs.txt
> +++ b/Documentation/mmc/mmc-dev-attrs.txt
> @@ -29,6 +29,7 @@ All attributes are read-only.
>         raw_rpmb_size_mult      RPMB partition size
>         rel_sectors             Reliable write sector count
>         ocr                     Operation Conditions Register
> +       dsr                     Driver Stage Register
>
>  Note on Erase Size and Preferred Erase Size:
>
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index 1848334..4363fdc 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -745,6 +745,22 @@ static ssize_t mmc_fwrev_show(struct device *dev,
>
>  static DEVICE_ATTR(fwrev, S_IRUGO, mmc_fwrev_show, NULL);
>
> +static ssize_t mmc_dsr_show(struct device *dev,
> +                           struct device_attribute *attr,
> +                           char *buf)
> +{
> +       struct mmc_card *card = mmc_dev_to_card(dev);
> +       struct mmc_host *host = card->host;
> +
> +       if (card->csd.dsr_imp && host->dsr_req)
> +               return sprintf(buf, "0x%x\n", host->dsr);
> +       else
> +               /* return default DSR value */
> +               return sprintf(buf, "0x%x\n", 0x404);
> +}
> +
> +static DEVICE_ATTR(dsr, S_IRUGO, mmc_dsr_show, NULL);
> +
>  static struct attribute *mmc_std_attrs[] = {
>         &dev_attr_cid.attr,
>         &dev_attr_csd.attr,
> @@ -764,6 +780,7 @@ static struct attribute *mmc_std_attrs[] = {
>         &dev_attr_raw_rpmb_size_mult.attr,
>         &dev_attr_rel_sectors.attr,
>         &dev_attr_ocr.attr,
> +       &dev_attr_dsr.attr,
>         NULL,
>  };
>  ATTRIBUTE_GROUPS(mmc_std);
> --
> 2.8.0.GIT
>

Could you please extend this change to also cover SD cards. They also
have DSR registers.

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-07-18 11:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-12 12:56 [PATCH] mmc: core: Extend sysfs with DSR register Bojan Prtvar
2016-07-18 11:20 ` Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®