From: Jonas Rebmann <jre@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@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 11:24:37 +0100 [thread overview]
Message-ID: <a706647c-82ed-4923-a6dd-6e0d3818d11c@pengutronix.de> (raw)
In-Reply-To: <a6d6bbcb-96b7-4a43-9322-c42562cd1bf1@pengutronix.de>
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.
>> +
>> + 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.
Regards,
Jonas
--
Pengutronix e.K. | Jonas Rebmann |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
next prev parent reply other threads:[~2025-11-14 10:25 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 [this message]
2025-11-14 13:50 ` Ahmad Fatoum
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=a706647c-82ed-4923-a6dd-6e0d3818d11c@pengutronix.de \
--to=jre@pengutronix.de \
--cc=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--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