All of lore.kernel.org
 help / color / mirror / Atom feed
From: khali@linux-fr.org (Jean Delvare)
To: lm-sensors@vger.kernel.org
Subject: [lm-sensors] [PATCH 5/30] i2c: __must_check fixes, i2c-dev
Date: Wed, 27 Sep 2006 10:00:02 +0000	[thread overview]
Message-ID: <20060927120002.bd941ab8.khali@linux-fr.org> (raw)
In-Reply-To: <11593189352843-git-send-email-greg@kroah.com>

> From: Jean Delvare <khali at linux-fr.org>
> 
> i2c: __must_check fixes (i2c-dev)
> 
> Check for error on sysfs file creation.
> Check for error on device creation.
> Delete sysfs file on device destruction.
> 
> I couldn't test this one beyond compilation, as it applies on top of
> another patch in Greg's tree [1] which breaks all my systems when I
> apply it (my udev isn't recent enough.) Anyone with bleeding edge udev
> is welcome to test and report.
> 
> [1] http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/i2c/i2c-dev-device.patch

For completeness, this comment no more applies thanks to a patch
reordering.

> Signed-off-by: Jean Delvare <khali at linux-fr.org>
> Signed-off-by: Greg Kroah-Hartman <gregkh at suse.de>
> ---
>  drivers/i2c/i2c-dev.c |   14 +++++++++++---
>  1 files changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
> index 2ce0833..567fb05 100644
> --- a/drivers/i2c/i2c-dev.c
> +++ b/drivers/i2c/i2c-dev.c
> @@ -406,6 +406,7 @@ static struct class *i2c_dev_class;
>  static int i2cdev_attach_adapter(struct i2c_adapter *adap)
>  {
>  	struct i2c_dev *i2c_dev;
> +	int res;
>  
>  	i2c_dev = get_free_i2c_dev(adap);
>  	if (IS_ERR(i2c_dev))
> @@ -419,14 +420,20 @@ static int i2cdev_attach_adapter(struct 
>  						 MKDEV(I2C_MAJOR, adap->nr),
>  						 &adap->dev, "i2c-%d",
>  						 adap->nr);
> -	if (!i2c_dev->class_dev)
> +	if (!i2c_dev->class_dev) {
> +		res = -ENODEV;
>  		goto error;
> -	class_device_create_file(i2c_dev->class_dev, &class_device_attr_name);
> +	}
> +	res = class_device_create_file(i2c_dev->class_dev, &class_device_attr_name);
> +	if (res)
> +		goto error_destroy;
>  	return 0;
> +error_destroy:
> +	class_device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr));
>  error:
>  	return_i2c_dev(i2c_dev);
>  	kfree(i2c_dev);
> -	return -ENODEV;
> +	return res;
>  }
>  
>  static int i2cdev_detach_adapter(struct i2c_adapter *adap)
> @@ -437,6 +444,7 @@ static int i2cdev_detach_adapter(struct 
>  	if (!i2c_dev)
>  		return -ENODEV;
>  
> +	class_device_remove_file(i2c_dev->class_dev, &class_device_attr_name);
>  	return_i2c_dev(i2c_dev);
>  	class_device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr));
>  	kfree(i2c_dev);
> -- 
> 1.4.2.1


-- 
Jean Delvare


      reply	other threads:[~2006-09-27 10:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-27  1:01 [lm-sensors] [PATCH 5/30] i2c: __must_check fixes, i2c-dev Greg KH
2006-09-27 10:00 ` Jean Delvare [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060927120002.bd941ab8.khali@linux-fr.org \
    --to=khali@linux-fr.org \
    --cc=lm-sensors@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.