From: Sascha Hauer <s.hauer@pengutronix.de>
To: Michael Tretter <m.tretter@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [RFC PATCH 6/7] firmware: add support for fpga-regions
Date: Fri, 5 Apr 2019 12:39:23 +0200 [thread overview]
Message-ID: <20190405103923.ingk2iup3dvw2umy@pengutronix.de> (raw)
In-Reply-To: <20190404145320.11465-7-m.tretter@pengutronix.de>
On Thu, Apr 04, 2019 at 04:53:19PM +0200, Michael Tretter wrote:
> The Barebox fpga-region driver is merely glue code between the
> devicetree overlay support and the various firmware handlers.
>
> The driver registers notifiers for each fpga-region in the devicetree.
> If an overlay is registered for a fpga-region, it uses the referenced
> firmware handler to load the specified firmware image.
>
> +#include <common.h>
> +#include <globalvar.h>
> +#include <firmware.h>
> +#include <init.h>
> +#include <magicvar.h>
> +#include <of.h>
> +
> +char *firmware_path;
static?
> +
> +struct fpga_region {
> + struct device_d *dev;
> + struct notifier_block nb;
> + struct firmware_mgr *mgr;
> +};
> +
> + if (action != OF_OVERLAY_PRE_APPLY) {
> + dev_dbg(region->dev, "only interested in pre-apply hook\n");
> + return 0;
> + }
> +
> + if (nd->target != region->dev->device_node) {
> + dev_dbg(region->dev, "%s is not overlay target %s\n",
> + nd->target->name, region->dev->device_node->name);
> + return 0;
> + }
> +
> + err = of_property_read_string(nd->target,
> + "firmware-name", &firmware_name);
> + if (err != -EINVAL) {
of_property_read_string could also return other error codes. I think you
should test for err == 0 here, maybe bail out with an error on other,
unexpected error codes.
> + dev_dbg(region->dev,
> + "%s has already been programmed with firmware %s\n",
> + nd->target->name, firmware_name);
> + return 0;
> + }
> +
> +static int of_fpga_region_probe(struct device_d *dev)
> +{
> + struct device_node *np = dev->device_node;
> + struct fpga_region *region;
> + struct firmware_mgr *mgr;
> + int err;
> +
> + mgr = of_fpga_region_get_mgr(np);
> + if (!mgr) {
> + pr_err("cannot find firmware loader for %s\n", np->name);
dev_err
> + return -EINVAL;
> + }
> +
> + region = kzalloc(sizeof(*region), GFP_KERNEL);
> + if (!region)
> + return -ENOMEM;
You can use xzalloc here.
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-04-05 10:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-04 14:53 [RFC PATCH 0/7] Device Tree Overlay Support Michael Tretter
2019-04-04 14:53 ` [RFC PATCH 1/7] commands: unify newlines for options Michael Tretter
2019-04-05 12:47 ` Sascha Hauer
2019-04-04 14:53 ` [RFC PATCH 2/7] dtc: add -@ option to enable __symbols__ Michael Tretter
2019-04-04 14:53 ` [RFC PATCH 3/7] of: add support for devicetree overlays Michael Tretter
2019-04-04 14:53 ` [RFC PATCH 4/7] commands: add oftree -o option for overlays Michael Tretter
2019-04-04 14:53 ` [RFC PATCH 5/7] firmware: allow to find manager by device node Michael Tretter
2019-04-04 14:53 ` [RFC PATCH 6/7] firmware: add support for fpga-regions Michael Tretter
2019-04-05 10:39 ` Sascha Hauer [this message]
2019-04-04 14:53 ` [RFC PATCH 7/7] blspec: add support for devicetree overlays Michael Tretter
2019-04-05 11:04 ` Sascha Hauer
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=20190405103923.ingk2iup3dvw2umy@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