From: Tomeu Vizoso <tomeu.vizoso-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
To: Tomasz Figa <tomasz.figa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>,
Thierry Reding
<thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Mike Turquette
<mturquette-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
rabin-66gdRtMMWGc@public.gmane.org,
linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Cc: Rabin Vincent
<rabin.vincent-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org>,
Javier Martinez Canillas
<javier.martinez-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>
Subject: Re: [RFC v2 3/5] clk: use struct clk only for external API
Date: Thu, 10 Jul 2014 11:16:34 +0200 [thread overview]
Message-ID: <53BE59F2.1090102@collabora.com> (raw)
In-Reply-To: <53BDA21D.3070504-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
On 07/09/2014 10:12 PM, Tomasz Figa wrote:
> Actually few more comments, see inline.
>
> On 03.07.2014 16:38, Tomeu Vizoso wrote:
>> From: Rabin Vincent <rabin.vincent-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org>
>>
>> In order to provide per-user accounting, this separates the struct clk
>> used in the common clock framework into two structures 'struct clk_core'
>> and 'struct clk'. struct clk_core will be used for internal
>> manipulation and struct clk will be used in the clock API
>> implementation.
>
> [snip]
>
>> diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c
>> index 8f57154..5f2aba9 100644
>> --- a/drivers/clk/clk-devres.c
>> +++ b/drivers/clk/clk-devres.c
>> @@ -5,6 +5,7 @@
>> */
>>
>> #include <linux/clk.h>
>> +#include <linux/clk-provider.h>
>> #include <linux/device.h>
>> #include <linux/export.h>
>> #include <linux/gfp.h>
>> @@ -14,15 +15,15 @@ static void devm_clk_release(struct device *dev, void *res)
>> clk_put(*(struct clk **)res);
>
> This function still expects to get a (struct clk *) here, but...
>
>> }
>>
>> -struct clk *devm_clk_get(struct device *dev, const char *id)
>> +struct clk_core *devm_clk_provider_get(struct device *dev, const char *id)
>> {
>> - struct clk **ptr, *clk;
>> + struct clk_core **ptr, *clk;
>>
>> ptr = devres_alloc(devm_clk_release, sizeof(*ptr), GFP_KERNEL);
>> if (!ptr)
>> return ERR_PTR(-ENOMEM);
>>
>> - clk = clk_get(dev, id);
>> + clk = clk_provider_get(dev, id);
>> if (!IS_ERR(clk)) {
>> *ptr = clk;
>
> ...here a (struct clk_core *) is stored.
Thanks, well spotted.
>> devres_add(dev, ptr);
>
> [snip]
>
>> diff --git a/drivers/clk/clk.h b/drivers/clk/clk.h
>> index d278572..c69f4fe 100644
>> --- a/drivers/clk/clk.h
>> +++ b/drivers/clk/clk.h
>> @@ -15,3 +15,7 @@ struct clk_core *__of_clk_get_from_provider(struct of_phandle_args *clkspec);
>> void of_clk_lock(void);
>> void of_clk_unlock(void);
>> #endif
>> +
>> +#if defined(CONFIG_COMMON_CLK)
>> +#define clk_to_clk_core(clk) (clk->core)
>
> Making this a static inline will benefit you with type checking at
> compilation time.
Good point.
>> +#endif
>
> [snip]
>
>> +
>> +#define clk_core_to_clk(core) ((struct clk *)(core))
>
> Hmm, I'm not following. clk_to_clk_core() returns clk->core, while
> clk_core_to_clk() simply casts whatever the former returns into a
> pointer to struct clk?
Yeah, this is totally wrong, v3 will be fixing this, I have tested it on
an Odroid U2, so the most embarrassing issues have been fixed.
Thanks,
Tomeu
> Also this should be a static inline to benefit from compiler type checking.
>
> Best regards,
> Tomasz
>
WARNING: multiple messages have this Message-ID (diff)
From: tomeu.vizoso@collabora.com (Tomeu Vizoso)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC v2 3/5] clk: use struct clk only for external API
Date: Thu, 10 Jul 2014 11:16:34 +0200 [thread overview]
Message-ID: <53BE59F2.1090102@collabora.com> (raw)
In-Reply-To: <53BDA21D.3070504@gmail.com>
On 07/09/2014 10:12 PM, Tomasz Figa wrote:
> Actually few more comments, see inline.
>
> On 03.07.2014 16:38, Tomeu Vizoso wrote:
>> From: Rabin Vincent <rabin.vincent@stericsson.com>
>>
>> In order to provide per-user accounting, this separates the struct clk
>> used in the common clock framework into two structures 'struct clk_core'
>> and 'struct clk'. struct clk_core will be used for internal
>> manipulation and struct clk will be used in the clock API
>> implementation.
>
> [snip]
>
>> diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c
>> index 8f57154..5f2aba9 100644
>> --- a/drivers/clk/clk-devres.c
>> +++ b/drivers/clk/clk-devres.c
>> @@ -5,6 +5,7 @@
>> */
>>
>> #include <linux/clk.h>
>> +#include <linux/clk-provider.h>
>> #include <linux/device.h>
>> #include <linux/export.h>
>> #include <linux/gfp.h>
>> @@ -14,15 +15,15 @@ static void devm_clk_release(struct device *dev, void *res)
>> clk_put(*(struct clk **)res);
>
> This function still expects to get a (struct clk *) here, but...
>
>> }
>>
>> -struct clk *devm_clk_get(struct device *dev, const char *id)
>> +struct clk_core *devm_clk_provider_get(struct device *dev, const char *id)
>> {
>> - struct clk **ptr, *clk;
>> + struct clk_core **ptr, *clk;
>>
>> ptr = devres_alloc(devm_clk_release, sizeof(*ptr), GFP_KERNEL);
>> if (!ptr)
>> return ERR_PTR(-ENOMEM);
>>
>> - clk = clk_get(dev, id);
>> + clk = clk_provider_get(dev, id);
>> if (!IS_ERR(clk)) {
>> *ptr = clk;
>
> ...here a (struct clk_core *) is stored.
Thanks, well spotted.
>> devres_add(dev, ptr);
>
> [snip]
>
>> diff --git a/drivers/clk/clk.h b/drivers/clk/clk.h
>> index d278572..c69f4fe 100644
>> --- a/drivers/clk/clk.h
>> +++ b/drivers/clk/clk.h
>> @@ -15,3 +15,7 @@ struct clk_core *__of_clk_get_from_provider(struct of_phandle_args *clkspec);
>> void of_clk_lock(void);
>> void of_clk_unlock(void);
>> #endif
>> +
>> +#if defined(CONFIG_COMMON_CLK)
>> +#define clk_to_clk_core(clk) (clk->core)
>
> Making this a static inline will benefit you with type checking at
> compilation time.
Good point.
>> +#endif
>
> [snip]
>
>> +
>> +#define clk_core_to_clk(core) ((struct clk *)(core))
>
> Hmm, I'm not following. clk_to_clk_core() returns clk->core, while
> clk_core_to_clk() simply casts whatever the former returns into a
> pointer to struct clk?
Yeah, this is totally wrong, v3 will be fixing this, I have tested it on
an Odroid U2, so the most embarrassing issues have been fixed.
Thanks,
Tomeu
> Also this should be a static inline to benefit from compiler type checking.
>
> Best regards,
> Tomasz
>
WARNING: multiple messages have this Message-ID (diff)
From: Tomeu Vizoso <tomeu.vizoso@collabora.com>
To: Tomasz Figa <tomasz.figa@gmail.com>,
Stephen Warren <swarren@wwwdotorg.org>,
Thierry Reding <thierry.reding@gmail.com>,
Mike Turquette <mturquette@linaro.org>,
rabin@rab.in, linux-tegra@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Cc: Rabin Vincent <rabin.vincent@stericsson.com>,
Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Subject: Re: [RFC v2 3/5] clk: use struct clk only for external API
Date: Thu, 10 Jul 2014 11:16:34 +0200 [thread overview]
Message-ID: <53BE59F2.1090102@collabora.com> (raw)
In-Reply-To: <53BDA21D.3070504@gmail.com>
On 07/09/2014 10:12 PM, Tomasz Figa wrote:
> Actually few more comments, see inline.
>
> On 03.07.2014 16:38, Tomeu Vizoso wrote:
>> From: Rabin Vincent <rabin.vincent@stericsson.com>
>>
>> In order to provide per-user accounting, this separates the struct clk
>> used in the common clock framework into two structures 'struct clk_core'
>> and 'struct clk'. struct clk_core will be used for internal
>> manipulation and struct clk will be used in the clock API
>> implementation.
>
> [snip]
>
>> diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c
>> index 8f57154..5f2aba9 100644
>> --- a/drivers/clk/clk-devres.c
>> +++ b/drivers/clk/clk-devres.c
>> @@ -5,6 +5,7 @@
>> */
>>
>> #include <linux/clk.h>
>> +#include <linux/clk-provider.h>
>> #include <linux/device.h>
>> #include <linux/export.h>
>> #include <linux/gfp.h>
>> @@ -14,15 +15,15 @@ static void devm_clk_release(struct device *dev, void *res)
>> clk_put(*(struct clk **)res);
>
> This function still expects to get a (struct clk *) here, but...
>
>> }
>>
>> -struct clk *devm_clk_get(struct device *dev, const char *id)
>> +struct clk_core *devm_clk_provider_get(struct device *dev, const char *id)
>> {
>> - struct clk **ptr, *clk;
>> + struct clk_core **ptr, *clk;
>>
>> ptr = devres_alloc(devm_clk_release, sizeof(*ptr), GFP_KERNEL);
>> if (!ptr)
>> return ERR_PTR(-ENOMEM);
>>
>> - clk = clk_get(dev, id);
>> + clk = clk_provider_get(dev, id);
>> if (!IS_ERR(clk)) {
>> *ptr = clk;
>
> ...here a (struct clk_core *) is stored.
Thanks, well spotted.
>> devres_add(dev, ptr);
>
> [snip]
>
>> diff --git a/drivers/clk/clk.h b/drivers/clk/clk.h
>> index d278572..c69f4fe 100644
>> --- a/drivers/clk/clk.h
>> +++ b/drivers/clk/clk.h
>> @@ -15,3 +15,7 @@ struct clk_core *__of_clk_get_from_provider(struct of_phandle_args *clkspec);
>> void of_clk_lock(void);
>> void of_clk_unlock(void);
>> #endif
>> +
>> +#if defined(CONFIG_COMMON_CLK)
>> +#define clk_to_clk_core(clk) (clk->core)
>
> Making this a static inline will benefit you with type checking at
> compilation time.
Good point.
>> +#endif
>
> [snip]
>
>> +
>> +#define clk_core_to_clk(core) ((struct clk *)(core))
>
> Hmm, I'm not following. clk_to_clk_core() returns clk->core, while
> clk_core_to_clk() simply casts whatever the former returns into a
> pointer to struct clk?
Yeah, this is totally wrong, v3 will be fixing this, I have tested it on
an Odroid U2, so the most embarrassing issues have been fixed.
Thanks,
Tomeu
> Also this should be a static inline to benefit from compiler type checking.
>
> Best regards,
> Tomasz
>
next prev parent reply other threads:[~2014-07-10 9:16 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-03 14:38 [RFC v2 0/5] Per-user clock constraints Tomeu Vizoso
2014-07-03 14:38 ` Tomeu Vizoso
2014-07-03 14:38 ` Tomeu Vizoso
2014-07-03 14:38 ` [RFC v2 1/5] clk: Add temporary mapping to the existing API Tomeu Vizoso
2014-07-03 14:38 ` Tomeu Vizoso
2014-07-03 14:38 ` [RFC v2 2/5] clk: Move all drivers to use internal API Tomeu Vizoso
2014-07-03 14:38 ` [RFC v2 3/5] clk: use struct clk only for external API Tomeu Vizoso
2014-07-03 14:38 ` Tomeu Vizoso
[not found] ` <1404398323-18934-4-git-send-email-tomeu.vizoso-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
2014-07-09 19:27 ` Tomasz Figa
2014-07-09 19:27 ` Tomasz Figa
2014-07-09 19:27 ` Tomasz Figa
[not found] ` <53BD97A0.2090909-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-07-10 9:13 ` Tomeu Vizoso
2014-07-10 9:13 ` Tomeu Vizoso
2014-07-10 9:13 ` Tomeu Vizoso
2014-07-09 20:12 ` Tomasz Figa
2014-07-09 20:12 ` Tomasz Figa
2014-07-09 20:12 ` Tomasz Figa
[not found] ` <53BDA21D.3070504-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-07-10 9:16 ` Tomeu Vizoso [this message]
2014-07-10 9:16 ` Tomeu Vizoso
2014-07-10 9:16 ` Tomeu Vizoso
2014-07-03 14:38 ` [RFC v2 4/5] clk: per-user clock accounting for debug Tomeu Vizoso
2014-07-03 14:38 ` Tomeu Vizoso
[not found] ` <1404398323-18934-5-git-send-email-tomeu.vizoso-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
2014-07-09 20:01 ` Tomasz Figa
2014-07-09 20:01 ` Tomasz Figa
2014-07-09 20:01 ` Tomasz Figa
[not found] ` <53BD9FA3.1040204-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-07-10 10:51 ` Tomeu Vizoso
2014-07-10 10:51 ` Tomeu Vizoso
2014-07-10 10:51 ` Tomeu Vizoso
2014-07-03 14:38 ` [RFC v2 5/5] clk: Add floor and ceiling constraints to clock rates Tomeu Vizoso
2014-07-03 14:38 ` Tomeu Vizoso
[not found] ` <1404398323-18934-1-git-send-email-tomeu.vizoso-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
2014-07-09 20:16 ` [RFC v2 0/5] Per-user clock constraints Tomasz Figa
2014-07-09 20:16 ` Tomasz Figa
2014-07-09 20:16 ` Tomasz Figa
[not found] ` <53BDA31D.40502-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-07-10 8:00 ` Tomeu Vizoso
2014-07-10 8:00 ` Tomeu Vizoso
2014-07-10 8:00 ` Tomeu Vizoso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53BE59F2.1090102@collabora.com \
--to=tomeu.vizoso-zgy8ohtn/8qb+jhodadfcq@public.gmane.org \
--cc=javier.martinez-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mturquette-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=rabin-66gdRtMMWGc@public.gmane.org \
--cc=rabin.vincent-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org \
--cc=swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org \
--cc=thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=tomasz.figa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.