All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Szyprowski <m.szyprowski@samsung.com>
To: Robin Murphy <robin.murphy@arm.com>,
	Maciej Purski <m.purski@samsung.com>,
	linux-media@vger.kernel.org, linux-samsung-soc@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	linux-clk@vger.kernel.org
Cc: David Airlie <airlied@linux.ie>,
	Michael Turquette <mturquette@baylibre.com>,
	Kamil Debski <kamil@wypas.org>,
	Andrzej Hajda <a.hajda@samsung.com>,
	Sylwester Nawrocki <s.nawrocki@samsung.com>,
	Thibault Saunier <thibault.saunier@osg.samsung.com>,
	Joonyoung Shim <jy0922.shim@samsung.com>,
	Russell King <linux@armlinux.org.uk>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	Javier Martinez Canillas <javier@osg.samsung.com>,
	Kukjin Kim <kgene@kernel.org>,
	Hoegeun Kwon <hoegeun.kwon@samsung.com>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	Inki Dae <inki.dae@samsung.com>,
	Jeongtae Park <jtp.park@samsung.com>,
	Jacek Anaszewski <jacek.anaszewski@gmail.com>,
	Andrzej Pietrasiewicz <andrzej.p@samsung.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Stephen Boyd <sboyd@kernel.org>,
	Seung-Woo Kim <sw0312.kim@samsung.com>,
	Hans Verkuil <hansverk@cisco.com>,
	Kyungmin Park <kyungmin.park@samsung.com>
Subject: Re: [PATCH 1/8] clk: Add clk_bulk_alloc functions
Date: Tue, 20 Feb 2018 10:36:03 +0100	[thread overview]
Message-ID: <f13fb12b-54e6-104b-4ec0-192d1bb72cc8@samsung.com> (raw)
In-Reply-To: <b67b5043-f5e5-826a-f0b8-f7cf722c61e6@arm.com>

Hi Robin,

On 2018-02-19 17:29, Robin Murphy wrote:
> Hi Maciej,
>
> On 19/02/18 15:43, Maciej Purski wrote:
>> When a driver is going to use clk_bulk_get() function, it has to
>> initialize an array of clk_bulk_data, by filling its id fields.
>>
>> Add a new function to the core, which dynamically allocates
>> clk_bulk_data array and fills its id fields. Add clk_bulk_free()
>> function, which frees the array allocated by clk_bulk_alloc() function.
>> Add a managed version of clk_bulk_alloc().
>
> Seeing how every subsequent patch ends up with the roughly this same 
> stanza:
>
>     x = devm_clk_bulk_alloc(dev, num, names);
>     if (IS_ERR(x)
>         return PTR_ERR(x);
>     ret = devm_clk_bulk_get(dev, x, num);
>
> I wonder if it might be better to simply implement:
>
>     int devm_clk_bulk_alloc_get(dev, &x, num, names)
>
> that does the whole lot in one go, and let drivers that want to do 
> more fiddly things continue to open-code the allocation.
>
> But perhaps that's an abstraction too far... I'm not all that familiar 
> with the lie of the land here.

Hmmm. This patchset clearly shows, that it would be much simpler if we
get rid of clk_bulk_data structure at all and let clk_bulk_* functions
to operate on struct clk *array[]. Typically the list of clock names
is already in some kind of array (taken from driver data or statically
embedded into driver), so there is little benefit from duplicating it
in clk_bulk_data. Sadly, I missed clk_bulk_* api discussion and maybe
there are other benefits from this approach.

If not, I suggest simplifying clk_bulk_* api by dropping clk_bulk_data
structure and switching to clock ptr array:

int clk_bulk_get(struct device *dev, int num_clock, struct clk *clocks[],
                  const char *clk_names[]);
int clk_bulk_prepare(int num_clks, struct clk *clks[]);
int clk_bulk_enable(int num_clks, struct clk *clks[]);
...



>
>> Signed-off-by: Maciej Purski <m.purski@samsung.com>
>> ---
>>   drivers/clk/clk-bulk.c   | 16 ++++++++++++
>>   drivers/clk/clk-devres.c | 37 +++++++++++++++++++++++++---
>>   include/linux/clk.h      | 64 
>> ++++++++++++++++++++++++++++++++++++++++++++++++
>>   3 files changed, 113 insertions(+), 4 deletions(-)
>>
>
> [...]
>> @@ -598,6 +645,23 @@ struct clk *clk_get_sys(const char *dev_id, 
>> const char *con_id);
>>     #else /* !CONFIG_HAVE_CLK */
>>   +static inline struct clk_bulk_data *clk_bulk_alloc(int num_clks,
>> +                           const char **clk_ids)
>> +{
>> +    return NULL;
>
> Either way, is it intentional not returning an ERR_PTR() value in this 
> case? Since NULL will pass an IS_ERR() check, it seems a bit fragile 
> for an allocation call to apparently succeed when the whole API is 
> configured out (and I believe introducing new uses of IS_ERR_OR_NULL() 
> is in general strongly discouraged.)
>
> Robin.
>
>> +}
>> +
>> +static inline struct clk_bulk_data *devm_clk_bulk_alloc(struct 
>> device *dev,
>> +                            int num_clks,
>> +                            const char **clk_ids)
>> +{
>> +    return NULL;
>> +}
>> +
>> +static inline void clk_bulk_free(struct clk_bulk_data *clks)
>> +{
>> +}
>> +
>>   static inline struct clk *clk_get(struct device *dev, const char *id)
>>   {
>>       return NULL;
>
Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland

WARNING: multiple messages have this Message-ID (diff)
From: Marek Szyprowski <m.szyprowski@samsung.com>
To: Robin Murphy <robin.murphy@arm.com>,
	Maciej Purski <m.purski@samsung.com>,
	linux-media@vger.kernel.org, linux-samsung-soc@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	linux-clk@vger.kernel.org
Cc: David Airlie <airlied@linux.ie>,
	Michael Turquette <mturquette@baylibre.com>,
	Kamil Debski <kamil@wypas.org>,
	Sylwester Nawrocki <s.nawrocki@samsung.com>,
	Thibault Saunier <thibault.saunier@osg.samsung.com>,
	Russell King <linux@armlinux.org.uk>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	Javier Martinez Canillas <javier@osg.samsung.com>,
	Kukjin Kim <kgene@kernel.org>,
	Hoegeun Kwon <hoegeun.kwon@samsung.com>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	Jeongtae Park <jtp.park@samsung.com>,
	Jacek Anaszewski <jacek.anaszewski@gmail.com>,
	Andrzej Pietrasiewicz <andrzej.p@samsung.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Stephen Boyd <sboyd@kernel.org>,
	Seung-Woo Kim <sw0312.kim@samsung.com>,
	Hans Verkuil <hansverk@cisco.com>,
	Kyungmin Park <kyungmin.park@samsung.com>
Subject: Re: [PATCH 1/8] clk: Add clk_bulk_alloc functions
Date: Tue, 20 Feb 2018 10:36:03 +0100	[thread overview]
Message-ID: <f13fb12b-54e6-104b-4ec0-192d1bb72cc8@samsung.com> (raw)
In-Reply-To: <b67b5043-f5e5-826a-f0b8-f7cf722c61e6@arm.com>

Hi Robin,

On 2018-02-19 17:29, Robin Murphy wrote:
> Hi Maciej,
>
> On 19/02/18 15:43, Maciej Purski wrote:
>> When a driver is going to use clk_bulk_get() function, it has to
>> initialize an array of clk_bulk_data, by filling its id fields.
>>
>> Add a new function to the core, which dynamically allocates
>> clk_bulk_data array and fills its id fields. Add clk_bulk_free()
>> function, which frees the array allocated by clk_bulk_alloc() function.
>> Add a managed version of clk_bulk_alloc().
>
> Seeing how every subsequent patch ends up with the roughly this same 
> stanza:
>
>     x = devm_clk_bulk_alloc(dev, num, names);
>     if (IS_ERR(x)
>         return PTR_ERR(x);
>     ret = devm_clk_bulk_get(dev, x, num);
>
> I wonder if it might be better to simply implement:
>
>     int devm_clk_bulk_alloc_get(dev, &x, num, names)
>
> that does the whole lot in one go, and let drivers that want to do 
> more fiddly things continue to open-code the allocation.
>
> But perhaps that's an abstraction too far... I'm not all that familiar 
> with the lie of the land here.

Hmmm. This patchset clearly shows, that it would be much simpler if we
get rid of clk_bulk_data structure at all and let clk_bulk_* functions
to operate on struct clk *array[]. Typically the list of clock names
is already in some kind of array (taken from driver data or statically
embedded into driver), so there is little benefit from duplicating it
in clk_bulk_data. Sadly, I missed clk_bulk_* api discussion and maybe
there are other benefits from this approach.

If not, I suggest simplifying clk_bulk_* api by dropping clk_bulk_data
structure and switching to clock ptr array:

int clk_bulk_get(struct device *dev, int num_clock, struct clk *clocks[],
                  const char *clk_names[]);
int clk_bulk_prepare(int num_clks, struct clk *clks[]);
int clk_bulk_enable(int num_clks, struct clk *clks[]);
...



>
>> Signed-off-by: Maciej Purski <m.purski@samsung.com>
>> ---
>>   drivers/clk/clk-bulk.c   | 16 ++++++++++++
>>   drivers/clk/clk-devres.c | 37 +++++++++++++++++++++++++---
>>   include/linux/clk.h      | 64 
>> ++++++++++++++++++++++++++++++++++++++++++++++++
>>   3 files changed, 113 insertions(+), 4 deletions(-)
>>
>
> [...]
>> @@ -598,6 +645,23 @@ struct clk *clk_get_sys(const char *dev_id, 
>> const char *con_id);
>>     #else /* !CONFIG_HAVE_CLK */
>>   +static inline struct clk_bulk_data *clk_bulk_alloc(int num_clks,
>> +                           const char **clk_ids)
>> +{
>> +    return NULL;
>
> Either way, is it intentional not returning an ERR_PTR() value in this 
> case? Since NULL will pass an IS_ERR() check, it seems a bit fragile 
> for an allocation call to apparently succeed when the whole API is 
> configured out (and I believe introducing new uses of IS_ERR_OR_NULL() 
> is in general strongly discouraged.)
>
> Robin.
>
>> +}
>> +
>> +static inline struct clk_bulk_data *devm_clk_bulk_alloc(struct 
>> device *dev,
>> +                            int num_clks,
>> +                            const char **clk_ids)
>> +{
>> +    return NULL;
>> +}
>> +
>> +static inline void clk_bulk_free(struct clk_bulk_data *clks)
>> +{
>> +}
>> +
>>   static inline struct clk *clk_get(struct device *dev, const char *id)
>>   {
>>       return NULL;
>
Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

WARNING: multiple messages have this Message-ID (diff)
From: m.szyprowski@samsung.com (Marek Szyprowski)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/8] clk: Add clk_bulk_alloc functions
Date: Tue, 20 Feb 2018 10:36:03 +0100	[thread overview]
Message-ID: <f13fb12b-54e6-104b-4ec0-192d1bb72cc8@samsung.com> (raw)
In-Reply-To: <b67b5043-f5e5-826a-f0b8-f7cf722c61e6@arm.com>

Hi Robin,

On 2018-02-19 17:29, Robin Murphy wrote:
> Hi Maciej,
>
> On 19/02/18 15:43, Maciej Purski wrote:
>> When a driver is going to use clk_bulk_get() function, it has to
>> initialize an array of clk_bulk_data, by filling its id fields.
>>
>> Add a new function to the core, which dynamically allocates
>> clk_bulk_data array and fills its id fields. Add clk_bulk_free()
>> function, which frees the array allocated by clk_bulk_alloc() function.
>> Add a managed version of clk_bulk_alloc().
>
> Seeing how every subsequent patch ends up with the roughly this same 
> stanza:
>
> ????x = devm_clk_bulk_alloc(dev, num, names);
> ????if (IS_ERR(x)
> ??????? return PTR_ERR(x);
> ????ret = devm_clk_bulk_get(dev, x, num);
>
> I wonder if it might be better to simply implement:
>
> ????int devm_clk_bulk_alloc_get(dev, &x, num, names)
>
> that does the whole lot in one go, and let drivers that want to do 
> more fiddly things continue to open-code the allocation.
>
> But perhaps that's an abstraction too far... I'm not all that familiar 
> with the lie of the land here.

Hmmm. This patchset clearly shows, that it would be much simpler if we
get rid of clk_bulk_data structure at all and let clk_bulk_* functions
to operate on struct clk *array[]. Typically the list of clock names
is already in some kind of array (taken from driver data or statically
embedded into driver), so there is little benefit from duplicating it
in clk_bulk_data. Sadly, I missed clk_bulk_* api discussion and maybe
there are other benefits from this approach.

If not, I suggest simplifying clk_bulk_* api by dropping clk_bulk_data
structure and switching to clock ptr array:

int clk_bulk_get(struct device *dev, int num_clock, struct clk *clocks[],
 ??? ??? ??? ???? const char *clk_names[]);
int clk_bulk_prepare(int num_clks, struct clk *clks[]);
int clk_bulk_enable(int num_clks, struct clk *clks[]);
...



>
>> Signed-off-by: Maciej Purski <m.purski@samsung.com>
>> ---
>> ? drivers/clk/clk-bulk.c?? | 16 ++++++++++++
>> ? drivers/clk/clk-devres.c | 37 +++++++++++++++++++++++++---
>> ? include/linux/clk.h????? | 64 
>> ++++++++++++++++++++++++++++++++++++++++++++++++
>> ? 3 files changed, 113 insertions(+), 4 deletions(-)
>>
>
> [...]
>> @@ -598,6 +645,23 @@ struct clk *clk_get_sys(const char *dev_id, 
>> const char *con_id);
>> ? ? #else /* !CONFIG_HAVE_CLK */
>> ? +static inline struct clk_bulk_data *clk_bulk_alloc(int num_clks,
>> +?????????????????????????? const char **clk_ids)
>> +{
>> +??? return NULL;
>
> Either way, is it intentional not returning an ERR_PTR() value in this 
> case? Since NULL will pass an IS_ERR() check, it seems a bit fragile 
> for an allocation call to apparently succeed when the whole API is 
> configured out (and I believe introducing new uses of IS_ERR_OR_NULL() 
> is in general strongly discouraged.)
>
> Robin.
>
>> +}
>> +
>> +static inline struct clk_bulk_data *devm_clk_bulk_alloc(struct 
>> device *dev,
>> +??????????????????????????? int num_clks,
>> +??????????????????????????? const char **clk_ids)
>> +{
>> +??? return NULL;
>> +}
>> +
>> +static inline void clk_bulk_free(struct clk_bulk_data *clks)
>> +{
>> +}
>> +
>> ? static inline struct clk *clk_get(struct device *dev, const char *id)
>> ? {
>> ????? return NULL;
>
Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland

  reply	other threads:[~2018-02-20  9:36 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20180219154456eucas1p178a82b3bb643028dc7c99ccca9c6eaca@eucas1p1.samsung.com>
2018-02-19 15:43 ` [PATCH 0/8] Use clk bulk API in exynos5433 drivers Maciej Purski
2018-02-19 15:43   ` Maciej Purski
2018-02-19 15:43   ` Maciej Purski
     [not found]   ` <CGME20180219154456eucas1p15f4073beaf61312238f142f217a8bb3c@eucas1p1.samsung.com>
2018-02-19 15:43     ` [PATCH 1/8] clk: Add clk_bulk_alloc functions Maciej Purski
2018-02-19 15:43       ` Maciej Purski
2018-02-19 15:43       ` Maciej Purski
2018-02-19 16:29       ` Robin Murphy
2018-02-19 16:29         ` Robin Murphy
2018-02-19 16:29         ` Robin Murphy
2018-02-20  9:36         ` Marek Szyprowski [this message]
2018-02-20  9:36           ` Marek Szyprowski
2018-02-20  9:36           ` Marek Szyprowski
2018-02-20 14:19           ` Robin Murphy
2018-02-20 14:19             ` Robin Murphy
2018-02-20 14:19             ` Robin Murphy
2018-03-15 22:55           ` Stephen Boyd
2018-03-15 22:55             ` Stephen Boyd
2018-03-15 22:55             ` Stephen Boyd
2018-03-15 22:55             ` Stephen Boyd
2018-02-19 18:22       ` Emil Velikov
2018-02-19 18:22         ` Emil Velikov
2018-02-19 18:22         ` Emil Velikov
     [not found]   ` <CGME20180219154457eucas1p163264992903698a8878aa5abbc8aa17b@eucas1p1.samsung.com>
2018-02-19 15:44     ` [PATCH 2/8] media: s5p-jpeg: Use bulk clk API Maciej Purski
2018-02-19 15:44       ` Maciej Purski
2018-02-19 15:44       ` Maciej Purski
2018-02-20  0:22       ` kbuild test robot
2018-02-20  0:22         ` kbuild test robot
2018-02-20  0:22         ` kbuild test robot
     [not found]   ` <CGME20180219154458eucas1p1b4e728757e78f3d5dde5c9aa565a5d20@eucas1p1.samsung.com>
2018-02-19 15:44     ` [PATCH 3/8] drm/exynos/decon: Use clk bulk API Maciej Purski
2018-02-19 15:44       ` Maciej Purski
2018-02-19 15:44       ` Maciej Purski
     [not found]   ` <CGME20180219154459eucas1p147525b88de5d34f646aa25cb8de1f1d0@eucas1p1.samsung.com>
2018-02-19 15:44     ` [PATCH 4/8] drm/exynos/dsi: " Maciej Purski
2018-02-19 15:44       ` Maciej Purski
2018-02-19 15:44       ` Maciej Purski
2018-02-20  1:39       ` kbuild test robot
2018-02-20  1:39         ` kbuild test robot
2018-02-20  1:39         ` kbuild test robot
     [not found]   ` <CGME20180219154500eucas1p25e9f3bf44901cb2bbe9720cdc5bdd855@eucas1p2.samsung.com>
2018-02-19 15:44     ` [PATCH 5/8] drm/exynos: mic: " Maciej Purski
2018-02-19 15:44       ` Maciej Purski
2018-02-19 15:44       ` Maciej Purski
     [not found]   ` <CGME20180219154501eucas1p1e16a883d2eb0c8a99bafce5d71656066@eucas1p1.samsung.com>
2018-02-19 15:44     ` [PATCH 6/8] drm/exynos/hdmi: " Maciej Purski
2018-02-19 15:44       ` Maciej Purski
2018-02-19 15:44       ` Maciej Purski
     [not found]   ` <CGME20180219154502eucas1p20e8daf3edc6737817f8d62db5a2099f2@eucas1p2.samsung.com>
2018-02-19 15:44     ` [PATCH 7/8] [media] exynos-gsc: " Maciej Purski
2018-02-19 15:44       ` Maciej Purski
2018-02-19 15:44       ` Maciej Purski
2018-02-19 22:38       ` kbuild test robot
2018-02-19 22:38         ` kbuild test robot
2018-02-19 22:38         ` kbuild test robot
     [not found]   ` <CGME20180219154503eucas1p1c8893411994bd1152d0ce5b386118416@eucas1p1.samsung.com>
2018-02-19 15:44     ` [PATCH 8/8] [media] s5p-mfc: " Maciej Purski
2018-02-19 15:44       ` Maciej Purski
2018-02-19 15:44       ` Maciej Purski
2018-02-20  1:56       ` kbuild test robot
2018-02-20  1:56         ` kbuild test robot
2018-02-20  1:56         ` kbuild test robot

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=f13fb12b-54e6-104b-4ec0-192d1bb72cc8@samsung.com \
    --to=m.szyprowski@samsung.com \
    --cc=a.hajda@samsung.com \
    --cc=airlied@linux.ie \
    --cc=andrzej.p@samsung.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hansverk@cisco.com \
    --cc=hoegeun.kwon@samsung.com \
    --cc=inki.dae@samsung.com \
    --cc=jacek.anaszewski@gmail.com \
    --cc=javier@osg.samsung.com \
    --cc=jtp.park@samsung.com \
    --cc=jy0922.shim@samsung.com \
    --cc=kamil@wypas.org \
    --cc=kgene@kernel.org \
    --cc=krzk@kernel.org \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=m.purski@samsung.com \
    --cc=mchehab@kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=robin.murphy@arm.com \
    --cc=s.nawrocki@samsung.com \
    --cc=sboyd@kernel.org \
    --cc=sw0312.kim@samsung.com \
    --cc=thibault.saunier@osg.samsung.com \
    /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.