From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Jonas Rebmann <jre@pengutronix.de>,
Sascha Hauer <s.hauer@pengutronix.de>,
BAREBOX <barebox@lists.infradead.org>
Subject: Re: [PATCH] tlv: Add tlv_bind_serial mapping
Date: Fri, 14 Nov 2025 14:50:54 +0100 [thread overview]
Message-ID: <430aa916-86e8-42b3-a272-d870be5b2e67@pengutronix.de> (raw)
In-Reply-To: <a706647c-82ed-4923-a6dd-6e0d3818d11c@pengutronix.de>
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 |
prev parent reply other threads:[~2025-11-14 13:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-12 16:43 Jonas Rebmann
2025-11-13 9:11 ` Ahmad Fatoum
2025-11-14 10:24 ` Jonas Rebmann
2025-11-14 13:50 ` Ahmad Fatoum [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=430aa916-86e8-42b3-a272-d870be5b2e67@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=jre@pengutronix.de \
--cc=s.hauer@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox