[U-Boot] [PATCH 2/2] common: Generic firmware loader for file system

Chee, Tien Fong tien.fong.chee at intel.com
Tue Dec 12 04:51:44 UTC 2017


On Isn, 2017-12-11 at 13:16 +0100, Lothar Waßmann wrote:
> Hi,
> 
> On Mon, 11 Dec 2017 18:53:46 +0800 tien.fong.chee at intel.com wrote:
> > 
> > From: Tien Fong Chee <tien.fong.chee at intel.com>
> > 
> [...}
> > 
> > +/*
> > + * Prepare firmware struct;
> > + * return -ve if fail.
> > + */
> > +static int _request_firmware_prepare(struct firmware **firmware_p,
> > +				     const char *name, void *dbuf,
> > +				     size_t size, u32 offset)
> > +{
> > +	struct firmware *firmware = NULL;
> > +	int ret = 0;
> > +
> > +	*firmware_p = NULL;
> > 
> Sigh. This is useless...
> > 
> > +	if (!name || name[0] == '\0')
> > +		ret = -EINVAL;
> > +
> unless you do a 'return -EINVAL' here!
> 
You are right, i missed to change this to return. I would fix it.
> > 
> > +	*firmware_p = firmware = calloc(1, sizeof(*firmware));
> > +
> > +	if (!firmware) {
> > +		printf("%s: calloc(struct firmware) failed\n",
> > __func__);
> > +		return -ENOMEM;
> > +	}
> > +
> > +	firmware->name = name;
> > +	firmware->data = dbuf;
> > +	firmware->size = size;
> > +	firmware->offset = offset;
> > +
> > +	return ret;
> > +}
> > +
> 
> Lothar Waßmann


More information about the U-Boot mailing list