Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/i2c dedup code.



details:   https://anonhg.NetBSD.org/src/rev/7772dd057eb0
branches:  trunk
changeset: 807298:7772dd057eb0
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Apr 04 15:16:54 2015 +0000

description:
dedup code.

diffstat:

 sys/dev/i2c/i2c.c |  18 +++++++-----------
 1 files changed, 7 insertions(+), 11 deletions(-)

diffs (50 lines):

diff -r d4f8cc7090dd -r 7772dd057eb0 sys/dev/i2c/i2c.c
--- a/sys/dev/i2c/i2c.c Sat Apr 04 15:14:42 2015 +0000
+++ b/sys/dev/i2c/i2c.c Sat Apr 04 15:16:54 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i2c.c,v 1.47 2015/04/04 15:14:42 riastradh Exp $       */
+/*     $NetBSD: i2c.c,v 1.48 2015/04/04 15:16:54 christos Exp $        */
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.47 2015/04/04 15:14:42 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.48 2015/04/04 15:16:54 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -519,19 +519,14 @@
                if (cmd == NULL)
                        return ENOMEM;
                error = copyin(iie->iie_cmd, cmd, iie->iie_cmdlen);
-               if (error) {
-                       kmem_free(cmd, iie->iie_cmdlen);
-                       return error;
-               }
+               if (error)
+                       goto out;
        }
 
        if (iie->iie_buf != NULL && I2C_OP_WRITE_P(iie->iie_op)) {
                error = copyin(iie->iie_buf, buf, iie->iie_buflen);
-               if (error) {
-                       if (cmd)
-                               kmem_free(cmd, iie->iie_cmdlen);
-                       return error;
-               }
+               if (error)
+                       goto out;
        }
 
        iic_acquire_bus(ic, 0);
@@ -545,6 +540,7 @@
        if (error < 0)
                error = EIO;
 
+out:
        if (cmd)
                kmem_free(cmd, iie->iie_cmdlen);
 



Home | Main Index | Thread Index | Old Index