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

Arnd Bergmann arnd at arndb.de
Thu May 3 16:53:17 EST 2007


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.

> +       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);


	Arnd <><



More information about the Linuxppc-dev mailing list