devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Kocialkowski <contact@paulk.fr>
To: Grant Likely <grant.likely@secretlab.ca>
Cc: Mark Rutland <mark.rutland@arm.com>,
	devicetree@vger.kernel.org, Russell King <linux@arm.linux.org.uk>,
	Pawel Moll <pawel.moll@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Stefan Agner <stefan@agner.ch>,
	Hans De Goede <hdegoede@redhat.com>,
	Rob Herring <robh+dt@kernel.org>,
	Kumar Gala <galak@codeaurora.org>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v4 2/2] arch: arm: Show the serial number from devicetree in cpuinfo
Date: Thu, 11 Jun 2015 09:06:58 +0200	[thread overview]
Message-ID: <1434006418.2669.18.camel@collins> (raw)
In-Reply-To: <20150607170306.376FBC40580@trevor.secretlab.ca>


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

  reply	other threads:[~2015-06-11  7:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-28  7:29 [PATCH v4 1/2] Documentation: devicetree: root node serial-number property documentation 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
     [not found]     ` <1430206196-3483-2-git-send-email-contact-W9ppeneeCTY@public.gmane.org>
2015-06-07 17:03       ` Grant Likely
2015-06-11  7:06         ` Paul Kocialkowski [this message]
2015-05-06 13:26   ` [PATCH v4 1/2] Documentation: devicetree: root node serial-number property documentation Rob Herring
     [not found]     ` <CAL_JsqKbSgZ4gXVc=FG_RKic-JM4_Mhzdh3Lh26NCa6zrc74dA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-05-06 14:26       ` Paul Kocialkowski

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=1434006418.2669.18.camel@collins \
    --to=contact@paulk.fr \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=grant.likely@secretlab.ca \
    --cc=hdegoede@redhat.com \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mark.rutland@arm.com \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=stefan@agner.ch \
    /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;
as well as URLs for NNTP newsgroup(s).