sys: Fix various abuse of struct device internals.

Will help to make struct device opaque later.
This commit is contained in:
riastradh 2022-02-12 03:24:34 +00:00
parent b8e6b89d9f
commit 3aa5a3ae30
22 changed files with 140 additions and 127 deletions

View File

@ -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 @@ iov_len field from the returned iovec.
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

View File

@ -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 @@ epcom_attach_subr(struct epcom_softc *sc)
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

View File

@ -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 @@ avic_attach(device_t parent, device_t self, void *aux)
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;

View File

@ -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>
@ -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 @@ tzic_attach(device_t parent, device_t self, void *aux)
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");

View File

@ -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 @@ omapl1xpsc_attach(device_t parent, device_t self, void *aux)
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;

View File

@ -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 @@ omapl1xtimer_attach (device_t parent, device_t self, void *aux)
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;

View File

@ -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 @@ prop_set_cnmac(device_t dev)
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);

View File

@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: if_le_oioc.c,v 1.5 2015/06/11 08:22:09 matt Exp $");
* 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 */

View File

@ -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 fbdevice {
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 */

View File

@ -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 @@ lcg_init_common(struct device *self, struct vsbus_attach_args *va)
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 @@ lcg_init_common(struct device *self, struct vsbus_attach_args *va)
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_init_common(struct device *self, struct vsbus_attach_args *va)
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 @@ lcg_init_common(struct device *self, struct vsbus_attach_args *va)
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 @@ lcg_init_common(struct device *self, struct vsbus_attach_args *va)
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 @@ lcg_init_common(struct device *self, struct vsbus_attach_args *va)
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",
self->dv_xname, err);
device_printf(self,
"unable to allocate FIFO memory block, err = %d\n",
err);
return;
}
err = bus_dmamem_map(va->va_dmat, &seg, rseg, LCG_FIFO_SIZE,
&fifo_mem_vaddr, BUS_DMA_NOWAIT);
if (err) {
printf("%s: unable to map FIFO memory block, err = %d\n",
self->dv_xname, err);
device_printf(self,
"unable to map FIFO memory block, err = %d\n",
err);
bus_dmamem_free(va->va_dmat, &seg, rseg);
return;
}
@ -1150,7 +1157,9 @@ lcg_init_common(struct device *self, struct vsbus_attach_args *va)
err = bus_dmamap_create(va->va_dmat, LCG_FIFO_SIZE, rseg,
LCG_FIFO_SIZE, 0, BUS_DMA_NOWAIT, &sc->sc_dm);
if (err) {
printf("%s: unable to create DMA map, err = %d\n", self->dv_xname, err);
device_printf(self,
"unable to create DMA map, err = %d\n",
err);
bus_dmamem_unmap(va->va_dmat, fifo_mem_vaddr, LCG_FIFO_SIZE);
bus_dmamem_free(va->va_dmat, &seg, rseg);
return;
@ -1159,7 +1168,9 @@ lcg_init_common(struct device *self, struct vsbus_attach_args *va)
err = bus_dmamap_load(va->va_dmat, sc->sc_dm, fifo_mem_vaddr,
LCG_FIFO_SIZE, NULL, BUS_DMA_NOWAIT);
if (err) {
printf("%s: unable to load DMA map, err = %d\n", self->dv_xname, err);
device_printf(self,
"unable to load DMA map, err = %d\n",
err);
bus_dmamap_destroy(va->va_dmat, sc->sc_dm);
bus_dmamem_unmap(va->va_dmat, fifo_mem_vaddr, LCG_FIFO_SIZE);
bus_dmamem_free(va->va_dmat, &seg, rseg);
@ -1288,6 +1299,7 @@ lcg_init_common(struct device *self, struct vsbus_attach_args *va)
#ifdef LCG_DEBUG
if (self != NULL)
printf("%s: video config register set 0x%08lx\n", video_conf, self->dv_xname);
device_printf(self, "video config register set 0x%08lx\n",
video_conf);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: x86_autoconf.c,v 1.85 2021/10/07 12:52:27 msaitoh Exp $ */
/* $NetBSD: x86_autoconf.c,v 1.86 2022/02/12 03:24:35 riastradh Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: x86_autoconf.c,v 1.85 2021/10/07 12:52:27 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: x86_autoconf.c,v 1.86 2022/02/12 03:24:35 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -568,7 +568,7 @@ device_register(device_t dev, void *aux)
* only for reading memory module EERPOMs and sensors.
*/
if (device_is_a(dev, "iic") &&
device_is_a(dev->dv_parent, "imcsmb")) {
device_is_a(device_parent(dev), "imcsmb")) {
static const char *imcsmb_device_permitlist[] = {
"spdmem",
"sdtemp",

View File

@ -1,4 +1,4 @@
/* $NetBSD: autoconf.c,v 1.14 2021/06/21 03:05:24 christos Exp $ */
/* $NetBSD: autoconf.c,v 1.15 2022/02/12 03:24:35 riastradh Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.14 2021/06/21 03:05:24 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.15 2022/02/12 03:24:35 riastradh Exp $");
#include "opt_md.h"
@ -226,7 +226,7 @@ device_register(device_t dev, void *aux)
* limited capabilities.
*/
if (device_is_a(dev, "iic") &&
device_is_a(dev->dv_parent, "ziic")) {
device_is_a(device_parent(dev), "ziic")) {
(void)prop_dictionary_set_string_nocopy(device_properties(dev),
I2C_PROP_INDIRECT_PROBE_STRATEGY, I2C_PROBE_STRATEGY_NONE);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ihidev.c,v 1.27 2022/01/15 06:22:30 skrll Exp $ */
/* $NetBSD: ihidev.c,v 1.28 2022/02/12 03:24:35 riastradh Exp $ */
/* $OpenBSD ihidev.c,v 1.13 2017/04/08 02:57:23 deraadt Exp $ */
/*-
@ -54,7 +54,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ihidev.c,v 1.27 2022/01/15 06:22:30 skrll Exp $");
__KERNEL_RCSID(0, "$NetBSD: ihidev.c,v 1.28 2022/02/12 03:24:35 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -204,8 +204,8 @@ ihidev_attach(device_t parent, device_t self, void *aux)
if (isize > sc->sc_isize)
sc->sc_isize = isize;
DPRINTF(("%s: repid %d size %d\n", sc->sc_dev.dv_xname, repid,
repsz));
DPRINTF(("%s: repid %d size %d\n",
device_xname(sc->sc_dev), repid, repsz));
}
sc->sc_ibuf = kmem_zalloc(sc->sc_isize, KM_SLEEP);
if (!ihidev_intr_init(sc)) {
@ -334,14 +334,14 @@ ihidev_hid_command(struct ihidev_softc *sc, int hidcmd, void *arg, bool poll)
};
DPRINTF(("%s: HID command I2C_HID_CMD_DESCR at 0x%x\n",
sc->sc_dev.dv_xname, htole16(sc->sc_hid_desc_addr)));
device_xname(sc->sc_dev), htole16(sc->sc_hid_desc_addr)));
/* 20 00 */
res = iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr,
&cmd, sizeof(cmd), &sc->hid_desc_buf,
sizeof(struct i2c_hid_desc), flags);
DPRINTF(("%s: HID descriptor:", sc->sc_dev.dv_xname));
DPRINTF(("%s: HID descriptor:", device_xname(sc->sc_dev)));
for (i = 0; i < sizeof(struct i2c_hid_desc); i++)
DPRINTF((" %.2x", sc->hid_desc_buf[i]));
DPRINTF(("\n"));
@ -357,7 +357,7 @@ ihidev_hid_command(struct ihidev_softc *sc, int hidcmd, void *arg, bool poll)
};
DPRINTF(("%s: HID command I2C_HID_CMD_RESET\n",
sc->sc_dev.dv_xname));
device_xname(sc->sc_dev)));
/* 22 00 00 01 */
res = iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP, sc->sc_addr,
@ -385,7 +385,7 @@ ihidev_hid_command(struct ihidev_softc *sc, int hidcmd, void *arg, bool poll)
uint8_t *tmprep;
DPRINTF(("%s: HID command I2C_HID_CMD_GET_REPORT %d "
"(type %d, len %d)\n", sc->sc_dev.dv_xname, report_id,
"(type %d, len %d)\n", device_xname(sc->sc_dev), report_id,
rreq->type, rreq->len));
/*
@ -431,7 +431,7 @@ ihidev_hid_command(struct ihidev_softc *sc, int hidcmd, void *arg, bool poll)
d = tmprep[0] | tmprep[1] << 8;
if (d != report_len) {
DPRINTF(("%s: response size %d != expected length %d\n",
sc->sc_dev.dv_xname, d, report_len));
device_xname(sc->sc_dev), d, report_len));
}
if (report_id_len == 2)
@ -441,13 +441,13 @@ ihidev_hid_command(struct ihidev_softc *sc, int hidcmd, void *arg, bool poll)
if (d != rreq->id) {
DPRINTF(("%s: response report id %d != %d\n",
sc->sc_dev.dv_xname, d, rreq->id));
device_xname(sc->sc_dev), d, rreq->id));
iic_release_bus(sc->sc_tag, 0);
kmem_free(tmprep, report_len);
return (1);
}
DPRINTF(("%s: response:", sc->sc_dev.dv_xname));
DPRINTF(("%s: response:", device_xname(sc->sc_dev)));
for (i = 0; i < report_len; i++)
DPRINTF((" %.2x", tmprep[i]));
DPRINTF(("\n"));
@ -475,7 +475,7 @@ ihidev_hid_command(struct ihidev_softc *sc, int hidcmd, void *arg, bool poll)
uint8_t *finalcmd;
DPRINTF(("%s: HID command I2C_HID_CMD_SET_REPORT %d "
"(type %d, len %d):", sc->sc_dev.dv_xname, report_id,
"(type %d, len %d):", device_xname(sc->sc_dev), report_id,
rreq->type, rreq->len));
for (i = 0; i < rreq->len; i++)
DPRINTF((" %.2x", ((uint8_t *)rreq->data)[i]));
@ -540,7 +540,7 @@ ihidev_hid_command(struct ihidev_softc *sc, int hidcmd, void *arg, bool poll)
};
DPRINTF(("%s: HID command I2C_HID_CMD_SET_POWER(%d)\n",
sc->sc_dev.dv_xname, power));
device_xname(sc->sc_dev), power));
/* 22 00 00 08 */
res = iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP, sc->sc_addr,
@ -555,14 +555,15 @@ ihidev_hid_command(struct ihidev_softc *sc, int hidcmd, void *arg, bool poll)
};
DPRINTF(("%s: HID command I2C_HID_REPORT_DESCR at 0x%x with "
"size %d\n", sc->sc_dev.dv_xname, cmd[0],
"size %d\n", device_xname(sc->sc_dev), cmd[0],
sc->sc_reportlen));
/* 20 00 */
res = iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr,
&cmd, sizeof(cmd), sc->sc_report, sc->sc_reportlen, flags);
DPRINTF(("%s: HID report descriptor:", sc->sc_dev.dv_xname));
DPRINTF(("%s: HID report descriptor:",
device_xname(sc->sc_dev)));
for (i = 0; i < sc->sc_reportlen; i++)
DPRINTF((" %.2x", sc->sc_report[i]));
DPRINTF(("\n"));
@ -582,7 +583,7 @@ ihidev_hid_command(struct ihidev_softc *sc, int hidcmd, void *arg, bool poll)
static int
ihidev_reset(struct ihidev_softc *sc, bool poll)
{
DPRINTF(("%s: resetting\n", sc->sc_dev.dv_xname));
DPRINTF(("%s: resetting\n", device_xname(sc->sc_dev)));
if (ihidev_hid_command(sc, I2C_HID_CMD_SET_POWER,
&I2C_HID_POWER_ON, poll)) {
@ -795,7 +796,7 @@ ihidev_work(struct work *wk, void *arg)
psize = sc->sc_ibuf[0] | sc->sc_ibuf[1] << 8;
if (!psize || psize > sc->sc_isize) {
DPRINTF(("%s: %s: invalid packet size (%d vs. %d)\n",
sc->sc_dev.dv_xname, __func__, psize, sc->sc_isize));
device_xname(sc->sc_dev), __func__, psize, sc->sc_isize));
goto out;
}
@ -811,7 +812,7 @@ ihidev_work(struct work *wk, void *arg)
goto out;
}
DPRINTF(("%s: %s: hid input (rep %d):", sc->sc_dev.dv_xname,
DPRINTF(("%s: %s: hid input (rep %d):", device_xname(sc->sc_dev),
__func__, rep));
for (i = 0; i < sc->sc_isize; i++)
DPRINTF((" %.2x", sc->sc_ibuf[i]));
@ -884,7 +885,7 @@ ihidev_open(struct ihidev *scd)
struct ihidev_softc *sc = scd->sc_parent;
int error;
DPRINTF(("%s: %s: state=%d refcnt=%d\n", sc->sc_dev.dv_xname,
DPRINTF(("%s: %s: state=%d refcnt=%d\n", device_xname(sc->sc_dev),
__func__, scd->sc_state, sc->sc_refcnt));
mutex_enter(&sc->sc_lock);
@ -914,7 +915,7 @@ ihidev_close(struct ihidev *scd)
{
struct ihidev_softc *sc = scd->sc_parent;
DPRINTF(("%s: %s: state=%d refcnt=%d\n", sc->sc_dev.dv_xname,
DPRINTF(("%s: %s: state=%d refcnt=%d\n", device_xname(sc->sc_dev),
__func__, scd->sc_state, sc->sc_refcnt));
mutex_enter(&sc->sc_lock);

View File

@ -1,4 +1,4 @@
/* $NetBSD: pcagpio.c,v 1.11 2021/06/21 03:12:54 christos Exp $ */
/* $NetBSD: pcagpio.c,v 1.12 2022/02/12 03:24:35 riastradh Exp $ */
/*-
* Copyright (c) 2020 Michael Lorenz
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pcagpio.c,v 1.11 2021/06/21 03:12:54 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: pcagpio.c,v 1.12 2022/02/12 03:24:35 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -172,9 +172,9 @@ pcagpio_attach(device_t parent, device_t self, void *aux)
out &= ~sc->sc_dir;
in &= sc->sc_dir;
printdir(sc->sc_dev->dv_xname, in, sc->sc_dir, 'I');
printdir(sc->sc_dev->dv_xname, out, ~sc->sc_dir, 'O');
printdir(device_xname(sc->sc_dev), in, sc->sc_dir, 'I');
printdir(device_xname(sc->sc_dev), out, ~sc->sc_dir, 'O');
callout_init(&sc->sc_timer, CALLOUT_MPSAFE);
callout_reset(&sc->sc_timer, hz*20, pcagpio_timeout, sc);
@ -246,15 +246,15 @@ pcagpio_timeout(void *v)
o_in = sc->sc_in;
o_out &= ~sc->sc_dir;
o_in &= sc->sc_dir;
printdir(sc->sc_dev->dv_xname, o_in, sc->sc_dir, 'I');
printdir(sc->sc_dev->dv_xname, o_out, ~sc->sc_dir, 'O');
printdir(device_xname(sc->sc_dev), o_in, sc->sc_dir, 'I');
printdir(device_xname(sc->sc_dev), o_out, ~sc->sc_dir, 'O');
sc->sc_state = out;
sc->sc_dir = dir;
sc->sc_in = in;
out &= ~sc->sc_dir;
in &= sc->sc_dir;
printdir(sc->sc_dev->dv_xname, in, sc->sc_dir, 'I');
printdir(sc->sc_dev->dv_xname, out, ~sc->sc_dir, 'O');
printdir(device_xname(sc->sc_dev), in, sc->sc_dir, 'I');
printdir(device_xname(sc->sc_dev), out, ~sc->sc_dir, 'O');
}
callout_reset(&sc->sc_timer, hz*60, pcagpio_timeout, sc);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: tsllux.c,v 1.3 2021/01/27 02:29:48 thorpej Exp $ */
/* $NetBSD: tsllux.c,v 1.4 2022/02/12 03:24:35 riastradh Exp $ */
/*-
* Copyright (c) 2018 Jason R. Thorpe
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tsllux.c,v 1.3 2021/01/27 02:29:48 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: tsllux.c,v 1.4 2022/02/12 03:24:35 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -154,8 +154,7 @@ tsllux_attach(device_t parent, device_t self, void *aux)
sc->sc_i2c = ia->ia_tag;
sc->sc_addr = ia->ia_addr;
if (self->dv_cfdata != NULL &&
self->dv_cfdata->cf_flags & TSLLUX_F_CS_PACKAGE)
if (device_cfdata(self)->cf_flags & TSLLUX_F_CS_PACKAGE)
sc->sc_cs_package = true;
if (iic_acquire_bus(ia->ia_tag, 0) != 0) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: wss_isa.c,v 1.30 2019/05/08 13:40:18 isaki Exp $ */
/* $NetBSD: wss_isa.c,v 1.31 2022/02/12 03:24:35 riastradh Exp $ */
/*
* Copyright (c) 1994 John Brezak
@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: wss_isa.c,v 1.30 2019/05/08 13:40:18 isaki Exp $");
__KERNEL_RCSID(0, "$NetBSD: wss_isa.c,v 1.31 2022/02/12 03:24:35 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -71,7 +71,7 @@ extern int wssdebug;
#define DPRINTF(x)
#endif
static int wssfind(device_t, struct wss_softc *, int,
static int wssfind(device_t, cfdata_t, struct wss_softc *, int,
struct isa_attach_args *);
static void madprobe(struct wss_softc *, int);
@ -91,9 +91,7 @@ int
wss_isa_probe(device_t parent, cfdata_t match, void *aux)
{
struct isa_attach_args *ia;
struct device probedev;
struct wss_softc probesc, *sc;
struct ad1848_softc *ac;
ia = aux;
if (ia->ia_nio < 1)
@ -106,13 +104,9 @@ wss_isa_probe(device_t parent, cfdata_t match, void *aux)
if (ISA_DIRECT_CONFIG(ia))
return 0;
memset(&probedev, 0, sizeof probedev);
memset(&probesc, 0, sizeof probesc);
sc = &probesc;
ac = &sc->sc_ad1848.sc_ad1848;
ac->sc_dev = &probedev;
ac->sc_dev->dv_cfdata = match;
if (wssfind(parent, sc, 1, aux)) {
if (wssfind(parent, match, sc, 1, aux)) {
bus_space_unmap(sc->sc_iot, sc->sc_ioh, WSS_CODEC);
ad1848_isa_unmap(&sc->sc_ad1848);
madunmap(sc);
@ -123,7 +117,7 @@ wss_isa_probe(device_t parent, cfdata_t match, void *aux)
}
static int
wssfind(device_t parent, struct wss_softc *sc, int probing,
wssfind(device_t parent, cfdata_t match, struct wss_softc *sc, int probing,
struct isa_attach_args *ia)
{
static u_char interrupt_bits[12] = {
@ -135,7 +129,7 @@ wssfind(device_t parent, struct wss_softc *sc, int probing,
ac = &sc->sc_ad1848.sc_ad1848;
sc->sc_iot = ia->ia_iot;
if (device_cfdata(ac->sc_dev)->cf_flags & 1)
if (match->cf_flags & 1)
madprobe(sc, ia->ia_io[0].ir_addr);
else
sc->mad_chip_type = MAD_NONE;
@ -245,7 +239,7 @@ wss_isa_attach(device_t parent, device_t self, void *aux)
ac = &sc->sc_ad1848.sc_ad1848;
ac->sc_dev = self;
ia = aux;
if (!wssfind(parent, sc, 0, ia)) {
if (!wssfind(parent, device_cfdata(self), sc, 0, ia)) {
aprint_error_dev(self, "wssfind failed\n");
return;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_mvxpe.c,v 1.37 2021/12/05 07:57:38 msaitoh Exp $ */
/* $NetBSD: if_mvxpe.c,v 1.38 2022/02/12 03:24:35 riastradh Exp $ */
/*
* Copyright (c) 2015 Internet Initiative Japan Inc.
* All rights reserved.
@ -25,7 +25,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_mvxpe.c,v 1.37 2021/12/05 07:57:38 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_mvxpe.c,v 1.38 2022/02/12 03:24:35 riastradh Exp $");
#include "opt_multiprocessor.h"
@ -482,7 +482,8 @@ mvxpe_attach(device_t parent, device_t self, void *aux)
* we assume phyaddress == MAC unit number here,
* but some boards may not.
*/
mii_attach(self, mii, 0xffffffff, MII_PHY_ANY, sc->sc_dev->dv_unit, 0);
mii_attach(self, mii, 0xffffffff, MII_PHY_ANY, device_unit(sc->sc_dev),
0);
child = LIST_FIRST(&mii->mii_phys);
if (child == NULL) {
aprint_error_dev(self, "no PHY found!\n");

View File

@ -1,4 +1,4 @@
/* $NetBSD: mvxpsec.c,v 1.9 2021/12/10 20:36:04 andvar Exp $ */
/* $NetBSD: mvxpsec.c,v 1.10 2022/02/12 03:24:36 riastradh Exp $ */
/*
* Copyright (c) 2015 Internet Initiative Japan Inc.
* All rights reserved.
@ -1036,7 +1036,7 @@ mvxpsec_init_sram(struct mvxpsec_softc *sc)
vaddr_t va;
int window;
switch (sc->sc_dev->dv_unit) {
switch (device_unit(sc->sc_dev)) {
case 0:
tag = ARMADAXP_TAG_CRYPT0;
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: xmm7360.c,v 1.13 2021/10/18 08:15:00 hannken Exp $ */
/* $NetBSD: xmm7360.c,v 1.14 2022/02/12 03:24:36 riastradh Exp $ */
/*
* Device driver for Intel XMM7360 LTE modems, eg. Fibocom L850-GL.
@ -75,7 +75,7 @@ MODULE_DEVICE_TABLE(pci, xmm7360_ids);
#include "opt_gateway.h"
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: xmm7360.c,v 1.13 2021/10/18 08:15:00 hannken Exp $");
__KERNEL_RCSID(0, "$NetBSD: xmm7360.c,v 1.14 2022/02/12 03:24:36 riastradh Exp $");
#endif
#include <sys/param.h>
@ -143,9 +143,9 @@ typedef void * wait_queue_head_t; /* just address for tsleep() */
#ifdef __OpenBSD__
typedef struct mutex spinlock_t;
#define dev_err(devp, fmt, ...) \
printf("%s: " fmt, (devp)->dv_xname, ##__VA_ARGS__)
printf("%s: " fmt, device_xname(devp), ##__VA_ARGS__)
#define dev_info(devp, fmt, ...) \
printf("%s: " fmt, (devp)->dv_xname, ##__VA_ARGS__)
printf("%s: " fmt, device_xname(devp), ##__VA_ARGS__)
#define kzalloc(size, flags) malloc(size, M_DEVBUF, M_WAITOK | M_ZERO)
#define kfree(addr) free(addr, M_DEVBUF, 0)
#define mutex_init(lock) mtx_init(lock, IPL_TTY)
@ -481,7 +481,9 @@ struct queue_pair {
u16 page_size;
int tty_index;
int tty_needs_wake;
#ifdef __linux__
struct device dev;
#endif
int num;
int open;
struct mutex lock;
@ -2220,9 +2222,9 @@ wwanc_attach(struct device *parent, struct device *self, void *aux)
/* Device initialized, can establish the interrupt now */
sc->sc_ih = pci_intr_establish(sc->sc_pc, sc->sc_pih, IPL_NET,
wwanc_intr, sc, sc->sc_dev->dv_xname);
wwanc_intr, sc, device_xname(sc->sc_dev));
if (sc->sc_ih == NULL) {
printf("%s: can't establish interrupt\n", self->dv_xname);
device_printf(self, "can't establish interrupt\n");
return;
}
@ -2353,8 +2355,8 @@ wwanc_activate(struct device *self, int act)
case DVACT_SUSPEND:
if (sc->sc_resume) {
/* Refuse to suspend if resume still ongoing */
printf("%s: not suspending, resume still ongoing\n",
self->dv_xname);
device_printf(self,
"not suspending, resume still ongoing\n");
return EBUSY;
}
@ -2860,7 +2862,7 @@ dma_alloc_coherent(struct device *self, size_t sz, dma_addr_t *physp, int flags)
BUS_DMA_WAITOK);
if (error) {
panic("%s: bus_dmamem_alloc(%lu) failed %d\n",
self->dv_xname, (unsigned long)sz, error);
device_xname(self), (unsigned long)sz, error);
/* NOTREACHED */
}
@ -2871,7 +2873,7 @@ dma_alloc_coherent(struct device *self, size_t sz, dma_addr_t *physp, int flags)
BUS_DMA_WAITOK | BUS_DMA_COHERENT);
if (error) {
panic("%s: bus_dmamem_alloc(%lu) failed %d\n",
self->dv_xname, (unsigned long)sz, error);
device_xname(self), (unsigned long)sz, error);
/* NOTREACHED */
}
@ -3236,7 +3238,8 @@ wwan_attach(struct device *parent, struct device *self, void *aux)
ifp->if_type = IFT_OTHER;
IFQ_SET_MAXLEN(&ifp->if_snd, xn->qp->depth);
IFQ_SET_READY(&ifp->if_snd);
bcopy(sc_if->sc_dev->dv_xname, ifp->if_xname, IFNAMSIZ);
CTASSERT(DEVICE_XNAME_SIZE == IFNAMSIZ);
bcopy(device_xname(sc_if->sc_dev), ifp->if_xname, IFNAMSIZ);
/* Call MI attach routines. */
if_attach(ifp);

View File

@ -1,4 +1,4 @@
/* $NetBSD: spkr.c,v 1.21 2021/08/07 16:19:08 thorpej Exp $ */
/* $NetBSD: spkr.c,v 1.22 2022/02/12 03:24:36 riastradh Exp $ */
/*
* Copyright (c) 1990 Eric S. Raymond (esr@snark.thyrsus.com)
@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: spkr.c,v 1.21 2021/08/07 16:19:08 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: spkr.c,v 1.22 2022/02/12 03:24:36 riastradh Exp $");
#if defined(_KERNEL_OPT)
#include "wsmux.h"
@ -416,7 +416,8 @@ spkr_attach(device_t self, void (*tone)(device_t, u_int, u_int))
struct spkr_softc *sc = device_private(self);
#ifdef SPKRDEBUG
aprint_debug("%s: entering for unit %d\n", __func__, self->dv_unit);
aprint_debug("%s: entering for unit %d\n", __func__,
device_unit(self));
#endif /* SPKRDEBUG */
sc->sc_dev = self;
sc->sc_tone = tone;
@ -433,7 +434,8 @@ spkr_detach(device_t self, int flags)
int rc;
#ifdef SPKRDEBUG
aprint_debug("%s: entering for unit %d\n", __func__, self->dv_unit);
aprint_debug("%s: entering for unit %d\n", __func__,
device_unit(self));
#endif /* SPKRDEBUG */
if (sc == NULL)
return ENXIO;

View File

@ -1,4 +1,4 @@
/* $NetBSD: vhci.c,v 1.22 2021/08/07 16:19:17 thorpej Exp $ */
/* $NetBSD: vhci.c,v 1.23 2022/02/12 03:24:36 riastradh Exp $ */
/*
* Copyright (c) 2019-2020 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vhci.c,v 1.22 2021/08/07 16:19:17 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: vhci.c,v 1.23 2022/02/12 03:24:36 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@ -1299,7 +1299,7 @@ vhci_attach(device_t parent, device_t self, void *aux)
sc->sc_dev = self;
sc->sc_bus.ub_revision = USBREV_2_0;
sc->sc_bus.ub_hctype = USBHCTYPE_VHCI;
sc->sc_bus.ub_busnum = self->dv_unit;
sc->sc_bus.ub_busnum = device_unit(self);
sc->sc_bus.ub_usedma = false;
sc->sc_bus.ub_methods = &vhci_bus_methods;
sc->sc_bus.ub_pipesize = sizeof(vhci_pipe_t);

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_drvctl.c,v 1.49 2021/06/16 00:19:46 riastradh Exp $ */
/* $NetBSD: kern_drvctl.c,v 1.50 2022/02/12 03:24:36 riastradh Exp $ */
/*
* Copyright (c) 2004
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_drvctl.c,v 1.49 2021/06/16 00:19:46 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_drvctl.c,v 1.50 2022/02/12 03:24:36 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -277,7 +277,8 @@ detachdevbyname(const char *devname)
* There might be a private notification mechanism,
* but better play it safe here.
*/
if (d->dv_parent && !d->dv_parent->dv_cfattach->ca_childdetached) {
if (device_parent(d) &&
!device_cfattach(device_parent(d))->ca_childdetached) {
error = ENOTSUP;
goto out;
}
@ -314,27 +315,27 @@ rescanbus(const char *busname, const char *ifattr,
* must support rescan, and must have something
* to attach to
*/
if (!d->dv_cfattach->ca_rescan ||
!d->dv_cfdriver->cd_attrs)
if (!device_cfattach(d)->ca_rescan ||
!device_cfdriver(d)->cd_attrs)
return ENODEV;
/* rescan all ifattrs if none is specified */
if (!ifattr) {
rc = 0;
for (ap = d->dv_cfdriver->cd_attrs; *ap; ap++) {
rc = (*d->dv_cfattach->ca_rescan)(d, (*ap)->ci_name,
locs);
for (ap = device_cfdriver(d)->cd_attrs; *ap; ap++) {
rc = (*device_cfattach(d)->ca_rescan)(d,
(*ap)->ci_name, locs);
if (rc)
break;
}
} else {
/* check for valid attribute passed */
for (ap = d->dv_cfdriver->cd_attrs; *ap; ap++)
for (ap = device_cfdriver(d)->cd_attrs; *ap; ap++)
if (!strcmp((*ap)->ci_name, ifattr))
break;
if (!*ap)
return EINVAL;
rc = (*d->dv_cfattach->ca_rescan)(d, ifattr, locs);
rc = (*device_cfattach(d)->ca_rescan)(d, ifattr, locs);
}
config_deferred(NULL);