[PATCH v2 1/2] tegra20: add pinctrl driver

Sascha Hauer s.hauer at pengutronix.de
Sat May 11 11:17:00 EDT 2013


On Fri, May 10, 2013 at 09:03:10PM +0200, Alexander Aring wrote:
> Hi Lucas,
> 
> On Fri, May 10, 2013 at 08:28:57PM +0200, Lucas Stach wrote:
> > This adds a pinctrl driver for the Tegra 20 line of SoCs. It only
> > supports the three basic pinconfiguration settings function mux,
> > tristate control and pullup/down control.
> > 
> > The driver understands the same devicetree bindings as the Linux one,
> > unimplemented pinconfiguration options will be ignored.
> > 
> > Signed-off-by: Lucas Stach <dev at lynxeye.de>

[...]

> > +
> > +static int pinctrl_tegra20_probe(struct device_d *dev)
> > +{
> > +	struct pinctrl_tegra20 *ctrl;
> > +	int i, ret;
> > +	u32 **regs;
> > +
> > +	ctrl = xzalloc(sizeof(*ctrl));
> > +
> > +	/*
> > +	 * Tegra pincontrol is split out into four independent memory ranges:
> > +	 * tristate control, function mux, pullup/down control, pad control
> > +	 * (from lowest to highest hardware address).
> > +	 * We are only interested in the first three for now.
> > +	 */
> > +	regs = (u32 **)&ctrl->regs;
> > +	for (i = 0; i <= 2; i++) {
> > +		regs[i] = dev_request_mem_region(dev, i);
> > +		if (!regs[i]) {
> > +			dev_err(dev, "Could not get iomem region %d\n", i);
> Do we need a free(ctrl); here?

To be correct, yes, we would need a free() here.

I've never been very thoroughly with releasing the resources in the
error pathes in the drivers in barebox though and I never felt bad about
it.

The probe calls are called only once for each device and whether or not
we have a few bytes of malloc space more doesn't really matter. Also you
may have noticed that there even is no dev_release_mem_region in barebox
which makes nearly all error pathes wrong in barebox anyway.

And no, I don't want to have -EPROBE_DEFER in barebox.

So I don't really know what to do with the error pathes in driver probe
functions. I don't really care about them, but I also don't feel like
removing the freeing of resources either to reduce the binary size.

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 |



More information about the barebox mailing list