mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] clk: bail out early when rate is already desired one
@ 2021-06-07 14:12 Sascha Hauer
  2021-06-07 15:46 ` Ahmad Fatoum
  0 siblings, 1 reply; 3+ messages in thread
From: Sascha Hauer @ 2021-06-07 14:12 UTC (permalink / raw)
  To: Barebox List

Return successfully from clk_set_rate() when the rate is already the
desired one. This prevents a failure in clk_set_rate() when the current
clock doesn't have a set_rate hook.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/clk/clk.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 8b90f30486..ba726c342c 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -169,6 +169,9 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
 	if (IS_ERR(clk))
 		return PTR_ERR(clk);
 
+	if (clk_get_rate(clk) == clk_round_rate(clk, rate))
+		return 0;
+
 	if (!clk->ops->set_rate)
 		return -ENOSYS;
 
-- 
2.29.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


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

* Re: [PATCH] clk: bail out early when rate is already desired one
  2021-06-07 14:12 [PATCH] clk: bail out early when rate is already desired one Sascha Hauer
@ 2021-06-07 15:46 ` Ahmad Fatoum
  2021-06-16  8:29   ` Sascha Hauer
  0 siblings, 1 reply; 3+ messages in thread
From: Ahmad Fatoum @ 2021-06-07 15:46 UTC (permalink / raw)
  To: Sascha Hauer, Barebox List



On 07.06.21 16:12, Sascha Hauer wrote:
> Return successfully from clk_set_rate() when the rate is already the
> desired one. This prevents a failure in clk_set_rate() when the current
> clock doesn't have a set_rate hook.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  drivers/clk/clk.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index 8b90f30486..ba726c342c 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -169,6 +169,9 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
>  	if (IS_ERR(clk))
>  		return PTR_ERR(clk);
>  
> +	if (clk_get_rate(clk) == clk_round_rate(clk, rate))
> +		return 0;
> +
>  	if (!clk->ops->set_rate)
>  		return -ENOSYS;


This means we can drop 459bf1fd31da ("ARM: clk: rk3188: don't set same
clk rate twice"), right?


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


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

* Re: [PATCH] clk: bail out early when rate is already desired one
  2021-06-07 15:46 ` Ahmad Fatoum
@ 2021-06-16  8:29   ` Sascha Hauer
  0 siblings, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2021-06-16  8:29 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: Barebox List

On Mon, Jun 07, 2021 at 05:46:12PM +0200, Ahmad Fatoum wrote:
> 
> 
> On 07.06.21 16:12, Sascha Hauer wrote:
> > Return successfully from clk_set_rate() when the rate is already the
> > desired one. This prevents a failure in clk_set_rate() when the current
> > clock doesn't have a set_rate hook.
> > 
> > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > ---
> >  drivers/clk/clk.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> > index 8b90f30486..ba726c342c 100644
> > --- a/drivers/clk/clk.c
> > +++ b/drivers/clk/clk.c
> > @@ -169,6 +169,9 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
> >  	if (IS_ERR(clk))
> >  		return PTR_ERR(clk);
> >  
> > +	if (clk_get_rate(clk) == clk_round_rate(clk, rate))
> > +		return 0;
> > +
> >  	if (!clk->ops->set_rate)
> >  		return -ENOSYS;
> 
> 
> This means we can drop 459bf1fd31da ("ARM: clk: rk3188: don't set same
> clk rate twice"), right?

Indeed, yes. This part was lost with "clk: rockchip: Update to current
Linux" anyway, so nothing to do here.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


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

end of thread, other threads:[~2021-06-16  8:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-07 14:12 [PATCH] clk: bail out early when rate is already desired one Sascha Hauer
2021-06-07 15:46 ` Ahmad Fatoum
2021-06-16  8:29   ` Sascha Hauer

mail archive of the barebox mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://lore.barebox.org/barebox/0 barebox/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 barebox barebox/ https://lore.barebox.org/barebox \
		barebox@lists.infradead.org barebox@lists.infradead.org
	public-inbox-index barebox

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git