From: Joel Stanley <joel@jms.id.au>
To: Andrew Jeffery <andrew@aj.id.au>
Cc: Rob Herring <robh+dt@kernel.org>,
linux-aspeed <linux-aspeed@lists.ozlabs.org>,
Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 2/3] soc: aspeed: Add soc info driver
Date: Mon, 21 Sep 2020 01:55:39 +0000 [thread overview]
Message-ID: <CACPK8Xdgd-PyfW1pTMW7pebLUVGcbco1XAC_=xBAsDfVsYUGUg@mail.gmail.com> (raw)
In-Reply-To: <aabf960e-33b3-4094-ad03-8305ca1794c7@www.fastmail.com>
On Wed, 16 Sep 2020 at 23:41, Andrew Jeffery <andrew@aj.id.au> wrote:
>
>
>
> On Wed, 16 Sep 2020, at 18:17, Joel Stanley wrote:
> > + np = of_find_compatible_node(NULL, NULL, "aspeed,silicon-id");
> > + if (!of_device_is_available(np)) {
> > + of_node_put(np);
> > + return -ENODEV;
> > + }
> > +
> > + reg = of_iomap(np, 0);
> > + if (!reg)
> > + return -ENODEV;
> > + siliconid = readl(reg);
> > + of_node_put(np);
> > + iounmap(reg);
> > +
> > + /* This is optional, the ast2400 does not have it */
> > + reg = of_iomap(np, 1);
>
> Use of np after of_node_put(np) above.
>
> > + if (reg) {
> > + has_chipid = true;
> > + chipid[0] = readl(reg);
> > + chipid[1] = readl(reg + 4);
> > + iounmap(reg);
> > + of_node_put(np);
>
> Double of_node_put() of np.
Good catch.
>
> > + }
> > +
> > + attrs = kzalloc(sizeof(*attrs), GFP_KERNEL);
> > + if (!attrs)
> > + return -ENODEV;
> > +
> > + /*
> > + * Machine: Romulus BMC
> > + * Family: AST2500
> > + * Revision: A1
> > + * SoC ID: raw silicon revision id
> > + * Serial Nnumber: 64-bit chipid
> > + */
> > +
> > + np = of_find_node_by_path("/");
> > + of_property_read_string(np, "model", &machine);
> > + if (machine)
> > + attrs->machine = kstrdup(machine, GFP_KERNEL);
> > + of_node_put(np);
> > +
> > + attrs->family = kasprintf(GFP_KERNEL, "%s",
> > + siliconid_to_name(siliconid));
> > +
> > + attrs->revision = kasprintf(GFP_KERNEL, "%s",
> > + siliconid_to_rev(siliconid));
>
> `struct soc_device_attribute` declares these as `const char *` and the strings
> are constants in the driver, so is there any reason to use kasprintf() here?
The first iteration of the driver had more complex strings here, so it
was a hold over from that. As long as the strings returned from the
helpers stick around forever then we can do that.
Cheers,
Joel
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-09-21 1:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-16 8:47 [PATCH 0/3] ARM: aspeed: Add socinfo driver Joel Stanley
2020-09-16 8:47 ` [PATCH 1/3] dt-bindings: aspeed: Add silicon id node to SCU Joel Stanley
2020-09-16 23:45 ` Andrew Jeffery
2020-09-21 1:56 ` Joel Stanley
2020-09-16 8:47 ` [PATCH 2/3] soc: aspeed: Add soc info driver Joel Stanley
2020-09-16 23:40 ` Andrew Jeffery
2020-09-21 1:55 ` Joel Stanley [this message]
2020-09-16 8:47 ` [PATCH 3/3] ARM: dts: aspeed: Add silicon id node Joel Stanley
2020-09-16 23:52 ` Andrew Jeffery
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='CACPK8Xdgd-PyfW1pTMW7pebLUVGcbco1XAC_=xBAsDfVsYUGUg@mail.gmail.com' \
--to=joel@jms.id.au \
--cc=andrew@aj.id.au \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=robh+dt@kernel.org \
/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).