CVS commit: [pgoyette-localcount] src/sys/dev/pci
Module Name:src Committed By: pgoyette Date: Wed Apr 26 05:52:57 UTC 2017 Modified Files: src/sys/dev/pci [pgoyette-localcount]: pcidevs.h pcidevs_data.h Log Message: Regen To generate a diff of this commit: cvs rdiff -u -r1.1246.2.5 -r1.1246.2.6 src/sys/dev/pci/pcidevs.h cvs rdiff -u -r1.1245.2.5 -r1.1245.2.6 src/sys/dev/pci/pcidevs_data.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/pcidevs.h diff -u src/sys/dev/pci/pcidevs.h:1.1246.2.5 src/sys/dev/pci/pcidevs.h:1.1246.2.6 --- src/sys/dev/pci/pcidevs.h:1.1246.2.5 Wed Apr 26 02:53:13 2017 +++ src/sys/dev/pci/pcidevs.h Wed Apr 26 05:52:48 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: pcidevs.h,v 1.1246.2.5 2017/04/26 02:53:13 pgoyette Exp $ */ +/* $NetBSD: pcidevs.h,v 1.1246.2.6 2017/04/26 05:52:48 pgoyette Exp $ */ /* * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. @@ -701,6 +701,7 @@ #define PCI_PRODUCT_3COM_3C339 0x3390 /* 3c339 TokenLink Velocity */ #define PCI_PRODUCT_3COM_3C359 0x3590 /* 3c359 TokenLink Velocity XL */ #define PCI_PRODUCT_3COM_3C450TX 0x4500 /* 3c450-TX 10/100 Ethernet */ +#define PCI_PRODUCT_3COM_3C555 0x5055 /* 3c555 10/100 Mini-PCI Ethernet */ #define PCI_PRODUCT_3COM_3C575TX 0x5057 /* 3c575-TX 10/100 Ethernet */ #define PCI_PRODUCT_3COM_3C575BTX 0x5157 /* 3CCFE575BT 10/100 Ethernet */ #define PCI_PRODUCT_3COM_3C575CTX 0x5257 /* 3CCFE575CT 10/100 Ethernet */ @@ -708,7 +709,6 @@ #define PCI_PRODUCT_3COM_3C595TX 0x5950 /* 3c595-TX 10/100 Ethernet */ #define PCI_PRODUCT_3COM_3C595T4 0x5951 /* 3c595-T4 10/100 Ethernet */ #define PCI_PRODUCT_3COM_3C595MII 0x5952 /* 3c595-MII 10/100 Ethernet */ -#define PCI_PRODUCT_3COM_3C555 0x5055 /* 3c555 10/100 Mini-PCI Ethernet */ #define PCI_PRODUCT_3COM_3C154G72 0x6001 /* 3CRWE154G72 Wireless LAN Adapter */ #define PCI_PRODUCT_3COM_3C556 0x6055 /* 3c556 10/100 Mini-PCI Ethernet */ #define PCI_PRODUCT_3COM_3C556B 0x6056 /* 3c556B 10/100 Mini-PCI Ethernet */ @@ -724,11 +724,11 @@ #define PCI_PRODUCT_3COM_TOKEN 0x8811 /* Token Ring */ #define PCI_PRODUCT_3COM_3C900TPO 0x9000 /* 3c900-TPO Ethernet */ #define PCI_PRODUCT_3COM_3C900COMBO 0x9001 /* 3c900-COMBO Ethernet */ -#define PCI_PRODUCT_3COM_3C905TX 0x9050 /* 3c905-TX 10/100 Ethernet */ -#define PCI_PRODUCT_3COM_3C905T4 0x9051 /* 3c905-T4 10/100 Ethernet */ #define PCI_PRODUCT_3COM_3C900BTPO 0x9004 /* 3c900B-TPO Ethernet */ #define PCI_PRODUCT_3COM_3C900BCOMBO 0x9005 /* 3c900B-COMBO Ethernet */ #define PCI_PRODUCT_3COM_3C900BTPC 0x9006 /* 3c900B-TPC Ethernet */ +#define PCI_PRODUCT_3COM_3C905TX 0x9050 /* 3c905-TX 10/100 Ethernet */ +#define PCI_PRODUCT_3COM_3C905T4 0x9051 /* 3c905-T4 10/100 Ethernet */ #define PCI_PRODUCT_3COM_3C905BTX 0x9055 /* 3c905B-TX 10/100 Ethernet */ #define PCI_PRODUCT_3COM_3C905BT4 0x9056 /* 3c905B-T4 10/100 Ethernet */ #define PCI_PRODUCT_3COM_3C905BCOMBO 0x9058 /* 3c905B-COMBO 10/100 Ethernet */ @@ -829,13 +829,13 @@ #define PCI_PRODUCT_ALI_M1689 0x1689 /* M1689 Host-PCI Bridge */ #define PCI_PRODUCT_ALI_M3309 0x3309 /* M3309 MPEG Decoder */ #define PCI_PRODUCT_ALI_M4803 0x5215 /* M4803 */ -#define PCI_PRODUCT_ALI_M5257 0x5257 /* M5257 PCI Software Modem */ #define PCI_PRODUCT_ALI_M5229 0x5229 /* M5229 UDMA IDE Controller */ #define PCI_PRODUCT_ALI_M5237 0x5237 /* M5237 USB 1.1 Host Controller */ #define PCI_PRODUCT_ALI_M5239 0x5239 /* M5239 USB 2.0 Host Controller */ #define PCI_PRODUCT_ALI_M5243 0x5243 /* M5243 PCI-AGP Bridge */ #define PCI_PRODUCT_ALI_M5247 0x5247 /* M5247 PCI-AGP Bridge */ #define PCI_PRODUCT_ALI_M5249 0x5249 /* M5249 Hypertransport to PCI Bridge */ +#define PCI_PRODUCT_ALI_M5257 0x5257 /* M5257 PCI Software Modem */ #define PCI_PRODUCT_ALI_M5261 0x5261 /* M5261 Tulip Ethernet Controller */ #define PCI_PRODUCT_ALI_M5288 0x5288 /* M5288 SATA/Raid Controller */ #define PCI_PRODUCT_ALI_M5451 0x5451 /* M5451 AC-Link Controller Audio Device */ @@ -849,10 +849,10 @@ #define PCI_PRODUCT_ADP_AIC7855 0x5578 /* AIC-7855 */ #define PCI_PRODUCT_ADP_AIC5900 0x5900 /* AIC-5900 ATM */ #define PCI_PRODUCT_ADP_AIC5905 0x5905 /* AIC-5905 ATM */ -#define PCI_PRODUCT_ADP_AIC6915 0x6915 /* AIC-6915 10/100 Ethernet */ -#define PCI_PRODUCT_ADP_AIC7860 0x6078 /* AIC-7860 */ #define PCI_PRODUCT_ADP_APA1480 0x6075 /* APA-1480 Ultra */ +#define PCI_PRODUCT_ADP_AIC7860 0x6078 /* AIC-7860 */ #define PCI_PRODUCT_ADP_2940AU 0x6178 /* AHA-2940A Ultra */ +#define PCI_PRODUCT_ADP_AIC6915 0x6915 /* AIC-6915 10/100 Ethernet */ #define PCI_PRODUCT_ADP_AIC7870 0x7078 /* AIC-7870 */ #define PCI_PRODUCT_ADP_2940 0x7178 /* AHA-2940 */ #define PCI_PRODUCT_ADP_3940 0x7278 /* AHA-3940 */ @@ -883,6 +883,7 @@ #define PCI_PRODUCT_ADP2_AIC7899P 0x00cf /* AIC-7899P U160 */ #define PCI_PRODUCT_ADP2_1420SA 0x0241 /* RAID 1420SA */ #define PCI_PRODUCT_ADP2_1430SA 0x0243 /* RAID 1430SA */ +#define PCI_PRODUCT_ADP2_SERVERAID
CVS commit: [pgoyette-localcount] src/sys/dev/pci
Module Name:src Committed By: pgoyette Date: Wed Apr 26 05:35:36 UTC 2017 Modified Files: src/sys/dev/pci [pgoyette-localcount]: pcidevs Log Message: Somehow this got out of sync on the branch. To generate a diff of this commit: cvs rdiff -u -r1.1253.2.5 -r1.1253.2.6 src/sys/dev/pci/pcidevs Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/pcidevs diff -u src/sys/dev/pci/pcidevs:1.1253.2.5 src/sys/dev/pci/pcidevs:1.1253.2.6 --- src/sys/dev/pci/pcidevs:1.1253.2.5 Wed Apr 26 02:53:13 2017 +++ src/sys/dev/pci/pcidevs Wed Apr 26 05:35:36 2017 @@ -1,4 +1,4 @@ -$NetBSD: pcidevs,v 1.1253.2.5 2017/04/26 02:53:13 pgoyette Exp $ +$NetBSD: pcidevs,v 1.1253.2.6 2017/04/26 05:35:36 pgoyette Exp $ /* * Copyright (c) 1995, 1996 Christopher G. Demetriou @@ -694,6 +694,7 @@ product 3COM 3C940 0x1700 3c940 Gigabit product 3COM 3C339 0x3390 3c339 TokenLink Velocity product 3COM 3C359 0x3590 3c359 TokenLink Velocity XL product 3COM 3C450TX 0x4500 3c450-TX 10/100 Ethernet +product 3COM 3C555 0x5055 3c555 10/100 Mini-PCI Ethernet product 3COM 3C575TX 0x5057 3c575-TX 10/100 Ethernet product 3COM 3C575BTX 0x5157 3CCFE575BT 10/100 Ethernet product 3COM 3C575CTX 0x5257 3CCFE575CT 10/100 Ethernet @@ -701,7 +702,6 @@ product 3COM 3C590 0x5900 3c590 Ethernet product 3COM 3C595TX 0x5950 3c595-TX 10/100 Ethernet product 3COM 3C595T4 0x5951 3c595-T4 10/100 Ethernet product 3COM 3C595MII 0x5952 3c595-MII 10/100 Ethernet -product 3COM 3C555 0x5055 3c555 10/100 Mini-PCI Ethernet product 3COM 3C154G72 0x6001 3CRWE154G72 Wireless LAN Adapter product 3COM 3C556 0x6055 3c556 10/100 Mini-PCI Ethernet product 3COM 3C556B 0x6056 3c556B 10/100 Mini-PCI Ethernet @@ -717,11 +717,11 @@ product 3COM 3C804 0x7980 3c804 FDDILink product 3COM TOKEN 0x8811 Token Ring product 3COM 3C900TPO 0x9000 3c900-TPO Ethernet product 3COM 3C900COMBO 0x9001 3c900-COMBO Ethernet -product 3COM 3C905TX 0x9050 3c905-TX 10/100 Ethernet -product 3COM 3C905T4 0x9051 3c905-T4 10/100 Ethernet product 3COM 3C900BTPO 0x9004 3c900B-TPO Ethernet product 3COM 3C900BCOMBO 0x9005 3c900B-COMBO Ethernet product 3COM 3C900BTPC 0x9006 3c900B-TPC Ethernet +product 3COM 3C905TX 0x9050 3c905-TX 10/100 Ethernet +product 3COM 3C905T4 0x9051 3c905-T4 10/100 Ethernet product 3COM 3C905BTX 0x9055 3c905B-TX 10/100 Ethernet product 3COM 3C905BT4 0x9056 3c905B-T4 10/100 Ethernet product 3COM 3C905BCOMBO 0x9058 3c905B-COMBO 10/100 Ethernet @@ -822,13 +822,13 @@ product ALI M1647 0x1647 M1647 Host-PCI product ALI M1689 0x1689 M1689 Host-PCI Bridge product ALI M3309 0x3309 M3309 MPEG Decoder product ALI M4803 0x5215 M4803 -product ALI M5257 0x5257 M5257 PCI Software Modem product ALI M5229 0x5229 M5229 UDMA IDE Controller product ALI M5237 0x5237 M5237 USB 1.1 Host Controller product ALI M5239 0x5239 M5239 USB 2.0 Host Controller product ALI M5243 0x5243 M5243 PCI-AGP Bridge product ALI M5247 0x5247 M5247 PCI-AGP Bridge product ALI M5249 0x5249 M5249 Hypertransport to PCI Bridge +product ALI M5257 0x5257 M5257 PCI Software Modem product ALI M5261 0x5261 M5261 Tulip Ethernet Controller product ALI M5288 0x5288 M5288 SATA/Raid Controller product ALI M5451 0x5451 M5451 AC-Link Controller Audio Device @@ -842,10 +842,10 @@ product ADP AIC7850 0x5078 AIC-7850 product ADP AIC7855 0x5578 AIC-7855 product ADP AIC5900 0x5900 AIC-5900 ATM product ADP AIC5905 0x5905 AIC-5905 ATM -product ADP AIC6915 0x6915 AIC-6915 10/100 Ethernet -product ADP AIC7860 0x6078 AIC-7860 product ADP APA1480 0x6075 APA-1480 Ultra +product ADP AIC7860 0x6078 AIC-7860 product ADP 2940AU 0x6178 AHA-2940A Ultra +product ADP AIC6915 0x6915 AIC-6915 10/100 Ethernet product ADP AIC7870 0x7078 AIC-7870 product ADP 2940 0x7178 AHA-2940 product ADP 3940 0x7278 AHA-3940 @@ -876,6 +876,7 @@ product ADP2 AIC7899F 0x00c5 AIC-7899F product ADP2 AIC7899P 0x00cf AIC-7899P U160 product ADP2 1420SA 0x0241 RAID 1420SA product ADP2 1430SA 0x0243 RAID 1430SA +product ADP2 SERVERAID 0x0250 ServeRAID 6/7 (marco) product ADP2 AAC2622 0x0282 AAC-2622 product ADP2 ASR2200S 0x0285 ASR-2200S product ADP2 ASR2120S 0x0286 ASR-2120S @@ -891,11 +892,10 @@ product ADP2 PERC_2QC 0x1364 Dell PERC /* XXX guess */ product ADP2 PERC_3QC 0x1365 Dell PERC 3/QC product ADP2 HP_M110_G2 0x3227 HP M110 G2 / ASR-2610SA -product ADP2 SERVERAID 0x0250 ServeRAID 6/7 (marco) /* Addtron Products */ -product ADDTRON 8139 0x1360 8139 Ethernet product ADDTRON RHINEII 0x1320 Rhine II 10/100 Ethernet +product ADDTRON 8139 0x1360 8139 Ethernet /* ADMtek products */ product ADMTEK AL981 0x0981 AL981 (Comet) 10/100 Ethernet @@ -920,9 +920,9 @@ product AGILENT TACHYON_DX2 0x0100 Tachy /* Aironet Wireless Communicasions products */ product AIRONET PC4xxx 0x0001 PC4500/PC4800 Wireless LAN Adapter product AIRONET PCI350 0x0350 PCI350 Wireless LAN Adapter -product AIRONET MPI350
CVS commit: [pgoyette-localcount] src/sys/dev/pci
Module Name:src Committed By: pgoyette Date: Wed Apr 26 05:35:36 UTC 2017 Modified Files: src/sys/dev/pci [pgoyette-localcount]: pcidevs Log Message: Somehow this got out of sync on the branch. To generate a diff of this commit: cvs rdiff -u -r1.1253.2.5 -r1.1253.2.6 src/sys/dev/pci/pcidevs Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Sun Jul 31 13:12:59 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: fss.c Log Message: mport rev 1.95 from HEAD To generate a diff of this commit: cvs rdiff -u -r1.93.2.6 -r1.93.2.7 src/sys/dev/fss.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fss.c diff -u src/sys/dev/fss.c:1.93.2.6 src/sys/dev/fss.c:1.93.2.7 --- src/sys/dev/fss.c:1.93.2.6 Sun Jul 31 01:36:49 2016 +++ src/sys/dev/fss.c Sun Jul 31 13:12:59 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: fss.c,v 1.93.2.6 2016/07/31 01:36:49 pgoyette Exp $ */ +/* $NetBSD: fss.c,v 1.93.2.7 2016/07/31 13:12:59 pgoyette Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.93.2.6 2016/07/31 01:36:49 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.93.2.7 2016/07/31 13:12:59 pgoyette Exp $"); #include #include @@ -472,17 +472,20 @@ fss_dump(dev_t dev, daddr_t blkno, void /* * An error occurred reading or writing the snapshot or backing store. - * If it is the first error log to console. + * If it is the first error log to console and disestablish cow handler. * The caller holds the mutex. */ static inline void fss_error(struct fss_softc *sc, const char *msg) { - if ((sc->sc_flags & (FSS_ACTIVE|FSS_ERROR)) == FSS_ACTIVE) - aprint_error_dev(sc->sc_dev, "snapshot invalid: %s\n", msg); - if ((sc->sc_flags & FSS_ACTIVE) == FSS_ACTIVE) - sc->sc_flags |= FSS_ERROR; + if ((sc->sc_flags & (FSS_ACTIVE | FSS_ERROR)) != FSS_ACTIVE) + return; + + aprint_error_dev(sc->sc_dev, "snapshot invalid: %s\n", msg); + if ((sc->sc_flags & FSS_PERSISTENT) == 0) + fscow_disestablish(sc->sc_mount, fss_copy_on_write, sc); + sc->sc_flags |= FSS_ERROR; } /* @@ -605,9 +608,8 @@ fss_unmount_hook(struct mount *mp) continue; sc = device_private(self); mutex_enter(>sc_slock); - if ((sc->sc_flags & FSS_ACTIVE) != 0 && - sc->sc_mount == mp) - fss_error(sc, "forced unmount"); + if ((sc->sc_flags & FSS_ACTIVE) != 0 && sc->sc_mount == mp) + fss_error(sc, "forced by unmount"); mutex_exit(>sc_slock); device_release(self); } @@ -917,7 +919,7 @@ static int fss_delete_snapshot(struct fss_softc *sc, struct lwp *l) { - if ((sc->sc_flags & FSS_PERSISTENT) == 0) + if ((sc->sc_flags & (FSS_PERSISTENT | FSS_ERROR)) == 0) fscow_disestablish(sc->sc_mount, fss_copy_on_write, sc); mutex_enter(>sc_slock);
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Sun Jul 31 13:12:59 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: fss.c Log Message: mport rev 1.95 from HEAD To generate a diff of this commit: cvs rdiff -u -r1.93.2.6 -r1.93.2.7 src/sys/dev/fss.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Sun Jul 31 01:32:00 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: ld.c Log Message: Use after initialization, not before To generate a diff of this commit: cvs rdiff -u -r1.94.2.4 -r1.94.2.5 src/sys/dev/ld.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ld.c diff -u src/sys/dev/ld.c:1.94.2.4 src/sys/dev/ld.c:1.94.2.5 --- src/sys/dev/ld.c:1.94.2.4 Wed Jul 27 01:13:50 2016 +++ src/sys/dev/ld.c Sun Jul 31 01:32:00 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ld.c,v 1.94.2.4 2016/07/27 01:13:50 pgoyette Exp $ */ +/* $NetBSD: ld.c,v 1.94.2.5 2016/07/31 01:32:00 pgoyette Exp $ */ /*- * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.94.2.4 2016/07/27 01:13:50 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.94.2.5 2016/07/31 01:32:00 pgoyette Exp $"); #include #include @@ -627,10 +627,11 @@ static void ld_config_interrupts(device_t d) { struct ld_softc *sc; - struct dk_softc *dksc = >sc_dksc; + struct dk_softc *dksc; device_acquire(d); sc = device_private(d); + dksc = >sc_dksc; dkwedge_discover(>sc_dkdev); device_release(d); } @@ -654,6 +655,7 @@ ld_discard(device_t dev, off_t pos, off_ static int lddiscard(dev_t dev, off_t pos, off_t len) { + device_t self; struct ld_softc *sc; struct dk_softc *dksc; int unit;
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Thu Jul 28 23:59:15 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: md.c Log Message: Since md(4) has a pointer from the softc back to the device_t, it is OK for us to use device_lookup_private_acquire() rather than calling device_lookup_acquire() followed by device_private(). So, redo earlier changes, which reduces diff to the original code at the branch-point. To generate a diff of this commit: cvs rdiff -u -r1.76.2.5 -r1.76.2.6 src/sys/dev/md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/md.c diff -u src/sys/dev/md.c:1.76.2.5 src/sys/dev/md.c:1.76.2.6 --- src/sys/dev/md.c:1.76.2.5 Wed Jul 27 03:25:00 2016 +++ src/sys/dev/md.c Thu Jul 28 23:59:15 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.76.2.5 2016/07/27 03:25:00 pgoyette Exp $ */ +/* $NetBSD: md.c,v 1.76.2.6 2016/07/28 23:59:15 pgoyette Exp $ */ /* * Copyright (c) 1995 Gordon W. Ross, Leo Weppelman. @@ -40,7 +40,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.76.2.5 2016/07/27 03:25:00 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.76.2.6 2016/07/28 23:59:15 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_md.h" @@ -243,14 +243,12 @@ static int md_ioctl_kalloc(struct md_sof static int mdsize(dev_t dev) { - device_t self; struct md_softc *sc; int res; - self = device_lookup_acquire(_cd, MD_UNIT(dev)); - if (self == NULL) + sc = device_lookup_private_acquire(_cd, MD_UNIT(dev)); + if (sc == NULL) return 0; - sc = device_private(self); mutex_enter(>sc_lock); if (sc->sc_type == MD_UNCONFIGURED) @@ -259,14 +257,14 @@ mdsize(dev_t dev) res = sc->sc_size >> DEV_BSHIFT; mutex_exit(>sc_lock); - device_release(self); + device_release(sc->sc_dev); return res; } static int mdopen(dev_t dev, int flag, int fmt, struct lwp *l) { - device_t self; + device_t self, new_self; int unit; int part = DISKPART(dev); int pmask = 1 << part; @@ -279,9 +277,8 @@ mdopen(dev_t dev, int flag, int fmt, str mutex_enter(_device_lock); unit = MD_UNIT(dev); - sc = NULL; - self = device_lookup_acquire(_cd, unit); - if (self == NULL) { + sc = device_lookup_private_acquire(_cd, unit); + if (sc == NULL) { if (part != RAW_PART) { mutex_exit(_device_lock); return ENXIO; @@ -291,19 +288,16 @@ mdopen(dev_t dev, int flag, int fmt, str cf->cf_atname = md_cd.cd_name; cf->cf_unit = unit; cf->cf_fstate = FSTATE_STAR; - self = config_attach_pseudo(cf); - if (self != NULL) { - device_acquire(self); - sc = device_private(self); - } + new_self = config_attach_pseudo(cf); + self = device_lookup_acquire(_cd, unit); + KASSERT(self == new_self); + sc = device_private(self); if (sc == NULL) { mutex_exit(_device_lock); - device_release(self); + device_release(sc->sc_dev); return ENOMEM; } } - else - sc = device_private(self); dk = >sc_dkdev; @@ -328,11 +322,11 @@ mdopen(dev_t dev, int flag, int fmt, str */ if (sc->sc_type == MD_UNCONFIGURED) { mutex_exit(_device_lock); - device_release(self); + device_release(sc->sc_dev); return ENXIO; } -ok: + ok: /* XXX duplicates code in dk_open(). Call dk_open(), instead? */ mutex_enter(>dk_openlock); /* Mark our unit as open. */ @@ -349,14 +343,13 @@ ok: mutex_exit(>dk_openlock); mutex_exit(_device_lock); - device_release(self); + device_release(sc->sc_dev); return 0; } static int mdclose(dev_t dev, int flag, int fmt, struct lwp *l) { - device_t self; int part = DISKPART(dev); int pmask = 1 << part; int error; @@ -364,10 +357,9 @@ mdclose(dev_t dev, int flag, int fmt, st struct md_softc *sc; struct disk *dk; - self = device_lookup_acquire(_cd, MD_UNIT(dev)); - if (self == NULL) + sc = device_lookup_private_acquire(_cd, MD_UNIT(dev)); + if (sc == NULL) return ENXIO; - sc = device_private(self); dk = >sc_dkdev; @@ -384,7 +376,7 @@ mdclose(dev_t dev, int flag, int fmt, st dk->dk_openmask = dk->dk_copenmask | dk->dk_bopenmask; if (dk->dk_openmask != 0) { mutex_exit(>dk_openlock); - device_release(self); + device_release(sc->sc_dev); return 0; } @@ -396,52 +388,48 @@ mdclose(dev_t dev, int flag, int fmt, st if (! error) free(cf, M_DEVBUF); mutex_exit(_device_lock); - device_release(self); + if (error) + device_release(sc->sc_dev); return error; } static int mdread(dev_t dev, struct uio *uio, int flags) { - device_t self; struct md_softc *sc; int error; - self = device_lookup_acquire(_cd, MD_UNIT(dev)); - if (self == NULL) - return ENXIO; + sc = device_lookup_private_acquire(_cd, MD_UNIT(dev)); - sc = device_private(self); if (sc == NULL || sc->sc_type == MD_UNCONFIGURED) { - device_release(self); + if (sc != NULL) + device_release(sc->sc_dev); return ENXIO; } error = (physio(mdstrategy, NULL, dev, B_READ, minphys, uio)); -
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Thu Jul 28 23:59:15 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: md.c Log Message: Since md(4) has a pointer from the softc back to the device_t, it is OK for us to use device_lookup_private_acquire() rather than calling device_lookup_acquire() followed by device_private(). So, redo earlier changes, which reduces diff to the original code at the branch-point. To generate a diff of this commit: cvs rdiff -u -r1.76.2.5 -r1.76.2.6 src/sys/dev/md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Thu Jul 28 06:45:32 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Remove duplicated code (cut-and-paste error) To generate a diff of this commit: cvs rdiff -u -r1.108.2.16 -r1.108.2.17 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/cgd.c diff -u src/sys/dev/cgd.c:1.108.2.16 src/sys/dev/cgd.c:1.108.2.17 --- src/sys/dev/cgd.c:1.108.2.16 Tue Jul 26 05:54:39 2016 +++ src/sys/dev/cgd.c Thu Jul 28 06:45:32 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd.c,v 1.108.2.16 2016/07/26 05:54:39 pgoyette Exp $ */ +/* $NetBSD: cgd.c,v 1.108.2.17 2016/07/28 06:45:32 pgoyette Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.16 2016/07/26 05:54:39 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.17 2016/07/28 06:45:32 pgoyette Exp $"); #include #include @@ -1157,12 +1157,6 @@ cgd_modcmd(modcmd_t cmd, void *arg) _cdevsw, _cmajor); /* - * Attach the {b,c}devsw's - */ - error = devsw_attach("cgd", _bdevsw, _bmajor, - _cdevsw, _cmajor); - - /* * If devsw_attach fails, remove from autoconf database */ if (error) {
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Thu Jul 28 06:45:32 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Remove duplicated code (cut-and-paste error) To generate a diff of this commit: cvs rdiff -u -r1.108.2.16 -r1.108.2.17 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Thu Jul 28 01:44:56 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: vnd.c Log Message: Don't try to call device_release() if we succesfully called vnd_destroy() To generate a diff of this commit: cvs rdiff -u -r1.256.2.11 -r1.256.2.12 src/sys/dev/vnd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/vnd.c diff -u src/sys/dev/vnd.c:1.256.2.11 src/sys/dev/vnd.c:1.256.2.12 --- src/sys/dev/vnd.c:1.256.2.11 Thu Jul 28 01:07:20 2016 +++ src/sys/dev/vnd.c Thu Jul 28 01:44:55 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vnd.c,v 1.256.2.11 2016/07/28 01:07:20 pgoyette Exp $ */ +/* $NetBSD: vnd.c,v 1.256.2.12 2016/07/28 01:44:55 pgoyette Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.11 2016/07/28 01:07:20 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.12 2016/07/28 01:44:55 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "opt_vnd.h" @@ -500,8 +500,8 @@ vndclose(dev_t dev, int flags, int mode, aprint_error_dev(sc->sc_dev, "unable to detach instance\n"); device_release(self); - return error; } + return error; } device_release(self);
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Thu Jul 28 01:44:56 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: vnd.c Log Message: Don't try to call device_release() if we succesfully called vnd_destroy() To generate a diff of this commit: cvs rdiff -u -r1.256.2.11 -r1.256.2.12 src/sys/dev/vnd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Thu Jul 28 01:07:20 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: vnd.c Log Message: Clean up the vnd_spawn() routine so it actually works. In particular, it needs to return the new unit's sc _after_ acquiring a reference to the unit. To generate a diff of this commit: cvs rdiff -u -r1.256.2.10 -r1.256.2.11 src/sys/dev/vnd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/vnd.c diff -u src/sys/dev/vnd.c:1.256.2.10 src/sys/dev/vnd.c:1.256.2.11 --- src/sys/dev/vnd.c:1.256.2.10 Wed Jul 27 23:17:31 2016 +++ src/sys/dev/vnd.c Thu Jul 28 01:07:20 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vnd.c,v 1.256.2.10 2016/07/27 23:17:31 pgoyette Exp $ */ +/* $NetBSD: vnd.c,v 1.256.2.11 2016/07/28 01:07:20 pgoyette Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.10 2016/07/27 23:17:31 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.11 2016/07/28 01:07:20 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "opt_vnd.h" @@ -311,12 +311,10 @@ vnd_spawn(int unit) cf->cf_unit = unit; cf->cf_fstate = FSTATE_STAR; + /* Attach a new unit */ self = config_attach_pseudo(cf); - return device_private(config_attach_pseudo(cf)); - - if (config_attach_pseudo(cf) == NULL) - return NULL; + /* And acquire a reference to it */ self = device_lookup_acquire(_cd, unit); if (self == NULL) return NULL;
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Thu Jul 28 01:07:20 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: vnd.c Log Message: Clean up the vnd_spawn() routine so it actually works. In particular, it needs to return the new unit's sc _after_ acquiring a reference to the unit. To generate a diff of this commit: cvs rdiff -u -r1.256.2.10 -r1.256.2.11 src/sys/dev/vnd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Wed Jul 27 23:17:31 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: vnd.c Log Message: Return ENXIO if the device is NOT found, not when the device IS found! To generate a diff of this commit: cvs rdiff -u -r1.256.2.9 -r1.256.2.10 src/sys/dev/vnd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Wed Jul 27 23:17:31 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: vnd.c Log Message: Return ENXIO if the device is NOT found, not when the device IS found! To generate a diff of this commit: cvs rdiff -u -r1.256.2.9 -r1.256.2.10 src/sys/dev/vnd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/vnd.c diff -u src/sys/dev/vnd.c:1.256.2.9 src/sys/dev/vnd.c:1.256.2.10 --- src/sys/dev/vnd.c:1.256.2.9 Wed Jul 27 11:51:57 2016 +++ src/sys/dev/vnd.c Wed Jul 27 23:17:31 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vnd.c,v 1.256.2.9 2016/07/27 11:51:57 pgoyette Exp $ */ +/* $NetBSD: vnd.c,v 1.256.2.10 2016/07/27 23:17:31 pgoyette Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.9 2016/07/27 11:51:57 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.10 2016/07/27 23:17:31 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "opt_vnd.h" @@ -1241,7 +1241,7 @@ vndioctl(dev_t dev, u_long cmd, void *da } self = device_lookup_acquire(_cd, unit); - if (self != NULL) + if (self == NULL) return ENXIO; vnd = device_private(self);
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Wed Jul 27 11:51:57 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: vnd.c Log Message: When detaching, call device_release() to allow the detach to complete. To generate a diff of this commit: cvs rdiff -u -r1.256.2.8 -r1.256.2.9 src/sys/dev/vnd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/vnd.c diff -u src/sys/dev/vnd.c:1.256.2.8 src/sys/dev/vnd.c:1.256.2.9 --- src/sys/dev/vnd.c:1.256.2.8 Wed Jul 27 11:23:32 2016 +++ src/sys/dev/vnd.c Wed Jul 27 11:51:57 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vnd.c,v 1.256.2.8 2016/07/27 11:23:32 pgoyette Exp $ */ +/* $NetBSD: vnd.c,v 1.256.2.9 2016/07/27 11:51:57 pgoyette Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.8 2016/07/27 11:23:32 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.9 2016/07/27 11:51:57 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "opt_vnd.h" @@ -275,6 +275,10 @@ vnd_attach(device_t parent, device_t sel aprint_error_dev(self, "couldn't establish power handler\n"); } +/* + * The caller must hold a reference to the device's localcount. the + * reference is released if the device is available for detach. + */ static int vnd_detach(device_t self, int flags) { @@ -291,6 +295,7 @@ vnd_detach(device_t self, int flags) bufq_free(sc->sc_tab); disk_destroy(>sc_dkdev); + device_release(self); return 0; }
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Wed Jul 27 11:51:57 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: vnd.c Log Message: When detaching, call device_release() to allow the detach to complete. To generate a diff of this commit: cvs rdiff -u -r1.256.2.8 -r1.256.2.9 src/sys/dev/vnd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Wed Jul 27 11:23:32 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: vnd.c Log Message: When we spawn a new unit, make sure we get a pointer to its device_t so we have something to give device_release() when we're finished! Also, add a call to device_release() in an error path. To generate a diff of this commit: cvs rdiff -u -r1.256.2.7 -r1.256.2.8 src/sys/dev/vnd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Wed Jul 27 11:23:32 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: vnd.c Log Message: When we spawn a new unit, make sure we get a pointer to its device_t so we have something to give device_release() when we're finished! Also, add a call to device_release() in an error path. To generate a diff of this commit: cvs rdiff -u -r1.256.2.7 -r1.256.2.8 src/sys/dev/vnd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/vnd.c diff -u src/sys/dev/vnd.c:1.256.2.7 src/sys/dev/vnd.c:1.256.2.8 --- src/sys/dev/vnd.c:1.256.2.7 Tue Jul 26 05:54:39 2016 +++ src/sys/dev/vnd.c Wed Jul 27 11:23:32 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vnd.c,v 1.256.2.7 2016/07/26 05:54:39 pgoyette Exp $ */ +/* $NetBSD: vnd.c,v 1.256.2.8 2016/07/27 11:23:32 pgoyette Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.7 2016/07/26 05:54:39 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.8 2016/07/27 11:23:32 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "opt_vnd.h" @@ -359,12 +359,21 @@ vndopen(dev_t dev, int flags, int mode, if (sc == NULL) return ENOMEM; + /* + * get a pointer to the new device_t; we don't need + * need to _acquire() it, since vnd_spawn() will + * already have taken a reference. + */ + self = device_lookup(_cd, unit); + /* compatibility, keep disklabel after close */ sc->sc_flags = VNF_KLABEL; } - if ((error = vndlock(sc)) != 0) + if ((error = vndlock(sc)) != 0) { + device_release(self); return error; + } mutex_enter(>sc_dkdev.dk_openlock);
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Wed Jul 27 03:25:00 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: fss.c md.c Log Message: Repair the inevitable tyops in previous. To generate a diff of this commit: cvs rdiff -u -r1.93.2.4 -r1.93.2.5 src/sys/dev/fss.c cvs rdiff -u -r1.76.2.4 -r1.76.2.5 src/sys/dev/md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fss.c diff -u src/sys/dev/fss.c:1.93.2.4 src/sys/dev/fss.c:1.93.2.5 --- src/sys/dev/fss.c:1.93.2.4 Wed Jul 27 01:13:50 2016 +++ src/sys/dev/fss.c Wed Jul 27 03:25:00 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: fss.c,v 1.93.2.4 2016/07/27 01:13:50 pgoyette Exp $ */ +/* $NetBSD: fss.c,v 1.93.2.5 2016/07/27 03:25:00 pgoyette Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.93.2.4 2016/07/27 01:13:50 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.93.2.5 2016/07/27 03:25:00 pgoyette Exp $"); #include #include @@ -225,7 +225,7 @@ fss_open(dev_t dev, int flags, int mode, cf->cf_atname = fss_cd.cd_name; cf->cf_unit = minor(dev); cf->cf_fstate = FSTATE_STAR; - self = config_attach_pseudo(cf)); + self = config_attach_pseudo(cf); device_acquire(self); sc = device_private(self); if (sc == NULL) { @@ -242,7 +242,7 @@ fss_open(dev_t dev, int flags, int mode, mutex_exit(>sc_slock); mutex_exit(_device_lock); - device_release(sc); + device_release(self); return 0; } Index: src/sys/dev/md.c diff -u src/sys/dev/md.c:1.76.2.4 src/sys/dev/md.c:1.76.2.5 --- src/sys/dev/md.c:1.76.2.4 Wed Jul 27 01:13:50 2016 +++ src/sys/dev/md.c Wed Jul 27 03:25:00 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.76.2.4 2016/07/27 01:13:50 pgoyette Exp $ */ +/* $NetBSD: md.c,v 1.76.2.5 2016/07/27 03:25:00 pgoyette Exp $ */ /* * Copyright (c) 1995 Gordon W. Ross, Leo Weppelman. @@ -40,7 +40,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.76.2.4 2016/07/27 01:13:50 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.76.2.5 2016/07/27 03:25:00 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_md.h" @@ -291,7 +291,7 @@ mdopen(dev_t dev, int flag, int fmt, str cf->cf_atname = md_cd.cd_name; cf->cf_unit = unit; cf->cf_fstate = FSTATE_STAR; - self = config_attach_pseudo(cf)); + self = config_attach_pseudo(cf); if (self != NULL) { device_acquire(self); sc = device_private(self); @@ -465,7 +465,7 @@ mdstrategy(struct buf *bp) } sc = device_private(self); - if (sc == NULL || sc->sc_type == MD_UNCONFIGURED) { + if (sc->sc_type == MD_UNCONFIGURED) { bp->b_error = ENXIO; goto done; } @@ -515,11 +515,11 @@ mdstrategy(struct buf *bp) break; } - done: mutex_exit(>sc_lock); - + done: biodone(bp); - device_release(self); + if (self != NULL) + device_release(self); } static int
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Wed Jul 27 03:25:00 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: fss.c md.c Log Message: Repair the inevitable tyops in previous. To generate a diff of this commit: cvs rdiff -u -r1.93.2.4 -r1.93.2.5 src/sys/dev/fss.c cvs rdiff -u -r1.76.2.4 -r1.76.2.5 src/sys/dev/md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Wed Jul 27 01:13:50 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: fss.c ld.c md.c Log Message: Update a few more drivers for localcount(9) To generate a diff of this commit: cvs rdiff -u -r1.93.2.3 -r1.93.2.4 src/sys/dev/fss.c cvs rdiff -u -r1.94.2.3 -r1.94.2.4 src/sys/dev/ld.c cvs rdiff -u -r1.76.2.3 -r1.76.2.4 src/sys/dev/md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fss.c diff -u src/sys/dev/fss.c:1.93.2.3 src/sys/dev/fss.c:1.93.2.4 --- src/sys/dev/fss.c:1.93.2.3 Tue Jul 26 05:54:39 2016 +++ src/sys/dev/fss.c Wed Jul 27 01:13:50 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: fss.c,v 1.93.2.3 2016/07/26 05:54:39 pgoyette Exp $ */ +/* $NetBSD: fss.c,v 1.93.2.4 2016/07/27 01:13:50 pgoyette Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.93.2.3 2016/07/26 05:54:39 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.93.2.4 2016/07/27 01:13:50 pgoyette Exp $"); #include #include @@ -172,6 +172,10 @@ fss_attach(device_t parent, device_t sel vfs_hooks_attach(_vfs_hooks); } +/* + * Caller must hold a reference to the device's localcount. The + * reference is released upon successful exit. + */ static int fss_detach(device_t self, int flags) { @@ -193,12 +197,14 @@ fss_detach(device_t self, int flags) disk_destroy(sc->sc_dkdev); free(sc->sc_dkdev, M_DEVBUF); + device_release(self); return 0; } int fss_open(dev_t dev, int flags, int mode, struct lwp *l) { + device_t self; int mflag; cfdata_t cf; struct fss_softc *sc; @@ -207,15 +213,23 @@ fss_open(dev_t dev, int flags, int mode, mutex_enter(_device_lock); - sc = device_lookup_private(_cd, minor(dev)); + self = device_lookup_acquire(_cd, minor(dev)); + if (self == NULL) + sc = NULL; + else + sc = device_private(self); + if (sc == NULL) { cf = malloc(sizeof(*cf), M_DEVBUF, M_WAITOK); cf->cf_name = fss_cd.cd_name; cf->cf_atname = fss_cd.cd_name; cf->cf_unit = minor(dev); cf->cf_fstate = FSTATE_STAR; - sc = device_private(config_attach_pseudo(cf)); + self = config_attach_pseudo(cf)); + device_acquire(self); + sc = device_private(self); if (sc == NULL) { + device_release(self); mutex_exit(_device_lock); return ENOMEM; } @@ -228,15 +242,17 @@ fss_open(dev_t dev, int flags, int mode, mutex_exit(>sc_slock); mutex_exit(_device_lock); + device_release(sc); return 0; } int fss_close(dev_t dev, int flags, int mode, struct lwp *l) { + device_t self = device_lookup_acquire(_cd, minor(dev)); int mflag, error; cfdata_t cf; - struct fss_softc *sc = device_lookup_private(_cd, minor(dev)); + struct fss_softc *sc = device_private(self); mflag = (mode == S_IFCHR ? FSS_CDEV_OPEN : FSS_BDEV_OPEN); error = 0; @@ -248,6 +264,7 @@ restart: sc->sc_flags &= ~mflag; mutex_exit(>sc_slock); mutex_exit(_device_lock); + device_release(self); return 0; } if ((sc->sc_flags & FSS_ACTIVE) != 0 && @@ -260,6 +277,7 @@ restart: if ((sc->sc_flags & FSS_ACTIVE) != 0) { mutex_exit(>sc_slock); mutex_exit(_device_lock); + device_release(self); return error; } @@ -272,14 +290,16 @@ restart: free(cf, M_DEVBUF); mutex_exit(_device_lock); + /* device_release() was called by fss_detach() from config_detach() */ return error; } void fss_strategy(struct buf *bp) { + device_t self = device_lookup_acquire(_cd, minor(bp->b_dev));; const bool write = ((bp->b_flags & B_READ) != B_READ); - struct fss_softc *sc = device_lookup_private(_cd, minor(bp->b_dev)); + struct fss_softc *sc = device_private(self); mutex_enter(>sc_slock); @@ -290,6 +310,7 @@ fss_strategy(struct buf *bp) bp->b_error = (write ? EROFS : ENXIO); bp->b_resid = bp->b_bcount; biodone(bp); + device_release(self); return; } @@ -298,6 +319,7 @@ fss_strategy(struct buf *bp) cv_signal(>sc_work_cv); mutex_exit(>sc_slock); + device_release(self); } int @@ -315,8 +337,9 @@ fss_write(dev_t dev, struct uio *uio, in int fss_ioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) { + device_t self = device_lookup_acquire(_cd, minor(dev)); int error; - struct fss_softc *sc = device_lookup_private(_cd, minor(dev)); + struct fss_softc *sc = device_private(self); struct fss_set _fss; struct fss_set *fss = (struct fss_set *)data; struct fss_set50 *fss50 = (struct fss_set50 *)data; @@ -430,6 +453,7 @@ fss_ioctl(dev_t dev, u_long cmd, void *d break; } + device_release(self); return error; } @@ -570,18 +594,22 @@ fss_softc_free(struct fss_softc *sc) static void fss_unmount_hook(struct mount *mp) { + device_t self; int i; struct fss_softc *sc; mutex_enter(_device_lock); for (i = 0; i < fss_cd.cd_ndevs; i++) { - if ((sc = device_lookup_private(_cd, i)) == NULL) + self =
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Wed Jul 27 01:13:50 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: fss.c ld.c md.c Log Message: Update a few more drivers for localcount(9) To generate a diff of this commit: cvs rdiff -u -r1.93.2.3 -r1.93.2.4 src/sys/dev/fss.c cvs rdiff -u -r1.94.2.3 -r1.94.2.4 src/sys/dev/ld.c cvs rdiff -u -r1.76.2.3 -r1.76.2.4 src/sys/dev/md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev/acpi
Module Name:src Committed By: pgoyette Date: Tue Jul 26 07:44:21 UTC 2016 Modified Files: src/sys/dev/acpi [pgoyette-localcount]: pckbc_acpi.c Log Message: Fix conversion to device_lookup_acquire() To generate a diff of this commit: cvs rdiff -u -r1.34.10.1 -r1.34.10.2 src/sys/dev/acpi/pckbc_acpi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/acpi/pckbc_acpi.c diff -u src/sys/dev/acpi/pckbc_acpi.c:1.34.10.1 src/sys/dev/acpi/pckbc_acpi.c:1.34.10.2 --- src/sys/dev/acpi/pckbc_acpi.c:1.34.10.1 Tue Jul 26 03:24:20 2016 +++ src/sys/dev/acpi/pckbc_acpi.c Tue Jul 26 07:44:21 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: pckbc_acpi.c,v 1.34.10.1 2016/07/26 03:24:20 pgoyette Exp $ */ +/* $NetBSD: pckbc_acpi.c,v 1.34.10.2 2016/07/26 07:44:21 pgoyette Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -42,7 +42,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pckbc_acpi.c,v 1.34.10.1 2016/07/26 03:24:20 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pckbc_acpi.c,v 1.34.10.2 2016/07/26 07:44:21 pgoyette Exp $"); #include #include @@ -234,7 +234,7 @@ out: static void pckbc_acpi_intr_establish(struct pckbc_softc *sc, pckbc_slot_t slot) { - device_t self; + device_t self = NULL; struct pckbc_acpi_softc *psc; isa_chipset_tag_t ic = NULL; void *rv = NULL; @@ -245,7 +245,11 @@ pckbc_acpi_intr_establish(struct pckbc_s * Note we're always called with sc == first. */ for (i = 0; i < pckbc_cd.cd_ndevs; i++) { - psc = device_lookup_private_acquire(_cd, i, ); + self = device_lookup_acquire(_cd, i); + if (self == NULL) + psc = NULL; + else + psc = device_private(self); if (psc && psc->sc_slot == slot) { irq = psc->sc_irq; ist = psc->sc_ist; @@ -263,7 +267,8 @@ pckbc_acpi_intr_establish(struct pckbc_s aprint_normal_dev(sc->sc_dv, "using irq %d for %s slot\n", irq, pckbc_slot_names[slot]); } - device_release(self); + if (self != NULL) + device_release(self); } static void
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Tue Jul 26 07:44:44 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: video.c Log Message: Typo To generate a diff of this commit: cvs rdiff -u -r1.32.8.1 -r1.32.8.2 src/sys/dev/video.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Tue Jul 26 07:44:44 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: video.c Log Message: Typo To generate a diff of this commit: cvs rdiff -u -r1.32.8.1 -r1.32.8.2 src/sys/dev/video.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/video.c diff -u src/sys/dev/video.c:1.32.8.1 src/sys/dev/video.c:1.32.8.2 --- src/sys/dev/video.c:1.32.8.1 Tue Jul 26 03:24:20 2016 +++ src/sys/dev/video.c Tue Jul 26 07:44:44 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: video.c,v 1.32.8.1 2016/07/26 03:24:20 pgoyette Exp $ */ +/* $NetBSD: video.c,v 1.32.8.2 2016/07/26 07:44:44 pgoyette Exp $ */ /* * Copyright (c) 2008 Patrick Mahoney@@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: video.c,v 1.32.8.1 2016/07/26 03:24:20 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: video.c,v 1.32.8.2 2016/07/26 07:44:44 pgoyette Exp $"); #include "video.h" #if NVIDEO > 0 @@ -1630,7 +1630,7 @@ videoopen(dev_t dev, int flags, int ifmt flags, sc, sc->hw_dev)); hw = sc->hw_if; - if (hw == NULL) [ + if (hw == NULL) { device_release(sc->sc_dev); return ENXIO; }
CVS commit: [pgoyette-localcount] src/sys/dev/acpi
Module Name:src Committed By: pgoyette Date: Tue Jul 26 07:44:21 UTC 2016 Modified Files: src/sys/dev/acpi [pgoyette-localcount]: pckbc_acpi.c Log Message: Fix conversion to device_lookup_acquire() To generate a diff of this commit: cvs rdiff -u -r1.34.10.1 -r1.34.10.2 src/sys/dev/acpi/pckbc_acpi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Tue Jul 26 07:42:40 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: midi.c Log Message: Fix botched edit. To generate a diff of this commit: cvs rdiff -u -r1.85.2.1 -r1.85.2.2 src/sys/dev/midi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/midi.c diff -u src/sys/dev/midi.c:1.85.2.1 src/sys/dev/midi.c:1.85.2.2 --- src/sys/dev/midi.c:1.85.2.1 Tue Jul 26 03:24:20 2016 +++ src/sys/dev/midi.c Tue Jul 26 07:42:39 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: midi.c,v 1.85.2.1 2016/07/26 03:24:20 pgoyette Exp $ */ +/* $NetBSD: midi.c,v 1.85.2.2 2016/07/26 07:42:39 pgoyette Exp $ */ /* * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: midi.c,v 1.85.2.1 2016/07/26 03:24:20 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: midi.c,v 1.85.2.2 2016/07/26 07:42:39 pgoyette Exp $"); #include "midi.h" #include "sequencer.h" @@ -1598,9 +1598,8 @@ out: int midi_writebytes(int unit, u_char *bf, int cc) { - device_t self = device_lookup_acquire(_cd, MIDIUNIT(dev)); + device_t self = device_lookup_acquire(_cd, unit); struct midi_softc *sc; - device_lookup_private_acquire(_cd, unit, ); int error; if (self == NULL)
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Tue Jul 26 07:42:40 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: midi.c Log Message: Fix botched edit. To generate a diff of this commit: cvs rdiff -u -r1.85.2.1 -r1.85.2.2 src/sys/dev/midi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Tue Jul 26 04:30:50 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: vnd.c Log Message: Fix some sloppy typos To generate a diff of this commit: cvs rdiff -u -r1.256.2.5 -r1.256.2.6 src/sys/dev/vnd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Tue Jul 26 04:30:50 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: vnd.c Log Message: Fix some sloppy typos To generate a diff of this commit: cvs rdiff -u -r1.256.2.5 -r1.256.2.6 src/sys/dev/vnd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/vnd.c diff -u src/sys/dev/vnd.c:1.256.2.5 src/sys/dev/vnd.c:1.256.2.6 --- src/sys/dev/vnd.c:1.256.2.5 Tue Jul 26 03:24:20 2016 +++ src/sys/dev/vnd.c Tue Jul 26 04:30:50 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vnd.c,v 1.256.2.5 2016/07/26 03:24:20 pgoyette Exp $ */ +/* $NetBSD: vnd.c,v 1.256.2.6 2016/07/26 04:30:50 pgoyette Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.5 2016/07/26 03:24:20 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.6 2016/07/26 04:30:50 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "opt_vnd.h" @@ -312,7 +312,7 @@ vnd_spawn(int unit) if (config_attach_pseudo(cf) == NULL) return NULL; - *self = device_lookup_acquire(_cd, unit); + self = device_lookup_acquire(_cd, unit); if (self == NULL) return NULL; else { @@ -320,7 +320,7 @@ vnd_spawn(int unit) * Note that we return while still holding a reference * to the device! */ - return device_private(*self); + return device_private(self); } } @@ -353,7 +353,7 @@ vndopen(dev_t dev, int flags, int mode, #endif self = device_lookup_acquire(_cd, unit); if (self != NULL) - sc = device-private(self); + sc = device_private(self); else { sc = vnd_spawn(unit); if (sc == NULL) @@ -1055,7 +1055,7 @@ vndwrite(dev_t dev, struct uio *uio, int self = device_lookup_acquire(_cd, unit); if (self == NULL) return ENXIO; - sc = device_lookup_private_acquire(_cd, unit, ); + sc = device_private(self); if ((sc->sc_flags & VNF_INITED) == 0) { device_release(self); @@ -1079,7 +1079,7 @@ vnd_cget(struct lwp *l, int unit, int *u if (*un < 0) return EINVAL; - self - device_lookup_acquire(_cd, unit); + self = device_lookup_acquire(_cd, unit); if (self == NULL) return -1; vnd = device_private(self); @@ -1226,12 +1226,11 @@ vndioctl(dev_t dev, u_long cmd, void *da break; } - vnd = device_lookup_private(_cd, unit); - if (vnd == NULL) { - if (self != NULL) - device_release(self); + self = device_lookup_acquire(_cd, unit); + if (self != NULL) return ENXIO; - } + vnd = device_private(self); + vio = (struct vnd_ioctl *)data; /* Must be open for writes for these commands... */
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Tue Jul 26 03:52:14 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: audio.c Log Message: Fix typo in local copy To generate a diff of this commit: cvs rdiff -u -r1.268.2.3 -r1.268.2.4 src/sys/dev/audio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Tue Jul 26 03:52:14 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: audio.c Log Message: Fix typo in local copy To generate a diff of this commit: cvs rdiff -u -r1.268.2.3 -r1.268.2.4 src/sys/dev/audio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/audio.c diff -u src/sys/dev/audio.c:1.268.2.3 src/sys/dev/audio.c:1.268.2.4 --- src/sys/dev/audio.c:1.268.2.3 Tue Jul 26 03:24:20 2016 +++ src/sys/dev/audio.c Tue Jul 26 03:52:14 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: audio.c,v 1.268.2.3 2016/07/26 03:24:20 pgoyette Exp $ */ +/* $NetBSD: audio.c,v 1.268.2.4 2016/07/26 03:52:14 pgoyette Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -155,7 +155,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.268.2.3 2016/07/26 03:24:20 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.268.2.4 2016/07/26 03:52:14 pgoyette Exp $"); #include "audio.h" #if NAUDIO > 0 @@ -1186,7 +1186,7 @@ audio_enter(dev_t dev, krw_t rw, struct struct audio_softc *sc; /* First, find the device and take sc_lock. */ - self = device_lookup_acquire(_cd, ADUIOUNIT(dev)); + self = device_lookup_acquire(_cd, AUDIOUNIT(dev)); if (self == NULL) return ENXIO; sc = device_private(self);
CVS commit: [pgoyette-localcount] src/sys/dev/isa
Module Name:src Committed By: pgoyette Date: Mon Jul 25 23:40:33 UTC 2016 Modified Files: src/sys/dev/isa [pgoyette-localcount]: fd.c isv.c mcd.c Log Message: Redo previous To generate a diff of this commit: cvs rdiff -u -r1.110.2.1 -r1.110.2.2 src/sys/dev/isa/fd.c cvs rdiff -u -r1.7.8.1 -r1.7.8.2 src/sys/dev/isa/isv.c cvs rdiff -u -r1.116.2.1 -r1.116.2.2 src/sys/dev/isa/mcd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/isa/fd.c diff -u src/sys/dev/isa/fd.c:1.110.2.1 src/sys/dev/isa/fd.c:1.110.2.2 --- src/sys/dev/isa/fd.c:1.110.2.1 Mon Jul 25 03:30:51 2016 +++ src/sys/dev/isa/fd.c Mon Jul 25 23:40:33 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: fd.c,v 1.110.2.1 2016/07/25 03:30:51 pgoyette Exp $ */ +/* $NetBSD: fd.c,v 1.110.2.2 2016/07/25 23:40:33 pgoyette Exp $ */ /*- * Copyright (c) 1998, 2003, 2008 The NetBSD Foundation, Inc. @@ -81,7 +81,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.110.2.1 2016/07/25 03:30:51 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.110.2.2 2016/07/25 23:40:33 pgoyette Exp $"); #include "opt_ddb.h" @@ -695,9 +695,8 @@ fd_dev_to_type(struct fd_softc *fd, dev_ void fdstrategy(struct buf *bp) { - device_t self; - struct fd_softc *fd = - device_lookup_private_acquire(_cd, FDUNIT(bp->b_dev), ); + device_t self = device_lookup_acquire(_cd, FDUNIT(bp->b_dev)); + struct fd_softc *fd = device_private(self); struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev)); int sz; @@ -925,12 +924,10 @@ fdopen(dev_t dev, int flags, int mode, s struct fd_softc *fd; const struct fd_type *type; - fd = device_lookup_private_acquire(_cd, FDUNIT(dev), ); - if (fd == NULL) { - if (self != NULL) - device_release(self); - return (ENXIO); - } + self = device_lookup_acquire(_cd, FDUNIT(dev)); + if (self == NULL) + return ENXIO; + fd = device_private(self); type = fd_dev_to_type(fd, dev); if (type == NULL) { @@ -958,9 +955,8 @@ fdopen(dev_t dev, int flags, int mode, s int fdclose(dev_t dev, int flags, int mode, struct lwp *l) { - device_t self; - struct fd_softc *fd = - device_lookup_private_acquire(_cd, FDUNIT(dev), ); + device_t self = device_lookup_acquire(_cd, FDUNIT(dev)); + struct fd_softc *fd = device_private(self); fd->sc_flags &= ~FD_OPEN; fd->sc_opts &= ~(FDOPT_NORETRY|FDOPT_SILENT); @@ -1411,9 +1407,8 @@ fdcretry(struct fdc_softc *fdc) int fdioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l) { - device_t self; - struct fd_softc *fd = - device_lookup_private_acquire(_cd, FDUNIT(dev), ); + device_t self = device_lookup_acquire(_cd, FDUNIT(dev)); + struct fd_softc *fd = device_private(self); struct fdformat_parms *form_parms; struct fdformat_cmd *form_cmd; struct ne7_fd_formb *fd_formb; @@ -1642,10 +1637,9 @@ fdioctl(dev_t dev, u_long cmd, void *add int fdformat(dev_t dev, struct ne7_fd_formb *finfo, struct lwp *l) { - device_t self; + device_t self = device_lookup_acquire(_cd, FDUNIT(dev)); int rv = 0; - struct fd_softc *fd = - device_lookup_private_acquire(_cd, FDUNIT(dev), ); + struct fd_softc *fd = device_private(self); struct fd_type *type = fd->sc_type; struct buf *bp; Index: src/sys/dev/isa/isv.c diff -u src/sys/dev/isa/isv.c:1.7.8.1 src/sys/dev/isa/isv.c:1.7.8.2 --- src/sys/dev/isa/isv.c:1.7.8.1 Mon Jul 25 03:30:51 2016 +++ src/sys/dev/isa/isv.c Mon Jul 25 23:40:33 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: isv.c,v 1.7.8.1 2016/07/25 03:30:51 pgoyette Exp $ */ +/* $NetBSD: isv.c,v 1.7.8.2 2016/07/25 23:40:33 pgoyette Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: isv.c,v 1.7.8.1 2016/07/25 03:30:51 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: isv.c,v 1.7.8.2 2016/07/25 23:40:33 pgoyette Exp $"); #include #include @@ -259,16 +259,14 @@ isv_attach(device_t parent, device_t sel int isv_open(dev_t dev, int flag, int devtype, lwp_t *l) { - device_t self; + device_t self = device_lookup_acquire(_cd, minor(dev)); vaddr_t va; - struct isv_softc *sc = - device_lookup_private_acquire(_cd, minor(dev), ); + struct isv_softc *sc; - if (sc == NULL) { - if (self != NULL) - device_release(self); + if (self == NULL) return ENXIO; - } + + sc = device_private(self); if (sc->sc_frame != NULL) { device_release(self); return 0; @@ -412,10 +410,9 @@ isv_capture(struct isv_softc *sc) int isv_ioctl(dev_t dev, u_long cmd, void *data, int flag, lwp_t *l) { - device_t self; + device_t self = device_lookup_acquire(_cd, minor(dev)); struct isv_cmd ic; - struct isv_softc *sc = - device_lookup_private_acquire(_cd, minor(dev), ); + struct isv_softc *sc; int error; if (cmd != ISV_CMD) { @@ -432,6 +429,11 @@ isv_ioctl(dev_t dev, u_long cmd, void *d return EINVAL; } + if (self == NULL) + return ENXIO; + + sc = device_private(self); + ic.c_frameno =
CVS commit: [pgoyette-localcount] src/sys/dev/isa
Module Name:src Committed By: pgoyette Date: Mon Jul 25 23:40:33 UTC 2016 Modified Files: src/sys/dev/isa [pgoyette-localcount]: fd.c isv.c mcd.c Log Message: Redo previous To generate a diff of this commit: cvs rdiff -u -r1.110.2.1 -r1.110.2.2 src/sys/dev/isa/fd.c cvs rdiff -u -r1.7.8.1 -r1.7.8.2 src/sys/dev/isa/isv.c cvs rdiff -u -r1.116.2.1 -r1.116.2.2 src/sys/dev/isa/mcd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Mon Jul 25 22:06:09 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: vnd.c Log Message: Update vnd for using localcount(9) To generate a diff of this commit: cvs rdiff -u -r1.256.2.3 -r1.256.2.4 src/sys/dev/vnd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/vnd.c diff -u src/sys/dev/vnd.c:1.256.2.3 src/sys/dev/vnd.c:1.256.2.4 --- src/sys/dev/vnd.c:1.256.2.3 Tue Jul 19 06:26:58 2016 +++ src/sys/dev/vnd.c Mon Jul 25 22:06:09 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vnd.c,v 1.256.2.3 2016/07/19 06:26:58 pgoyette Exp $ */ +/* $NetBSD: vnd.c,v 1.256.2.4 2016/07/25 22:06:09 pgoyette Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.3 2016/07/19 06:26:58 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.4 2016/07/25 22:06:09 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "opt_vnd.h" @@ -324,6 +324,7 @@ vnd_destroy(device_t dev) static int vndopen(dev_t dev, int flags, int mode, struct lwp *l) { + device_t self; int unit = vndunit(dev); struct vnd_softc *sc; int error = 0, part, pmask; @@ -333,7 +334,7 @@ vndopen(dev_t dev, int flags, int mode, if (vnddebug & VDB_FOLLOW) printf("vndopen(0x%"PRIx64", 0x%x, 0x%x, %p)\n", dev, flags, mode, l); #endif - sc = device_lookup_private(_cd, unit); + sc = device_lookup_private_acquire(_cd, unit, ); if (sc == NULL) { sc = vnd_spawn(unit); if (sc == NULL) @@ -410,12 +411,14 @@ vndopen(dev_t dev, int flags, int mode, done: mutex_exit(>sc_dkdev.dk_openlock); vndunlock(sc); + device_release(self); return error; } static int vndclose(dev_t dev, int flags, int mode, struct lwp *l) { + device_t self; int unit = vndunit(dev); struct vnd_softc *sc; int error = 0, part; @@ -424,12 +427,17 @@ vndclose(dev_t dev, int flags, int mode, if (vnddebug & VDB_FOLLOW) printf("vndclose(0x%"PRIx64", 0x%x, 0x%x, %p)\n", dev, flags, mode, l); #endif - sc = device_lookup_private(_cd, unit); - if (sc == NULL) + sc = device_lookup_private_acquire(_cd, unit, ); + if (sc == NULL) { + if (self != NULL) + device_release(self); return ENXIO; + } - if ((error = vndlock(sc)) != 0) + if ((error = vndlock(sc)) != 0) { + device_release(self); return error; + } mutex_enter(>sc_dkdev.dk_openlock); @@ -462,10 +470,12 @@ vndclose(dev_t dev, int flags, int mode, if ((error = vnd_destroy(sc->sc_dev)) != 0) { aprint_error_dev(sc->sc_dev, "unable to detach instance\n"); + device_release(self); return error; } } + device_release(self); return 0; } @@ -475,9 +485,10 @@ vndclose(dev_t dev, int flags, int mode, static void vndstrategy(struct buf *bp) { + device_t self; int unit = vndunit(bp->b_dev); struct vnd_softc *vnd = - device_lookup_private(_cd, unit); + device_lookup_private_acquire(_cd, unit, ); struct disklabel *lp; daddr_t blkno; int s = splbio(); @@ -561,12 +572,15 @@ vndstrategy(struct buf *bp) bufq_put(vnd->sc_tab, bp); wakeup(>sc_tab); splx(s); + device_release(self); return; done: bp->b_resid = bp->b_bcount; biodone(bp); splx(s); + if (self != NULL) + device_release(self); } static bool @@ -981,6 +995,8 @@ vndiodone(struct buf *bp) static int vndread(dev_t dev, struct uio *uio, int flags) { + device_t self; + int error; int unit = vndunit(dev); struct vnd_softc *sc; @@ -989,20 +1005,29 @@ vndread(dev_t dev, struct uio *uio, int printf("vndread(0x%"PRIx64", %p)\n", dev, uio); #endif - sc = device_lookup_private(_cd, unit); - if (sc == NULL) + sc = device_lookup_private_acquire(_cd, unit, ); + if (sc == NULL) { + if (self != NULL) + device_release(self); return ENXIO; + } - if ((sc->sc_flags & VNF_INITED) == 0) + if ((sc->sc_flags & VNF_INITED) == 0) { + device_release(self); return ENXIO; + } - return physio(vndstrategy, NULL, dev, B_READ, minphys, uio); + error = physio(vndstrategy, NULL, dev, B_READ, minphys, uio); + device_release(self); + return error; } /* ARGSUSED */ static int vndwrite(dev_t dev, struct uio *uio, int flags) { + device_t self; + int error; int unit = vndunit(dev); struct vnd_softc *sc; @@ -1011,19 +1036,27 @@ vndwrite(dev_t dev, struct uio *uio, int printf("vndwrite(0x%"PRIx64", %p)\n", dev, uio); #endif - sc = device_lookup_private(_cd, unit); - if (sc == NULL) + sc = device_lookup_private_acquire(_cd, unit, ); + if (sc == NULL) { + if (self != NULL) + device_release(self); return ENXIO; + } - if ((sc->sc_flags & VNF_INITED) == 0) + if ((sc->sc_flags & VNF_INITED) == 0) { + device_release(self); return ENXIO; + } - return physio(vndstrategy, NULL, dev, B_WRITE, minphys, uio); + error = physio(vndstrategy, NULL, dev, B_WRITE, minphys, uio); + device_release(self); +
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Mon Jul 25 22:06:09 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: vnd.c Log Message: Update vnd for using localcount(9) To generate a diff of this commit: cvs rdiff -u -r1.256.2.3 -r1.256.2.4 src/sys/dev/vnd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Mon Jul 25 03:40:52 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Add a comment to describe why we didn't convert one caller of device_lokup_private(). To generate a diff of this commit: cvs rdiff -u -r1.108.2.13 -r1.108.2.14 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Mon Jul 25 03:40:52 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Add a comment to describe why we didn't convert one caller of device_lokup_private(). To generate a diff of this commit: cvs rdiff -u -r1.108.2.13 -r1.108.2.14 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/cgd.c diff -u src/sys/dev/cgd.c:1.108.2.13 src/sys/dev/cgd.c:1.108.2.14 --- src/sys/dev/cgd.c:1.108.2.13 Sun Jul 24 10:44:57 2016 +++ src/sys/dev/cgd.c Mon Jul 25 03:40:52 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd.c,v 1.108.2.13 2016/07/24 10:44:57 pgoyette Exp $ */ +/* $NetBSD: cgd.c,v 1.108.2.14 2016/07/25 03:40:52 pgoyette Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.13 2016/07/24 10:44:57 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.14 2016/07/25 03:40:52 pgoyette Exp $"); #include #include @@ -910,6 +910,11 @@ cgd_ioctl_get(dev_t dev, void *data, str return EINVAL; /* XXX: should this be ENXIO? */ } + /* + * XXX This appears to be redundant, given the initialization + * XXX when it was declared. Leave it for now, but don't + * XXX take an extra reference to the device! + */ cs = device_lookup_private(_cd, unit); if (cs == NULL || !DK_ATTACHED(dksc)) { cgu->cgu_dev = 0;
CVS commit: [pgoyette-localcount] src/sys/dev/isa
Module Name:src Committed By: pgoyette Date: Mon Jul 25 03:30:52 UTC 2016 Modified Files: src/sys/dev/isa [pgoyette-localcount]: fd.c isv.c mcd.c Log Message: Update a few drivers for localcount(9) To generate a diff of this commit: cvs rdiff -u -r1.110 -r1.110.2.1 src/sys/dev/isa/fd.c cvs rdiff -u -r1.7 -r1.7.8.1 src/sys/dev/isa/isv.c cvs rdiff -u -r1.116 -r1.116.2.1 src/sys/dev/isa/mcd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/isa/fd.c diff -u src/sys/dev/isa/fd.c:1.110 src/sys/dev/isa/fd.c:1.110.2.1 --- src/sys/dev/isa/fd.c:1.110 Tue Dec 8 20:36:15 2015 +++ src/sys/dev/isa/fd.c Mon Jul 25 03:30:51 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: fd.c,v 1.110 2015/12/08 20:36:15 christos Exp $ */ +/* $NetBSD: fd.c,v 1.110.2.1 2016/07/25 03:30:51 pgoyette Exp $ */ /*- * Copyright (c) 1998, 2003, 2008 The NetBSD Foundation, Inc. @@ -81,7 +81,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.110 2015/12/08 20:36:15 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.110.2.1 2016/07/25 03:30:51 pgoyette Exp $"); #include "opt_ddb.h" @@ -695,7 +695,9 @@ fd_dev_to_type(struct fd_softc *fd, dev_ void fdstrategy(struct buf *bp) { - struct fd_softc *fd = device_lookup_private(_cd, FDUNIT(bp->b_dev)); + device_t self; + struct fd_softc *fd = + device_lookup_private_acquire(_cd, FDUNIT(bp->b_dev), ); struct fdc_softc *fdc = device_private(device_parent(fd->sc_dev)); int sz; @@ -753,12 +755,14 @@ fdstrategy(struct buf *bp) } #endif mutex_exit(>sc_mtx); + device_release(self); return; done: /* Toss transfer; we're done early. */ bp->b_resid = bp->b_bcount; biodone(bp); + device_release(self); } void @@ -917,20 +921,28 @@ out_fdc(bus_space_tag_t iot, bus_space_h int fdopen(dev_t dev, int flags, int mode, struct lwp *l) { + device_t self; struct fd_softc *fd; const struct fd_type *type; - fd = device_lookup_private(_cd, FDUNIT(dev)); - if (fd == NULL) + fd = device_lookup_private_acquire(_cd, FDUNIT(dev), ); + if (fd == NULL) { + if (self != NULL) + device_release(self); return (ENXIO); + } type = fd_dev_to_type(fd, dev); - if (type == NULL) + if (type == NULL) { + device_release(self); return ENXIO; + } if ((fd->sc_flags & FD_OPEN) != 0 && - memcmp(fd->sc_type, type, sizeof(*type))) + memcmp(fd->sc_type, type, sizeof(*type))) { + device_release(self); return EBUSY; + } fd->sc_type_copy = *type; fd->sc_type = >sc_type_copy; @@ -939,17 +951,20 @@ fdopen(dev_t dev, int flags, int mode, s fd_set_geometry(fd); + device_release(self); return 0; } int fdclose(dev_t dev, int flags, int mode, struct lwp *l) { + device_t self; struct fd_softc *fd = - device_lookup_private(_cd, FDUNIT(dev)); + device_lookup_private_acquire(_cd, FDUNIT(dev), ); fd->sc_flags &= ~FD_OPEN; fd->sc_opts &= ~(FDOPT_NORETRY|FDOPT_SILENT); + device_release(self); return 0; } @@ -1396,8 +1411,9 @@ fdcretry(struct fdc_softc *fdc) int fdioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l) { + device_t self; struct fd_softc *fd = - device_lookup_private(_cd, FDUNIT(dev)); + device_lookup_private_acquire(_cd, FDUNIT(dev), ); struct fdformat_parms *form_parms; struct fdformat_cmd *form_cmd; struct ne7_fd_formb *fd_formb; @@ -1426,20 +1442,25 @@ fdioctl(dev_t dev, u_long cmd, void *add lp->d_secpercyl = fd->sc_type->seccyl; lp->d_secperunit = fd->sc_type->size; - if (readdisklabel(dev, fdstrategy, lp, NULL) != NULL) + if (readdisklabel(dev, fdstrategy, lp, NULL) != NULL) { + device_release(self); return EINVAL; + } break; } error = disk_ioctl(>sc_dk, dev, cmd, addr, flag, l); - if (error != EPASSTHROUGH) + if (error != EPASSTHROUGH) { + device_release(self); return error; + } switch (cmd) { case DIOCWLABEL: if ((flag & FWRITE) == 0) return EBADF; /* XXX do something */ + device_release(self); return 0; case DIOCWDINFO: @@ -1447,8 +1468,10 @@ fdioctl(dev_t dev, u_long cmd, void *add case ODIOCWDINFO: #endif { - if ((flag & FWRITE) == 0) + if ((flag & FWRITE) == 0) { + device_release(self); return EBADF; + } #ifdef __HAVE_OLD_DISKLABEL if (cmd == ODIOCWDINFO) { memset(, 0, sizeof newlabel); @@ -1457,10 +1480,10 @@ fdioctl(dev_t dev, u_long cmd, void *add } #endif error = setdisklabel(lp, addr, 0, NULL); - if (error) - return error; + if (error == 0) + error = writedisklabel(dev, fdstrategy, lp, NULL); - error = writedisklabel(dev, fdstrategy, lp, NULL); + device_release(self); return error; } @@ -1488,21 +1511,23 @@ fdioctl(dev_t dev, u_long cmd, void *add default: return EINVAL; } + device_release(self); return 0; case FDIOCSETFORMAT: if((flag & FWRITE) == 0) return EBADF; /* must be opened for writing */ form_parms = (struct fdformat_parms *)addr;
CVS commit: [pgoyette-localcount] src/sys/dev/isa
Module Name:src Committed By: pgoyette Date: Mon Jul 25 03:30:52 UTC 2016 Modified Files: src/sys/dev/isa [pgoyette-localcount]: fd.c isv.c mcd.c Log Message: Update a few drivers for localcount(9) To generate a diff of this commit: cvs rdiff -u -r1.110 -r1.110.2.1 src/sys/dev/isa/fd.c cvs rdiff -u -r1.7 -r1.7.8.1 src/sys/dev/isa/isv.c cvs rdiff -u -r1.116 -r1.116.2.1 src/sys/dev/isa/mcd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Sun Jul 24 10:44:57 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Call device_release() in appropriate error paths. In the module initialization code, make the bmajor/cmajor variables global so they can be shared with the rump component initialization. To generate a diff of this commit: cvs rdiff -u -r1.108.2.12 -r1.108.2.13 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Sun Jul 24 10:44:57 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Call device_release() in appropriate error paths. In the module initialization code, make the bmajor/cmajor variables global so they can be shared with the rump component initialization. To generate a diff of this commit: cvs rdiff -u -r1.108.2.12 -r1.108.2.13 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/cgd.c diff -u src/sys/dev/cgd.c:1.108.2.12 src/sys/dev/cgd.c:1.108.2.13 --- src/sys/dev/cgd.c:1.108.2.12 Sun Jul 24 00:14:08 2016 +++ src/sys/dev/cgd.c Sun Jul 24 10:44:57 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd.c,v 1.108.2.12 2016/07/24 00:14:08 pgoyette Exp $ */ +/* $NetBSD: cgd.c,v 1.108.2.13 2016/07/24 10:44:57 pgoyette Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.12 2016/07/24 00:14:08 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.13 2016/07/24 10:44:57 pgoyette Exp $"); #include #include @@ -179,6 +179,13 @@ static void hexprint(const char *, void /* The code */ +/* + * Lookup the device and return it's softc. If the device doesn't + * exist, spawn it. + * + * In either case, the device is "acquired", and must be "released" + * by the caller after it is finished with the softc. + */ static struct cgd_softc * getcgd_softc(dev_t dev, device_t *self) { @@ -208,7 +215,9 @@ cgd_match(device_t self, cfdata_t cfdata static void cgd_attach(device_t parent, device_t self, void *aux) { - struct cgd_softc *sc = device_private(self); + struct cgd_softc *sc; + + sc = device_private(self); mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_BIO); dk_init(>sc_dksc, self, DKTYPE_CGD); @@ -220,6 +229,10 @@ cgd_attach(device_t parent, device_t sel } +/* + * The caller must hold a reference to the device's localcount. the + * reference is released if the device is available for detach. + */ static int cgd_detach(device_t self, int flags) { @@ -238,6 +251,7 @@ cgd_detach(device_t self, int flags) disk_destroy(>sc_dkdev); mutex_destroy(>sc_lock); + device_release(self); return 0; } @@ -256,6 +270,7 @@ static struct cgd_softc * cgd_spawn(int unit, device_t *self) { cfdata_t cf; + struct cgd_softc *sc; cf = malloc(sizeof(*cf), M_DEVBUF, M_WAITOK); cf->cf_name = cgd_cd.cd_name; @@ -269,12 +284,14 @@ cgd_spawn(int unit, device_t *self) *self = device_lookup_acquire(_cd, unit); if (self == NULL) return NULL; - else + else { /* * Note that we return while still holding a reference * to the device! */ - return device_private(*self); + sc = device_private(*self); + return sc; + } } static int @@ -285,10 +302,10 @@ cgd_destroy(device_t dev) cf = device_cfdata(dev); error = config_detach(dev, DETACH_QUIET); - if (error) - return error; - free(cf, M_DEVBUF); - return 0; + if (error == 0) + free(cf, M_DEVBUF); + + return error; } static int @@ -325,11 +342,10 @@ cgdclose(dev_t dev, int flags, int fmt, if ((error = cgd_destroy(cs->sc_dksc.sc_dev)) != 0) { aprint_error_dev(dksc->sc_dev, "unable to detach instance\n"); - device_release(self); return error; } - } - device_release(self); + } else + device_release(self); return 0; } @@ -597,8 +613,10 @@ cgdread(dev_t dev, struct uio *uio, int (unsigned long long)dev, uio, flags)); GETCGD_SOFTC(cs, dev, self); dksc = >sc_dksc; - if (!DK_ATTACHED(dksc)) + if (!DK_ATTACHED(dksc)) { + device_release(self); return ENXIO; + } error = physio(cgdstrategy, NULL, dev, B_READ, minphys, uio); device_release(self); return error; @@ -1104,6 +1122,8 @@ MODULE(MODULE_CLASS_DRIVER, cgd, "dk_sub #ifdef _MODULE CFDRIVER_DECL(cgd, DV_DISK, NULL); + +devmajor_t cgd_bmajor = -1, cgd_cmajor = -1; #endif static int @@ -,10 +1131,6 @@ cgd_modcmd(modcmd_t cmd, void *arg) { int error = 0; -#ifdef _MODULE - devmajor_t bmajor = -1, cmajor = -1; -#endif - switch (cmd) { case MODULE_CMD_INIT: #ifdef _MODULE @@ -1133,8 +1149,8 @@ cgd_modcmd(modcmd_t cmd, void *arg) /* * Attach the {b,c}devsw's */ - error = devsw_attach("cgd", _bdevsw, , - _cdevsw, ); + error = devsw_attach("cgd", _bdevsw, _bmajor, + _cdevsw, _cmajor); /* * If devsw_attach fails, remove from autoconf database @@ -1161,8 +1177,8 @@ cgd_modcmd(modcmd_t cmd, void *arg) */ error = config_cfattach_detach(cgd_cd.cd_name, _ca); if (error) { - error = devsw_attach("cgd", _bdevsw, , - _cdevsw, ); + error = devsw_attach("cgd", _bdevsw, _bmajor, + _cdevsw, _cmajor); aprint_error("%s: failed to detach %s cfattach, " "error %d\n", __func__, cgd_cd.cd_name, error); break; @@ -1170,8 +1186,8 @@ cgd_modcmd(modcmd_t cmd, void *arg)
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Sun Jul 24 00:14:08 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Remove cgd_release() - it's not needed now that getcgd_softc() provides access to the device_t Restore original cgdattach() - seems to be needed after all. Remove some debug printf's from GETCGD_SOFTC() macro. To generate a diff of this commit: cvs rdiff -u -r1.108.2.11 -r1.108.2.12 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Sun Jul 24 00:14:08 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Remove cgd_release() - it's not needed now that getcgd_softc() provides access to the device_t Restore original cgdattach() - seems to be needed after all. Remove some debug printf's from GETCGD_SOFTC() macro. To generate a diff of this commit: cvs rdiff -u -r1.108.2.11 -r1.108.2.12 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/cgd.c diff -u src/sys/dev/cgd.c:1.108.2.11 src/sys/dev/cgd.c:1.108.2.12 --- src/sys/dev/cgd.c:1.108.2.11 Sat Jul 23 03:20:37 2016 +++ src/sys/dev/cgd.c Sun Jul 24 00:14:08 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd.c,v 1.108.2.11 2016/07/23 03:20:37 pgoyette Exp $ */ +/* $NetBSD: cgd.c,v 1.108.2.12 2016/07/24 00:14:08 pgoyette Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.11 2016/07/23 03:20:37 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.12 2016/07/24 00:14:08 pgoyette Exp $"); #include #include @@ -173,25 +173,12 @@ static void hexprint(const char *, void #define CGDUNIT(x) DISKUNIT(x) #define GETCGD_SOFTC(_cs, x, _dv) \ - printf("%s: GETCGD_SOFTC\n", __func__); \ - if (!((_cs) = getcgd_softc(x, &_dv))) { \ - printf("%s: cs NULL\n", __func__); \ + if (((_cs) = getcgd_softc(x, &_dv)) == NULL) { \ return ENXIO;\ } /* The code */ -static void -cgd_release(dev_t dev) -{ - int unit = CGDUNIT(dev); - device_t self; - - self = device_lookup_acquire(_cd, unit); - if (self != NULL) - device_release(self); -} - static struct cgd_softc * getcgd_softc(dev_t dev, device_t *self) { @@ -257,18 +244,12 @@ cgd_detach(device_t self, int flags) void cgdattach(int num) { -/* - * We don't need to do anything here - the config database is updated - * in module initialization code. - int error; error = config_cfattach_attach(cgd_cd.cd_name, _ca); if (error != 0) aprint_error("%s: unable to register cfattach\n", cgd_cd.cd_name); - * - */ } static struct cgd_softc * @@ -349,7 +330,7 @@ cgdclose(dev_t dev, int flags, int fmt, } } device_release(self); - return error; + return 0; } static void @@ -374,14 +355,12 @@ cgdstrategy(struct buf *bp) bp->b_error = EINVAL; bp->b_resid = bp->b_bcount; biodone(bp); - cgd_release(bp->b_dev); device_release(self); return; } /* XXXrcd: Should we test for (cs != NULL)? */ dk_strategy(>sc_dksc, bp); - cgd_release(bp->b_dev); device_release(self); return; } @@ -399,7 +378,6 @@ cgdsize(dev_t dev) else retval = dk_size(>sc_dksc, dev); - cgd_release(dev); device_release(self); return retval; } @@ -510,7 +488,6 @@ cgd_diskstart(device_t dev, struct buf * static void cgdiodone(struct buf *nbp) { - dev_t dev; device_t self; struct buf *obp = nbp->b_private; struct cgd_softc *cs = getcgd_softc(obp->b_dev, ); @@ -555,13 +532,7 @@ cgdiodone(struct buf *nbp) if (obp->b_error != 0) obp->b_resid = obp->b_bcount; - /* - * copy the dev_t, finish the disk operation, and release the - * reference we're holding on to (from getcgd_softc() earlier) - */ - dev = obp->b_dev; dk_done(dksc, obp); - cgd_release(dev); device_release(self); dk_start(dksc, NULL); @@ -917,7 +888,6 @@ cgd_ioctl_get(dev_t dev, void *data, str cgu->cgu_unit = unit; if (cgu->cgu_unit < 0) { - cgd_release(dev); device_release(self); return EINVAL; /* XXX: should this be ENXIO? */ } @@ -938,7 +908,6 @@ cgd_ioctl_get(dev_t dev, void *data, str cgu->cgu_mode = cs->sc_cdata.cf_mode; cgu->cgu_keylen = cs->sc_cdata.cf_keylen; } - cgd_release(dev); device_release(self); return 0; } @@ -1175,6 +1144,7 @@ cgd_modcmd(modcmd_t cmd, void *arg) config_cfdriver_detach(_cd); aprint_error("%s: unable to attach %s devsw, " "error %d", __func__, cgd_cd.cd_name, error); + break; } #endif break;
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Sat Jul 23 03:20:37 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Remove debug printfs. For MODULE builds, define cgd_cd via CFDRIVER_DECL To generate a diff of this commit: cvs rdiff -u -r1.108.2.10 -r1.108.2.11 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/cgd.c diff -u src/sys/dev/cgd.c:1.108.2.10 src/sys/dev/cgd.c:1.108.2.11 --- src/sys/dev/cgd.c:1.108.2.10 Sat Jul 23 02:36:51 2016 +++ src/sys/dev/cgd.c Sat Jul 23 03:20:37 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd.c,v 1.108.2.10 2016/07/23 02:36:51 pgoyette Exp $ */ +/* $NetBSD: cgd.c,v 1.108.2.11 2016/07/23 03:20:37 pgoyette Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.10 2016/07/23 02:36:51 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.11 2016/07/23 03:20:37 pgoyette Exp $"); #include #include @@ -200,16 +200,13 @@ getcgd_softc(dev_t dev, device_t *self) DPRINTF_FOLLOW(("getcgd_softc(0x%"PRIx64"): unit = %d\n", dev, unit)); -printf("%s: unit %d\n", __func__, unit); *self = device_lookup_acquire(_cd, unit); -printf("%s: *self %p\n", __func__, *self); if (*self == NULL) { sc = cgd_spawn(unit, self); } else { sc = device_private(*self); } -printf("%s: return, sc %p\n", __func__, sc); return sc; } @@ -286,13 +283,9 @@ cgd_spawn(int unit, device_t *self) cf->cf_fstate = FSTATE_STAR; if (config_attach_pseudo(cf) == NULL) -{ -printf("%s: config_attach_pseudo() failed\n", __func__); return NULL; -} *self = device_lookup_acquire(_cd, unit); -printf("%s: pseudo added, *self %p\n", __func__, *self); if (self == NULL) return NULL; else @@ -674,7 +667,6 @@ cgdioctl(dev_t dev, u_long cmd, void *da DPRINTF_FOLLOW(("cgdioctl(0x%"PRIx64", %ld, %p, %d, %p)\n", dev, cmd, data, flag, l)); -printf("%s: dev %lx cmd %lx\n", __func__, (long unsigned int)dev, cmd); switch (cmd) { case CGDIOCGET: return cgd_ioctl_get(dev, data, l); @@ -688,25 +680,21 @@ printf("%s: dev %lx cmd %lx\n", __func__ dksc = >sc_dksc; break; } -printf("%s: softc %p, self %p\n", __func__, cs, self); switch (cmd) { case CGDIOCSET: -printf("%s: case CGDIOCSET\n", __func__); if (DK_ATTACHED(dksc)) error = EBUSY; else error = cgd_ioctl_set(cs, data, l); break; case CGDIOCCLR: -printf("%s: case CGDIOCCLR\n", __func__); if (DK_BUSY(>sc_dksc, pmask)) error = EBUSY; else error = cgd_ioctl_clr(cs, l); break; case DIOCCACHESYNC: -printf("%s: case CGDIOCCACHESYNC\n", __func__); /* * XXX Do we really need to care about having a writable * file descriptor here? @@ -723,24 +711,20 @@ printf("%s: case CGDIOCCACHESYNC\n", __f break; case DIOCGSTRATEGY: case DIOCSSTRATEGY: -printf("%s: case CGDIOCxSTRATEGY\n", __func__); if (!DK_ATTACHED(dksc)) { error = ENOENT; break; } /*FALLTHROUGH*/ default: -printf("%s: case default\n", __func__); error = dk_ioctl(dksc, dev, cmd, data, flag, l); break; case CGDIOCGET: -printf("%s: case CGDIOCGET\n", __func__); KASSERT(0); error = EINVAL; break; } device_release(self); -printf("%s: return value %d\n", __func__, error); return error; } @@ -1150,7 +1134,7 @@ hexprint(const char *start, void *buf, i MODULE(MODULE_CLASS_DRIVER, cgd, "dk_subr"); #ifdef _MODULE -#include "ioconf.c" +CFDRIVER_DECL(cgd, DV_DISK, NULL); #endif static int @@ -1172,7 +1156,7 @@ cgd_modcmd(modcmd_t cmd, void *arg) error = config_cfattach_attach(cgd_cd.cd_name, _ca); if (error) { config_cfdriver_detach(_cd); - aprint_error("%s: unable to register cfattach for ", + aprint_error("%s: unable to register cfattach for " "%s, error %d", __func__, cgd_cd.cd_name, error); break; }
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Sat Jul 23 03:20:37 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Remove debug printfs. For MODULE builds, define cgd_cd via CFDRIVER_DECL To generate a diff of this commit: cvs rdiff -u -r1.108.2.10 -r1.108.2.11 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Sat Jul 23 02:36:51 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Revert changes in revision 1.108.2.3 For pseudo-devices, config(1) doesn't provide a valid cfattach, so when a modular driver calls config_pseudo_attach() it will fail. This is not an issue for built-in drivers. To generate a diff of this commit: cvs rdiff -u -r1.108.2.9 -r1.108.2.10 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Sat Jul 23 02:36:51 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Revert changes in revision 1.108.2.3 For pseudo-devices, config(1) doesn't provide a valid cfattach, so when a modular driver calls config_pseudo_attach() it will fail. This is not an issue for built-in drivers. To generate a diff of this commit: cvs rdiff -u -r1.108.2.9 -r1.108.2.10 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/cgd.c diff -u src/sys/dev/cgd.c:1.108.2.9 src/sys/dev/cgd.c:1.108.2.10 --- src/sys/dev/cgd.c:1.108.2.9 Fri Jul 22 06:32:54 2016 +++ src/sys/dev/cgd.c Sat Jul 23 02:36:51 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd.c,v 1.108.2.9 2016/07/22 06:32:54 pgoyette Exp $ */ +/* $NetBSD: cgd.c,v 1.108.2.10 2016/07/23 02:36:51 pgoyette Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.9 2016/07/22 06:32:54 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.10 2016/07/23 02:36:51 pgoyette Exp $"); #include #include @@ -172,8 +172,12 @@ static void hexprint(const char *, void /* Utility Functions */ #define CGDUNIT(x) DISKUNIT(x) -#define GETCGD_SOFTC(_cs, x, _dv)\ - if (!((_cs) = getcgd_softc(x, &_dv))) return ENXIO; +#define GETCGD_SOFTC(_cs, x, _dv) \ + printf("%s: GETCGD_SOFTC\n", __func__); \ + if (!((_cs) = getcgd_softc(x, &_dv))) { \ + printf("%s: cs NULL\n", __func__); \ + return ENXIO;\ + } /* The code */ @@ -196,13 +200,16 @@ getcgd_softc(dev_t dev, device_t *self) DPRINTF_FOLLOW(("getcgd_softc(0x%"PRIx64"): unit = %d\n", dev, unit)); +printf("%s: unit %d\n", __func__, unit); *self = device_lookup_acquire(_cd, unit); +printf("%s: *self %p\n", __func__, *self); if (*self == NULL) { sc = cgd_spawn(unit, self); } else { sc = device_private(*self); } +printf("%s: return, sc %p\n", __func__, sc); return sc; } @@ -253,12 +260,18 @@ cgd_detach(device_t self, int flags) void cgdattach(int num) { +/* + * We don't need to do anything here - the config database is updated + * in module initialization code. + int error; error = config_cfattach_attach(cgd_cd.cd_name, _ca); if (error != 0) aprint_error("%s: unable to register cfattach\n", cgd_cd.cd_name); + * + */ } static struct cgd_softc * @@ -273,11 +286,13 @@ cgd_spawn(int unit, device_t *self) cf->cf_fstate = FSTATE_STAR; if (config_attach_pseudo(cf) == NULL) -{ printf("%s: config_attach_pseudo() failed\n", __func__); +{ +printf("%s: config_attach_pseudo() failed\n", __func__); return NULL; } *self = device_lookup_acquire(_cd, unit); +printf("%s: pseudo added, *self %p\n", __func__, *self); if (self == NULL) return NULL; else @@ -659,6 +674,7 @@ cgdioctl(dev_t dev, u_long cmd, void *da DPRINTF_FOLLOW(("cgdioctl(0x%"PRIx64", %ld, %p, %d, %p)\n", dev, cmd, data, flag, l)); +printf("%s: dev %lx cmd %lx\n", __func__, (long unsigned int)dev, cmd); switch (cmd) { case CGDIOCGET: return cgd_ioctl_get(dev, data, l); @@ -672,21 +688,25 @@ cgdioctl(dev_t dev, u_long cmd, void *da dksc = >sc_dksc; break; } +printf("%s: softc %p, self %p\n", __func__, cs, self); switch (cmd) { case CGDIOCSET: +printf("%s: case CGDIOCSET\n", __func__); if (DK_ATTACHED(dksc)) error = EBUSY; else - cgd_ioctl_set(cs, data, l); + error = cgd_ioctl_set(cs, data, l); break; case CGDIOCCLR: +printf("%s: case CGDIOCCLR\n", __func__); if (DK_BUSY(>sc_dksc, pmask)) error = EBUSY; else - cgd_ioctl_clr(cs, l); + error = cgd_ioctl_clr(cs, l); break; case DIOCCACHESYNC: +printf("%s: case CGDIOCCACHESYNC\n", __func__); /* * XXX Do we really need to care about having a writable * file descriptor here? @@ -703,18 +723,24 @@ cgdioctl(dev_t dev, u_long cmd, void *da break; case DIOCGSTRATEGY: case DIOCSSTRATEGY: - if (!DK_ATTACHED(dksc)) +printf("%s: case CGDIOCxSTRATEGY\n", __func__); + if (!DK_ATTACHED(dksc)) { error = ENOENT; + break; + } /*FALLTHROUGH*/ default: - if (error == 0) - error = dk_ioctl(dksc, dev, cmd, data, flag, l); +printf("%s: case default\n", __func__); + error = dk_ioctl(dksc, dev, cmd, data, flag, l); break; case CGDIOCGET: +printf("%s: case CGDIOCGET\n", __func__); KASSERT(0); error = EINVAL; + break; } device_release(self); +printf("%s: return value %d\n", __func__, error); return error; } @@ -1139,14 +1165,15 @@ cgd_modcmd(modcmd_t cmd, void *arg) switch (cmd) { case MODULE_CMD_INIT: #ifdef _MODULE - /* - * Insert the driver into the autoconf database - */ - error = config_init_component(cfdriver_ioconf_cgd, -cfattach_ioconf_cgd, cfdata_ioconf_cgd); - if (error) { - aprint_error("%s: unable to init component" -
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Fri Jul 22 06:32:54 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Remove debug To generate a diff of this commit: cvs rdiff -u -r1.108.2.8 -r1.108.2.9 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/cgd.c diff -u src/sys/dev/cgd.c:1.108.2.8 src/sys/dev/cgd.c:1.108.2.9 --- src/sys/dev/cgd.c:1.108.2.8 Fri Jul 22 05:49:53 2016 +++ src/sys/dev/cgd.c Fri Jul 22 06:32:54 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd.c,v 1.108.2.8 2016/07/22 05:49:53 pgoyette Exp $ */ +/* $NetBSD: cgd.c,v 1.108.2.9 2016/07/22 06:32:54 pgoyette Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.8 2016/07/22 05:49:53 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.9 2016/07/22 06:32:54 pgoyette Exp $"); #include #include @@ -194,18 +194,15 @@ getcgd_softc(dev_t dev, device_t *self) int unit = CGDUNIT(dev); struct cgd_softc *sc; -printf("%s: unit %d\n", __func__, unit); DPRINTF_FOLLOW(("getcgd_softc(0x%"PRIx64"): unit = %d\n", dev, unit)); *self = device_lookup_acquire(_cd, unit); -printf("%s: *self %p\n", __func__, *self); - if (*self == NULL) + if (*self == NULL) { sc = cgd_spawn(unit, self); -printf("%s: return sc %p\n", __func__, sc); - else + } else { sc = device_private(*self); -printf("%s: sc %p\n", __func__, sc); + } return sc; } @@ -281,7 +278,6 @@ cgd_spawn(int unit, device_t *self) } *self = device_lookup_acquire(_cd, unit); -printf("%s: self %p\n", __func__, *self); if (self == NULL) return NULL; else @@ -314,12 +310,9 @@ cgdopen(dev_t dev, int flags, int fmt, s struct cgd_softc *cs; DPRINTF_FOLLOW(("cgdopen(0x%"PRIx64", %d)\n", dev, flags)); -printf("%s: dev %lx\n", __func__, (long unsigned int)dev); GETCGD_SOFTC(cs, dev, self); -printf("%s: cs %p, self %p\n", __func__, cs, self); error = dk_open(>sc_dksc, dev, flags, fmt, l); device_release(self); -printf("%s: return %d\n", __func__, error); return error; } @@ -1143,7 +1136,6 @@ cgd_modcmd(modcmd_t cmd, void *arg) devmajor_t bmajor = -1, cmajor = -1; #endif -printf("%s: cmd %d\n", __func__, cmd); switch (cmd) { case MODULE_CMD_INIT: #ifdef _MODULE @@ -1208,7 +1200,6 @@ printf("%s: cmd %d\n", __func__, cmd); error = ENOTTY; break; } -printf("%s: return %d\n", __func__, error); return error; }
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Fri Jul 22 06:32:54 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Remove debug To generate a diff of this commit: cvs rdiff -u -r1.108.2.8 -r1.108.2.9 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Fri Jul 22 05:49:53 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Call cgd_spawn() if the requested device doesn't exist, rather than if the device exists but without any softc data. To generate a diff of this commit: cvs rdiff -u -r1.108.2.7 -r1.108.2.8 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/cgd.c diff -u src/sys/dev/cgd.c:1.108.2.7 src/sys/dev/cgd.c:1.108.2.8 --- src/sys/dev/cgd.c:1.108.2.7 Fri Jul 22 03:44:36 2016 +++ src/sys/dev/cgd.c Fri Jul 22 05:49:53 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd.c,v 1.108.2.7 2016/07/22 03:44:36 pgoyette Exp $ */ +/* $NetBSD: cgd.c,v 1.108.2.8 2016/07/22 05:49:53 pgoyette Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.7 2016/07/22 03:44:36 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.8 2016/07/22 05:49:53 pgoyette Exp $"); #include #include @@ -194,15 +194,19 @@ getcgd_softc(dev_t dev, device_t *self) int unit = CGDUNIT(dev); struct cgd_softc *sc; +printf("%s: unit %d\n", __func__, unit); DPRINTF_FOLLOW(("getcgd_softc(0x%"PRIx64"): unit = %d\n", dev, unit)); *self = device_lookup_acquire(_cd, unit); +printf("%s: *self %p\n", __func__, *self); + if (*self == NULL) - return NULL; - - sc = device_private(*self); - if (sc == NULL) sc = cgd_spawn(unit, self); +printf("%s: return sc %p\n", __func__, sc); + else + sc = device_private(*self); +printf("%s: sc %p\n", __func__, sc); + return sc; } @@ -272,9 +276,12 @@ cgd_spawn(int unit, device_t *self) cf->cf_fstate = FSTATE_STAR; if (config_attach_pseudo(cf) == NULL) +{ printf("%s: config_attach_pseudo() failed\n", __func__); return NULL; +} *self = device_lookup_acquire(_cd, unit); +printf("%s: self %p\n", __func__, *self); if (self == NULL) return NULL; else @@ -307,9 +314,12 @@ cgdopen(dev_t dev, int flags, int fmt, s struct cgd_softc *cs; DPRINTF_FOLLOW(("cgdopen(0x%"PRIx64", %d)\n", dev, flags)); +printf("%s: dev %lx\n", __func__, (long unsigned int)dev); GETCGD_SOFTC(cs, dev, self); +printf("%s: cs %p, self %p\n", __func__, cs, self); error = dk_open(>sc_dksc, dev, flags, fmt, l); device_release(self); +printf("%s: return %d\n", __func__, error); return error; } @@ -546,7 +556,7 @@ cgdiodone(struct buf *nbp) /* * copy the dev_t, finish the disk operation, and release the - * reference we're holding on to (from cgd_getsoftc() earlier) + * reference we're holding on to (from getcgd_softc() earlier) */ dev = obp->b_dev; dk_done(dksc, obp);
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Fri Jul 22 05:49:53 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Call cgd_spawn() if the requested device doesn't exist, rather than if the device exists but without any softc data. To generate a diff of this commit: cvs rdiff -u -r1.108.2.7 -r1.108.2.8 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Fri Jul 22 03:44:36 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Pass correct arg to cgd_spawn() To generate a diff of this commit: cvs rdiff -u -r1.108.2.6 -r1.108.2.7 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Fri Jul 22 03:44:36 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Pass correct arg to cgd_spawn() To generate a diff of this commit: cvs rdiff -u -r1.108.2.6 -r1.108.2.7 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/cgd.c diff -u src/sys/dev/cgd.c:1.108.2.6 src/sys/dev/cgd.c:1.108.2.7 --- src/sys/dev/cgd.c:1.108.2.6 Fri Jul 22 03:40:51 2016 +++ src/sys/dev/cgd.c Fri Jul 22 03:44:36 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd.c,v 1.108.2.6 2016/07/22 03:40:51 pgoyette Exp $ */ +/* $NetBSD: cgd.c,v 1.108.2.7 2016/07/22 03:44:36 pgoyette Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.6 2016/07/22 03:40:51 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.7 2016/07/22 03:44:36 pgoyette Exp $"); #include #include @@ -202,7 +202,7 @@ getcgd_softc(dev_t dev, device_t *self) sc = device_private(*self); if (sc == NULL) - sc = cgd_spawn(unit, *self); + sc = cgd_spawn(unit, self); return sc; }
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Fri Jul 22 03:40:51 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Use correct prototype. To generate a diff of this commit: cvs rdiff -u -r1.108.2.5 -r1.108.2.6 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/cgd.c diff -u src/sys/dev/cgd.c:1.108.2.5 src/sys/dev/cgd.c:1.108.2.6 --- src/sys/dev/cgd.c:1.108.2.5 Fri Jul 22 03:39:43 2016 +++ src/sys/dev/cgd.c Fri Jul 22 03:40:51 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd.c,v 1.108.2.5 2016/07/22 03:39:43 pgoyette Exp $ */ +/* $NetBSD: cgd.c,v 1.108.2.6 2016/07/22 03:40:51 pgoyette Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.5 2016/07/22 03:39:43 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.6 2016/07/22 03:40:51 pgoyette Exp $"); #include #include @@ -102,7 +102,7 @@ const struct cdevsw cgd_cdevsw = { static int cgd_match(device_t, cfdata_t, void *); static void cgd_attach(device_t, device_t, void *); static int cgd_detach(device_t, int); -static struct cgd_softc *cgd_spawn(int, *device_t); +static struct cgd_softc *cgd_spawn(int, device_t *); static int cgd_destroy(device_t); /* Internal Functions */
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Fri Jul 22 03:40:51 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Use correct prototype. To generate a diff of this commit: cvs rdiff -u -r1.108.2.5 -r1.108.2.6 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Fri Jul 22 03:39:43 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Make sure that whenever we're using the cgd device's softc, we maintain a reference to the device so things won't get deleted out from under us! To generate a diff of this commit: cvs rdiff -u -r1.108.2.4 -r1.108.2.5 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/cgd.c diff -u src/sys/dev/cgd.c:1.108.2.4 src/sys/dev/cgd.c:1.108.2.5 --- src/sys/dev/cgd.c:1.108.2.4 Wed Jul 20 06:51:13 2016 +++ src/sys/dev/cgd.c Fri Jul 22 03:39:43 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd.c,v 1.108.2.4 2016/07/20 06:51:13 pgoyette Exp $ */ +/* $NetBSD: cgd.c,v 1.108.2.5 2016/07/22 03:39:43 pgoyette Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.4 2016/07/20 06:51:13 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.5 2016/07/22 03:39:43 pgoyette Exp $"); #include #include @@ -102,7 +102,7 @@ const struct cdevsw cgd_cdevsw = { static int cgd_match(device_t, cfdata_t, void *); static void cgd_attach(device_t, device_t, void *); static int cgd_detach(device_t, int); -static struct cgd_softc *cgd_spawn(int); +static struct cgd_softc *cgd_spawn(int, *device_t); static int cgd_destroy(device_t); /* Internal Functions */ @@ -172,7 +172,8 @@ static void hexprint(const char *, void /* Utility Functions */ #define CGDUNIT(x) DISKUNIT(x) -#define GETCGD_SOFTC(_cs, x) if (!((_cs) = getcgd_softc(x))) return ENXIO +#define GETCGD_SOFTC(_cs, x, _dv)\ + if (!((_cs) = getcgd_softc(x, &_dv))) return ENXIO; /* The code */ @@ -188,16 +189,20 @@ cgd_release(dev_t dev) } static struct cgd_softc * -getcgd_softc(dev_t dev) +getcgd_softc(dev_t dev, device_t *self) { int unit = CGDUNIT(dev); struct cgd_softc *sc; DPRINTF_FOLLOW(("getcgd_softc(0x%"PRIx64"): unit = %d\n", dev, unit)); - sc = device_lookup_private(_cd, unit); + *self = device_lookup_acquire(_cd, unit); + if (*self == NULL) + return NULL; + + sc = device_private(*self); if (sc == NULL) - sc = cgd_spawn(unit); + sc = cgd_spawn(unit, *self); return sc; } @@ -256,9 +261,8 @@ cgdattach(int num) } static struct cgd_softc * -cgd_spawn(int unit) +cgd_spawn(int unit, device_t *self) { - device_t self; cfdata_t cf; cf = malloc(sizeof(*cf), M_DEVBUF, M_WAITOK); @@ -270,14 +274,15 @@ cgd_spawn(int unit) if (config_attach_pseudo(cf) == NULL) return NULL; - self = device_lookup_acquire(_cd, unit); + *self = device_lookup_acquire(_cd, unit); if (self == NULL) return NULL; else /* - * Note that we return with a reference to the device! + * Note that we return while still holding a reference + * to the device! */ - return device_private(self); + return device_private(*self); } static int @@ -297,40 +302,50 @@ cgd_destroy(device_t dev) static int cgdopen(dev_t dev, int flags, int fmt, struct lwp *l) { + device_t self; + int error; struct cgd_softc *cs; DPRINTF_FOLLOW(("cgdopen(0x%"PRIx64", %d)\n", dev, flags)); - GETCGD_SOFTC(cs, dev); - return dk_open(>sc_dksc, dev, flags, fmt, l); + GETCGD_SOFTC(cs, dev, self); + error = dk_open(>sc_dksc, dev, flags, fmt, l); + device_release(self); + return error; } static int cgdclose(dev_t dev, int flags, int fmt, struct lwp *l) { int error; + device_t self; struct cgd_softc *cs; struct dk_softc *dksc; DPRINTF_FOLLOW(("cgdclose(0x%"PRIx64", %d)\n", dev, flags)); - GETCGD_SOFTC(cs, dev); + GETCGD_SOFTC(cs, dev, self); dksc = >sc_dksc; - if ((error = dk_close(dksc, dev, flags, fmt, l)) != 0) + if ((error = dk_close(dksc, dev, flags, fmt, l)) != 0) { + device_release(self); return error; + } if (!DK_ATTACHED(dksc)) { if ((error = cgd_destroy(cs->sc_dksc.sc_dev)) != 0) { aprint_error_dev(dksc->sc_dev, "unable to detach instance\n"); + device_release(self); return error; } } - return 0; + device_release(self); + return error; } static void cgdstrategy(struct buf *bp) { - struct cgd_softc *cs = getcgd_softc(bp->b_dev); + device_t self; + struct cgd_softc *cs = getcgd_softc(bp->b_dev, ); struct dk_softc *dksc = >sc_dksc; struct disk_geom *dg = >sc_dkdev.dk_geom; @@ -349,12 +364,14 @@ cgdstrategy(struct buf *bp) bp->b_resid = bp->b_bcount; biodone(bp); cgd_release(bp->b_dev); + device_release(self); return; } /* XXXrcd: Should we test for (cs != NULL)? */ dk_strategy(>sc_dksc, bp); cgd_release(bp->b_dev); + device_release(self); return; } @@ -362,7 +379,8 @@ static int cgdsize(dev_t dev) { int retval; - struct cgd_softc *cs = getcgd_softc(dev); + device_t self; + struct cgd_softc *cs = getcgd_softc(dev, ); DPRINTF_FOLLOW(("cgdsize(0x%"PRIx64")\n", dev)); if (!cs) @@
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Fri Jul 22 03:39:43 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Make sure that whenever we're using the cgd device's softc, we maintain a reference to the device so things won't get deleted out from under us! To generate a diff of this commit: cvs rdiff -u -r1.108.2.4 -r1.108.2.5 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev/mscp
Module Name:src Committed By: pgoyette Date: Thu Jul 21 00:02:13 UTC 2016 Modified Files: src/sys/dev/mscp [pgoyette-localcount]: mscp_disk.c Log Message: Partial adaptation to the new {b,c}devsw locking. Still needs some work. (See XXX comments in code) To generate a diff of this commit: cvs rdiff -u -r1.89 -r1.89.2.1 src/sys/dev/mscp/mscp_disk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev/mscp
Module Name:src Committed By: pgoyette Date: Thu Jul 21 00:02:13 UTC 2016 Modified Files: src/sys/dev/mscp [pgoyette-localcount]: mscp_disk.c Log Message: Partial adaptation to the new {b,c}devsw locking. Still needs some work. (See XXX comments in code) To generate a diff of this commit: cvs rdiff -u -r1.89 -r1.89.2.1 src/sys/dev/mscp/mscp_disk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/mscp/mscp_disk.c diff -u src/sys/dev/mscp/mscp_disk.c:1.89 src/sys/dev/mscp/mscp_disk.c:1.89.2.1 --- src/sys/dev/mscp/mscp_disk.c:1.89 Tue Mar 29 04:55:53 2016 +++ src/sys/dev/mscp/mscp_disk.c Thu Jul 21 00:02:13 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: mscp_disk.c,v 1.89 2016/03/29 04:55:53 mlelstv Exp $ */ +/* $NetBSD: mscp_disk.c,v 1.89.2.1 2016/07/21 00:02:13 pgoyette Exp $ */ /* * Copyright (c) 1988 Regents of the University of California. * All rights reserved. @@ -82,7 +82,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mscp_disk.c,v 1.89 2016/03/29 04:55:53 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mscp_disk.c,v 1.89.2.1 2016/07/21 00:02:13 pgoyette Exp $"); #include #include @@ -1129,6 +1129,9 @@ ra_putonline(dev_t dev, struct ra_softc { struct disklabel *dl; const char *msg; +#if NRACD + const struct cdevsw *cdev; +#endif if (rx_putonline(ra) != MSCP_DONE) return MSCP_FAILED; @@ -1144,10 +1147,15 @@ ra_putonline(dev_t dev, struct ra_softc ra->ra_state = DK_OPEN; } #if NRACD - else if (cdevsw_lookup(dev) == _cdevsw) { - dl->d_partitions[0].p_offset = 0; - dl->d_partitions[0].p_size = dl->d_secperunit; - dl->d_partitions[0].p_fstype = FS_ISO9660; + else { + cdev = cdevsw_lookup_acquire(dev); + if (cdev == _cdevsw) { + dl->d_partitions[0].p_offset = 0; + dl->d_partitions[0].p_size = dl->d_secperunit; + dl->d_partitions[0].p_fstype = FS_ISO9660; + } + if (cdev != NULL) + cdevsw_release(cdev); } #endif /* NRACD */ else { @@ -1159,7 +1167,14 @@ ra_putonline(dev_t dev, struct ra_softc return MSCP_DONE; } - +/* XXX + * This code needs to be restructured to deal with the localcount(9) + * referencing counting on {b,c}devsw. Since we're returning the + * softc address here, we need to use cdevsw_lookup_acquire() to + * keep a reference to the device. So all callers need to be able + * to determine which device's cdevsw needs to be released later on. + * XXX + */ static inline struct ra_softc * mscp_device_lookup(dev_t dev) {
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Wed Jul 20 06:51:13 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: First pass at updating the cgd(4) driver for use with localcount(9) ref-counts. So far all I've done is to manage the ref-counts. This will defer removal of the driver from the devsw tables and/or the autoconf tree while anyone has a reference to any of the device's critical data (mostly, the softc or the device_t). Note that these ref-counts will only defer the removal; once the references are released, the removal will proceed. On-going work is needed to identify potentially blocking operations, and to deny any removals if such operations are in-flight. We really shouldn't be waiting (possibly indefinitely) for these operations to complete, especially since removals could be attempted by the module(9) subsystem while holding the kernel_config lock. To generate a diff of this commit: cvs rdiff -u -r1.108.2.3 -r1.108.2.4 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/cgd.c diff -u src/sys/dev/cgd.c:1.108.2.3 src/sys/dev/cgd.c:1.108.2.4 --- src/sys/dev/cgd.c:1.108.2.3 Wed Jul 20 04:33:53 2016 +++ src/sys/dev/cgd.c Wed Jul 20 06:51:13 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd.c,v 1.108.2.3 2016/07/20 04:33:53 pgoyette Exp $ */ +/* $NetBSD: cgd.c,v 1.108.2.4 2016/07/20 06:51:13 pgoyette Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.3 2016/07/20 04:33:53 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.4 2016/07/20 06:51:13 pgoyette Exp $"); #include #include @@ -176,6 +176,17 @@ static void hexprint(const char *, void /* The code */ +static void +cgd_release(dev_t dev) +{ + int unit = CGDUNIT(dev); + device_t self; + + self = device_lookup_acquire(_cd, unit); + if (self != NULL) + device_release(self); +} + static struct cgd_softc * getcgd_softc(dev_t dev) { @@ -247,6 +258,7 @@ cgdattach(int num) static struct cgd_softc * cgd_spawn(int unit) { + device_t self; cfdata_t cf; cf = malloc(sizeof(*cf), M_DEVBUF, M_WAITOK); @@ -255,7 +267,17 @@ cgd_spawn(int unit) cf->cf_unit = unit; cf->cf_fstate = FSTATE_STAR; - return device_private(config_attach_pseudo(cf)); + if (config_attach_pseudo(cf) == NULL) + return NULL; + + self = device_lookup_acquire(_cd, unit); + if (self == NULL) + return NULL; + else + /* + * Note that we return with a reference to the device! + */ + return device_private(self); } static int @@ -326,23 +348,30 @@ cgdstrategy(struct buf *bp) bp->b_error = EINVAL; bp->b_resid = bp->b_bcount; biodone(bp); + cgd_release(bp->b_dev); return; } /* XXXrcd: Should we test for (cs != NULL)? */ dk_strategy(>sc_dksc, bp); + cgd_release(bp->b_dev); return; } static int cgdsize(dev_t dev) { + int retval; struct cgd_softc *cs = getcgd_softc(dev); DPRINTF_FOLLOW(("cgdsize(0x%"PRIx64")\n", dev)); if (!cs) - return -1; - return dk_size(>sc_dksc, dev); + retval = -1; + else + retval = dk_size(>sc_dksc, dev); + + cgd_release(dev); + return retval; } /* @@ -451,6 +480,7 @@ cgd_diskstart(device_t dev, struct buf * static void cgdiodone(struct buf *nbp) { + dev_t dev; struct buf *obp = nbp->b_private; struct cgd_softc *cs = getcgd_softc(obp->b_dev); struct dk_softc *dksc = >sc_dksc; @@ -494,7 +524,14 @@ cgdiodone(struct buf *nbp) if (obp->b_error != 0) obp->b_resid = obp->b_bcount; + /* + * copy the dev_t, finish the disk operation, and release the + * reference we're holding on to (from cgd_getsoftc() earlier) + */ + dev = obp->b_dev; dk_done(dksc, obp); + cgd_release(dev); + dk_start(dksc, NULL); } @@ -817,8 +854,10 @@ cgd_ioctl_get(dev_t dev, void *data, str if (cgu->cgu_unit == -1) cgu->cgu_unit = unit; - if (cgu->cgu_unit < 0) + if (cgu->cgu_unit < 0) { + cgd_release(dev); return EINVAL; /* XXX: should this be ENXIO? */ + } cs = device_lookup_private(_cd, unit); if (cs == NULL || !DK_ATTACHED(dksc)) { @@ -836,6 +875,7 @@ cgd_ioctl_get(dev_t dev, void *data, str cgu->cgu_mode = cs->sc_cdata.cf_mode; cgu->cgu_keylen = cs->sc_cdata.cf_keylen; } + cgd_release(dev); return 0; } @@ -1030,7 +1070,7 @@ hexprint(const char *start, void *buf, i MODULE(MODULE_CLASS_DRIVER, cgd, "dk_subr"); #ifdef _MODULE -CFDRIVER_DECL(cgd, DV_DISK, NULL); +#include "ioconf.c" #endif static int @@ -1051,8 +1091,8 @@ cgd_modcmd(modcmd_t cmd, void *arg) error = config_init_component(cfdriver_ioconf_cgd, cfattach_ioconf_cgd, cfdata_ioconf_cgd); if (error) { - aprint_error("%s: unable to init component", - cgd_cd.cd_name); + aprint_error("%s: unable to init component" + ", error %d", cgd_cd.cd_name, error); break; } @@ -1068,8 +1108,8 @@
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Wed Jul 20 06:51:13 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: First pass at updating the cgd(4) driver for use with localcount(9) ref-counts. So far all I've done is to manage the ref-counts. This will defer removal of the driver from the devsw tables and/or the autoconf tree while anyone has a reference to any of the device's critical data (mostly, the softc or the device_t). Note that these ref-counts will only defer the removal; once the references are released, the removal will proceed. On-going work is needed to identify potentially blocking operations, and to deny any removals if such operations are in-flight. We really shouldn't be waiting (possibly indefinitely) for these operations to complete, especially since removals could be attempted by the module(9) subsystem while holding the kernel_config lock. To generate a diff of this commit: cvs rdiff -u -r1.108.2.3 -r1.108.2.4 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Wed Jul 20 04:33:53 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Rather than manually manipulating individual autoconf data, just use config_{init,fini}_component() to do it all at once. To generate a diff of this commit: cvs rdiff -u -r1.108.2.2 -r1.108.2.3 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Wed Jul 20 04:33:53 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: cgd.c Log Message: Rather than manually manipulating individual autoconf data, just use config_{init,fini}_component() to do it all at once. To generate a diff of this commit: cvs rdiff -u -r1.108.2.2 -r1.108.2.3 src/sys/dev/cgd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/cgd.c diff -u src/sys/dev/cgd.c:1.108.2.2 src/sys/dev/cgd.c:1.108.2.3 --- src/sys/dev/cgd.c:1.108.2.2 Tue Jul 19 06:26:58 2016 +++ src/sys/dev/cgd.c Wed Jul 20 04:33:53 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cgd.c,v 1.108.2.2 2016/07/19 06:26:58 pgoyette Exp $ */ +/* $NetBSD: cgd.c,v 1.108.2.3 2016/07/20 04:33:53 pgoyette Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.2 2016/07/19 06:26:58 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.108.2.3 2016/07/20 04:33:53 pgoyette Exp $"); #include #include @@ -1045,35 +1045,54 @@ cgd_modcmd(modcmd_t cmd, void *arg) switch (cmd) { case MODULE_CMD_INIT: #ifdef _MODULE - error = config_cfdriver_attach(_cd); - if (error) - break; - - error = config_cfattach_attach(cgd_cd.cd_name, _ca); - if (error) { - config_cfdriver_detach(_cd); - aprint_error("%s: unable to register cfattach\n", + /* + * Insert the driver into the autoconf database + */ + error = config_init_component(cfdriver_ioconf_cgd, +cfattach_ioconf_cgd, cfdata_ioconf_cgd); + if (error) { + aprint_error("%s: unable to init component", cgd_cd.cd_name); break; } + /* + * Attach the {b,c}devsw's + */ error = devsw_attach("cgd", _bdevsw, , _cdevsw, ); + + /* + * If devsw_attach fails, remove from autoconf database + */ if (error) { - config_cfattach_detach(cgd_cd.cd_name, _ca); - config_cfdriver_detach(_cd); - break; + config_fini_component(cfdriver_ioconf_cgd, + cfattach_ioconf_cgd, cfdata_ioconf_cgd); + aprint_error("%s: unable to attach devsw", +cgd_cd.cd_name); } #endif break; case MODULE_CMD_FINI: #ifdef _MODULE - error = config_cfattach_detach(cgd_cd.cd_name, _ca); - if (error) - break; - config_cfdriver_detach(_cd); + /* + * Remove {b,c}devsw's + */ devsw_detach(_bdevsw, _cdevsw); + + /* + * Now remove device from autoconf database + */ + error = config_fini_component(cfdriver_ioconf_cgd, + cfattach_ioconf_cgd, cfdata_ioconf_cgd); + + /* + * If removal fails, re-attach our {b,c}devsw's + */ + if (error) + devsw_attach("cgd", _bdevsw, , + _cdevsw, ); #endif break;
CVS commit: [pgoyette-localcount] src/sys/dev/pud
Module Name:src Committed By: pgoyette Date: Mon Jul 18 22:00:05 UTC 2016 Modified Files: src/sys/dev/pud [pgoyette-localcount]: pud_dev.c Log Message: And use the address of the localcount ... To generate a diff of this commit: cvs rdiff -u -r1.7.2.1 -r1.7.2.2 src/sys/dev/pud/pud_dev.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pud/pud_dev.c diff -u src/sys/dev/pud/pud_dev.c:1.7.2.1 src/sys/dev/pud/pud_dev.c:1.7.2.2 --- src/sys/dev/pud/pud_dev.c:1.7.2.1 Mon Jul 18 21:55:44 2016 +++ src/sys/dev/pud/pud_dev.c Mon Jul 18 22:00:05 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: pud_dev.c,v 1.7.2.1 2016/07/18 21:55:44 pgoyette Exp $ */ +/* $NetBSD: pud_dev.c,v 1.7.2.2 2016/07/18 22:00:05 pgoyette Exp $ */ /* * Copyright (c) 2007 Antti Kantee. All Rights Reserved. @@ -29,7 +29,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pud_dev.c,v 1.7.2.1 2016/07/18 21:55:44 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pud_dev.c,v 1.7.2.2 2016/07/18 22:00:05 pgoyette Exp $"); #include #include @@ -113,7 +113,7 @@ struct bdevsw pud_bdevsw = { .d_psize = pud_bdev_size, #endif #ifdef _MODULE - .d_localcount = pud_b_localcount, + .d_localcount = _b_localcount, #endif }; @@ -219,7 +219,7 @@ struct cdevsw pud_cdevsw = { .d_mmap = pud_cdev_mmap, .d_kqfilter = pud_cdev_kqfilter, #ifdef _MODULE - .d_localcount = pud_b_localcount, + .d_localcount = _b_localcount, #endif .d_flag = D_OTHER, };
CVS commit: [pgoyette-localcount] src/sys/dev/pud
Module Name:src Committed By: pgoyette Date: Mon Jul 18 22:00:05 UTC 2016 Modified Files: src/sys/dev/pud [pgoyette-localcount]: pud_dev.c Log Message: And use the address of the localcount ... To generate a diff of this commit: cvs rdiff -u -r1.7.2.1 -r1.7.2.2 src/sys/dev/pud/pud_dev.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev/pud
Module Name:src Committed By: pgoyette Date: Mon Jul 18 21:55:44 UTC 2016 Modified Files: src/sys/dev/pud [pgoyette-localcount]: pud_dev.c Log Message: Another driver that needs its 'struct localcount' since it is used in rump. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.7.2.1 src/sys/dev/pud/pud_dev.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev/pud
Module Name:src Committed By: pgoyette Date: Mon Jul 18 21:55:44 UTC 2016 Modified Files: src/sys/dev/pud [pgoyette-localcount]: pud_dev.c Log Message: Another driver that needs its 'struct localcount' since it is used in rump. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.7.2.1 src/sys/dev/pud/pud_dev.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pud/pud_dev.c diff -u src/sys/dev/pud/pud_dev.c:1.7 src/sys/dev/pud/pud_dev.c:1.7.2.1 --- src/sys/dev/pud/pud_dev.c:1.7 Tue Dec 8 20:36:15 2015 +++ src/sys/dev/pud/pud_dev.c Mon Jul 18 21:55:44 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: pud_dev.c,v 1.7 2015/12/08 20:36:15 christos Exp $ */ +/* $NetBSD: pud_dev.c,v 1.7.2.1 2016/07/18 21:55:44 pgoyette Exp $ */ /* * Copyright (c) 2007 Antti Kantee. All Rights Reserved. @@ -29,7 +29,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pud_dev.c,v 1.7 2015/12/08 20:36:15 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pud_dev.c,v 1.7.2.1 2016/07/18 21:55:44 pgoyette Exp $"); #include #include @@ -39,6 +39,7 @@ __KERNEL_RCSID(0, "$NetBSD: pud_dev.c,v #include #include #include +#include #include @@ -98,6 +99,10 @@ static dev_type_dump(pud_bdev_dump); static dev_type_size(pud_bdev_size); #endif +#ifdef _MODULE +struct localcount pud_b_localcount, pud_c_localcount; +#endif + struct bdevsw pud_bdevsw = { .d_open = pud_bdev_open, .d_close = pud_bdev_close, @@ -107,6 +112,9 @@ struct bdevsw pud_bdevsw = { .d_dump = pud_bdev_dump, .d_psize = pud_bdev_size, #endif +#ifdef _MODULE + .d_localcount = pud_b_localcount, +#endif }; static int @@ -210,6 +218,9 @@ struct cdevsw pud_cdevsw = { .d_poll = pud_cdev_poll, .d_mmap = pud_cdev_mmap, .d_kqfilter = pud_cdev_kqfilter, +#ifdef _MODULE + .d_localcount = pud_b_localcount, +#endif .d_flag = D_OTHER, };
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Mon Jul 18 21:18:49 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: vnd.c Log Message: Another case of needing to use the two different localcount that were allocated. To generate a diff of this commit: cvs rdiff -u -r1.256.2.1 -r1.256.2.2 src/sys/dev/vnd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev
Module Name:src Committed By: pgoyette Date: Mon Jul 18 21:18:49 UTC 2016 Modified Files: src/sys/dev [pgoyette-localcount]: vnd.c Log Message: Another case of needing to use the two different localcount that were allocated. To generate a diff of this commit: cvs rdiff -u -r1.256.2.1 -r1.256.2.2 src/sys/dev/vnd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/vnd.c diff -u src/sys/dev/vnd.c:1.256.2.1 src/sys/dev/vnd.c:1.256.2.2 --- src/sys/dev/vnd.c:1.256.2.1 Mon Jul 18 03:49:59 2016 +++ src/sys/dev/vnd.c Mon Jul 18 21:18:49 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vnd.c,v 1.256.2.1 2016/07/18 03:49:59 pgoyette Exp $ */ +/* $NetBSD: vnd.c,v 1.256.2.2 2016/07/18 21:18:49 pgoyette Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.1 2016/07/18 03:49:59 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.256.2.2 2016/07/18 21:18:49 pgoyette Exp $"); #if defined(_KERNEL_OPT) #include "opt_vnd.h" @@ -228,7 +228,7 @@ const struct cdevsw vnd_cdevsw = { .d_kqfilter = nokqfilter, .d_discard = nodiscard, #ifdef _MODULE - .d_localcount = _b_localcount, + .d_localcount = _c_localcount, #endif .d_flag = D_DISK };
CVS commit: [pgoyette-localcount] src/sys/dev/pad
Module Name:src Committed By: pgoyette Date: Mon Jul 18 11:25:07 UTC 2016 Modified Files: src/sys/dev/pad [pgoyette-localcount]: pad.c Log Message: Good grief - what was I thinking? Let's make the d_localcount pointer point to a 'struct localcount' as intended. To generate a diff of this commit: cvs rdiff -u -r1.25.2.1 -r1.25.2.2 src/sys/dev/pad/pad.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev/pad
Module Name:src Committed By: pgoyette Date: Mon Jul 18 11:25:07 UTC 2016 Modified Files: src/sys/dev/pad [pgoyette-localcount]: pad.c Log Message: Good grief - what was I thinking? Let's make the d_localcount pointer point to a 'struct localcount' as intended. To generate a diff of this commit: cvs rdiff -u -r1.25.2.1 -r1.25.2.2 src/sys/dev/pad/pad.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pad/pad.c diff -u src/sys/dev/pad/pad.c:1.25.2.1 src/sys/dev/pad/pad.c:1.25.2.2 --- src/sys/dev/pad/pad.c:1.25.2.1 Mon Jul 18 11:12:11 2016 +++ src/sys/dev/pad/pad.c Mon Jul 18 11:25:07 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: pad.c,v 1.25.2.1 2016/07/18 11:12:11 pgoyette Exp $ */ +/* $NetBSD: pad.c,v 1.25.2.2 2016/07/18 11:25:07 pgoyette Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill@@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.25.2.1 2016/07/18 11:12:11 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.25.2.2 2016/07/18 11:25:07 pgoyette Exp $"); #include #include @@ -147,7 +147,7 @@ const struct cdevsw pad_cdevsw = { .d_kqfilter = nokqfilter, .d_discard = nodiscard, #ifdef _MODULE - .d_localcount = _cdevsw, + .d_localcount = _localcount, #endif .d_flag = D_OTHER | D_MPSAFE, };
CVS commit: [pgoyette-localcount] src/sys/dev/raidframe
Module Name:src Committed By: pgoyette Date: Mon Jul 18 11:13:23 UTC 2016 Modified Files: src/sys/dev/raidframe [pgoyette-localcount]: rf_netbsdkintf.c Log Message: We created two different 'stuct localcount' for a reason - devsw_attach() requires them to be different! So use them both in their respective {b,c}devsw initializations. To generate a diff of this commit: cvs rdiff -u -r1.345.2.2 -r1.345.2.3 src/sys/dev/raidframe/rf_netbsdkintf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/raidframe/rf_netbsdkintf.c diff -u src/sys/dev/raidframe/rf_netbsdkintf.c:1.345.2.2 src/sys/dev/raidframe/rf_netbsdkintf.c:1.345.2.3 --- src/sys/dev/raidframe/rf_netbsdkintf.c:1.345.2.2 Sun Jul 17 05:05:10 2016 +++ src/sys/dev/raidframe/rf_netbsdkintf.c Mon Jul 18 11:13:23 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_netbsdkintf.c,v 1.345.2.2 2016/07/17 05:05:10 pgoyette Exp $ */ +/* $NetBSD: rf_netbsdkintf.c,v 1.345.2.3 2016/07/18 11:13:23 pgoyette Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc. @@ -101,7 +101,7 @@ ***/ #include -__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.345.2.2 2016/07/17 05:05:10 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.345.2.3 2016/07/18 11:13:23 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -248,7 +248,7 @@ const struct cdevsw raid_cdevsw = { .d_kqfilter = nokqfilter, .d_discard = nodiscard, #ifdef _MODULE - .d_localcount = _localcount_bdev, + .d_localcount = _localcount_cdev, #endif .d_flag = D_DISK };
CVS commit: [pgoyette-localcount] src/sys/dev/raidframe
Module Name:src Committed By: pgoyette Date: Mon Jul 18 11:13:23 UTC 2016 Modified Files: src/sys/dev/raidframe [pgoyette-localcount]: rf_netbsdkintf.c Log Message: We created two different 'stuct localcount' for a reason - devsw_attach() requires them to be different! So use them both in their respective {b,c}devsw initializations. To generate a diff of this commit: cvs rdiff -u -r1.345.2.2 -r1.345.2.3 src/sys/dev/raidframe/rf_netbsdkintf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev/pad
Module Name:src Committed By: pgoyette Date: Mon Jul 18 11:12:11 UTC 2016 Modified Files: src/sys/dev/pad [pgoyette-localcount]: pad.c Log Message: Add 'struct localcount' for modular builds To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.25.2.1 src/sys/dev/pad/pad.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev/pad
Module Name:src Committed By: pgoyette Date: Mon Jul 18 11:12:11 UTC 2016 Modified Files: src/sys/dev/pad [pgoyette-localcount]: pad.c Log Message: Add 'struct localcount' for modular builds To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.25.2.1 src/sys/dev/pad/pad.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pad/pad.c diff -u src/sys/dev/pad/pad.c:1.25 src/sys/dev/pad/pad.c:1.25.2.1 --- src/sys/dev/pad/pad.c:1.25 Thu Jul 7 06:55:41 2016 +++ src/sys/dev/pad/pad.c Mon Jul 18 11:12:11 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: pad.c,v 1.25 2016/07/07 06:55:41 msaitoh Exp $ */ +/* $NetBSD: pad.c,v 1.25.2.1 2016/07/18 11:12:11 pgoyette Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill@@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.25 2016/07/07 06:55:41 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.25.2.1 2016/07/18 11:12:11 pgoyette Exp $"); #include #include @@ -44,6 +44,7 @@ __KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.25 #include #include #include +#include #include #include @@ -129,6 +130,10 @@ dev_type_open(pad_open); dev_type_close(pad_close); dev_type_read(pad_read); +#ifdef _MODULE +struct localcount pad_localcount; +#endif + const struct cdevsw pad_cdevsw = { .d_open = pad_open, .d_close = pad_close, @@ -141,6 +146,9 @@ const struct cdevsw pad_cdevsw = { .d_mmap = nommap, .d_kqfilter = nokqfilter, .d_discard = nodiscard, +#ifdef _MODULE + .d_localcount = _cdevsw, +#endif .d_flag = D_OTHER | D_MPSAFE, };
CVS commit: [pgoyette-localcount] src/sys/dev/putter
Module Name:src Committed By: pgoyette Date: Mon Jul 18 06:25:40 UTC 2016 Modified Files: src/sys/dev/putter [pgoyette-localcount]: putter.c Log Message: Another devsw needing a localcount when built as a module. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.35.8.1 src/sys/dev/putter/putter.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/putter/putter.c diff -u src/sys/dev/putter/putter.c:1.35 src/sys/dev/putter/putter.c:1.35.8.1 --- src/sys/dev/putter/putter.c:1.35 Fri Jul 25 08:10:38 2014 +++ src/sys/dev/putter/putter.c Mon Jul 18 06:25:40 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: putter.c,v 1.35 2014/07/25 08:10:38 dholland Exp $ */ +/* $NetBSD: putter.c,v 1.35.8.1 2016/07/18 06:25:40 pgoyette Exp $ */ /* * Copyright (c) 2006, 2007 Antti Kantee. All Rights Reserved. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: putter.c,v 1.35 2014/07/25 08:10:38 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: putter.c,v 1.35.8.1 2016/07/18 06:25:40 pgoyette Exp $"); #include #include @@ -48,6 +48,7 @@ __KERNEL_RCSID(0, "$NetBSD: putter.c,v 1 #include #include #include +#include #include @@ -61,6 +62,10 @@ dev_type_close(puttercdclose); dev_type_ioctl(puttercdioctl); /* dev */ +#ifdef _MODULE +struct localcount putter_localcount; +#endif + const struct cdevsw putter_cdevsw = { .d_open = puttercdopen, .d_close = puttercdclose, @@ -73,6 +78,9 @@ const struct cdevsw putter_cdevsw = { .d_mmap = nommap, .d_kqfilter = nokqfilter, .d_discard = nodiscard, +#ifdef _MODULE + .d_localcount = _localcount, +#endif .d_flag = D_OTHER };
CVS commit: [pgoyette-localcount] src/sys/dev/putter
Module Name:src Committed By: pgoyette Date: Mon Jul 18 06:25:40 UTC 2016 Modified Files: src/sys/dev/putter [pgoyette-localcount]: putter.c Log Message: Another devsw needing a localcount when built as a module. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.35.8.1 src/sys/dev/putter/putter.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [pgoyette-localcount] src/sys/dev/raidframe
Module Name:src Committed By: pgoyette Date: Sun Jul 17 02:44:41 UTC 2016 Modified Files: src/sys/dev/raidframe [pgoyette-localcount]: rf_netbsdkintf.c Log Message: Don't call devsw_attach() and devsw_detach() for built-in modules. To generate a diff of this commit: cvs rdiff -u -r1.345 -r1.345.2.1 src/sys/dev/raidframe/rf_netbsdkintf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/raidframe/rf_netbsdkintf.c diff -u src/sys/dev/raidframe/rf_netbsdkintf.c:1.345 src/sys/dev/raidframe/rf_netbsdkintf.c:1.345.2.1 --- src/sys/dev/raidframe/rf_netbsdkintf.c:1.345 Wed Apr 27 02:47:39 2016 +++ src/sys/dev/raidframe/rf_netbsdkintf.c Sun Jul 17 02:44:41 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_netbsdkintf.c,v 1.345 2016/04/27 02:47:39 christos Exp $ */ +/* $NetBSD: rf_netbsdkintf.c,v 1.345.2.1 2016/07/17 02:44:41 pgoyette Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc. @@ -101,7 +101,7 @@ ***/ #include -__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.345 2016/04/27 02:47:39 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.345.2.1 2016/07/17 02:44:41 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -3766,7 +3766,9 @@ static int raid_modcmd_init(void) { int error; +#ifdef _MODULE int bmajor, cmajor; +#endif mutex_init(_lock, MUTEX_DEFAULT, IPL_NONE); mutex_enter(_lock); @@ -3778,15 +3780,15 @@ raid_modcmd_init(void) rf_sparet_wait_queue = rf_sparet_resp_queue = NULL; #endif +#ifdef _MODULE bmajor = cmajor = -1; error = devsw_attach("raid", _bdevsw, , _cdevsw, ); - if (error != 0 && error != EEXIST) { + if (error != 0) { aprint_error("%s: devsw_attach failed %d\n", __func__, error); mutex_exit(_lock); return error; } -#ifdef _MODULE error = config_cfdriver_attach(_cd); if (error != 0) { aprint_error("%s: config_cfdriver_attach failed %d\n", @@ -3860,17 +3862,15 @@ raid_modcmd_fini(void) mutex_exit(_lock); return error; } -#endif error = devsw_detach(_bdevsw, _cdevsw); if (error != 0) { aprint_error("%s: cannot detach devsw\n",__func__); -#ifdef _MODULE config_cfdriver_attach(_cd); -#endif config_cfattach_attach(raid_cd.cd_name, _ca); mutex_exit(_lock); return error; } +#endif rf_BootRaidframe(false); #if (RF_INCLUDE_PARITY_DECLUSTERING_DS > 0) rf_destroy_mutex2(rf_sparet_wait_mutex);
CVS commit: [pgoyette-localcount] src/sys/dev/raidframe
Module Name:src Committed By: pgoyette Date: Sun Jul 17 02:44:41 UTC 2016 Modified Files: src/sys/dev/raidframe [pgoyette-localcount]: rf_netbsdkintf.c Log Message: Don't call devsw_attach() and devsw_detach() for built-in modules. To generate a diff of this commit: cvs rdiff -u -r1.345 -r1.345.2.1 src/sys/dev/raidframe/rf_netbsdkintf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.