All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrice CHOTARD <patrice.chotard@st.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 04/11] clk: add clk_count()
Date: Thu, 1 Jun 2017 07:56:54 +0000	[thread overview]
Message-ID: <38dde972-06c6-6d6c-8de3-cd8b8e668a92@st.com> (raw)
In-Reply-To: <CAPnjgZ3L3UUC_sOGqrBBhbgk4ECbAc2pKkRSkDFkQAq0pdzU4Q@mail.gmail.com>

Hi Simon

On 06/01/2017 05:10 AM, Simon Glass wrote:
> Hi Patrice,
> 
> On 24 May 2017 at 07:01,  <patrice.chotard@st.com> wrote:
>> From: Patrice Chotard <patrice.chotard@st.com>
>>
>> Add clk_count() method to be able to get the number
>> of clocks contained into a clock property. This will allow
>> to allocate the right amount of memory in order to keep clock
>> reference. These clock reference can be used later on error path
>> or in .remove callback to release these clocks.
>>
>> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
>> ---
>>
>> v4:     _ add clk_count() method
>>
>>   drivers/clk/clk-uclass.c | 12 ++++++++++++
>>   include/clk.h            | 12 ++++++++++++
>>   2 files changed, 24 insertions(+)
>>
>> diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
>> index 6fcfd69..5c4dd19 100644
>> --- a/drivers/clk/clk-uclass.c
>> +++ b/drivers/clk/clk-uclass.c
>> @@ -96,8 +96,20 @@ int clk_get_by_index(struct udevice *dev, int index, struct clk *clk)
>>
>>          return clk_request(dev_clk, clk);
>>   }
>> +
>>   # endif /* OF_PLATDATA */
>>
>> +int clk_count(struct udevice *dev)
>> +{
>> +       int count;
>> +       struct clk clk;
>> +
>> +       for (count = 0; ; count++) {
>> +               if (clk_get_by_index(dev, count, &clk))
>> +                       return count;
>> +       }
>> +}
>> +
>>   int clk_get_by_name(struct udevice *dev, const char *name, struct clk *clk)
>>   {
>>          int index;
>> diff --git a/include/clk.h b/include/clk.h
>> index 5a5c2ff..801920c 100644
>> --- a/include/clk.h
>> +++ b/include/clk.h
>> @@ -98,6 +98,18 @@ int clk_get_by_index(struct udevice *dev, int index, struct clk *clk);
>>    * @return 0 if OK, or a negative error code.
>>    */
>>   int clk_get_by_name(struct udevice *dev, const char *name, struct clk *clk);
>> +
>> +/**
>> + * clk_count - Get clock count contained in the "clocks" property.
>> + *
>> + * This returns the count of clock found into the "clocks" property. This
>> + * allows to allocate the right amount of memory to keep clock reference.
> 
> Can you document here that it 'gets' each clock and the clocks should
> be freed? Or do you prefer to free the clocks within the function.

It don't 'gets' each clock, it just returns the number of "clocks" 
declared into the clocks property

Patrice

> 
>> + *
>> + * @dev:       The client device.
>> + * @return number of clocks found.
>> + */
>> +int clk_count(struct udevice *dev);
>> +
>>   #else
>>   static inline int clk_get_by_index(struct udevice *dev, int index,
>>                                     struct clk *clk)
>> --
>> 1.9.1
>>
> 
> Regards,
> Simon
> 

  reply	other threads:[~2017-06-01  7:56 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-24 13:01 [U-Boot] [PATCH v4 00/11] usb: Extend ehci and ohci generic drivers patrice.chotard at st.com
2017-05-24 13:01 ` [U-Boot] [PATCH v4 01/11] reset: add reset_request() patrice.chotard at st.com
2017-05-24 13:01 ` [U-Boot] [PATCH v4 02/11] reset: add reset_count() patrice.chotard at st.com
2017-06-01  3:10   ` Simon Glass
2017-06-01  7:49     ` Patrice CHOTARD
2017-05-24 13:01 ` [U-Boot] [PATCH v4 03/11] reset: add reset_assert_all() patrice.chotard at st.com
2017-06-01  3:10   ` Simon Glass
2017-05-24 13:01 ` [U-Boot] [PATCH v4 04/11] clk: add clk_count() patrice.chotard at st.com
2017-06-01  3:10   ` Simon Glass
2017-06-01  7:56     ` Patrice CHOTARD [this message]
2017-06-05  8:59       ` Patrice CHOTARD
2017-05-24 13:01 ` [U-Boot] [PATCH v4 05/11] clk: add clk_disable_all() patrice.chotard at st.com
2017-05-24 13:01 ` [U-Boot] [PATCH v4 06/11] usb: host: ehci-generic: replace printf() by error() patrice.chotard at st.com
2017-05-24 13:01 ` [U-Boot] [PATCH v4 07/11] usb: host: ehci-generic: add error path and .remove callback patrice.chotard at st.com
2017-06-01  3:10   ` Simon Glass
2017-05-24 13:01 ` [U-Boot] [PATCH v4 08/11] usb: host: ehci-generic: add generic PHY support patrice.chotard at st.com
2017-06-01  3:10   ` Simon Glass
2017-05-24 13:01 ` [U-Boot] [PATCH v4 09/11] usb: host: ohci-generic: add CLOCK support patrice.chotard at st.com
2017-06-01  3:10   ` Simon Glass
2017-05-24 13:01 ` [U-Boot] [PATCH v4 10/11] usb: host: ohci-generic: add RESET support patrice.chotard at st.com
2017-06-01  3:11   ` Simon Glass
2017-05-24 13:01 ` [U-Boot] [PATCH v4 11/11] usb: host: ohci-generic: add generic PHY support patrice.chotard at st.com
2017-06-01  3:11   ` Simon Glass
2017-05-24 13:04 ` [U-Boot] [PATCH v4 00/11] usb: Extend ehci and ohci generic drivers Patrice CHOTARD
2017-05-24 13:07 patrice.chotard at st.com
2017-05-24 13:07 ` [U-Boot] [PATCH v4 04/11] clk: add clk_count() patrice.chotard at st.com

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=38dde972-06c6-6d6c-8de3-cd8b8e668a92@st.com \
    --to=patrice.chotard@st.com \
    --cc=u-boot@lists.denx.de \
    /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.