i2c: Fix return value check
PATCH 1/1 i2c: Fix return value check
class_device_create() returns error code as pointer on failure. This patch checks the return value of class_device_create() by using IS_ERR().
drivers/i2c/i2c-dev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/i2c/i2c-dev.c +2 -2
@@ -417,8 +417,8 @@ static int i2cdev_attach_adapter(structMKDEV (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);
Hi Akinobu,
Quoted 6 lines · Akinobu Mita
class_device_create()returns error code as pointer on failure. This patch checks the return value ofclass_device_create()by usingIS_ERR().Cc Greg Kroah-Hartman <[email protected]>Cc Jean Delvare <[email protected]>Signed-off-by Akinbou Mita <[email protected]>
Typo ;)
Quoted 9 lines
drivers/i2c/i2c-dev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Index:
2.6-rc/drivers/i2c/i2c-dev.c
===================================================================
drivers/i2c/i2c-dev.c static int i2cdev_attach_adapter(struct · line 424
Quoted 10 lines
drivers/i2c/i2c-dev.c +2
-2@@ -417,8 +417,8 @@ static int i2cdev_attach_adapter(structMKDEV (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,
Signature · 1 line
Jean Delvare
Quoted 3 lines · Jean Delvare
Quoted 1 line
Signed-off-by Akinbou Mita <[email protected]>Typo ;)
Thank you. My template was broken.
Quoted 7 lines
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.patchSo 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().
drivers/i2c/i2c-dev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/i2c/i2c-dev.c +2 -2
@@ -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);
Hi Akinobu,
Quoted 28 lines · Akinobu Mita
Quoted 7 lines · Jean Delvare
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.patchSo 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 ofdevice_create()by usingIS_ERR().Cc Greg Kroah-Hartman <[email protected]>Cc Jean Delvare <[email protected]>Signed-off-by Akinobu Mita <[email protected]>drivers/i2c/i2c-dev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Index:
work-fault-inject/drivers/i2c/i2c-dev.c
===================================================================
drivers/i2c/i2c-dev.c static int i2cdev_attach_adapter(struct · line 424
Quoted 10 lines
drivers/i2c/i2c-dev.c +2
-2@@ -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,
Signature · 1 line
Jean Delvare