On 12/5/23 19:18, Andy Shevchenko wrote:
> On Tue, Dec 05, 2023 at 06:12:18PM +0200, Ceclan Dumitru wrote:
>> On 12/5/23 17:28, Andy Shevchenko wrote:
>>>> + ref_label =
>>>> + ad7173_ref_sel_str[AD7173_SETUP_REF_SEL_INT_REF];
>>>> +
>>>> + fwnode_property_read_string(child, "adi,reference-select",
>>>> + &ref_label);
>>>> + ref_sel = match_string(ad7173_ref_sel_str,
>>>> + ARRAY_SIZE(ad7173_ref_sel_str), ref_label);
>>>> + if (ref_sel < 0) {
>>> Can we use fwnode_property_match_property_string()?
>>
>> fwnode_property_match_string() searches a given string in a
>> device-tree string array and returns the index. I do not think that
>> this function fits here as the DT attribute is a single string.
>
> I'm not talking about that. I mentioned different API call.
>
> /**
> * fwnode_property_match_property_string - find a property string value in an array and return index
> * @fwnode: Firmware node to get the property of
> * @propname: Name of the property holding the string value
> * @array: String array to search in
> * @n: Size of the @array
> *
> * Find a property string value in a given @array and if it is found return
> * the index back.
> *
> * Return: index, starting from %0, if the string value was found in the @array (success),
> * %-ENOENT when the string value was not found in the @array,
> * %-EINVAL if given arguments are not valid,
> * %-ENODATA if the property does not have a value,
> * %-EPROTO or %-EILSEQ if the property is not a string,
> * %-ENXIO if no suitable firmware interface is present.
> */
>
> --
> With Best Regards,
> Andy Shevchenko
>
>
Yep, it can be used. I cannot seem to find it upstream but found the
thread, when the patch containing that function will be applied I'll
change to that.