All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH v2] clk: fix clk_get_rate() always return ulong
@ 2022-08-29  9:11 Julien Masson
  2022-08-30  2:30 ` Simon Glass
  2022-09-28 17:30 ` Sean Anderson
  0 siblings, 2 replies; 4+ messages in thread
From: Julien Masson @ 2022-08-29  9:11 UTC (permalink / raw)
  To: u-boot; +Cc: Sean Anderson, Lukasz Majewski

According to clk_ops struct definition, the callback `get_rate()`
return current clock rate value as ulong.
`clk_get_rate()` should handle the clock rate returned as ulong also.

Otherwise we may have invalid/truncated clock rate value returned by
`clk_get_rate()`.

`log_ret` has also been removed since it use an `int` in the macro
definition.

Signed-off-by: Julien Masson <jmasson@baylibre.com>
---
 drivers/clk/clk-uclass.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index b89c77bf79..c351fa97d1 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -469,7 +469,7 @@ void clk_free(struct clk *clk)
 ulong clk_get_rate(struct clk *clk)
 {
 	const struct clk_ops *ops;
-	int ret;
+	ulong ret;
 
 	debug("%s(clk=%p)\n", __func__, clk);
 	if (!clk_valid(clk))
@@ -479,11 +479,7 @@ ulong clk_get_rate(struct clk *clk)
 	if (!ops->get_rate)
 		return -ENOSYS;
 
-	ret = ops->get_rate(clk);
-	if (ret)
-		return log_ret(ret);
-
-	return 0;
+	return ops->get_rate(clk);
 }
 
 struct clk *clk_get_parent(struct clk *clk)
-- 
2.37.2


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

* Re: [RFC PATCH v2] clk: fix clk_get_rate() always return ulong
  2022-08-29  9:11 [RFC PATCH v2] clk: fix clk_get_rate() always return ulong Julien Masson
@ 2022-08-30  2:30 ` Simon Glass
  2022-08-30  8:34   ` Julien Masson
  2022-09-28 17:30 ` Sean Anderson
  1 sibling, 1 reply; 4+ messages in thread
From: Simon Glass @ 2022-08-30  2:30 UTC (permalink / raw)
  To: Julien Masson; +Cc: U-Boot Mailing List, Sean Anderson, Lukasz Majewski

Hi Julien,

On Mon, 29 Aug 2022 at 06:06, Julien Masson <jmasson@baylibre.com> wrote:
>
> According to clk_ops struct definition, the callback `get_rate()`
> return current clock rate value as ulong.
> `clk_get_rate()` should handle the clock rate returned as ulong also.
>
> Otherwise we may have invalid/truncated clock rate value returned by
> `clk_get_rate()`.
>
> `log_ret` has also been removed since it use an `int` in the macro
> definition.
>
> Signed-off-by: Julien Masson <jmasson@baylibre.com>
> ---
>  drivers/clk/clk-uclass.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

I would prefer to create a new log_rete() to handle this, with a long
argument and return value. But this is OK, I suppose.

>
> diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
> index b89c77bf79..c351fa97d1 100644
> --- a/drivers/clk/clk-uclass.c
> +++ b/drivers/clk/clk-uclass.c
> @@ -469,7 +469,7 @@ void clk_free(struct clk *clk)
>  ulong clk_get_rate(struct clk *clk)
>  {
>         const struct clk_ops *ops;
> -       int ret;
> +       ulong ret;
>
>         debug("%s(clk=%p)\n", __func__, clk);
>         if (!clk_valid(clk))
> @@ -479,11 +479,7 @@ ulong clk_get_rate(struct clk *clk)
>         if (!ops->get_rate)
>                 return -ENOSYS;
>
> -       ret = ops->get_rate(clk);
> -       if (ret)
> -               return log_ret(ret);
> -
> -       return 0;
> +       return ops->get_rate(clk);
>  }
>
>  struct clk *clk_get_parent(struct clk *clk)
> --
> 2.37.2
>

Regards,
Simon

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

* Re: [RFC PATCH v2] clk: fix clk_get_rate() always return ulong
  2022-08-30  2:30 ` Simon Glass
@ 2022-08-30  8:34   ` Julien Masson
  0 siblings, 0 replies; 4+ messages in thread
From: Julien Masson @ 2022-08-30  8:34 UTC (permalink / raw)
  To: Simon Glass; +Cc: U-Boot Mailing List, Sean Anderson, Lukasz Majewski

Hi Simon,

On Tue 30 Aug 2022 at 10:32, Simon Glass <sjg@chromium.org> wrote:

> Hi Julien,
> 
> On Mon, 29 Aug 2022 at 06:06, Julien Masson <jmasson@baylibre.com> wrote:
>>
>> According to clk_ops struct definition, the callback `get_rate()`
>> return current clock rate value as ulong.
>> `clk_get_rate()` should handle the clock rate returned as ulong also.
>>
>> Otherwise we may have invalid/truncated clock rate value returned by
>> `clk_get_rate()`.
>>
>> `log_ret` has also been removed since it use an `int` in the macro
>> definition.
>>
>> Signed-off-by: Julien Masson <jmasson@baylibre.com>
>> ---
>> drivers/clk/clk-uclass.c | 8 ++------
>> 1 file changed, 2 insertions(+), 6 deletions(-)
> 
> Reviewed-by: Simon Glass <sjg@chromium.org>
Thanks for the review, I appreciate it.

> 
> I would prefer to create a new log_rete() to handle this, with a long
> argument and return value. But this is OK, I suppose.
Yes and I guess that could be used in other functions in clk-uclass.c

> 
>>
>> diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
>> index b89c77bf79..c351fa97d1 100644
>> --- a/drivers/clk/clk-uclass.c
>> +++ b/drivers/clk/clk-uclass.c
>> @@ -469,7 +469,7 @@ void clk_free(struct clk *clk)
>> ulong clk_get_rate(struct clk *clk)
>> {
>> const struct clk_ops *ops;
>> -       int ret;
>> +       ulong ret;
>>
>> debug("%s(clk=%p)\n", __func__, clk);
>> if (!clk_valid(clk))
>> @@ -479,11 +479,7 @@ ulong clk_get_rate(struct clk *clk)
>> if (!ops->get_rate)
>> return -ENOSYS;
>>
>> -       ret = ops->get_rate(clk);
>> -       if (ret)
>> -               return log_ret(ret);
>> -
>> -       return 0;
>> +       return ops->get_rate(clk);
>> }
>>
>> struct clk *clk_get_parent(struct clk *clk)
>> --
>> 2.37.2
>>
> 
> Regards,
> Simon

-- 
Julien Masson

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

* Re: [RFC PATCH v2] clk: fix clk_get_rate() always return ulong
  2022-08-29  9:11 [RFC PATCH v2] clk: fix clk_get_rate() always return ulong Julien Masson
  2022-08-30  2:30 ` Simon Glass
@ 2022-09-28 17:30 ` Sean Anderson
  1 sibling, 0 replies; 4+ messages in thread
From: Sean Anderson @ 2022-09-28 17:30 UTC (permalink / raw)
  To: Julien Masson, u-boot; +Cc: Lukasz Majewski

On 8/29/22 05:11, Julien Masson wrote:
> According to clk_ops struct definition, the callback `get_rate()`
> return current clock rate value as ulong.
> `clk_get_rate()` should handle the clock rate returned as ulong also.
> 
> Otherwise we may have invalid/truncated clock rate value returned by
> `clk_get_rate()`.
> 
> `log_ret` has also been removed since it use an `int` in the macro
> definition.
> 
> Signed-off-by: Julien Masson <jmasson@baylibre.com>
> ---
>   drivers/clk/clk-uclass.c | 8 ++------
>   1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
> index b89c77bf79..c351fa97d1 100644
> --- a/drivers/clk/clk-uclass.c
> +++ b/drivers/clk/clk-uclass.c
> @@ -469,7 +469,7 @@ void clk_free(struct clk *clk)
>   ulong clk_get_rate(struct clk *clk)
>   {
>   	const struct clk_ops *ops;
> -	int ret;
> +	ulong ret;
>   
>   	debug("%s(clk=%p)\n", __func__, clk);
>   	if (!clk_valid(clk))
> @@ -479,11 +479,7 @@ ulong clk_get_rate(struct clk *clk)
>   	if (!ops->get_rate)
>   		return -ENOSYS;
>   
> -	ret = ops->get_rate(clk);
> -	if (ret)
> -		return log_ret(ret);
> -
> -	return 0;
> +	return ops->get_rate(clk);
>   }
>   
>   struct clk *clk_get_parent(struct clk *clk)

Reviewed-by: Sean Anderson <seanga2@gmail.com>

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

end of thread, other threads:[~2022-09-28 17:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-29  9:11 [RFC PATCH v2] clk: fix clk_get_rate() always return ulong Julien Masson
2022-08-30  2:30 ` Simon Glass
2022-08-30  8:34   ` Julien Masson
2022-09-28 17:30 ` Sean Anderson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.