* [PATCH] mmc: sdhi: fill in actual_clock
@ 2019-08-28 18:55 Tamás Szűcs
2019-08-29 7:47 ` Geert Uytterhoeven
0 siblings, 1 reply; 4+ messages in thread
From: Tamás Szűcs @ 2019-08-28 18:55 UTC (permalink / raw)
To: Wolfram Sang, Ulf Hansson, linux-mmc, linux-kernel
Cc: linux-renesas-soc, Tamás Szűcs
Save set clock in mmc_host actual_clock enabling exporting it via debugfs.
This will indicate the precise SD clock in I/O settings rather than only the
sometimes misleading requested clock.
Signed-off-by: Tamás Szűcs <tszucs@protonmail.ch>
---
drivers/mmc/host/renesas_sdhi_core.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
index 64d3b5fb7fe5..ae842d0b59f9 100644
--- a/drivers/mmc/host/renesas_sdhi_core.c
+++ b/drivers/mmc/host/renesas_sdhi_core.c
@@ -124,7 +124,7 @@ static unsigned int renesas_sdhi_clk_update(struct tmio_mmc_host *host,
{
struct renesas_sdhi *priv = host_to_priv(host);
unsigned int freq, diff, best_freq = 0, diff_min = ~0;
- int i, ret;
+ int i;
/* tested only on R-Car Gen2+ currently; may work for others */
if (!(host->pdata->flags & TMIO_MMC_MIN_RCAR2))
@@ -153,9 +153,11 @@ static unsigned int renesas_sdhi_clk_update(struct tmio_mmc_host *host,
}
}
- ret = clk_set_rate(priv->clk, best_freq);
+ host->mmc->actual_clock =
+ clk_set_rate(priv->clk, best_freq) == 0 ?
+ best_freq : clk_get_rate(priv->clk);
- return ret == 0 ? best_freq : clk_get_rate(priv->clk);
+ return host->mmc->actual_clock;
}
static void renesas_sdhi_set_clock(struct tmio_mmc_host *host,
--
2.11.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mmc: sdhi: fill in actual_clock
2019-08-28 18:55 [PATCH] mmc: sdhi: fill in actual_clock Tamás Szűcs
@ 2019-08-29 7:47 ` Geert Uytterhoeven
2019-08-29 15:59 ` Tamás Szűcs
0 siblings, 1 reply; 4+ messages in thread
From: Geert Uytterhoeven @ 2019-08-29 7:47 UTC (permalink / raw)
To: Tamás Szűcs
Cc: Wolfram Sang, Ulf Hansson, Linux MMC List,
Linux Kernel Mailing List, Linux-Renesas
Hi Tamás,
On Wed, Aug 28, 2019 at 9:02 PM Tamás Szűcs <tszucs@protonmail.ch> wrote:
> Save set clock in mmc_host actual_clock enabling exporting it via debugfs.
> This will indicate the precise SD clock in I/O settings rather than only the
> sometimes misleading requested clock.
>
> Signed-off-by: Tamás Szűcs <tszucs@protonmail.ch>
Thanks for your patch!
> --- a/drivers/mmc/host/renesas_sdhi_core.c
> +++ b/drivers/mmc/host/renesas_sdhi_core.c
> @@ -124,7 +124,7 @@ static unsigned int renesas_sdhi_clk_update(struct tmio_mmc_host *host,
> {
> struct renesas_sdhi *priv = host_to_priv(host);
> unsigned int freq, diff, best_freq = 0, diff_min = ~0;
> - int i, ret;
> + int i;
>
> /* tested only on R-Car Gen2+ currently; may work for others */
> if (!(host->pdata->flags & TMIO_MMC_MIN_RCAR2))
> @@ -153,9 +153,11 @@ static unsigned int renesas_sdhi_clk_update(struct tmio_mmc_host *host,
> }
> }
>
> - ret = clk_set_rate(priv->clk, best_freq);
> + host->mmc->actual_clock =
> + clk_set_rate(priv->clk, best_freq) == 0 ?
> + best_freq : clk_get_rate(priv->clk);
When clk_set_rate() returns 0 to indicate success, it may still have
rounded the requested clock rate, no?
So wouldn't it be better to always call clk_get_rate()?
>
> - return ret == 0 ? best_freq : clk_get_rate(priv->clk);
> + return host->mmc->actual_clock;
> }
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mmc: sdhi: fill in actual_clock
2019-08-29 7:47 ` Geert Uytterhoeven
@ 2019-08-29 15:59 ` Tamás Szűcs
2019-08-29 17:34 ` Wolfram Sang
0 siblings, 1 reply; 4+ messages in thread
From: Tamás Szűcs @ 2019-08-29 15:59 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Wolfram Sang, Ulf Hansson, Linux MMC List,
Linux Kernel Mailing List, Linux-Renesas
Hi Geert,
It would be possible to call clk_get_rate() unconditionally but there's usually no need, thus the ternary. Are you in favor of that though?
It turns out I need to send a followup to fix some glitches. Please stay tuned.
Kind regards,
Tamas
Tamás Szűcs
tszucs@protonmail.ch
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Thursday, August 29, 2019 9:47 AM, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> Hi Tamás,
>
> On Wed, Aug 28, 2019 at 9:02 PM Tamás Szűcs tszucs@protonmail.ch wrote:
>
> > Save set clock in mmc_host actual_clock enabling exporting it via debugfs.
> > This will indicate the precise SD clock in I/O settings rather than only the
> > sometimes misleading requested clock.
> > Signed-off-by: Tamás Szűcs tszucs@protonmail.ch
>
> Thanks for your patch!
>
> > --- a/drivers/mmc/host/renesas_sdhi_core.c
> > +++ b/drivers/mmc/host/renesas_sdhi_core.c
> > @@ -124,7 +124,7 @@ static unsigned int renesas_sdhi_clk_update(struct tmio_mmc_host *host,
> > {
> > struct renesas_sdhi *priv = host_to_priv(host);
> > unsigned int freq, diff, best_freq = 0, diff_min = ~0;
> >
> > - int i, ret;
> >
> >
> >
> > - int i;
> >
> > /* tested only on R-Car Gen2+ currently; may work for others */
> > if (!(host->pdata->flags & TMIO_MMC_MIN_RCAR2))
> >
> >
> >
> > @@ -153,9 +153,11 @@ static unsigned int renesas_sdhi_clk_update(struct tmio_mmc_host *host,
> > }
> > }
> >
> > - ret = clk_set_rate(priv->clk, best_freq);
> >
> >
> >
> > - host->mmc->actual_clock =
> >
> >
> > - clk_set_rate(priv->clk, best_freq) == 0 ?
> >
> >
> > - best_freq : clk_get_rate(priv->clk);
> >
> >
>
> When clk_set_rate() returns 0 to indicate success, it may still have
> rounded the requested clock rate, no?
> So wouldn't it be better to always call clk_get_rate()?
>
> > - return ret == 0 ? best_freq : clk_get_rate(priv->clk);
> >
> >
> >
> > - return host->mmc->actual_clock;
> >
> >
> >
> > }
>
> Gr{oetje,eeting}s,
>
> Geert
>
> ----------------------------
>
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> -- Linus Torvalds
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mmc: sdhi: fill in actual_clock
2019-08-29 15:59 ` Tamás Szűcs
@ 2019-08-29 17:34 ` Wolfram Sang
0 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2019-08-29 17:34 UTC (permalink / raw)
To: Tamás Szűcs
Cc: Geert Uytterhoeven, Wolfram Sang, Ulf Hansson, Linux MMC List,
Linux Kernel Mailing List, Linux-Renesas
[-- Attachment #1: Type: text/plain, Size: 283 bytes --]
> It would be possible to call clk_get_rate() unconditionally but
> there's usually no need, thus the ternary. Are you in favor of that
> though?
I like Geert's suggestion. Even if it is "usually" not needed, I think
it is better to be always proper. This is not a hot code path.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-08-29 17:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-28 18:55 [PATCH] mmc: sdhi: fill in actual_clock Tamás Szűcs
2019-08-29 7:47 ` Geert Uytterhoeven
2019-08-29 15:59 ` Tamás Szűcs
2019-08-29 17:34 ` Wolfram Sang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).