From: Sascha Hauer <s.hauer@pengutronix.de>
To: Michael Tretter <m.tretter@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 3/7] blspec: add support for devicetree overlays
Date: Fri, 6 Sep 2019 09:33:02 +0200 [thread overview]
Message-ID: <20190906073302.uyhxt32q5j73clcg@pengutronix.de> (raw)
In-Reply-To: <20190905105142.13681-4-m.tretter@pengutronix.de>
On Thu, Sep 05, 2019 at 12:51:38PM +0200, Michael Tretter wrote:
> Read the devicetree-overlay property from the blspec entry and register
> the overlays when booting the blspec entry.
>
> Do not fail the boot if an overlay cannot be loaded, because if Linux
> fails to boot without an overlay, the base device tree is broken.
>
> Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
> ---
> Documentation/user/booting-linux.rst | 4 ++
> common/blspec.c | 59 ++++++++++++++++++++++++++++
> 2 files changed, 63 insertions(+)
>
> diff --git a/Documentation/user/booting-linux.rst b/Documentation/user/booting-linux.rst
> index 437f4e80ca..12cd505e71 100644
> --- a/Documentation/user/booting-linux.rst
> +++ b/Documentation/user/booting-linux.rst
> @@ -232,6 +232,10 @@ device where the entry is found on. This makes it possible to use the same rootf
> image on different devices without having to specify a different root= option each
> time.
>
> +Additionally to the options defined in the original spec, Barebox has the
> +``devicetree-overlay`` option. This is a string value that refer to overlays
> +that will be applied to the device tree before passing it to Linux.
> +
> Network boot
> ------------
>
> diff --git a/common/blspec.c b/common/blspec.c
> index 66e5033e35..6b15d36d67 100644
> --- a/common/blspec.c
> +++ b/common/blspec.c
> @@ -42,6 +42,60 @@ int blspec_entry_var_set(struct blspec_entry *entry, const char *name,
> val ? strlen(val) + 1 : 0, 1);
> }
>
> +static int blspec_apply_oftree_overlay(char *file, const char *abspath,
> + int dryrun)
> +{
> + int ret;
> + struct fdt_header *fdt;
> + struct device_node *overlay;
> + char *path;
> +
> + path = basprintf("%s/%s", abspath, file);
> +
> + fdt = read_file(path, NULL);
This memory is never freed.
> + if (!fdt) {
> + pr_warn("unable to read \"%s\"\n", path);
> + ret = -EINVAL;
> + goto out;
> + }
> +
> + overlay = of_unflatten_dtb(fdt);
> + if (IS_ERR(overlay)) {
> + printf("\"%s\" is not a valid devicetree\n", path);
> + ret = -EINVAL;
> + goto out;
> + }
> +
> + if (dryrun) {
> + pr_info("dry run: skip overlay %s\n", path);
> + of_delete_node(overlay);
> + goto out;
> + }
> +
> + ret = of_register_overlay(overlay);
> + if (ret)
> + pr_warn("cannot register devicetree overlay \"%s\"\n", path);
You do not free the overlay in the error path. What happens to this
memory when succesful? Should of_register_overlay() make a copy or free
it when succesfully fixed up?
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2019-09-06 7:33 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-05 10:51 [PATCH 0/7] Device Tree Overlay Support Michael Tretter
2019-09-05 10:51 ` [PATCH 1/7] dtc: add -@ option to enable __symbols__ Michael Tretter
2019-09-05 10:51 ` [PATCH 2/7] of: add support for devicetree overlays Michael Tretter
2019-09-05 15:24 ` Ahmad Fatoum
2019-09-06 7:15 ` Michael Tretter
2019-09-06 7:29 ` Sascha Hauer
2019-09-05 10:51 ` [PATCH 3/7] blspec: " Michael Tretter
2019-09-06 7:33 ` Sascha Hauer [this message]
2019-09-05 10:51 ` [PATCH 4/7] of: add iterator for overlays Michael Tretter
2019-09-05 10:51 ` [PATCH 5/7] firmware: add support to load firmware from dt overlay Michael Tretter
2019-09-05 10:51 ` [PATCH 6/7] blspec: load firmware if specified in " Michael Tretter
2019-09-05 10:51 ` [PATCH 7/7] commands: add of_overlay command for device tree overlays Michael Tretter
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=20190906073302.uyhxt32q5j73clcg@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=m.tretter@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