Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/powerpc/booke/dev powerpc: Use config_detach_childr...



details:   https://anonhg.NetBSD.org/src/rev/7037819433cf
branches:  trunk
changeset: 374686:7037819433cf
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Wed May 10 00:08:07 2023 +0000

description:
powerpc: Use config_detach_children to reduce error branch bugs.

diffstat:

 sys/arch/powerpc/booke/dev/pq3cfi.c     |  15 ++++++++-------
 sys/arch/powerpc/booke/dev/pq3nandfcm.c |  13 +++++++------
 2 files changed, 15 insertions(+), 13 deletions(-)

diffs (74 lines):

diff -r 1d5d49d6ede0 -r 7037819433cf sys/arch/powerpc/booke/dev/pq3cfi.c
--- a/sys/arch/powerpc/booke/dev/pq3cfi.c       Wed May 10 00:07:58 2023 +0000
+++ b/sys/arch/powerpc/booke/dev/pq3cfi.c       Wed May 10 00:08:07 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pq3cfi.c,v 1.7 2020/07/06 10:22:44 rin Exp $   */
+/*     $NetBSD: pq3cfi.c,v 1.8 2023/05/10 00:08:07 riastradh Exp $     */
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pq3cfi.c,v 1.7 2020/07/06 10:22:44 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3cfi.c,v 1.8 2023/05/10 00:08:07 riastradh Exp $");
 
 #include "locators.h"
 
@@ -164,14 +164,15 @@ static int
 pq3cfi_detach(device_t self, int flags)
 {
        struct pq3cfi_softc *sc = device_private(self);
-       int rv = 0;
+       int error;
+
+       error = config_detach_children(self, flags);
+       if (error)
+               return error;
 
        pmf_device_deregister(self);
 
-       if (sc->sc_nordev != NULL)
-               rv = config_detach(sc->sc_nordev, flags);
-
        bus_space_unmap(sc->sc_cfi.cfi_bst, sc->sc_cfi.cfi_bsh, sc->sc_size);
 
-       return rv;
+       return 0;
 }
diff -r 1d5d49d6ede0 -r 7037819433cf sys/arch/powerpc/booke/dev/pq3nandfcm.c
--- a/sys/arch/powerpc/booke/dev/pq3nandfcm.c   Wed May 10 00:07:58 2023 +0000
+++ b/sys/arch/powerpc/booke/dev/pq3nandfcm.c   Wed May 10 00:08:07 2023 +0000
@@ -30,7 +30,7 @@
 #define LBC_PRIVATE
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pq3nandfcm.c,v 1.4 2020/07/06 10:22:44 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3nandfcm.c,v 1.5 2023/05/10 00:08:07 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -111,16 +111,17 @@ int
 pq3nandfcm_detach(device_t self, int flags)
 {
        struct pq3nandfcm_softc * const sc = device_private(self);
-       int rv = 0;
+       int error;
+
+       error = config_detach_children(self, flags);
+       if (error)
+               return error;
 
        pmf_device_deregister(self);
 
-       if (sc->sc_nanddev != NULL)
-               rv = config_detach(sc->sc_nanddev, flags);
-
        bus_space_unmap(sc->sc_window_bst, sc->sc_window_bsh,
            sc->sc_window_size);
-       return rv;
+       return 0;
 }
 void
 pq3nandfcm_command(device_t self, uint8_t command)



Home | Main Index | Thread Index | Old Index