From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ctpYa-0007Kt-Pm for barebox@lists.infradead.org; Fri, 31 Mar 2017 05:57:10 +0000 Date: Fri, 31 Mar 2017 07:56:46 +0200 From: Sascha Hauer Message-ID: <20170331055646.r25oixsqwc4xvu5j@pengutronix.de> References: <20170329075927.1131-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170329075927.1131-1-o.rempel@pengutronix.de> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: Re: [PATCH v3] bootm: fit: support multiple configuration nodes To: Oleksij Rempel Cc: barebox@lists.infradead.org, Steffen Trumtrar On Wed, Mar 29, 2017 at 09:59:27AM +0200, Oleksij Rempel wrote: > From: Steffen Trumtrar > > Signed-off-by: Steffen Trumtrar > Signed-off-by: Oleksij Rempel > --- > common/image-fit.c | 40 ++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 38 insertions(+), 2 deletions(-) Applied, thanks Sascha > > diff --git a/common/image-fit.c b/common/image-fit.c > index 0536c49b1..81433e6ec 100644 > --- a/common/image-fit.c > +++ b/common/image-fit.c > @@ -491,6 +491,38 @@ static int fit_config_verify_signature(struct fit_handle *handle, struct device_ > return ret; > } > > +static int fit_find_compatible_unit(struct device_node *conf_node, > + const char **unit) > +{ > + struct device_node *child = NULL; > + struct device_node *barebox_root; > + const char *machine; > + int ret; > + > + barebox_root = of_get_root_node(); > + if (!barebox_root) > + goto default_unit; > + > + ret = of_property_read_string(barebox_root, "compatible", &machine); > + if (ret) > + return -ENOENT; > + > + for_each_child_of_node(conf_node, child) { > + if (of_device_is_compatible(child, machine)) { > + *unit = child->name; > + pr_info("matching unit '%s' found\n", *unit); > + return 0; > + } > + } > + > +default_unit: > + pr_info("No match found. Trying default.\n"); > + if (of_property_read_string(conf_node, "default", unit) == 0) > + return 0; > + > + return -ENOENT; > +} > + > static int fit_open_configuration(struct fit_handle *handle, const char *name) > { > struct device_node *conf_node = NULL; > @@ -503,8 +535,12 @@ static int fit_open_configuration(struct fit_handle *handle, const char *name) > > if (name) { > unit = name; > - } else if (of_property_read_string(conf_node, "default", &unit)) { > - unit = "conf@1"; > + } else { > + ret = fit_find_compatible_unit(conf_node, &unit); > + if (ret) { > + pr_info("Couldn't get a valid configuration. Aborting.\n"); > + return ret; > + } > } > > conf_node = of_get_child_by_name(conf_node, unit); > -- > 2.11.0 > > > _______________________________________________ > barebox mailing list > barebox@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/barebox > -- 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