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

From: Arnd Bergmann <[email-masked]>
Date: Thu, 3 May 2007 08:53:17 +0200

On Wednesday 02 May 2007, Dale Farnsworth wrote:
> +=A0=A0=A0=A0=A0=A0=A0static int called_count;
> +=A0=A0=A0=A0=A0=A0=A0int instance =3D 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 =3D platform_device_register_simple(MV64XXX_I2C_CTLR_NAME,
> +                                              instance, r, 2);
> +       if (IS_ERR(pdev))
> +               return PTR_ERR(pdev);
> +
> +       err =3D 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 =3D platform_device_alloc(MV64XXX_I2C_CTLR_NAME, instance);
	if (!pdev)
		return -ENOMEM;
	err =3D platform_device_add_resources(pdev, r, 2);
	if (err)
		goto error;
	err =3D platform_device_add_data(pdev, &pdata, sizeof(pdata));
	if (err)
		goto error;
	err =3D platform_device_add(pdev);
	if (err)
		goto error;
	return pdev;
error:
	platform_device_put(pdev);
	return ERR_PTR(err);

	Arnd <><