From: Jaehoon Chung Date: Fri, 28 Jul 2017 21:59:32 +0900 Subject: [U-Boot] [U-Boot, v2, 1/3] dm: core: Add functions to get strings and the string count from a stringlist In-Reply-To: <1500472344-29876-2-git-send-email-jjhiblot@ti.com> References: <1500472344-29876-2-git-send-email-jjhiblot@ti.com> Message-ID: <462d4b71-71c4-9f66-c373-dd10fdb496fd@samsung.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 07/19/2017 10:52 PM, Jean-Jacques Hiblot wrote: > dev_read_string_count() is used to get the number of strings in a > stringlist. > dev_read_string_index() is used to get a string in the stringlist based on > its position in the list. > > Signed-off-by: Jean-Jacques Hiblot Applied to u-boot-mmc. Thanks! Best Regards, Jaehoon Chung > --- > > not present in the v1 of this series > > drivers/core/read.c | 11 +++++++++++ > include/dm/read.h | 36 ++++++++++++++++++++++++++++++++++++ > 2 files changed, 47 insertions(+) > > diff --git a/drivers/core/read.c b/drivers/core/read.c > index eafe727..cb4c45e 100644 > --- a/drivers/core/read.c > +++ b/drivers/core/read.c > @@ -74,6 +74,17 @@ int dev_read_stringlist_search(struct udevice *dev, const char *property, > return ofnode_stringlist_search(dev_ofnode(dev), property, string); > } > > +int dev_read_string_index(struct udevice *dev, const char *propname, int index, > + const char **outp) > +{ > + return ofnode_read_string_index(dev_ofnode(dev), propname, index, outp); > +} > + > +int dev_read_string_count(struct udevice *dev, const char *propname) > +{ > + return ofnode_read_string_count(dev_ofnode(dev), propname); > +} > + > int dev_read_phandle_with_args(struct udevice *dev, const char *list_name, > const char *cells_name, int cell_count, > int index, > diff --git a/include/dm/read.h b/include/dm/read.h > index b86a2f5..4ef99cb 100644 > --- a/include/dm/read.h > +++ b/include/dm/read.h > @@ -166,6 +166,29 @@ int dev_read_stringlist_search(struct udevice *dev, const char *property, > const char *string); > > /** > + * dev_read_string_index() - obtain an indexed string from a string list > + * > + * @dev: device to examine > + * @propname: name of the property containing the string list > + * @index: index of the string to return > + * @out: return location for the string > + * > + * @return: > + * length of string, if found or -ve error value if not found > + */ > +int dev_read_string_index(struct udevice *dev, const char *propname, int index, > + const char **outp); > + > +/** > + * dev_read_string_count() - find the number of strings in a string list > + * > + * @dev: device to examine > + * @propname: name of the property containing the string list > + * @return: > + * number of strings in the list, or -ve error value if not found > + */ > +int dev_read_string_count(struct udevice *dev, const char *propname); > +/** > * dev_read_phandle_with_args() - Find a node pointed by phandle in a list > * > * This function is useful to parse lists of phandles and their arguments. > @@ -407,6 +430,19 @@ static inline int dev_read_stringlist_search(struct udevice *dev, > return ofnode_stringlist_search(dev_ofnode(dev), propname, string); > } > > +static inline int dev_read_string_index(struct udevice *dev, > + const char *propname, int index, > + const char **outp) > +{ > + return ofnode_read_string_index(dev_ofnode(dev), propname, index, outp); > +} > + > +static inline int dev_read_string_count(struct udevice *dev, > + const char *propname) > +{ > + return ofnode_read_string_count(dev_ofnode(dev), propname); > +} > + > static inline int dev_read_phandle_with_args(struct udevice *dev, > const char *list_name, const char *cells_name, int cell_count, > int index, struct ofnode_phandle_args *out_args) >