carlu: fix error code propagation
authorChristian Lamparter <chunkeey@googlemail.com>
Tue, 15 Feb 2011 11:02:54 +0000 (12:02 +0100)
committerChristian Lamparter <chunkeey@googlemail.com>
Tue, 15 Feb 2011 11:02:54 +0000 (12:02 +0100)
Signed-off-by: Christian Lamparter <chunkeey@googlemail.com>
tools/carlu/src/usb.c

index f242c97c57ab432856c3ad2122430b5920e7204e..ebc19a92307be57a11a72e80a1bb786c56215924 100644 (file)
@@ -253,7 +253,7 @@ static void carlusb_zap_queues(struct carlu *ar)
 
 static void carlusb_free_driver(struct carlu *ar)
 {
-       if (ar) {
+       if (!IS_ERR_OR_NULL(ar)) {
                if (ar->event_pipe[0] > -1)
                        close(ar->event_pipe[0]);
 
@@ -303,7 +303,7 @@ static struct carlu *carlusb_open(void)
 
 err_out:
        carlusb_free_driver(tmp);
-       return NULL;
+       return ERR_PTR(err);
 }
 
 static void carlusb_cancel_rings(struct carlu *ar)
@@ -692,8 +692,11 @@ struct carlu *carlusb_probe(void)
        int ret = -ENOMEM;
 
        ar = carlusb_open();
-       if (ar == NULL)
+       if (IS_ERR_OR_NULL(ar)) {
+               if (IS_ERR(ar))
+                       ret = PTR_ERR(ar);
                goto err_out;
+       }
 
        ret = carlusb_show_devinfo(ar);
        if (ret)
@@ -740,8 +743,7 @@ err_kill:
 err_out:
        carlusb_free_driver(ar);
        err("usb device rendezvous failed (%d).\n", ret);
-
-       return NULL;
+       return ERR_PTR(ret);
 }
 
 void carlusb_close(struct carlu *ar)