[PATCH 2/5] spi: i.MX: Move to coredevice_initcall

Sascha Hauer s.hauer at pengutronix.de
Mon May 19 01:47:50 PDT 2014


On Wed, May 14, 2014 at 09:57:57PM +0400, Alexander Shiyan wrote:
> > 
> > - put the drivers private data into dev->priv
> > - when returning an error from probe, instead of freeing the data
> >   keep it.
> > - when probing again re-use the data.
> > 
> > With this drivers could be written like:
> > 
> > 	priv = dev->priv;
> > 	if (!priv) {
> > 		priv = xzalloc(sizeof(priv));
> > 		dev->priv = priv;
> > 	}
> > 
> > 	if (!priv->clk) {
> > 		clk = clk_get(dev, NULL);
> > 		if (IS_ERR(clk))
> > 			return PTR_ERR(clk);
> > 		priv->clk = clk;
> > 		clk_enable(priv->clk);
> > 	}
> > 
> > 	if (!priv->regulator) {
> > 		regulator = regulator_get(dev, "vmmc");
> > 		if (IS_ERR(regulator))
> > 			return PTR_ERR(regulator);
> > 		priv->regulator = regulator;
> > 	}
> > 
> > This way drivers could allocate the missing resources as needed without
> > freeing them between different calls to probe().
> 
> The idea is good, but I think that it will not be so easy to do.

Where do you expect problems?

> In addition, we obtain additional incompatibility with the kernel code.

I think this is not a problem in this case. The probe pathes of the
device drivers contain nearly the same elements, but are quite different
in the details anyway.

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