* [PATCH v2 1/2] Documentation: devicetree: root node serial-number property documentation
@ 2015-04-17 18:43 Paul Kocialkowski
[not found] ` <1429296235-14123-1-git-send-email-contact-W9ppeneeCTY@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Paul Kocialkowski @ 2015-04-17 18:43 UTC (permalink / raw)
To: devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
Cc: Rob Herring, Russell King, Hans De Goede, Pawel Moll,
Mark Rutland, Ian Campbell, Stefan Agner, Kumar Gala,
Paul Kocialkowski
Open firmware is already using the serial-number property for passing the
device's serial number from the bootloader to the kernel. In addition, lshw
already has support for scanning this property.
The serial number is a string that somewhat represents the device's serial
number. It might come from some form of storage (e.g. an eeprom) and be
programmed at factory-time by the manufacturer or come from identification
bits available in e.g. the SoC (note that the soc_id property in the SoC bus
should hold a full account of those bits).
The serial number is taken as-is from the bootloader, so it is up to the
bootloader to define where the serial number comes from and what length it
should be. Some use cases for the serial number require it to have a maximum
length (e.g. for USB serial number) and some other cases imply more restrictions
on what the serial number should look like (e.g. in Android, the ro.serialno
property is usually a 16-bytes (plus one null byte) representation of a 64 bit
number).
Signed-off-by: Paul Kocialkowski <contact-W9ppeneeCTY@public.gmane.org>
---
Documentation/devicetree/booting-without-of.txt | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Documentation/devicetree/booting-without-of.txt b/Documentation/devicetree/booting-without-of.txt
index 7768518..95fc385 100644
--- a/Documentation/devicetree/booting-without-of.txt
+++ b/Documentation/devicetree/booting-without-of.txt
@@ -828,6 +828,10 @@ address which can extend beyond that limit.
name may clash with standard defined ones, you prefix them with your
vendor name and a comma.
+ Additional properties for the root node:
+
+ - serial-number : a string representing the device's serial number
+
b) The /cpus node
This node is the parent of all individual CPU nodes. It doesn't
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/2] arch: arm: Show the serial number from devicetree in cpuinfo
[not found] ` <1429296235-14123-1-git-send-email-contact-W9ppeneeCTY@public.gmane.org>
@ 2015-04-17 18:43 ` Paul Kocialkowski
[not found] ` <1429296235-14123-2-git-send-email-contact-W9ppeneeCTY@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Paul Kocialkowski @ 2015-04-17 18:43 UTC (permalink / raw)
To: devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
Cc: Rob Herring, Russell King, Hans De Goede, Pawel Moll,
Mark Rutland, Ian Campbell, Stefan Agner, Kumar Gala,
Paul Kocialkowski
This grabs the serial number shown in cpuinfo from the serial-number devicetree
property in priority. When booting with ATAGs (and without device-tree), the
provided number is still shown instead.
Signed-off-by: Paul Kocialkowski <contact-W9ppeneeCTY@public.gmane.org>
---
arch/arm/include/asm/system_info.h | 1 +
arch/arm/kernel/setup.c | 21 +++++++++++++++++++--
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/arch/arm/include/asm/system_info.h b/arch/arm/include/asm/system_info.h
index 720ea03..3860cbd40 100644
--- a/arch/arm/include/asm/system_info.h
+++ b/arch/arm/include/asm/system_info.h
@@ -17,6 +17,7 @@
/* information about the system we're running on */
extern unsigned int system_rev;
+extern const char *system_serial;
extern unsigned int system_serial_low;
extern unsigned int system_serial_high;
extern unsigned int mem_fclk_21285;
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 1d60beb..d1833ce 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -93,6 +93,9 @@ unsigned int __atags_pointer __initdata;
unsigned int system_rev;
EXPORT_SYMBOL(system_rev);
+const char *system_serial;
+EXPORT_SYMBOL(system_serial);
+
unsigned int system_serial_low;
EXPORT_SYMBOL(system_serial_low);
@@ -821,6 +824,21 @@ arch_initcall(customize_machine);
static int __init init_machine_late(void)
{
+#ifdef CONFIG_OF
+ unsigned long dt_root;
+ int size;
+
+ dt_root = of_get_flat_dt_root();
+
+ /* Scan for serial number */
+ system_serial = of_get_flat_dt_prop(dt_root, "serial-number", &size);
+#endif
+
+ if (!system_serial)
+ system_serial = kasprintf(GFP_KERNEL, "%08x%08x",
+ system_serial_high,
+ system_serial_low);
+
if (machine_desc->init_late)
machine_desc->init_late();
return 0;
@@ -1091,8 +1109,7 @@ static int c_show(struct seq_file *m, void *v)
seq_printf(m, "Hardware\t: %s\n", machine_name);
seq_printf(m, "Revision\t: %04x\n", system_rev);
- seq_printf(m, "Serial\t\t: %08x%08x\n",
- system_serial_high, system_serial_low);
+ seq_printf(m, "Serial\t\t: %s\n", system_serial);
return 0;
}
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] arch: arm: Show the serial number from devicetree in cpuinfo
[not found] ` <1429296235-14123-2-git-send-email-contact-W9ppeneeCTY@public.gmane.org>
@ 2015-04-18 9:13 ` Russell King - ARM Linux
[not found] ` <20150418091310.GI12732-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Russell King - ARM Linux @ 2015-04-18 9:13 UTC (permalink / raw)
To: Paul Kocialkowski
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Rob Herring,
Hans De Goede, Pawel Moll, Mark Rutland, Ian Campbell,
Stefan Agner, Kumar Gala
Hi,
On Fri, Apr 17, 2015 at 08:43:55PM +0200, Paul Kocialkowski wrote:
> static int __init init_machine_late(void)
> {
> +#ifdef CONFIG_OF
> + unsigned long dt_root;
> + int size;
> +
> + dt_root = of_get_flat_dt_root();
> +
> + /* Scan for serial number */
> + system_serial = of_get_flat_dt_prop(dt_root, "serial-number", &size);
I was really hoping for:
if (of_property_read_string(of_root, "serial-number", &system_serial))
system_serial = NULL;
here. I can't see a reason to use the flattened DT at this point as
we've already parsed it.
I'd also put this after the call to machine_desc->init_late().
Thanks.
--
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] arch: arm: Show the serial number from devicetree in cpuinfo
[not found] ` <20150418091310.GI12732-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
@ 2015-04-18 9:45 ` Paul Kocialkowski
2015-04-18 12:27 ` Russell King - ARM Linux
0 siblings, 1 reply; 6+ messages in thread
From: Paul Kocialkowski @ 2015-04-18 9:45 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Rob Herring,
Hans De Goede, Pawel Moll, Mark Rutland, Ian Campbell,
Stefan Agner, Kumar Gala
[-- Attachment #1: Type: text/plain, Size: 958 bytes --]
Le samedi 18 avril 2015 à 10:13 +0100, Russell King - ARM Linux a
écrit :
> Hi,
>
> On Fri, Apr 17, 2015 at 08:43:55PM +0200, Paul Kocialkowski wrote:
> > static int __init init_machine_late(void)
> > {
> > +#ifdef CONFIG_OF
> > + unsigned long dt_root;
> > + int size;
> > +
> > + dt_root = of_get_flat_dt_root();
> > +
> > + /* Scan for serial number */
> > + system_serial = of_get_flat_dt_prop(dt_root, "serial-number", &size);
>
> I was really hoping for:
>
> if (of_property_read_string(of_root, "serial-number", &system_serial))
> system_serial = NULL;
>
> here. I can't see a reason to use the flattened DT at this point as
> we've already parsed it.
Good point -- I'm not very used to using device-tree so I didn't think
of it, thanks for mentioning it.
At this point, I guess I can also add your Signed-Off-By to the patch.
> I'd also put this after the call to machine_desc->init_late().
Will do.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] arch: arm: Show the serial number from devicetree in cpuinfo
2015-04-18 9:45 ` Paul Kocialkowski
@ 2015-04-18 12:27 ` Russell King - ARM Linux
[not found] ` <20150418122758.GJ12732-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Russell King - ARM Linux @ 2015-04-18 12:27 UTC (permalink / raw)
To: Paul Kocialkowski
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Rob Herring,
Hans De Goede, Pawel Moll, Mark Rutland, Ian Campbell,
Stefan Agner, Kumar Gala
On Sat, Apr 18, 2015 at 11:45:13AM +0200, Paul Kocialkowski wrote:
> Le samedi 18 avril 2015 à 10:13 +0100, Russell King - ARM Linux a
> écrit :
> > Hi,
> >
> > On Fri, Apr 17, 2015 at 08:43:55PM +0200, Paul Kocialkowski wrote:
> > > static int __init init_machine_late(void)
> > > {
> > > +#ifdef CONFIG_OF
> > > + unsigned long dt_root;
> > > + int size;
> > > +
> > > + dt_root = of_get_flat_dt_root();
> > > +
> > > + /* Scan for serial number */
> > > + system_serial = of_get_flat_dt_prop(dt_root, "serial-number", &size);
> >
> > I was really hoping for:
> >
> > if (of_property_read_string(of_root, "serial-number", &system_serial))
> > system_serial = NULL;
> >
> > here. I can't see a reason to use the flattened DT at this point as
> > we've already parsed it.
>
> Good point -- I'm not very used to using device-tree so I didn't think
> of it, thanks for mentioning it.
>
> At this point, I guess I can also add your Signed-Off-By to the patch.
No - Signed-off-by is to indicate the path by which it was committed
into the git tree, not for review, etc.
I'm assuming you'll be submitting this to my patch system eventually,
which means when I apply the patch, it'll have my S-o-b automatically
added.
--
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] arch: arm: Show the serial number from devicetree in cpuinfo
[not found] ` <20150418122758.GJ12732-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
@ 2015-04-18 12:37 ` Paul Kocialkowski
0 siblings, 0 replies; 6+ messages in thread
From: Paul Kocialkowski @ 2015-04-18 12:37 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Rob Herring,
Hans De Goede, Pawel Moll, Mark Rutland, Ian Campbell,
Stefan Agner, Kumar Gala
[-- Attachment #1: Type: text/plain, Size: 1637 bytes --]
Le samedi 18 avril 2015 à 13:27 +0100, Russell King - ARM Linux a
écrit :
> On Sat, Apr 18, 2015 at 11:45:13AM +0200, Paul Kocialkowski wrote:
> > Le samedi 18 avril 2015 à 10:13 +0100, Russell King - ARM Linux a
> > écrit :
> > > Hi,
> > >
> > > On Fri, Apr 17, 2015 at 08:43:55PM +0200, Paul Kocialkowski wrote:
> > > > static int __init init_machine_late(void)
> > > > {
> > > > +#ifdef CONFIG_OF
> > > > + unsigned long dt_root;
> > > > + int size;
> > > > +
> > > > + dt_root = of_get_flat_dt_root();
> > > > +
> > > > + /* Scan for serial number */
> > > > + system_serial = of_get_flat_dt_prop(dt_root, "serial-number", &size);
> > >
> > > I was really hoping for:
> > >
> > > if (of_property_read_string(of_root, "serial-number", &system_serial))
> > > system_serial = NULL;
> > >
> > > here. I can't see a reason to use the flattened DT at this point as
> > > we've already parsed it.
> >
> > Good point -- I'm not very used to using device-tree so I didn't think
> > of it, thanks for mentioning it.
> >
> > At this point, I guess I can also add your Signed-Off-By to the patch.
>
> No - Signed-off-by is to indicate the path by which it was committed
> into the git tree, not for review, etc.
Right, but since you've provided me with code samples, you might as well
hold part of the authorship of the patch.
> I'm assuming you'll be submitting this to my patch system eventually,
> which means when I apply the patch, it'll have my S-o-b automatically
> added.
V3 (that includes your suggestion) was sent already.
Thanks for the review and comprehensive help!
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-04-18 12:37 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-17 18:43 [PATCH v2 1/2] Documentation: devicetree: root node serial-number property documentation Paul Kocialkowski
[not found] ` <1429296235-14123-1-git-send-email-contact-W9ppeneeCTY@public.gmane.org>
2015-04-17 18:43 ` [PATCH v2 2/2] arch: arm: Show the serial number from devicetree in cpuinfo Paul Kocialkowski
[not found] ` <1429296235-14123-2-git-send-email-contact-W9ppeneeCTY@public.gmane.org>
2015-04-18 9:13 ` Russell King - ARM Linux
[not found] ` <20150418091310.GI12732-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2015-04-18 9:45 ` Paul Kocialkowski
2015-04-18 12:27 ` Russell King - ARM Linux
[not found] ` <20150418122758.GJ12732-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2015-04-18 12:37 ` Paul Kocialkowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).