* [PATCH] powerpc/BSR: cleanup the error path of bsr_init
@ 2012-07-15 13:22 Devendra Naga
2012-07-15 19:52 ` Arnd Bergmann
0 siblings, 1 reply; 2+ messages in thread
From: Devendra Naga @ 2012-07-15 13:22 UTC (permalink / raw)
To: Arnd Bergmann, Greg Kroah-Hartman, linux-kernel; +Cc: Devendra Naga
class_create if succeeded returns a pointer to the struct class,
and if it fails, it returns a value enclosed by the pointer, which
can be read by using PTR_ERR.
Handle the error and return it.
result is for error checking of the alloc_chrdev_region, instead
ret can be used, and also if the alloc_chrdev_region fail,
we are still returning -ENODEV, use ret and the error path will
take care of returning of the ret.
Signed-off-by: Devendra Naga <develkernel412222@gmail.com>
---
This patch is not compile tested because i dont have the
powerpc toolchain, i am trying hard to setit up one,
drivers/char/bsr.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/char/bsr.c b/drivers/char/bsr.c
index 0c68823..9746705 100644
--- a/drivers/char/bsr.c
+++ b/drivers/char/bsr.c
@@ -297,7 +297,6 @@ static int __init bsr_init(void)
struct device_node *np;
dev_t bsr_dev;
int ret = -ENODEV;
- int result;
np = of_find_compatible_node(NULL, NULL, "ibm,bsr");
if (!np)
@@ -306,13 +305,14 @@ static int __init bsr_init(void)
bsr_class = class_create(THIS_MODULE, "bsr");
if (IS_ERR(bsr_class)) {
printk(KERN_ERR "class_create() failed for bsr_class\n");
+ ret = PTR_ERR(bsr_class);
goto out_err_1;
}
bsr_class->dev_attrs = bsr_dev_attrs;
- result = alloc_chrdev_region(&bsr_dev, 0, BSR_MAX_DEVS, "bsr");
+ ret = alloc_chrdev_region(&bsr_dev, 0, BSR_MAX_DEVS, "bsr");
bsr_major = MAJOR(bsr_dev);
- if (result < 0) {
+ if (ret < 0) {
printk(KERN_ERR "alloc_chrdev_region() failed for bsr\n");
goto out_err_2;
}
--
1.7.0.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] powerpc/BSR: cleanup the error path of bsr_init
2012-07-15 13:22 [PATCH] powerpc/BSR: cleanup the error path of bsr_init Devendra Naga
@ 2012-07-15 19:52 ` Arnd Bergmann
0 siblings, 0 replies; 2+ messages in thread
From: Arnd Bergmann @ 2012-07-15 19:52 UTC (permalink / raw)
To: Devendra Naga; +Cc: Greg Kroah-Hartman, linux-kernel
On Sunday 15 July 2012, Devendra Naga wrote:
> class_create if succeeded returns a pointer to the struct class,
> and if it fails, it returns a value enclosed by the pointer, which
> can be read by using PTR_ERR.
>
> Handle the error and return it.
>
> result is for error checking of the alloc_chrdev_region, instead
> ret can be used, and also if the alloc_chrdev_region fail,
> we are still returning -ENODEV, use ret and the error path will
> take care of returning of the ret.
>
> Signed-off-by: Devendra Naga <develkernel412222@gmail.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-07-15 19:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-15 13:22 [PATCH] powerpc/BSR: cleanup the error path of bsr_init Devendra Naga
2012-07-15 19:52 ` Arnd Bergmann
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.