Source-Changes-HG archive

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

[src/trunk]: src/sys/sys Replace devhandle_invalidate(), which invalidates a ...



details:   https://anonhg.NetBSD.org/src/rev/c8d45534f941
branches:  trunk
changeset: 359750:c8d45534f941
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Fri Jan 21 15:55:36 2022 +0000

description:
Replace devhandle_invalidate(), which invalidates a devhandle, with
devhandle_invalid(), which returns an invalid devhandle.

diffstat:

 sys/arch/sparc/sparc/promlib.c |  10 +++-------
 sys/dev/i2c/i2c.c              |   6 +++---
 sys/dev/pci/pci.c              |   6 +++---
 sys/kern/subr_device.c         |  15 +++++++++------
 sys/sys/device.h               |   4 ++--
 5 files changed, 20 insertions(+), 21 deletions(-)

diffs (140 lines):

diff -r 85042e33431c -r c8d45534f941 sys/arch/sparc/sparc/promlib.c
--- a/sys/arch/sparc/sparc/promlib.c    Fri Jan 21 15:07:33 2022 +0000
+++ b/sys/arch/sparc/sparc/promlib.c    Fri Jan 21 15:55:36 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: promlib.c,v 1.50 2021/09/17 16:16:18 thorpej Exp $ */
+/*     $NetBSD: promlib.c,v 1.51 2022/01/21 15:55:36 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: promlib.c,v 1.50 2021/09/17 16:16:18 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: promlib.c,v 1.51 2022/01/21 15:55:36 thorpej Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_sparc_arch.h"
@@ -99,11 +99,7 @@
 static devhandle_t
 null_prom_to_devhandle(int node __unused)
 {
-       devhandle_t devhandle;
-
-       devhandle_invalidate(&devhandle);
-
-       return devhandle;
+       return devhandle_invalid();
 }
 
 static int
diff -r 85042e33431c -r c8d45534f941 sys/dev/i2c/i2c.c
--- a/sys/dev/i2c/i2c.c Fri Jan 21 15:07:33 2022 +0000
+++ b/sys/dev/i2c/i2c.c Fri Jan 21 15:55:36 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i2c.c,v 1.81 2022/01/17 19:34:31 thorpej Exp $ */
+/*     $NetBSD: i2c.c,v 1.82 2022/01/21 15:55:36 thorpej Exp $ */
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -53,7 +53,7 @@
 #endif /* _KERNEL_OPT */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.81 2022/01/17 19:34:31 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.82 2022/01/21 15:55:36 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -495,7 +495,7 @@
                        ia.ia_cookietype = cookietype;
                        ia.ia_prop = dev;
 
-                       devhandle_invalidate(&devhandle);
+                       devhandle = devhandle_invalid();
 #ifdef I2C_USE_FDT
                        if (cookietype == I2C_COOKIE_OF) {
                                devhandle = devhandle_from_of((int)cookie);
diff -r 85042e33431c -r c8d45534f941 sys/dev/pci/pci.c
--- a/sys/dev/pci/pci.c Fri Jan 21 15:07:33 2022 +0000
+++ b/sys/dev/pci/pci.c Fri Jan 21 15:55:36 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pci.c,v 1.163 2021/10/10 23:28:36 msaitoh Exp $        */
+/*     $NetBSD: pci.c,v 1.164 2022/01/21 15:55:36 thorpej Exp $        */
 
 /*
  * Copyright (c) 1995, 1996, 1997, 1998
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.163 2021/10/10 23:28:36 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.164 2022/01/21 15:55:36 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -283,7 +283,7 @@
                 * device was not found in the platform device tree.
                 * Return an invalid handle.
                 */
-               devhandle_invalidate(&args.devhandle);
+               return devhandle_invalid();
        }
 
        return args.devhandle;
diff -r 85042e33431c -r c8d45534f941 sys/kern/subr_device.c
--- a/sys/kern/subr_device.c    Fri Jan 21 15:07:33 2022 +0000
+++ b/sys/kern/subr_device.c    Fri Jan 21 15:55:36 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_device.c,v 1.9 2021/09/15 17:33:08 thorpej Exp $  */
+/*     $NetBSD: subr_device.c,v 1.10 2022/01/21 15:55:36 thorpej Exp $ */
 
 /*
  * Copyright (c) 2006, 2021 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_device.c,v 1.9 2021/09/15 17:33:08 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_device.c,v 1.10 2022/01/21 15:55:36 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -57,11 +57,14 @@
        return devhandle_is_valid_internal(&handle);
 }
 
-void
-devhandle_invalidate(devhandle_t * const handlep)
+devhandle_t
+devhandle_invalid(void)
 {
-       handlep->impl = NULL;
-       handlep->uintptr = 0;
+       static const devhandle_t invalid_devhandle = {
+               .impl = NULL,
+               .uintptr = 0,
+       };
+       return invalid_devhandle;
 }
 
 devhandle_type_t
diff -r 85042e33431c -r c8d45534f941 sys/sys/device.h
--- a/sys/sys/device.h  Fri Jan 21 15:07:33 2022 +0000
+++ b/sys/sys/device.h  Fri Jan 21 15:55:36 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: device.h,v 1.175 2021/09/15 17:33:08 thorpej Exp $ */
+/* $NetBSD: device.h,v 1.176 2022/01/21 15:55:36 thorpej Exp $ */
 
 /*
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -672,7 +672,7 @@
 devhandle_t    device_handle(device_t);
 
 bool           devhandle_is_valid(devhandle_t);
-void           devhandle_invalidate(devhandle_t *);
+devhandle_t    devhandle_invalid(void);
 devhandle_type_t devhandle_type(devhandle_t);
 
 device_call_t  devhandle_lookup_device_call(devhandle_t, const char *,



Home | Main Index | Thread Index | Old Index