[PATCH 9/13] powerpc: Add arch/powerpc mv64x60 I2C platform data setup


Thu May 3 23:06:23 EST 2007


On Thu, May 03, 2007 at 08:53:17AM +0200, Arnd Bergmann wrote:
> On Wednesday 02 May 2007, Dale Farnsworth wrote:
> > +???????static int called_count;
> > +???????int instance = called_count++;
> 
> I would think it's simpler to count the instances in the outer loop
> when looking for the devices than having a static counter here.

Maybe.  I did it with passing an outer counter in a previous
incarnation.  I'll look at it again.

> > +       pdev = platform_device_register_simple(MV64XXX_I2C_CTLR_NAME,
> > +                                              instance, r, 2);
> > +       if (IS_ERR(pdev))
> > +               return PTR_ERR(pdev);
> > +
> > +       err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
> > +       if (err) {
> > +               platform_device_unregister(pdev);
> > +               return err;
> 
> Doing the initialization in this order means that you have to add the
> devices before the driver is loaded. I haven't checked if you do
> the same thing in the oder places as well, but I think it would be
> better to do it open coded like
> 
> 	pdev = platform_device_alloc(MV64XXX_I2C_CTLR_NAME, instance);
> 	if (!pdev)
> 		return -ENOMEM;
> 	err = platform_device_add_resources(pdev, r, 2);
> 	if (err)
> 		goto error;
> 	err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
> 	if (err)
> 		goto error;
> 	err = platform_device_add(pdev);
> 	if (err)
> 		goto error;
> 	return pdev;
> error:
> 	platform_device_put(pdev);
> 	return ERR_PTR(err);

Makes sense to me.  I'll change it (in all three places).

Thanks.

-Dale



More information about the Linuxppc-dev mailing list