Source-Changes-HG archive

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

[src/pgoyette-compat]: src/sys Split the COMPAT_CALL_HOOK to separate the dec...



details:   https://anonhg.NetBSD.org/src/rev/8528aa7dd8d6
branches:  pgoyette-compat
changeset: 830720:8528aa7dd8d6
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Tue Sep 18 01:15:57 2018 +0000

description:
Split the COMPAT_CALL_HOOK to separate the declaration from the
implementation.  Some hooks are called from multiple source files,
and the old method resulted in duplicate implementations.

Implement MP-safe hooks for the usb_subr_30 code.  Pass the helper
functions as arguments to the compat code so it does not have to
determine if the kernel contains usb code.

diffstat:

 sys/compat/common/if_43.c          |   5 +++--
 sys/compat/common/usb_subr_30.c    |  23 ++++++++++++++---------
 sys/dev/bio.c                      |   7 +++++--
 sys/dev/ccd.c                      |   8 ++++++--
 sys/dev/clockctl.c                 |   7 +++++--
 sys/dev/raidframe/rf_netbsdkintf.c |  15 +++++++++++++--
 sys/dev/sysmon/sysmon_power.c      |   7 +++++--
 sys/dev/usb/ugen.c                 |  16 ++++++++++++----
 sys/dev/usb/uhid.c                 |  17 ++++++++++++-----
 sys/dev/usb/usb.c                  |  31 +++++++++++++++++++++++++++----
 sys/dev/vnd.c                      |   9 +++++++--
 sys/dev/wscons/wsevent.c           |   7 +++++--
 sys/fs/puffs/puffs_msgif.c         |  10 ++++++++--
 sys/kern/compat_stub.c             |  27 ++-------------------------
 sys/kern/sys_module.c              |   6 ++++--
 sys/net/if_spppsubr.c              |   6 ++++--
 sys/net/rtsock.c                   |  16 ++++++++++++----
 sys/opencrypto/cryptodev.c         |   6 ++++--
 sys/sys/compat_stub.h              |  26 +++++++++-----------------
 19 files changed, 157 insertions(+), 92 deletions(-)

diffs (truncated from 741 to 300 lines):

diff -r de536bea7c5b -r 8528aa7dd8d6 sys/compat/common/if_43.c
--- a/sys/compat/common/if_43.c Tue Sep 18 01:11:33 2018 +0000
+++ b/sys/compat/common/if_43.c Tue Sep 18 01:15:57 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_43.c,v 1.14.2.2 2018/09/17 11:04:30 pgoyette Exp $  */
+/*     $NetBSD: if_43.c,v 1.14.2.3 2018/09/18 01:15:57 pgoyette Exp $  */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1990, 1993
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_43.c,v 1.14.2.2 2018/09/17 11:04:30 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_43.c,v 1.14.2.3 2018/09/18 01:15:57 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -78,6 +78,7 @@
 #include <uvm/uvm_extern.h>
 
 /* COMPAT_HOOK for replacing the cmdcvt() function */
+COMPAT_CALL_HOOK_DECL(ieee80211_get_ostats_20_hook, f, (int cmd), (cmd), cmd);
 COMPAT_CALL_HOOK(ieee80211_get_ostats_20_hook, f, (int cmd), (cmd), cmd);
 
 u_long 
diff -r de536bea7c5b -r 8528aa7dd8d6 sys/compat/common/usb_subr_30.c
--- a/sys/compat/common/usb_subr_30.c   Tue Sep 18 01:11:33 2018 +0000
+++ b/sys/compat/common/usb_subr_30.c   Tue Sep 18 01:15:57 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usb_subr_30.c,v 1.1.2.1 2018/03/29 23:23:03 pgoyette Exp $     */
+/*     $NetBSD: usb_subr_30.c,v 1.1.2.2 2018/09/18 01:15:57 pgoyette Exp $     */
 /*     $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $   */
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usb_subr_30.c,v 1.1.2.1 2018/03/29 23:23:03 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_subr_30.c,v 1.1.2.2 2018/09/18 01:15:57 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -126,7 +126,10 @@
 
 static int
 usbd_fill_deviceinfo_old(struct usbd_device *dev,
-    struct usb_device_info_old *di, int usedev)
+    struct usb_device_info_old *di, int usedev,
+    void (*do_devinfo_vp)(struct usbd_device *, char *, size_t, char *,
+           size_t, int, int),
+    int (*do_printBCD)(char *cp, size_t l, int bcd))
 {
        struct usbd_port *p;
        int i, j, err;
@@ -134,9 +137,9 @@
        di->udi_bus = device_unit(dev->ud_bus->ub_usbctl);
        di->udi_addr = dev->ud_addr;
        di->udi_cookie = dev->ud_cookie;
-       (*vec_usbd_devinfo_vp)(dev, di->udi_vendor, sizeof(di->udi_vendor),
+       (*do_devinfo_vp)(dev, di->udi_vendor, sizeof(di->udi_vendor),
            di->udi_product, sizeof(di->udi_product), usedev, 0);
-       (*vec_usbd_printBCD)(di->udi_release, sizeof(di->udi_release),
+       (*do_printBCD)(di->udi_release, sizeof(di->udi_release),
            UGETW(dev->ud_ddesc.bcdDevice));
        di->udi_vendorNo = UGETW(dev->ud_ddesc.idVendor);
        di->udi_productNo = UGETW(dev->ud_ddesc.idProduct);
@@ -226,18 +229,20 @@
        return 0;
 }
 
+COMPAT_SET_HOOK2(usb_subr_30_hook, "usb_30", usbd_fill_deviceinfo_old,
+    usb_copy_to_old30);
+COMPAT_UNSET_HOOK2(usb_subr_30_hook);
+
 void
 usb_30_init(void)
 {
 
-       usbd30_fill_deviceinfo_old = usbd_fill_deviceinfo_old;
-       usb30_copy_to_old = usb_copy_to_old30;
+       usb_subr_30_hook_set();
 }
 
 void
 usb_30_fini(void)
 {
 
-       usbd30_fill_deviceinfo_old = (void *)enosys;
-       usb30_copy_to_old = (void *)enosys;
+       usb_subr_30_hook_unset();
 }
diff -r de536bea7c5b -r 8528aa7dd8d6 sys/dev/bio.c
--- a/sys/dev/bio.c     Tue Sep 18 01:11:33 2018 +0000
+++ b/sys/dev/bio.c     Tue Sep 18 01:15:57 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bio.c,v 1.13.16.2 2018/09/17 11:04:30 pgoyette Exp $ */
+/*     $NetBSD: bio.c,v 1.13.16.3 2018/09/18 01:15:57 pgoyette Exp $ */
 /*     $OpenBSD: bio.c,v 1.9 2007/03/20 02:35:55 marco Exp $   */
 
 /*
@@ -28,7 +28,7 @@
 /* A device controller ioctl tunnelling device.  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bio.c,v 1.13.16.2 2018/09/17 11:04:30 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bio.c,v 1.13.16.3 2018/09/18 01:15:57 pgoyette Exp $");
 
 #include "opt_compat_netbsd.h"
 
@@ -115,6 +115,9 @@
 }
 
 /* Hook up the compat_bio_30 routine */
+COMPAT_CALL_HOOK_DECL(compat_bio_30_hook, f,
+    (void * cookie, u_long cmd, void *addr, int(*ff)(void *, u_long, void *)),
+    (cookie, cmd, addr, ff), enosys());
 COMPAT_CALL_HOOK(compat_bio_30_hook, f,
     (void * cookie, u_long cmd, void *addr, int(*ff)(void *, u_long, void *)),
     (cookie, cmd, addr, ff), enosys());
diff -r de536bea7c5b -r 8528aa7dd8d6 sys/dev/ccd.c
--- a/sys/dev/ccd.c     Tue Sep 18 01:11:33 2018 +0000
+++ b/sys/dev/ccd.c     Tue Sep 18 01:15:57 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ccd.c,v 1.175.2.5 2018/09/16 04:57:22 pgoyette Exp $   */
+/*     $NetBSD: ccd.c,v 1.175.2.6 2018/09/18 01:15:57 pgoyette Exp $   */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc.
@@ -88,7 +88,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.175.2.5 2018/09/16 04:57:22 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.175.2.6 2018/09/18 01:15:57 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -1061,6 +1061,10 @@
  * This looks ugly, since we pass the "real" ioctl function as an
  * argument to the compat_xxx function.
  */
+COMPAT_CALL_HOOK_DECL(ccd_ioctl_60_hook, f, (dev_t dev, u_long cmd, void *data,
+    int flag, struct lwp *l, int (*ff)(dev_t, u_long, void *, int,
+                                        struct lwp *)),
+    (dev, cmd, data, flag, l, ccdioctl), enosys());
 COMPAT_CALL_HOOK(ccd_ioctl_60_hook, f, (dev_t dev, u_long cmd, void *data,
     int flag, struct lwp *l, int (*ff)(dev_t, u_long, void *, int,
                                         struct lwp *)),
diff -r de536bea7c5b -r 8528aa7dd8d6 sys/dev/clockctl.c
--- a/sys/dev/clockctl.c        Tue Sep 18 01:11:33 2018 +0000
+++ b/sys/dev/clockctl.c        Tue Sep 18 01:15:57 2018 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: clockctl.c,v 1.35.14.2 2018/09/17 11:04:30 pgoyette Exp $ */
+/*      $NetBSD: clockctl.c,v 1.35.14.3 2018/09/18 01:15:57 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: clockctl.c,v 1.35.14.2 2018/09/17 11:04:30 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clockctl.c,v 1.35.14.3 2018/09/18 01:15:57 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ntp.h"
@@ -201,6 +201,9 @@
 }
 
 /* Hook the compat_50 stuff */
+COMPAT_CALL_HOOK_DECL(clockctl_ioctl_50_hook, f,
+    (dev_t dev, u_long cmd, void *data, int flags, struct lwp *l),
+    (dev, cmd, data, flags, l), enosys());
 COMPAT_CALL_HOOK(clockctl_ioctl_50_hook, f,
     (dev_t dev, u_long cmd, void *data, int flags, struct lwp *l),
     (dev, cmd, data, flags, l), enosys());
diff -r de536bea7c5b -r 8528aa7dd8d6 sys/dev/raidframe/rf_netbsdkintf.c
--- a/sys/dev/raidframe/rf_netbsdkintf.c        Tue Sep 18 01:11:33 2018 +0000
+++ b/sys/dev/raidframe/rf_netbsdkintf.c        Tue Sep 18 01:15:57 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_netbsdkintf.c,v 1.356.2.3 2018/09/17 11:04:30 pgoyette Exp $        */
+/*     $NetBSD: rf_netbsdkintf.c,v 1.356.2.4 2018/09/18 01:15:57 pgoyette Exp $        */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  ***********************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.356.2.3 2018/09/17 11:04:30 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.356.2.4 2018/09/18 01:15:57 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1038,11 +1038,22 @@
 }
 
 /* Hooks to call the 5.0 and 8.0 ioctl compat code */
+COMPAT_CALL_HOOK_DECL(raidframe50_ioctl_hook, f,
+    (int cmd, int initted, RF_Raid_t *raidPtr, int unit, void *data,
+     RF_Config_t **k_cfg),
+    (cmd, initted, raidPtr, unit, data, k_cfg),
+    enosys());
 COMPAT_CALL_HOOK(raidframe50_ioctl_hook, f,
     (int cmd, int initted, RF_Raid_t *raidPtr, int unit, void *data,
      RF_Config_t **k_cfg),
     (cmd, initted, raidPtr, unit, data, k_cfg),
     enosys());
+
+COMPAT_CALL_HOOK_DECL(raidframe80_ioctl_hook, f,
+    (int cmd, int initted, RF_Raid_t *raidPtr, int unit, void *data,
+     RF_Config_t **k_cfg),
+    (cmd, initted, raidPtr, unit, data, k_cfg),
+    enosys());
 COMPAT_CALL_HOOK(raidframe80_ioctl_hook, f,
     (int cmd, int initted, RF_Raid_t *raidPtr, int unit, void *data,
      RF_Config_t **k_cfg),
diff -r de536bea7c5b -r 8528aa7dd8d6 sys/dev/sysmon/sysmon_power.c
--- a/sys/dev/sysmon/sysmon_power.c     Tue Sep 18 01:11:33 2018 +0000
+++ b/sys/dev/sysmon/sysmon_power.c     Tue Sep 18 01:15:57 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sysmon_power.c,v 1.58.2.2 2018/09/17 11:04:31 pgoyette Exp $   */
+/*     $NetBSD: sysmon_power.c,v 1.58.2.3 2018/09/18 01:15:58 pgoyette Exp $   */
 
 /*-
  * Copyright (c) 2007 Juan Romero Pardines.
@@ -69,7 +69,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.58.2.2 2018/09/17 11:04:31 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.58.2.3 2018/09/18 01:15:58 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -318,6 +318,9 @@
 /*
  * Call the compat hook function
  */
+COMPAT_CALL_HOOK_DECL(compat_sysmon_power_40_hook, f,
+    (power_event_t *pev, struct sysmon_pswitch *pswitch, int event),
+    (pev, pswitch, event), enosys());
 COMPAT_CALL_HOOK(compat_sysmon_power_40_hook, f,
     (power_event_t *pev, struct sysmon_pswitch *pswitch, int event),
     (pev, pswitch, event), enosys());
diff -r de536bea7c5b -r 8528aa7dd8d6 sys/dev/usb/ugen.c
--- a/sys/dev/usb/ugen.c        Tue Sep 18 01:11:33 2018 +0000
+++ b/sys/dev/usb/ugen.c        Tue Sep 18 01:15:57 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ugen.c,v 1.139.2.2 2018/09/06 06:56:04 pgoyette Exp $  */
+/*     $NetBSD: ugen.c,v 1.139.2.3 2018/09/18 01:15:58 pgoyette Exp $  */
 
 /*
  * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.139.2.2 2018/09/06 06:56:04 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.139.2.3 2018/09/18 01:15:58 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1439,6 +1439,13 @@
        return usbd_get_interface_altindex(iface);
 }
 
+COMPAT_CALL_HOOK_DECL(usb_subr_30_hook, f1,
+    (struct usbd_device *udev, struct usb_device_info_old * addr, int usedev,
+      void (*fill_devinfo_vp)(struct usbd_device *, char *, size_t, char *,
+       size_t, int, int), int (*printBCD)(char *, size_t, int)),
+    (udev, addr, usedev, fill_devinfo_vp, printBCD),
+    enosys());
+
 Static int
 ugen_do_ioctl(struct ugen_softc *sc, int endpt, u_long cmd,
              void *addr, int flag, struct lwp *l)
@@ -1837,8 +1844,9 @@
                                     (struct usb_device_info *)addr, 0);
                break;
        case USB_GET_DEVICEINFO_OLD:
-               if ((*usbd30_fill_deviceinfo_old)(sc->sc_udev,
-                            (struct usb_device_info_old *)addr, 0) == 0)
+               if (usb_subr_30_hook_f1_call(sc->sc_udev,
+                            (struct usb_device_info_old *)addr, 0,
+                            usbd_devinfo_vp, usbd_printBCD) == 0)
                        return 0;
                return EINVAL;
        default:
diff -r de536bea7c5b -r 8528aa7dd8d6 sys/dev/usb/uhid.c
--- a/sys/dev/usb/uhid.c        Tue Sep 18 01:11:33 2018 +0000
+++ b/sys/dev/usb/uhid.c        Tue Sep 18 01:15:57 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uhid.c,v 1.101.2.2 2018/09/06 06:56:04 pgoyette Exp $  */
+/*     $NetBSD: uhid.c,v 1.101.2.3 2018/09/18 01:15:58 pgoyette Exp $  */
 
 /*
  * Copyright (c) 1998, 2004, 2008, 2012 The NetBSD Foundation, Inc.



Home | Main Index | Thread Index | Old Index