All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 1/2] Documentation: devicetree: root node serial-number property documentation
@ 2015-04-28  7:29 ` Paul Kocialkowski
  0 siblings, 0 replies; 12+ messages in thread
From: Paul Kocialkowski @ 2015-04-28  7:29 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] 12+ messages in thread

* [PATCH v4 1/2] Documentation: devicetree: root node serial-number property documentation
@ 2015-04-28  7:29 ` Paul Kocialkowski
  0 siblings, 0 replies; 12+ messages in thread
From: Paul Kocialkowski @ 2015-04-28  7:29 UTC (permalink / raw)
  To: linux-arm-kernel

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@paulk.fr>
---
 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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v4 2/2] arch: arm: Show the serial number from devicetree in cpuinfo
  2015-04-28  7:29 ` Paul Kocialkowski
@ 2015-04-28  7:29     ` Paul Kocialkowski
  -1 siblings, 0 replies; 12+ messages in thread
From: Paul Kocialkowski @ 2015-04-28  7:29 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            | 23 +++++++++++++++++++++--
 2 files changed, 22 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..b501754 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,8 +824,25 @@ arch_initcall(customize_machine);
 
 static int __init init_machine_late(void)
 {
+	struct device_node *root;
+	int ret;
+
 	if (machine_desc->init_late)
 		machine_desc->init_late();
+
+	root = of_find_node_by_path("/");
+	if (root) {
+		ret = of_property_read_string(root, "serial-number",
+					      &system_serial);
+		if (ret)
+			system_serial = NULL;
+	}
+
+	if (!system_serial)
+		system_serial = kasprintf(GFP_KERNEL, "%08x%08x",
+					  system_serial_high,
+					  system_serial_low);
+
 	return 0;
 }
 late_initcall(init_machine_late);
@@ -1091,8 +1111,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] 12+ messages in thread

* [PATCH v4 2/2] arch: arm: Show the serial number from devicetree in cpuinfo
@ 2015-04-28  7:29     ` Paul Kocialkowski
  0 siblings, 0 replies; 12+ messages in thread
From: Paul Kocialkowski @ 2015-04-28  7:29 UTC (permalink / raw)
  To: linux-arm-kernel

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@paulk.fr>
---
 arch/arm/include/asm/system_info.h |  1 +
 arch/arm/kernel/setup.c            | 23 +++++++++++++++++++++--
 2 files changed, 22 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..b501754 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,8 +824,25 @@ arch_initcall(customize_machine);
 
 static int __init init_machine_late(void)
 {
+	struct device_node *root;
+	int ret;
+
 	if (machine_desc->init_late)
 		machine_desc->init_late();
+
+	root = of_find_node_by_path("/");
+	if (root) {
+		ret = of_property_read_string(root, "serial-number",
+					      &system_serial);
+		if (ret)
+			system_serial = NULL;
+	}
+
+	if (!system_serial)
+		system_serial = kasprintf(GFP_KERNEL, "%08x%08x",
+					  system_serial_high,
+					  system_serial_low);
+
 	return 0;
 }
 late_initcall(init_machine_late);
@@ -1091,8 +1111,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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v4 1/2] Documentation: devicetree: root node serial-number property documentation
  2015-04-28  7:29 ` Paul Kocialkowski
@ 2015-05-06 13:26     ` Rob Herring
  -1 siblings, 0 replies; 12+ messages in thread
From: Rob Herring @ 2015-05-06 13:26 UTC (permalink / raw)
  To: Paul Kocialkowski
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Rob Herring,
	Russell King, Hans De Goede, Pawel Moll, Mark Rutland,
	Ian Campbell, Stefan Agner, Kumar Gala

On Tue, Apr 28, 2015 at 2:29 AM, Paul Kocialkowski <contact-W9ppeneeCTY@public.gmane.org> wrote:
> 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>

Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>

What Russell was referring to for submitting is his patch tracker:

http://www.arm.linux.org.uk/developer/patches/

Rob

> ---
>  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	[flat|nested] 12+ messages in thread

* [PATCH v4 1/2] Documentation: devicetree: root node serial-number property documentation
@ 2015-05-06 13:26     ` Rob Herring
  0 siblings, 0 replies; 12+ messages in thread
From: Rob Herring @ 2015-05-06 13:26 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Apr 28, 2015 at 2:29 AM, Paul Kocialkowski <contact@paulk.fr> wrote:
> 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@paulk.fr>

Acked-by: Rob Herring <robh@kernel.org>

What Russell was referring to for submitting is his patch tracker:

http://www.arm.linux.org.uk/developer/patches/

Rob

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v4 1/2] Documentation: devicetree: root node serial-number property documentation
  2015-05-06 13:26     ` Rob Herring
@ 2015-05-06 14:26         ` Paul Kocialkowski
  -1 siblings, 0 replies; 12+ messages in thread
From: Paul Kocialkowski @ 2015-05-06 14:26 UTC (permalink / raw)
  To: Rob Herring
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Rob Herring,
	Russell King, Hans De Goede, Pawel Moll, Mark Rutland,
	Ian Campbell, Stefan Agner, Kumar Gala

[-- Attachment #1: Type: text/plain, Size: 2427 bytes --]

Le mercredi 06 mai 2015 à 08:26 -0500, Rob Herring a écrit :
> On Tue, Apr 28, 2015 at 2:29 AM, Paul Kocialkowski <contact-W9ppeneeCTY@public.gmane.org> wrote:
> > 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>
> 
> Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> 
> What Russell was referring to for submitting is his patch tracker:
> 
> http://www.arm.linux.org.uk/developer/patches/

Thanks for the hint, that's done now.

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


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v4 1/2] Documentation: devicetree: root node serial-number property documentation
@ 2015-05-06 14:26         ` Paul Kocialkowski
  0 siblings, 0 replies; 12+ messages in thread
From: Paul Kocialkowski @ 2015-05-06 14:26 UTC (permalink / raw)
  To: linux-arm-kernel

Le mercredi 06 mai 2015 ? 08:26 -0500, Rob Herring a ?crit :
> On Tue, Apr 28, 2015 at 2:29 AM, Paul Kocialkowski <contact@paulk.fr> wrote:
> > 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@paulk.fr>
> 
> Acked-by: Rob Herring <robh@kernel.org>
> 
> What Russell was referring to for submitting is his patch tracker:
> 
> http://www.arm.linux.org.uk/developer/patches/

Thanks for the hint, that's done now.

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150506/fc3e1a07/attachment.sig>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v4 2/2] arch: arm: Show the serial number from devicetree in cpuinfo
  2015-04-28  7:29     ` Paul Kocialkowski
@ 2015-06-07 17:03         ` Grant Likely
  -1 siblings, 0 replies; 12+ messages in thread
From: Grant Likely @ 2015-06-07 17:03 UTC (permalink / raw)
  To: devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: Mark Rutland, Russell King, Pawel Moll, Ian Campbell,
	Paul Kocialkowski, Stefan Agner, Hans De Goede, Rob Herring,
	Kumar Gala

On Tue, 28 Apr 2015 09:29:56 +0200
, Paul Kocialkowski <contact-W9ppeneeCTY@public.gmane.org>
 wrote:
> 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>

One comment below, but otherwise:

Acked-by: Grant Likely <grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

> ---
>  arch/arm/include/asm/system_info.h |  1 +
>  arch/arm/kernel/setup.c            | 23 +++++++++++++++++++++--
>  2 files changed, 22 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..b501754 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);
> +

Is there any need to export this symbol? It's only used by built-in
code. Not by modules.

>  unsigned int system_serial_low;
>  EXPORT_SYMBOL(system_serial_low);
>  
> @@ -821,8 +824,25 @@ arch_initcall(customize_machine);
>  
>  static int __init init_machine_late(void)
>  {
> +	struct device_node *root;
> +	int ret;
> +
>  	if (machine_desc->init_late)
>  		machine_desc->init_late();
> +
> +	root = of_find_node_by_path("/");
> +	if (root) {
> +		ret = of_property_read_string(root, "serial-number",
> +					      &system_serial);

of_property_read_string() will not modify the argument on failure. If
system_serial is initialized to NULL, then the failure path is
unnecessary.

> +		if (ret)
> +			system_serial = NULL;
> +	}

Calls to of_find_node* functions increment the refcount for the node.
Need an of_node_put() here, or just use the of_root pointer directly. It
is safe to call of_property_read_string() with a NULL node pointer too,
it will fail gracefully.

So, the whole thing can safely boil down to:

	of_property_read_string(of_root, "serial-number", &system_serial);
	if (!system_serial)
		system_serial = kasprintf(GFP_KERNEL, "%08x%08x",
					  system_serial_high, system_serial_low);

g.

--
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] 12+ messages in thread

* [PATCH v4 2/2] arch: arm: Show the serial number from devicetree in cpuinfo
@ 2015-06-07 17:03         ` Grant Likely
  0 siblings, 0 replies; 12+ messages in thread
From: Grant Likely @ 2015-06-07 17:03 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 28 Apr 2015 09:29:56 +0200
, Paul Kocialkowski <contact@paulk.fr>
 wrote:
> 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@paulk.fr>

One comment below, but otherwise:

Acked-by: Grant Likely <grant.likely@linaro.org>

> ---
>  arch/arm/include/asm/system_info.h |  1 +
>  arch/arm/kernel/setup.c            | 23 +++++++++++++++++++++--
>  2 files changed, 22 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..b501754 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);
> +

Is there any need to export this symbol? It's only used by built-in
code. Not by modules.

>  unsigned int system_serial_low;
>  EXPORT_SYMBOL(system_serial_low);
>  
> @@ -821,8 +824,25 @@ arch_initcall(customize_machine);
>  
>  static int __init init_machine_late(void)
>  {
> +	struct device_node *root;
> +	int ret;
> +
>  	if (machine_desc->init_late)
>  		machine_desc->init_late();
> +
> +	root = of_find_node_by_path("/");
> +	if (root) {
> +		ret = of_property_read_string(root, "serial-number",
> +					      &system_serial);

of_property_read_string() will not modify the argument on failure. If
system_serial is initialized to NULL, then the failure path is
unnecessary.

> +		if (ret)
> +			system_serial = NULL;
> +	}

Calls to of_find_node* functions increment the refcount for the node.
Need an of_node_put() here, or just use the of_root pointer directly. It
is safe to call of_property_read_string() with a NULL node pointer too,
it will fail gracefully.

So, the whole thing can safely boil down to:

	of_property_read_string(of_root, "serial-number", &system_serial);
	if (!system_serial)
		system_serial = kasprintf(GFP_KERNEL, "%08x%08x",
					  system_serial_high, system_serial_low);

g.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v4 2/2] arch: arm: Show the serial number from devicetree in cpuinfo
  2015-06-07 17:03         ` Grant Likely
@ 2015-06-11  7:06           ` Paul Kocialkowski
  -1 siblings, 0 replies; 12+ messages in thread
From: Paul Kocialkowski @ 2015-06-11  7:06 UTC (permalink / raw)
  To: Grant Likely
  Cc: Mark Rutland, devicetree, Russell King, Pawel Moll, Ian Campbell,
	Stefan Agner, Hans De Goede, Rob Herring, Kumar Gala,
	linux-arm-kernel


[-- Attachment #1.1: Type: text/plain, Size: 3717 bytes --]

Le dimanche 07 juin 2015 à 18:03 +0100, Grant Likely a écrit :
> On Tue, 28 Apr 2015 09:29:56 +0200
> , Paul Kocialkowski <contact@paulk.fr>
>  wrote:
> > 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@paulk.fr>
> 
> One comment below, but otherwise:
> 
> Acked-by: Grant Likely <grant.likely@linaro.org>

I'm afraid this was merged in Russell's tree already:
http://ftp.arm.linux.org.uk/cgit/linux-arm.git/commit/?h=for-next&id=3f599875e5202986b350618a617527ab441bf206

Still, it might be useful to make another patch on top with your
comments!

> > ---
> >  arch/arm/include/asm/system_info.h |  1 +
> >  arch/arm/kernel/setup.c            | 23 +++++++++++++++++++++--
> >  2 files changed, 22 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..b501754 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);
> > +
> 
> Is there any need to export this symbol? It's only used by built-in
> code. Not by modules.

I agree, but I thought it would be consistent with the way
system_serial_high/low are exported. I'm not sure this was ever needed
either, but generally, I guess it makes sense to export parameters that
are passed to the kernel (it was through ATAGs before, now it's through
device-tree, but the logic remains the same).

> >  unsigned int system_serial_low;
> >  EXPORT_SYMBOL(system_serial_low);
> >  
> > @@ -821,8 +824,25 @@ arch_initcall(customize_machine);
> >  
> >  static int __init init_machine_late(void)
> >  {
> > +	struct device_node *root;
> > +	int ret;
> > +
> >  	if (machine_desc->init_late)
> >  		machine_desc->init_late();
> > +
> > +	root = of_find_node_by_path("/");
> > +	if (root) {
> > +		ret = of_property_read_string(root, "serial-number",
> > +					      &system_serial);
> 
> of_property_read_string() will not modify the argument on failure. If
> system_serial is initialized to NULL, then the failure path is
> unnecessary.

Makes sense.

> > +		if (ret)
> > +			system_serial = NULL;
> > +	}
> 
> Calls to of_find_node* functions increment the refcount for the node.
> Need an of_node_put() here, or just use the of_root pointer directly. It
> is safe to call of_property_read_string() with a NULL node pointer too,
> it will fail gracefully.
> 
> So, the whole thing can safely boil down to:
> 
> 	of_property_read_string(of_root, "serial-number", &system_serial);
> 	if (!system_serial)
> 		system_serial = kasprintf(GFP_KERNEL, "%08x%08x",
> 					  system_serial_high, system_serial_low);

Looks good to me, feel free to commit this change, on top of:
http://ftp.arm.linux.org.uk/cgit/linux-arm.git/commit/?h=for-next&id=3f599875e5202986b350618a617527ab441bf206

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v4 2/2] arch: arm: Show the serial number from devicetree in cpuinfo
@ 2015-06-11  7:06           ` Paul Kocialkowski
  0 siblings, 0 replies; 12+ messages in thread
From: Paul Kocialkowski @ 2015-06-11  7:06 UTC (permalink / raw)
  To: linux-arm-kernel

Le dimanche 07 juin 2015 ? 18:03 +0100, Grant Likely a ?crit :
> On Tue, 28 Apr 2015 09:29:56 +0200
> , Paul Kocialkowski <contact@paulk.fr>
>  wrote:
> > 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@paulk.fr>
> 
> One comment below, but otherwise:
> 
> Acked-by: Grant Likely <grant.likely@linaro.org>

I'm afraid this was merged in Russell's tree already:
http://ftp.arm.linux.org.uk/cgit/linux-arm.git/commit/?h=for-next&id=3f599875e5202986b350618a617527ab441bf206

Still, it might be useful to make another patch on top with your
comments!

> > ---
> >  arch/arm/include/asm/system_info.h |  1 +
> >  arch/arm/kernel/setup.c            | 23 +++++++++++++++++++++--
> >  2 files changed, 22 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..b501754 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);
> > +
> 
> Is there any need to export this symbol? It's only used by built-in
> code. Not by modules.

I agree, but I thought it would be consistent with the way
system_serial_high/low are exported. I'm not sure this was ever needed
either, but generally, I guess it makes sense to export parameters that
are passed to the kernel (it was through ATAGs before, now it's through
device-tree, but the logic remains the same).

> >  unsigned int system_serial_low;
> >  EXPORT_SYMBOL(system_serial_low);
> >  
> > @@ -821,8 +824,25 @@ arch_initcall(customize_machine);
> >  
> >  static int __init init_machine_late(void)
> >  {
> > +	struct device_node *root;
> > +	int ret;
> > +
> >  	if (machine_desc->init_late)
> >  		machine_desc->init_late();
> > +
> > +	root = of_find_node_by_path("/");
> > +	if (root) {
> > +		ret = of_property_read_string(root, "serial-number",
> > +					      &system_serial);
> 
> of_property_read_string() will not modify the argument on failure. If
> system_serial is initialized to NULL, then the failure path is
> unnecessary.

Makes sense.

> > +		if (ret)
> > +			system_serial = NULL;
> > +	}
> 
> Calls to of_find_node* functions increment the refcount for the node.
> Need an of_node_put() here, or just use the of_root pointer directly. It
> is safe to call of_property_read_string() with a NULL node pointer too,
> it will fail gracefully.
> 
> So, the whole thing can safely boil down to:
> 
> 	of_property_read_string(of_root, "serial-number", &system_serial);
> 	if (!system_serial)
> 		system_serial = kasprintf(GFP_KERNEL, "%08x%08x",
> 					  system_serial_high, system_serial_low);

Looks good to me, feel free to commit this change, on top of:
http://ftp.arm.linux.org.uk/cgit/linux-arm.git/commit/?h=for-next&id=3f599875e5202986b350618a617527ab441bf206
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150611/b66a37b3/attachment.sig>

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2015-06-11  7:06 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-28  7:29 [PATCH v4 1/2] Documentation: devicetree: root node serial-number property documentation Paul Kocialkowski
2015-04-28  7:29 ` Paul Kocialkowski
     [not found] ` <1430206196-3483-1-git-send-email-contact-W9ppeneeCTY@public.gmane.org>
2015-04-28  7:29   ` [PATCH v4 2/2] arch: arm: Show the serial number from devicetree in cpuinfo Paul Kocialkowski
2015-04-28  7:29     ` Paul Kocialkowski
     [not found]     ` <1430206196-3483-2-git-send-email-contact-W9ppeneeCTY@public.gmane.org>
2015-06-07 17:03       ` Grant Likely
2015-06-07 17:03         ` Grant Likely
2015-06-11  7:06         ` Paul Kocialkowski
2015-06-11  7:06           ` Paul Kocialkowski
2015-05-06 13:26   ` [PATCH v4 1/2] Documentation: devicetree: root node serial-number property documentation Rob Herring
2015-05-06 13:26     ` Rob Herring
     [not found]     ` <CAL_JsqKbSgZ4gXVc=FG_RKic-JM4_Mhzdh3Lh26NCa6zrc74dA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-05-06 14:26       ` Paul Kocialkowski
2015-05-06 14:26         ` Paul Kocialkowski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.