Re: [RFC PATCH 6/7] firmware: add support for fpga-regions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux