From mboxrd@z Thu Jan 1 00:00:00 1970 From: Simon Glass Date: Mon, 12 Jun 2017 17:51:10 -0600 Subject: [U-Boot] [PATCH v5 02/11] reset: add reset_count() In-Reply-To: <01df1d10-b535-2eb1-f797-68823e626df5@st.com> References: <1496316982-16572-1-git-send-email-patrice.chotard@st.com> <1496316982-16572-3-git-send-email-patrice.chotard@st.com> <1cd7dc96-ae81-f6fe-3833-c8719c6c258c@st.com> <01df1d10-b535-2eb1-f797-68823e626df5@st.com> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Patrice, On 12 June 2017 at 01:51, Patrice CHOTARD wrote: > > > On 06/12/2017 09:27 AM, Patrice CHOTARD wrote: >> Hi Simon >> >> On 06/06/2017 11:08 PM, Simon Glass wrote: >>> Hi, >>> >>> On 5 June 2017 at 05:18, Marek Vasut wrote: >>>> On 06/05/2017 11:34 AM, Patrice CHOTARD wrote: >>>>> Hi Marek >>>>> >>>>> On 06/03/2017 08:02 AM, Marek Vasut wrote: >>>>>> On 06/01/2017 01:36 PM, patrice.chotard at st.com wrote: >>>>>>> From: Patrice Chotard >>>>>>> >>>>>>> Add reset_count() method to be able to get the number >>>>>>> of resets contained into a resets property. This will allow >>>>>>> to allocate the right amount of memory in order to keep resets >>>>>>> reference. These resets reference can be used later on error path >>>>>>> or in .remove callback to release these resets. >>>>>>> >>>>>>> Signed-off-by: Patrice Chotard >>>>>>> --- >>>>>>> v5: _ replace fdtdec_parse_phandle_with_args() by dev_read_phandle_with_args() >>>>>>> v4: _ add reset_count() method >>>>>>> >>>>>>> drivers/reset/reset-uclass.c | 13 +++++++++++++ >>>>>>> include/reset.h | 11 +++++++++++ >>>>>>> 2 files changed, 24 insertions(+) >>>>>>> >>>>>>> diff --git a/drivers/reset/reset-uclass.c b/drivers/reset/reset-uclass.c >>>>>>> index 4fd82b9..4b17d4c 100644 >>>>>>> --- a/drivers/reset/reset-uclass.c >>>>>>> +++ b/drivers/reset/reset-uclass.c >>>>>>> @@ -97,6 +97,19 @@ int reset_get_by_name(struct udevice *dev, const char *name, >>>>>>> return reset_get_by_index(dev, index, reset_ctl); >>>>>>> } >>>>>>> >>>>>>> +int reset_count(struct udevice *dev) >>>>>>> +{ >>>>>>> + int count; >>>>>>> + struct ofnode_phandle_args args; >>>>>>> + >>>>>>> + for (count = 0; ; count++) { >>>>>>> + if (dev_read_phandle_with_args(dev, >>>>>>> + "resets", "#reset-cells", 0, >>>>>>> + count, &args)) >>>>>> >>>>>> Don't we have some generic thing in libfdt to count number of phandle >>>>>> args ? This looks weird to me ... >>>>> >>>>> I didn't find anything in libfdt doing that. >>>> >>>> Maybe someone else can hop in, I'm quite sure there should be something >>>> like that. >>> >>> In linux there is of_count_phandle_with_args(). Now that we have >>> livetree we could copy that function over. Then for flat tree we could >>> use fdtdec_parse_phandle_with_args() passing a -ve index. >>> >>> Then we need something like dev_read_phandle_count(). >>> >>> Patrice what do you think? >> >> Agree with that. >> Ping me when this will be available, then i will update and resubmit my >> series. > > Or do you prefer me to do this ? just tell me ? Please go ahead, thanks. Regards, Simon