Re: [PATCH v6] mmc: Export host capabilities to debugfs.
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.
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.
> -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