[PATCH 1/4] PBL: fdt: implement fdt_device_get_match_data

Ahmad Fatoum a.fatoum at pengutronix.de
Sun Apr 4 12:22:44 BST 2021


Hello Jules,

On 03.04.21 14:00, Jules Maselbas wrote:
>> +		for (id = ids; id->compatible; id++) {
>> +			if (strlen(id->compatible) == length &&
>> +			    !memcmp(list, id->compatible, length))
>> +				return id->data;
> Why not using strcmp, or even strcasecmp as done by of_compat_cmp ?
> If both string doesn't have the same length, strcmp will report a diff.

The code is based on fdt_stringlist_search. I assume it compared length
first, because it already computed it, so an early comparison
saves some cycles. Good point on case-insensitivity. I'll send out a v2.

Thanks,
Ahmad

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list