[PATCH] ARM/mx35/3ds: gpio: add mc9s08dz60 gpio function

Russell King - ARM Linux linux at arm.linux.org.uk
Fri Nov 4 05:51:02 EDT 2011


In addition to Sascha's points...

On Fri, Nov 04, 2011 at 12:32:23PM +0800, wu guoxing wrote:
> +static int mc9s08dz60_remove(struct i2c_client *client)
> +{
> +	struct gpio_chip *chip;
> +	int ret;
> +
> +	chip = i2c_get_clientdata(client);
> +	if (chip == NULL)
> +		return -ENODEV;
> +
> +	i2c_set_clientdata(client, NULL);
> +
> +	ret = gpiochip_remove(chip);
> +	if (!ret)
> +		kfree(chip);

Two points here:
1. remove functions can't actually fail (their return value is not checked)
   so there's no point returning errors.
2. the remove function for a particular device will only be called after
   a probe for the same device/driver pair has been successful.  As you've
   initialized the i2c client data in the probe function, it should never
   be NULL here.

> +int __init mc9s08dz60_init(void)
> +{
> +	int err;
> +
> +	err = i2c_add_driver(&mc9s08dz60_i2c_driver);
> +	return err;

There's no need for this 'err' variable - just use

	return i2c_add_driver(&mc9s08dz60_i2c_driver);



More information about the linux-arm-kernel mailing list