Re: [PATCH v6] mmc: Export host capabilities to debugfs.

2018-03-07 Thread Andy Shevchenko
On Wed, 2018-03-07 at 12:34 +0530, Harish Jenny K N wrote:

> > > > > > 
> > > +static int mmc_caps_show(struct seq_file *s, void *unused) {
> > > + struct mmc_host *host = s->private;
> > > + u32 caps = host->caps;
> > > +
> > > > > > +   seq_puts(s, "\nMMC Host capabilities are:\n");

First of all, avoid leading '\n' in the messages.

> > > > > > +   seq_puts(s,
> > > 
"=\n");
> > > + seq_printf(s, "Can the host do 4 bit transfers :\t%s\n",
> > > +((caps & MMC_CAP_4_BIT_DATA) ? "Yes" : "No"));
> > 
> > Maybe use a more compact form, and just call a macro with the
> > applicable (stringified) bit?
> 
> Something like this ?
> 
> #define YN(bit) ((caps & bit) ? "Yes" : "No")
> and then call
> seq_printf(s, "Can the host do 4 bit transfers :\t%s\n",
> YN(MMC_CAP_4_BIT_DATA));
> 

I would rather say something like this:

static const char * const mmc_host_capabilities[] = {
 "4-bit transfers allowed",
 "...",
 ...
};

...
  for_each_set_bit(i, caps)
   seq_printf("%s\n", mmc_host_capabilities[i]);
...


-- 
Andy Shevchenko 
Intel Finland Oy


Re: [PATCH v6] mmc: Export host capabilities to debugfs.

2018-03-07 Thread Andy Shevchenko
On Wed, 2018-03-07 at 12:34 +0530, Harish Jenny K N wrote:

> > > > > > 
> > > +static int mmc_caps_show(struct seq_file *s, void *unused) {
> > > + struct mmc_host *host = s->private;
> > > + u32 caps = host->caps;
> > > +
> > > > > > +   seq_puts(s, "\nMMC Host capabilities are:\n");

First of all, avoid leading '\n' in the messages.

> > > > > > +   seq_puts(s,
> > > 
"=\n");
> > > + seq_printf(s, "Can the host do 4 bit transfers :\t%s\n",
> > > +((caps & MMC_CAP_4_BIT_DATA) ? "Yes" : "No"));
> > 
> > Maybe use a more compact form, and just call a macro with the
> > applicable (stringified) bit?
> 
> Something like this ?
> 
> #define YN(bit) ((caps & bit) ? "Yes" : "No")
> and then call
> seq_printf(s, "Can the host do 4 bit transfers :\t%s\n",
> YN(MMC_CAP_4_BIT_DATA));
> 

I would rather say something like this:

static const char * const mmc_host_capabilities[] = {
 "4-bit transfers allowed",
 "...",
 ...
};

...
  for_each_set_bit(i, caps)
   seq_printf("%s\n", mmc_host_capabilities[i]);
...


-- 
Andy Shevchenko 
Intel Finland Oy


Re: [PATCH v6] mmc: Export host capabilities to debugfs.

2018-03-06 Thread Harish Jenny K N


On Wednesday 07 March 2018 12:10 PM, Avri Altman wrote:
>
>> -Original Message-
>> From: Harish Jenny K N [mailto:harish_kand...@mentor.com]
>> Sent: Wednesday, March 07, 2018 7:38 AM
>> To: ulf.hans...@linaro.org; linus.wall...@linaro.org;
>> adrian.hun...@intel.com; shawn@rock-chips.com; Avri Altman
>> <avri.alt...@wdc.com>; andriy.shevche...@linux.intel.com
>> Cc: linux-...@vger.kernel.org; linux-kernel@vger.kernel.org;
>> harish_kand...@mentor.com; vladimir_zapols...@mentor.com
>> Subject: [PATCH v6] mmc: Export host capabilities to debugfs.
>>
>> This patch exports the host capabilities to debugfs
>>
>> This idea of sharing host capabilities over debugfs came up from Abbas Raza
>> <abbas_r...@mentor.com> Earlier discussions:
>> https://lkml.org/lkml/2018/3/5/357
>> https://www.spinics.net/lists/linux-mmc/msg48219.html
>>
>> Signed-off-by: Harish Jenny K N <harish_kand...@mentor.com>
>> ---
>>
>>
>> +static int mmc_caps_show(struct seq_file *s, void *unused) {
>> +struct mmc_host *host = s->private;
>> +u32 caps = host->caps;
>> +
>> +seq_puts(s, "\nMMC Host capabilities are:\n");
>> +seq_puts(s,
>> "=\n");
>> +seq_printf(s, "Can the host do 4 bit transfers :\t%s\n",
>> +   ((caps & MMC_CAP_4_BIT_DATA) ? "Yes" : "No"));
> Maybe use a more compact form, and just call a macro with the applicable 
> (stringified) bit?

Something like this ?

#define YN(bit) ((caps & bit) ? "Yes" : "No")
and then call
seq_printf(s, "Can the host do 4 bit transfers :\t%s\n", 
YN(MMC_CAP_4_BIT_DATA));



Thanks,
Harish Jenny K N


Re: [PATCH v6] mmc: Export host capabilities to debugfs.

2018-03-06 Thread Harish Jenny K N


On Wednesday 07 March 2018 12:10 PM, Avri Altman wrote:
>
>> -Original Message-
>> From: Harish Jenny K N [mailto:harish_kand...@mentor.com]
>> Sent: Wednesday, March 07, 2018 7:38 AM
>> To: ulf.hans...@linaro.org; linus.wall...@linaro.org;
>> adrian.hun...@intel.com; shawn@rock-chips.com; Avri Altman
>> ; andriy.shevche...@linux.intel.com
>> Cc: linux-...@vger.kernel.org; linux-kernel@vger.kernel.org;
>> harish_kand...@mentor.com; vladimir_zapols...@mentor.com
>> Subject: [PATCH v6] mmc: Export host capabilities to debugfs.
>>
>> This patch exports the host capabilities to debugfs
>>
>> This idea of sharing host capabilities over debugfs came up from Abbas Raza
>>  Earlier discussions:
>> https://lkml.org/lkml/2018/3/5/357
>> https://www.spinics.net/lists/linux-mmc/msg48219.html
>>
>> Signed-off-by: Harish Jenny K N 
>> ---
>>
>>
>> +static int mmc_caps_show(struct seq_file *s, void *unused) {
>> +struct mmc_host *host = s->private;
>> +u32 caps = host->caps;
>> +
>> +seq_puts(s, "\nMMC Host capabilities are:\n");
>> +seq_puts(s,
>> "=\n");
>> +seq_printf(s, "Can the host do 4 bit transfers :\t%s\n",
>> +   ((caps & MMC_CAP_4_BIT_DATA) ? "Yes" : "No"));
> Maybe use a more compact form, and just call a macro with the applicable 
> (stringified) bit?

Something like this ?

#define YN(bit) ((caps & bit) ? "Yes" : "No")
and then call
seq_printf(s, "Can the host do 4 bit transfers :\t%s\n", 
YN(MMC_CAP_4_BIT_DATA));



Thanks,
Harish Jenny K N


RE: [PATCH v6] mmc: Export host capabilities to debugfs.

2018-03-06 Thread Avri Altman


> -Original Message-
> From: Harish Jenny K N [mailto:harish_kand...@mentor.com]
> Sent: Wednesday, March 07, 2018 7:38 AM
> To: ulf.hans...@linaro.org; linus.wall...@linaro.org;
> adrian.hun...@intel.com; shawn@rock-chips.com; Avri Altman
> <avri.alt...@wdc.com>; andriy.shevche...@linux.intel.com
> Cc: linux-...@vger.kernel.org; linux-kernel@vger.kernel.org;
> harish_kand...@mentor.com; vladimir_zapols...@mentor.com
> Subject: [PATCH v6] mmc: Export host capabilities to debugfs.
> 
> This patch exports the host capabilities to debugfs
> 
> This idea of sharing host capabilities over debugfs came up from Abbas Raza
> <abbas_r...@mentor.com> Earlier discussions:
> https://lkml.org/lkml/2018/3/5/357
> https://www.spinics.net/lists/linux-mmc/msg48219.html
> 
> Signed-off-by: Harish Jenny K N <harish_kand...@mentor.com>
> ---
> 
> 
> +static int mmc_caps_show(struct seq_file *s, void *unused) {
> + struct mmc_host *host = s->private;
> + u32 caps = host->caps;
> +
> + seq_puts(s, "\nMMC Host capabilities are:\n");
> + seq_puts(s,
> "=\n");
> + seq_printf(s, "Can the host do 4 bit transfers :\t%s\n",
> +((caps & MMC_CAP_4_BIT_DATA) ? "Yes" : "No"));

Maybe use a more compact form, and just call a macro with the applicable 
(stringified) bit?


Thanks,
Avri


RE: [PATCH v6] mmc: Export host capabilities to debugfs.

2018-03-06 Thread Avri Altman


> -Original Message-
> From: Harish Jenny K N [mailto:harish_kand...@mentor.com]
> Sent: Wednesday, March 07, 2018 7:38 AM
> To: ulf.hans...@linaro.org; linus.wall...@linaro.org;
> adrian.hun...@intel.com; shawn@rock-chips.com; Avri Altman
> ; andriy.shevche...@linux.intel.com
> Cc: linux-...@vger.kernel.org; linux-kernel@vger.kernel.org;
> harish_kand...@mentor.com; vladimir_zapols...@mentor.com
> Subject: [PATCH v6] mmc: Export host capabilities to debugfs.
> 
> This patch exports the host capabilities to debugfs
> 
> This idea of sharing host capabilities over debugfs came up from Abbas Raza
>  Earlier discussions:
> https://lkml.org/lkml/2018/3/5/357
> https://www.spinics.net/lists/linux-mmc/msg48219.html
> 
> Signed-off-by: Harish Jenny K N 
> ---
> 
> 
> +static int mmc_caps_show(struct seq_file *s, void *unused) {
> + struct mmc_host *host = s->private;
> + u32 caps = host->caps;
> +
> + seq_puts(s, "\nMMC Host capabilities are:\n");
> + seq_puts(s,
> "=\n");
> + seq_printf(s, "Can the host do 4 bit transfers :\t%s\n",
> +((caps & MMC_CAP_4_BIT_DATA) ? "Yes" : "No"));

Maybe use a more compact form, and just call a macro with the applicable 
(stringified) bit?


Thanks,
Avri


[PATCH v6] mmc: Export host capabilities to debugfs.

2018-03-06 Thread Harish Jenny K N
This patch exports the host capabilities to debugfs

This idea of sharing host capabilities over debugfs
came up from Abbas Raza 
Earlier discussions:
https://lkml.org/lkml/2018/3/5/357
https://www.spinics.net/lists/linux-mmc/msg48219.html

Signed-off-by: Harish Jenny K N 
---

Changes in v6:
- Used DEFINE_SHOW_ATTRIBUTE

Changes in v5:
- Added parser logic in kernel by using debugfs_create_file  for caps and caps2 
instead of debugfs_create_x32
- Changed Author

Changes in v4:
- Moved the creation of nodes to mmc_add_host_debugfs
- Exported caps2
- Renamed host_caps to caps

Changes in v3:
- Removed typecasting of >caps to (u32 *)

Changes in v2:
- Changed Author

 drivers/mmc/core/debugfs.c | 120 +
 1 file changed, 120 insertions(+)

diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
index c51e0c0..136bdf7 100644
--- a/drivers/mmc/core/debugfs.c
+++ b/drivers/mmc/core/debugfs.c
@@ -225,6 +225,120 @@ static int mmc_clock_opt_set(void *data, u64 val)
 DEFINE_SIMPLE_ATTRIBUTE(mmc_clock_fops, mmc_clock_opt_get, mmc_clock_opt_set,
"%llu\n");

+static int mmc_caps_show(struct seq_file *s, void *unused)
+{
+   struct mmc_host *host = s->private;
+   u32 caps = host->caps;
+
+   seq_puts(s, "\nMMC Host capabilities are:\n");
+   seq_puts(s, "=\n");
+   seq_printf(s, "Can the host do 4 bit transfers :\t%s\n",
+  ((caps & MMC_CAP_4_BIT_DATA) ? "Yes" : "No"));
+   seq_printf(s, "Can do MMC high-speed timing :\t%s\n",
+  ((caps & MMC_CAP_MMC_HIGHSPEED) ? "Yes" : "No"));
+   seq_printf(s, "Can do SD high-speed timing :\t%s\n",
+  ((caps & MMC_CAP_SD_HIGHSPEED) ? "Yes" : "No"));
+   seq_printf(s, "Can signal pending SDIO IRQs :\t%s\n",
+  ((caps & MMC_CAP_SDIO_IRQ) ? "Yes" : "No"));
+   seq_printf(s, "Talks only SPI protocols :\t%s\n",
+  ((caps & MMC_CAP_SPI) ? "Yes" : "No"));
+   seq_printf(s, "Needs polling for card-detection :\t%s\n",
+  ((caps & MMC_CAP_NEEDS_POLL) ? "Yes" : "No"));
+   seq_printf(s, "Can the host do 8 bit transfers :\t%s\n",
+  ((caps & MMC_CAP_8_BIT_DATA) ? "Yes" : "No"));
+   seq_printf(s, "Suspend (e)MMC/SD at idle :\t%s\n",
+  ((caps & MMC_CAP_AGGRESSIVE_PM) ? "Yes" : "No"));
+   seq_printf(s, "Nonremovable e.g. eMMC :\t%s\n",
+  ((caps & MMC_CAP_NONREMOVABLE) ? "Yes" : "No"));
+   seq_printf(s, "Waits while card is busy :\t%s\n",
+  ((caps & MMC_CAP_WAIT_WHILE_BUSY) ? "Yes" : "No"));
+   seq_printf(s, "Allow erase/trim commands :\t%s\n",
+  ((caps & MMC_CAP_ERASE) ? "Yes" : "No"));
+   seq_printf(s, "Can support DDR mode at 3.3V :\t%s\n",
+  ((caps & MMC_CAP_3_3V_DDR) ? "Yes" : "No"));
+   seq_printf(s, "Can support DDR mode at 1.8V :\t%s\n",
+  ((caps & MMC_CAP_1_8V_DDR) ? "Yes" : "No"));
+   seq_printf(s, "Can support DDR mode at 1.2V :\t%s\n",
+  ((caps & MMC_CAP_1_2V_DDR) ? "Yes" : "No"));
+   seq_printf(s, "Can power off after boot :\t%s\n",
+  ((caps & MMC_CAP_POWER_OFF_CARD) ? "Yes" : "No"));
+   seq_printf(s, "CMD14/CMD19 bus width ok :\t%s\n",
+  ((caps & MMC_CAP_BUS_WIDTH_TEST) ? "Yes" : "No"));
+   seq_printf(s, "Host supports UHS SDR12 mode :\t%s\n",
+  ((caps & MMC_CAP_UHS_SDR12) ? "Yes" : "No"));
+   seq_printf(s, "Host supports UHS SDR25 mode :\t%s\n",
+  ((caps & MMC_CAP_UHS_SDR25) ? "Yes" : "No"));
+   seq_printf(s, "Host supports UHS SDR50 mode :\t%s\n",
+  ((caps & MMC_CAP_UHS_SDR50) ? "Yes" : "No"));
+   seq_printf(s, "Host supports UHS SDR104 mode :\t%s\n",
+  ((caps & MMC_CAP_UHS_SDR104) ? "Yes" : "No"));
+   seq_printf(s, "Host supports UHS DDR50 mode :\t%s\n",
+  ((caps & MMC_CAP_UHS_DDR50) ? "Yes" : "No"));
+   seq_printf(s, "Host supports Driver Type A :\t%s\n",
+  ((caps & MMC_CAP_DRIVER_TYPE_A) ? "Yes" : "No"));
+   seq_printf(s, "Host supports Driver Type C :\t%s\n",
+  ((caps & MMC_CAP_DRIVER_TYPE_C) ? "Yes" : "No"));
+   seq_printf(s, "Host supports Driver Type D :\t%s\n",
+  ((caps & MMC_CAP_DRIVER_TYPE_D) ? "Yes" : "No"));
+   seq_printf(s, "RW reqs can be completed within mmc_request_done() 
:\t%s\n",
+  ((caps & MMC_CAP_DONE_COMPLETE) ? "Yes" : "No"));
+   seq_printf(s, "Enable card detect wake :\t%s\n",
+  ((caps & MMC_CAP_CD_WAKE) ? "Yes" : "No"));
+   seq_printf(s, "Commands during data transfer :\t%s\n",
+  ((caps & MMC_CAP_CMD_DURING_TFR) ? "Yes" : "No"));
+   seq_printf(s, "CMD23 supported. :\t%s\n",
+  ((caps & 

[PATCH v6] mmc: Export host capabilities to debugfs.

2018-03-06 Thread Harish Jenny K N
This patch exports the host capabilities to debugfs

This idea of sharing host capabilities over debugfs
came up from Abbas Raza 
Earlier discussions:
https://lkml.org/lkml/2018/3/5/357
https://www.spinics.net/lists/linux-mmc/msg48219.html

Signed-off-by: Harish Jenny K N 
---

Changes in v6:
- Used DEFINE_SHOW_ATTRIBUTE

Changes in v5:
- Added parser logic in kernel by using debugfs_create_file  for caps and caps2 
instead of debugfs_create_x32
- Changed Author

Changes in v4:
- Moved the creation of nodes to mmc_add_host_debugfs
- Exported caps2
- Renamed host_caps to caps

Changes in v3:
- Removed typecasting of >caps to (u32 *)

Changes in v2:
- Changed Author

 drivers/mmc/core/debugfs.c | 120 +
 1 file changed, 120 insertions(+)

diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
index c51e0c0..136bdf7 100644
--- a/drivers/mmc/core/debugfs.c
+++ b/drivers/mmc/core/debugfs.c
@@ -225,6 +225,120 @@ static int mmc_clock_opt_set(void *data, u64 val)
 DEFINE_SIMPLE_ATTRIBUTE(mmc_clock_fops, mmc_clock_opt_get, mmc_clock_opt_set,
"%llu\n");

+static int mmc_caps_show(struct seq_file *s, void *unused)
+{
+   struct mmc_host *host = s->private;
+   u32 caps = host->caps;
+
+   seq_puts(s, "\nMMC Host capabilities are:\n");
+   seq_puts(s, "=\n");
+   seq_printf(s, "Can the host do 4 bit transfers :\t%s\n",
+  ((caps & MMC_CAP_4_BIT_DATA) ? "Yes" : "No"));
+   seq_printf(s, "Can do MMC high-speed timing :\t%s\n",
+  ((caps & MMC_CAP_MMC_HIGHSPEED) ? "Yes" : "No"));
+   seq_printf(s, "Can do SD high-speed timing :\t%s\n",
+  ((caps & MMC_CAP_SD_HIGHSPEED) ? "Yes" : "No"));
+   seq_printf(s, "Can signal pending SDIO IRQs :\t%s\n",
+  ((caps & MMC_CAP_SDIO_IRQ) ? "Yes" : "No"));
+   seq_printf(s, "Talks only SPI protocols :\t%s\n",
+  ((caps & MMC_CAP_SPI) ? "Yes" : "No"));
+   seq_printf(s, "Needs polling for card-detection :\t%s\n",
+  ((caps & MMC_CAP_NEEDS_POLL) ? "Yes" : "No"));
+   seq_printf(s, "Can the host do 8 bit transfers :\t%s\n",
+  ((caps & MMC_CAP_8_BIT_DATA) ? "Yes" : "No"));
+   seq_printf(s, "Suspend (e)MMC/SD at idle :\t%s\n",
+  ((caps & MMC_CAP_AGGRESSIVE_PM) ? "Yes" : "No"));
+   seq_printf(s, "Nonremovable e.g. eMMC :\t%s\n",
+  ((caps & MMC_CAP_NONREMOVABLE) ? "Yes" : "No"));
+   seq_printf(s, "Waits while card is busy :\t%s\n",
+  ((caps & MMC_CAP_WAIT_WHILE_BUSY) ? "Yes" : "No"));
+   seq_printf(s, "Allow erase/trim commands :\t%s\n",
+  ((caps & MMC_CAP_ERASE) ? "Yes" : "No"));
+   seq_printf(s, "Can support DDR mode at 3.3V :\t%s\n",
+  ((caps & MMC_CAP_3_3V_DDR) ? "Yes" : "No"));
+   seq_printf(s, "Can support DDR mode at 1.8V :\t%s\n",
+  ((caps & MMC_CAP_1_8V_DDR) ? "Yes" : "No"));
+   seq_printf(s, "Can support DDR mode at 1.2V :\t%s\n",
+  ((caps & MMC_CAP_1_2V_DDR) ? "Yes" : "No"));
+   seq_printf(s, "Can power off after boot :\t%s\n",
+  ((caps & MMC_CAP_POWER_OFF_CARD) ? "Yes" : "No"));
+   seq_printf(s, "CMD14/CMD19 bus width ok :\t%s\n",
+  ((caps & MMC_CAP_BUS_WIDTH_TEST) ? "Yes" : "No"));
+   seq_printf(s, "Host supports UHS SDR12 mode :\t%s\n",
+  ((caps & MMC_CAP_UHS_SDR12) ? "Yes" : "No"));
+   seq_printf(s, "Host supports UHS SDR25 mode :\t%s\n",
+  ((caps & MMC_CAP_UHS_SDR25) ? "Yes" : "No"));
+   seq_printf(s, "Host supports UHS SDR50 mode :\t%s\n",
+  ((caps & MMC_CAP_UHS_SDR50) ? "Yes" : "No"));
+   seq_printf(s, "Host supports UHS SDR104 mode :\t%s\n",
+  ((caps & MMC_CAP_UHS_SDR104) ? "Yes" : "No"));
+   seq_printf(s, "Host supports UHS DDR50 mode :\t%s\n",
+  ((caps & MMC_CAP_UHS_DDR50) ? "Yes" : "No"));
+   seq_printf(s, "Host supports Driver Type A :\t%s\n",
+  ((caps & MMC_CAP_DRIVER_TYPE_A) ? "Yes" : "No"));
+   seq_printf(s, "Host supports Driver Type C :\t%s\n",
+  ((caps & MMC_CAP_DRIVER_TYPE_C) ? "Yes" : "No"));
+   seq_printf(s, "Host supports Driver Type D :\t%s\n",
+  ((caps & MMC_CAP_DRIVER_TYPE_D) ? "Yes" : "No"));
+   seq_printf(s, "RW reqs can be completed within mmc_request_done() 
:\t%s\n",
+  ((caps & MMC_CAP_DONE_COMPLETE) ? "Yes" : "No"));
+   seq_printf(s, "Enable card detect wake :\t%s\n",
+  ((caps & MMC_CAP_CD_WAKE) ? "Yes" : "No"));
+   seq_printf(s, "Commands during data transfer :\t%s\n",
+  ((caps & MMC_CAP_CMD_DURING_TFR) ? "Yes" : "No"));
+   seq_printf(s, "CMD23 supported. :\t%s\n",
+  ((caps & MMC_CAP_CMD23) ? "Yes" : "No"));
+   seq_printf(s,