Source-Changes-HG archive

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

[src/trunk]: src/sys/kern sys: Fix various abuse of struct device internals.



details:   https://anonhg.NetBSD.org/src/rev/632601e57eba
branches:  trunk
changeset: 361146:632601e57eba
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Feb 12 03:24:34 2022 +0000

description:
sys: Fix various abuse of struct device internals.

Will help to make struct device opaque later.

diffstat:

 share/man/man4/iop.4               |   4 +-
 sys/arch/arm/ep93xx/epcom.c        |   6 ++--
 sys/arch/arm/imx/imx31_icu.c       |   6 ++--
 sys/arch/arm/imx/imx51_tzic.c      |   6 ++--
 sys/arch/arm/omap/omapl1x_psc.c    |   4 +-
 sys/arch/arm/omap/omapl1x_timer.c  |   4 +-
 sys/arch/evbmips/cavium/autoconf.c |   6 ++--
 sys/arch/sgimips/ioc/if_le_oioc.c  |  10 ++++----
 sys/arch/sun3/dev/fbvar.h          |   4 +-
 sys/arch/vax/vsa/lcg.c             |  46 +++++++++++++++++++++++--------------
 sys/arch/x86/x86/x86_autoconf.c    |   6 ++--
 sys/arch/zaurus/zaurus/autoconf.c  |   6 ++--
 sys/dev/i2c/ihidev.c               |  41 +++++++++++++++++----------------
 sys/dev/i2c/pcagpio.c              |  18 +++++++-------
 sys/dev/i2c/tsllux.c               |   7 ++---
 sys/dev/isa/wss_isa.c              |  20 +++++----------
 sys/dev/marvell/if_mvxpe.c         |   7 +++--
 sys/dev/marvell/mvxpsec.c          |   4 +-
 sys/dev/pci/xmm7360.c              |  25 +++++++++++---------
 sys/dev/spkr.c                     |  10 ++++---
 sys/dev/usb/vhci.c                 |   6 ++--
 sys/kern/kern_drvctl.c             |  21 +++++++++--------
 22 files changed, 140 insertions(+), 127 deletions(-)

diffs (truncated from 996 to 300 lines):

diff -r 2f50df54bd54 -r 632601e57eba share/man/man4/iop.4
--- a/share/man/man4/iop.4      Sat Feb 12 02:58:50 2022 +0000
+++ b/share/man/man4/iop.4      Sat Feb 12 03:24:34 2022 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: iop.4,v 1.22 2017/07/03 21:30:58 wiz Exp $
+.\"    $NetBSD: iop.4,v 1.23 2022/02/12 03:24:34 riastradh Exp $
 .\"
 .\" Copyright (c) 2000, 2001, 2007 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -169,7 +169,7 @@
 struct iop_tidmap {
        u_short it_tid;
        u_short it_flags;
-       char    it_dvname[sizeof(((struct device *)NULL)->dv_xname)];
+       char    it_dvname[16];  /* DEVICE_XNAME_SIZE */
 };
 #define        IT_CONFIGURED   0x02    /* target configured */
 .Ed
diff -r 2f50df54bd54 -r 632601e57eba sys/arch/arm/ep93xx/epcom.c
--- a/sys/arch/arm/ep93xx/epcom.c       Sat Feb 12 02:58:50 2022 +0000
+++ b/sys/arch/arm/ep93xx/epcom.c       Sat Feb 12 03:24:34 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: epcom.c,v 1.34 2021/11/21 08:44:28 skrll Exp $ */
+/*     $NetBSD: epcom.c,v 1.35 2022/02/12 03:24:34 riastradh Exp $ */
 /*
  * Copyright (c) 1998, 1999, 2001, 2002, 2004 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -73,7 +73,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: epcom.c,v 1.34 2021/11/21 08:44:28 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: epcom.c,v 1.35 2022/02/12 03:24:34 riastradh Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -260,7 +260,7 @@
        if (sc->sc_iot == kgdb_sc.sc_iot &&
            sc->sc_hwbase == kgdb_sc.sc_hwbase) {
                SET(sc->sc_hwflags, COM_HW_KGDB);
-               printf("%s: kgdb\n", sc->sc_dev.dv_xname);
+               device_printf(sc->sc_dev, "kgdb\n");
        }
 #endif
 
diff -r 2f50df54bd54 -r 632601e57eba sys/arch/arm/imx/imx31_icu.c
--- a/sys/arch/arm/imx/imx31_icu.c      Sat Feb 12 02:58:50 2022 +0000
+++ b/sys/arch/arm/imx/imx31_icu.c      Sat Feb 12 03:24:34 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: imx31_icu.c,v 1.7 2012/10/27 17:17:39 chs Exp $        */
+/*     $NetBSD: imx31_icu.c,v 1.8 2022/02/12 03:24:34 riastradh Exp $  */
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: imx31_icu.c,v 1.7 2012/10/27 17:17:39 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx31_icu.c,v 1.8 2022/02/12 03:24:34 riastradh Exp $");
 
 #define _INTR_PRIVATE
  
@@ -225,7 +225,7 @@
        int error;
 
        KASSERT(ahba->ahba_irqbase != AHBCF_IRQBASE_DEFAULT);
-       KASSERT(self->dv_unit == 0);
+       KASSERT(device_unit(self) == 0);
 
        if (ahba->ahba_size == AHBCF_SIZE_DEFAULT)
                ahba->ahba_size = INTC_SIZE;
diff -r 2f50df54bd54 -r 632601e57eba sys/arch/arm/imx/imx51_tzic.c
--- a/sys/arch/arm/imx/imx51_tzic.c     Sat Feb 12 02:58:50 2022 +0000
+++ b/sys/arch/arm/imx/imx51_tzic.c     Sat Feb 12 03:24:34 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: imx51_tzic.c,v 1.7 2014/07/25 07:49:56 hkenken Exp $   */
+/*     $NetBSD: imx51_tzic.c,v 1.8 2022/02/12 03:24:34 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2010 SHIMIZU Ryo <ryo%nerv.org@localhost>
@@ -26,7 +26,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: imx51_tzic.c,v 1.7 2014/07/25 07:49:56 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx51_tzic.c,v 1.8 2022/02/12 03:24:34 riastradh Exp $");
 
 #define        _INTR_PRIVATE   /* for arm/pic/picvar.h */
 
@@ -124,7 +124,7 @@
        int error;
 
        KASSERT(aa->aa_irqbase != AXICF_IRQBASE_DEFAULT);
-       KASSERT(self->dv_unit == 0);
+       KASSERT(device_unit(self) == 0);
 
        aprint_normal(": TrustZone Interrupt Controller\n");
        aprint_naive("\n");
diff -r 2f50df54bd54 -r 632601e57eba sys/arch/arm/omap/omapl1x_psc.c
--- a/sys/arch/arm/omap/omapl1x_psc.c   Sat Feb 12 02:58:50 2022 +0000
+++ b/sys/arch/arm/omap/omapl1x_psc.c   Sat Feb 12 03:24:34 2022 +0000
@@ -27,7 +27,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: omapl1x_psc.c,v 1.1 2013/10/02 16:48:26 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omapl1x_psc.c,v 1.2 2022/02/12 03:24:34 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -120,7 +120,7 @@
        sc = device_private(self);
 
        sc->sc_iot = tipb->tipb_iot;
-       sc->sc_unit = self->dv_unit;
+       sc->sc_unit = device_unit(self);
        sc->sc_addr = tipb->tipb_addr;
        sc->sc_size = tipb->tipb_size;
 
diff -r 2f50df54bd54 -r 632601e57eba sys/arch/arm/omap/omapl1x_timer.c
--- a/sys/arch/arm/omap/omapl1x_timer.c Sat Feb 12 02:58:50 2022 +0000
+++ b/sys/arch/arm/omap/omapl1x_timer.c Sat Feb 12 03:24:34 2022 +0000
@@ -25,7 +25,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: omapl1x_timer.c,v 1.2 2020/07/22 01:24:39 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omapl1x_timer.c,v 1.3 2022/02/12 03:24:34 riastradh Exp $");
 
 #include "opt_timer.h"
 
@@ -436,7 +436,7 @@
        struct omapl1xtmr_softc *sc = device_private(self);
        struct tipb_attach_args *tipb = aux;
 
-       sc->sc_timerno = self->dv_unit;
+       sc->sc_timerno = device_unit(self);
        sc->sc_iot = tipb->tipb_iot;
        sc->sc_intr = tipb->tipb_intr;
        sc->sc_addr = tipb->tipb_addr;
diff -r 2f50df54bd54 -r 632601e57eba sys/arch/evbmips/cavium/autoconf.c
--- a/sys/arch/evbmips/cavium/autoconf.c        Sat Feb 12 02:58:50 2022 +0000
+++ b/sys/arch/evbmips/cavium/autoconf.c        Sat Feb 12 03:24:34 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.c,v 1.9 2020/08/17 06:23:01 simonb Exp $      */
+/*     $NetBSD: autoconf.c,v 1.10 2022/02/12 03:24:34 riastradh Exp $  */
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.9 2020/08/17 06:23:01 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.10 2022/02/12 03:24:34 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -172,7 +172,7 @@
                pn = prop_number_create_signed(7 - unit);
                break;
        case BOARD_TYPE_UBIQUITI_E300:
-               pn = prop_number_create_signed(4 + dev->dv_unit);
+               pn = prop_number_create_signed(4 + device_unit(dev));
                break;
        default:
                pn = prop_number_create_signed(-1);
diff -r 2f50df54bd54 -r 632601e57eba sys/arch/sgimips/ioc/if_le_oioc.c
--- a/sys/arch/sgimips/ioc/if_le_oioc.c Sat Feb 12 02:58:50 2022 +0000
+++ b/sys/arch/sgimips/ioc/if_le_oioc.c Sat Feb 12 03:24:34 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_le_oioc.c,v 1.5 2015/06/11 08:22:09 matt Exp $      */
+/*     $NetBSD: if_le_oioc.c,v 1.6 2022/02/12 03:24:34 riastradh Exp $ */
 
 /*
  * Copyright (c) 2009 Stephen M. Rumble
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_le_oioc.c,v 1.5 2015/06/11 08:22:09 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_le_oioc.c,v 1.6 2022/02/12 03:24:34 riastradh Exp $");
 
 #include "opt_inet.h"
 
@@ -88,9 +88,9 @@
  *             bus_space_tag ...
  *     }
  *
- * So, we can cast any three to any other three, plus sc_dev->dv_private points
- * back at the top (i.e. to le_softc, am7990_softc and lance_softc). Bloody
- * hell!
+ * So, we can cast any three to any other three, plus
+ * device_private(sc_dev) points back at the top (i.e. to le_softc,
+ * am7990_softc and lance_softc). Bloody hell!
  */
 struct le_softc {
        struct  am7990_softc sc_am7990;         /* glue to MI code */
diff -r 2f50df54bd54 -r 632601e57eba sys/arch/sun3/dev/fbvar.h
--- a/sys/arch/sun3/dev/fbvar.h Sat Feb 12 02:58:50 2022 +0000
+++ b/sys/arch/sun3/dev/fbvar.h Sat Feb 12 03:24:34 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fbvar.h,v 1.13 2008/06/28 12:13:38 tsutsui Exp $       */
+/*     $NetBSD: fbvar.h,v 1.14 2022/02/12 03:24:35 riastradh Exp $     */
 
 /*
  * Copyright (c) 1992, 1993
@@ -53,7 +53,7 @@
        struct  fbtype fb_fbtype;       /* see fbio.h */
        struct  fbdriver *fb_driver;    /* pointer to driver */
        void *fb_private;               /* for fb driver use */
-       const char *fb_name;            /* i.e. sc_dev->dv_xname */
+       const char *fb_name;            /* i.e. device_xname(sc_dev) */
 
        void *  fb_pixels;              /* display RAM */
        int     fb_linebytes;           /* bytes per display line */
diff -r 2f50df54bd54 -r 632601e57eba sys/arch/vax/vsa/lcg.c
--- a/sys/arch/vax/vsa/lcg.c    Sat Feb 12 02:58:50 2022 +0000
+++ b/sys/arch/vax/vsa/lcg.c    Sat Feb 12 03:24:34 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lcg.c,v 1.7 2021/08/07 16:19:07 thorpej Exp $ */
+/*     $NetBSD: lcg.c,v 1.8 2022/02/12 03:24:35 riastradh Exp $ */
 /*
  * LCG accelerated framebuffer driver
  * Copyright (c) 2003, 2004 Blaz Antonic
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lcg.c,v 1.7 2021/08/07 16:19:07 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lcg.c,v 1.8 2022/02/12 03:24:35 riastradh Exp $");
 
 #define LCG_NO_ACCEL
 
@@ -991,7 +991,8 @@
        if (self != NULL) {
                regaddr = (long*)vax_map_physmem(LCG_REG_ADDR, (LCG_REG_SIZE/VAX_NBPG));
                if (regaddr == 0) {
-                       printf("%s: Couldn't allocate register memory.\n", self->dv_xname);
+                       device_printf(self,
+                           "Couldn't allocate register memory.\n");
                        return;
                }
        } else {
@@ -1061,8 +1062,9 @@
                panic("LCG model not supported");
        }
        if (self != NULL)
-               aprint_normal("%s: framebuffer size %dx%d, depth %d (magic 0x%x)\n",
-                       self->dv_xname, lcg_xsize, lcg_ysize, lcg_depth, magic);
+               aprint_normal_dev(self,
+                   "framebuffer size %dx%d, depth %d (magic 0x%x)\n",
+                   lcg_xsize, lcg_ysize, lcg_depth, magic);
 
        wsfont_init();
        cookie = wsfont_find(NULL, 12, 22, 0, WSDISPLAY_FONTORDER_R2L,
@@ -1079,8 +1081,9 @@
        lcg_cols = lcg_xsize / lcg_font.fontwidth;
        lcg_rows = lcg_ysize / lcg_font.fontheight;
        if (self != NULL) {
-               aprint_normal("%s: using font %s (%dx%d), ", self->dv_xname, lcg_font.name,
-                               lcg_font.fontwidth, lcg_font.fontheight);
+               aprint_normal_dev(self, "using font %s (%dx%d), ",
+                   lcg_font.name,
+                   lcg_font.fontwidth, lcg_font.fontheight);
                aprint_normal("console size: %dx%d\n", lcg_cols, lcg_rows);
        }
        lcg_onerow = lcg_xsize * lcg_font.fontheight;
@@ -1098,7 +1101,8 @@
                lcgaddr = (void *)vax_map_physmem(va->va_paddr,
                                        ((lcg_fb_size + LCG_FONT_STORAGE_SIZE)/VAX_NBPG));
                if (lcgaddr == 0) {
-                       printf("%s: unable to allocate framebuffer memory.\n", self->dv_xname);
+                       device_printf(self,
+                           "unable to allocate framebuffer memory.\n");
                        return;
                }
 #ifndef LCG_NO_ACCEL
@@ -1120,12 +1124,13 @@
 
                lutaddr = (void *)vax_map_physmem(LCG_LUT_ADDR, (LCG_LUT_SIZE/VAX_NBPG));
                if (lutaddr == 0) {
-                       printf("%s: unable to allocate LUT memory.\n", self->dv_xname);
+                       device_printf(self,
+                           "unable to allocate LUT memory.\n");
                        return;
                }
                fifoaddr = (long*)vax_map_physmem(LCG_FIFO_WIN_ADDR, (LCG_FIFO_WIN_SIZE/VAX_NBPG));
                if (regaddr == 0) {
-                       printf("%s: unable to map FIFO window\n", self->dv_xname);
+                       device_printf(self, "unable to map FIFO window\n");
                        return;
                }
 
@@ -1133,16 +1138,18 @@
                err = bus_dmamem_alloc(va->va_dmat, LCG_FIFO_SIZE, 
                        LCG_FIFO_ALIGN, 0, &seg, 1, &rseg, BUS_DMA_NOWAIT);
                if (err) {
-                       printf("%s: unable to allocate FIFO memory block, err = %d\n", 



Home | Main Index | Thread Index | Old Index