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

Wu Guoxing-B39297 B39297 at freescale.com
Fri Nov 4 06:55:49 EDT 2011


Thanks Russell and Sascha for the comments!

I have send out the changed patches for review.

Best Regards
Wu Guoxing

-----Original Message-----
From: Russell King - ARM Linux [mailto:linux at arm.linux.org.uk] 
Sent: Friday, November 04, 2011 5:51 PM
To: Wu Guoxing-B39297
Cc: linux-arm-kernel at lists.infradead.org; s.hauer at pengutronix.de; shawn.guo at linaro.org
Subject: Re: [PATCH] ARM/mx35/3ds: gpio: add mc9s08dz60 gpio function

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