[PATCH] tlv: Add tlv_bind_serial mapping

Ahmad Fatoum a.fatoum at pengutronix.de
Fri Nov 14 05:50:54 PST 2025


Hi,

On 11/14/25 11:24 AM, Jonas Rebmann wrote:
> Hi Ahmad,
> 
> On 2025-11-13 10:11, Ahmad Fatoum wrote:
>>> +    struct bus_type *bus;
>>> +    struct device_d *socdev;
>>> +    const char *soc_serial;
>>> +    char *tlv_serial = basprintf("%.*s", len, val);
>>
>> strndup would also work here.
> 
> Since a such basprintf is used in __tlv_format_str() and
> tlv_format_blob(), I found it adequate to do it the same way.

No idea why I did it that way, but ye either works.

> 
>>> +
>>> +    bus = get_bus_by_name("soc");
>>> +    if (!bus) {
>>> +        pr_err("No 'soc' bus found\n");
>>
>> goto out and use a common error message? That way you also cover the
>> case of no socdev existing.
> 
> Ah indeed, will do that in v2.
> 
>>> +        return -EACCES;
>>> +    }
>>> +
>>> +    for_each_device(socdev) {
>>> +        soc_serial = dev_get_param(socdev, "serial_number");
>>> +        if (!soc_serial)
>>> +            continue;
>>> +
>>> +        if (streq_ptr(tlv_serial, soc_serial))
>>> +            return __tlv_format_str(dev, map, len, val) ? 0 : -ENOMEM;
>>
>>     return tlv_format_str(...) directly instead?
>>
>> I talked with Sascha yesterday and I believe he is implementing a common
>> get_soc_uid(). If so, that might be suitable for use here.
> 
> Sounds good! When I wrote this code, I was unsure whether multiple SoC
> UIDs or a soc1.serial_number are cases we ever want to care about. If
> not, I would habe only tested against the one/first serial_number here
> and then break the loop...
> 
> Will update to get_soc_uid() if that's posted before v2.

See Sascha's series on the mailing list.

Cheers,
Ahmad

> 
> Regards,
> Jonas
> 

-- 
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