* [PATCH] i2c: Fix return value check
@ 2006-10-17 6:24 Akinobu Mita
2006-10-18 14:54 ` Jean Delvare
0 siblings, 1 reply; 4+ messages in thread
From: Akinobu Mita @ 2006-10-17 6:24 UTC (permalink / raw)
To: linux-kernel; +Cc: Greg Kroah-Hartman, Jean Delvare
class_device_create() returns error code as pointer on failure.
This patch checks the return value of class_device_create() by using IS_ERR().
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Akinbou Mita <akinobu.mita@gmail.com>
drivers/i2c/i2c-dev.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Index: 2.6-rc/drivers/i2c/i2c-dev.c
===================================================================
--- 2.6-rc.orig/drivers/i2c/i2c-dev.c
+++ 2.6-rc/drivers/i2c/i2c-dev.c
@@ -417,8 +417,8 @@ static int i2cdev_attach_adapter(struct
MKDEV(I2C_MAJOR, adap->nr),
&adap->dev, "i2c-%d",
adap->nr);
- if (!i2c_dev->class_dev) {
- res = -ENODEV;
+ if (IS_ERR(i2c_dev->class_dev)) {
+ res = PTR_ERR(i2c_dev->class_dev);
goto error;
}
res = class_device_create_file(i2c_dev->class_dev, &class_device_attr_name);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] i2c: Fix return value check
2006-10-17 6:24 [PATCH] i2c: Fix return value check Akinobu Mita
@ 2006-10-18 14:54 ` Jean Delvare
2006-10-19 3:28 ` Akinobu Mita
0 siblings, 1 reply; 4+ messages in thread
From: Jean Delvare @ 2006-10-18 14:54 UTC (permalink / raw)
To: Akinobu Mita; +Cc: linux-kernel, Greg Kroah-Hartman
Hi Akinobu,
On Tue, 17 Oct 2006 15:24:49 +0900, Akinobu Mita wrote:
> class_device_create() returns error code as pointer on failure.
> This patch checks the return value of class_device_create() by using IS_ERR().
>
> Cc: Greg Kroah-Hartman <gregkh@suse.de>
> Cc: Jean Delvare <khali@linux-fr.org>
> Signed-off-by: Akinbou Mita <akinobu.mita@gmail.com>
Typo ;)
>
> drivers/i2c/i2c-dev.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> Index: 2.6-rc/drivers/i2c/i2c-dev.c
> ===================================================================
> --- 2.6-rc.orig/drivers/i2c/i2c-dev.c
> +++ 2.6-rc/drivers/i2c/i2c-dev.c
> @@ -417,8 +417,8 @@ static int i2cdev_attach_adapter(struct
> MKDEV(I2C_MAJOR, adap->nr),
> &adap->dev, "i2c-%d",
> adap->nr);
> - if (!i2c_dev->class_dev) {
> - res = -ENODEV;
> + if (IS_ERR(i2c_dev->class_dev)) {
> + res = PTR_ERR(i2c_dev->class_dev);
> goto error;
> }
> res = class_device_create_file(i2c_dev->class_dev, &class_device_attr_name);
Patch looks correct, however class devices are going away soon, and
this patch will conflict with Greg's work:
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/driver-class/i2c-dev-device.patch
So your patch should apply on top of Greg's, if still needed after his
changes. It might even be later folded into Greg's patch to make things
easier to handle.
Thanks,
--
Jean Delvare
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] i2c: Fix return value check
2006-10-18 14:54 ` Jean Delvare
@ 2006-10-19 3:28 ` Akinobu Mita
2006-10-19 10:11 ` Jean Delvare
0 siblings, 1 reply; 4+ messages in thread
From: Akinobu Mita @ 2006-10-19 3:28 UTC (permalink / raw)
To: Jean Delvare; +Cc: linux-kernel, Greg Kroah-Hartman
On Wed, Oct 18, 2006 at 04:54:50PM +0200, Jean Delvare wrote:
> > Signed-off-by: Akinbou Mita <akinobu.mita@gmail.com>
>
> Typo ;)
Thank you. My template was broken.
> Patch looks correct, however class devices are going away soon, and
> this patch will conflict with Greg's work:
> http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/driver-class/i2c-dev-device.patch
>
> So your patch should apply on top of Greg's, if still needed after his
> changes. It might even be later folded into Greg's patch to make things
> easier to handle.
I made the patch on top of i2c-dev-device.patch
Subject: i2c: Fix return value check
device_create() returns error code as pointer on failures.
This patch checks the return value of device_create() by using IS_ERR().
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
drivers/i2c/i2c-dev.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Index: work-fault-inject/drivers/i2c/i2c-dev.c
===================================================================
--- work-fault-inject.orig/drivers/i2c/i2c-dev.c
+++ work-fault-inject/drivers/i2c/i2c-dev.c
@@ -417,8 +417,8 @@ static int i2cdev_attach_adapter(struct
i2c_dev->dev = device_create(i2c_dev_class, &adap->dev,
MKDEV(I2C_MAJOR, adap->nr),
"i2c-%d", adap->nr);
- if (!i2c_dev->dev) {
- res = -ENODEV;
+ if (IS_ERR(i2c_dev->dev)) {
+ res = PTR_ERR(i2c_dev->dev);
goto error;
}
res = device_create_file(i2c_dev->dev, &dev_attr_name);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] i2c: Fix return value check
2006-10-19 3:28 ` Akinobu Mita
@ 2006-10-19 10:11 ` Jean Delvare
0 siblings, 0 replies; 4+ messages in thread
From: Jean Delvare @ 2006-10-19 10:11 UTC (permalink / raw)
To: Akinobu Mita, Greg Kroah-Hartman; +Cc: linux-kernel
Hi Akinobu,
On Thu, 19 Oct 2006 12:28:01 +0900, Akinobu Mita wrote:
> On Wed, Oct 18, 2006 at 04:54:50PM +0200, Jean Delvare wrote:
> > Patch looks correct, however class devices are going away soon, and
> > this patch will conflict with Greg's work:
> > http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/driver-class/i2c-dev-device.patch
> >
> > So your patch should apply on top of Greg's, if still needed after his
> > changes. It might even be later folded into Greg's patch to make things
> > easier to handle.
>
> I made the patch on top of i2c-dev-device.patch
>
> Subject: i2c: Fix return value check
>
> device_create() returns error code as pointer on failures.
> This patch checks the return value of device_create() by using IS_ERR().
>
> Cc: Greg Kroah-Hartman <gregkh@suse.de>
> Cc: Jean Delvare <khali@linux-fr.org>
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
>
> drivers/i2c/i2c-dev.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> Index: work-fault-inject/drivers/i2c/i2c-dev.c
> ===================================================================
> --- work-fault-inject.orig/drivers/i2c/i2c-dev.c
> +++ work-fault-inject/drivers/i2c/i2c-dev.c
> @@ -417,8 +417,8 @@ static int i2cdev_attach_adapter(struct
> i2c_dev->dev = device_create(i2c_dev_class, &adap->dev,
> MKDEV(I2C_MAJOR, adap->nr),
> "i2c-%d", adap->nr);
> - if (!i2c_dev->dev) {
> - res = -ENODEV;
> + if (IS_ERR(i2c_dev->dev)) {
> + res = PTR_ERR(i2c_dev->dev);
> goto error;
> }
> res = device_create_file(i2c_dev->dev, &dev_attr_name);
Great, thanks. I've this in my tree now so it won't be lost.
Greg, do you want to fold this into i2c-dev-device.patch?
Thanks,
--
Jean Delvare
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-10-19 10:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-17 6:24 [PATCH] i2c: Fix return value check Akinobu Mita
2006-10-18 14:54 ` Jean Delvare
2006-10-19 3:28 ` Akinobu Mita
2006-10-19 10:11 ` Jean Delvare
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox