summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorriastradh <riastradh@NetBSD.org>2022-03-28 12:43:12 +0000
committerriastradh <riastradh@NetBSD.org>2022-03-28 12:43:12 +0000
commit61daad76269fa3106571d4cf4388476ecd520b98 (patch)
tree16a47a389b4c1cc8db06701803f43a9f229a5264 /sys/dev
parent5e68d6d51c5b7e76a98b76138b98716a4a880afc (diff)
uhidev(9): Get the device and interface through attach args.
This way uhidev drivers don't need access to uhidev_softc itself for it.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/usb/uatp.c18
-rw-r--r--sys/dev/usb/uhid.c15
-rw-r--r--sys/dev/usb/ukbd.c19
-rw-r--r--sys/dev/usb/ums.c8
-rw-r--r--sys/dev/usb/uthum.c6
5 files changed, 39 insertions, 27 deletions
diff --git a/sys/dev/usb/uatp.c b/sys/dev/usb/uatp.c
index a94e755f1ed..ff6fbea48fe 100644
--- a/sys/dev/usb/uatp.c
+++ b/sys/dev/usb/uatp.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uatp.c,v 1.27 2021/08/07 16:19:17 thorpej Exp $ */
+/* $NetBSD: uatp.c,v 1.28 2022/03/28 12:43:12 riastradh Exp $ */
/*-
* Copyright (c) 2011-2014 The NetBSD Foundation, Inc.
@@ -146,7 +146,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uatp.c,v 1.27 2021/08/07 16:19:17 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uatp.c,v 1.28 2022/03/28 12:43:12 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -486,7 +486,8 @@ static const struct uatp_knobs default_knobs = {
};
struct uatp_softc {
- struct uhidev sc_hdev; /* USB parent. */
+ struct uhidev sc_hdev; /* uhidev(9) parent. */
+ struct usbd_device *sc_udev; /* USB device. */
device_t sc_wsmousedev; /* Attached wsmouse device. */
const struct uatp_parameters *sc_parameters;
struct uatp_knobs sc_knobs;
@@ -936,6 +937,8 @@ uatp_attach(device_t parent, device_t self, void *aux)
sc->sc_hdev.sc_parent = uha->parent;
sc->sc_hdev.sc_report_id = uha->reportid;
+ sc->sc_udev = uha->uiaa->uiaa_device;
+
/* Identify ourselves to dmesg. */
uatp_descriptor = find_uatp_descriptor(uha);
KASSERT(uatp_descriptor != NULL);
@@ -1296,7 +1299,7 @@ uatp_ioctl(void *v, unsigned long cmd, void *data, int flag, struct lwp *p)
static void
geyser34_enable_raw_mode(struct uatp_softc *sc)
{
- struct usbd_device *udev = sc->sc_hdev.sc_parent->sc_udev;
+ struct usbd_device *udev = sc->sc_udev;
usb_device_request_t req;
usbd_status status;
uint8_t report[GEYSER34_MODE_PACKET_SIZE];
@@ -1368,8 +1371,8 @@ geyser34_finalize(struct uatp_softc *sc)
{
DPRINTF(sc, UATP_DEBUG_MISC, ("finalizing\n"));
- usb_rem_task_wait(sc->sc_hdev.sc_parent->sc_udev, &sc->sc_reset_task,
- USB_TASKQ_DRIVER, NULL);
+ usb_rem_task_wait(sc->sc_udev, &sc->sc_reset_task, USB_TASKQ_DRIVER,
+ NULL);
return 0;
}
@@ -1379,8 +1382,7 @@ geyser34_deferred_reset(struct uatp_softc *sc)
{
DPRINTF(sc, UATP_DEBUG_RESET, ("deferring reset\n"));
- usb_add_task(sc->sc_hdev.sc_parent->sc_udev, &sc->sc_reset_task,
- USB_TASKQ_DRIVER);
+ usb_add_task(sc->sc_udev, &sc->sc_reset_task, USB_TASKQ_DRIVER);
}
static void
diff --git a/sys/dev/usb/uhid.c b/sys/dev/usb/uhid.c
index 02831eef8dd..724b4c35e5c 100644
--- a/sys/dev/usb/uhid.c
+++ b/sys/dev/usb/uhid.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uhid.c,v 1.121 2022/03/28 12:42:54 riastradh Exp $ */
+/* $NetBSD: uhid.c,v 1.122 2022/03/28 12:43:12 riastradh Exp $ */
/*
* Copyright (c) 1998, 2004, 2008, 2012 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uhid.c,v 1.121 2022/03/28 12:42:54 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhid.c,v 1.122 2022/03/28 12:43:12 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -86,6 +86,7 @@ int uhiddebug = 0;
struct uhid_softc {
struct uhidev sc_hdev;
+ struct usbd_device *sc_udev;
kmutex_t sc_lock;
kcondvar_t sc_cv;
@@ -181,6 +182,8 @@ uhid_attach(device_t parent, device_t self, void *aux)
sc->sc_hdev.sc_parent = uha->parent;
sc->sc_hdev.sc_report_id = uha->reportid;
+ sc->sc_udev = uha->uiaa->uiaa_device;
+
uhidev_get_report_desc(uha->parent, &desc, &size);
repid = uha->reportid;
sc->sc_isize = hid_report_size(desc, size, hid_input, repid);
@@ -655,16 +658,16 @@ uhidioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l)
case USB_GET_DEVICE_DESC:
*(usb_device_descriptor_t *)addr =
- *usbd_get_device_descriptor(sc->sc_hdev.sc_parent->sc_udev);
+ *usbd_get_device_descriptor(sc->sc_udev);
break;
case USB_GET_DEVICEINFO:
- usbd_fill_deviceinfo(sc->sc_hdev.sc_parent->sc_udev,
+ usbd_fill_deviceinfo(sc->sc_udev,
(struct usb_device_info *)addr, 0);
break;
case USB_GET_DEVICEINFO_OLD:
MODULE_HOOK_CALL(usb_subr_fill_30_hook,
- (sc->sc_hdev.sc_parent->sc_udev,
+ (sc->sc_udev,
(struct usb_device_info_old *)addr, 0,
usbd_devinfo_vp, usbd_printBCD),
enosys(), err);
@@ -674,7 +677,7 @@ uhidioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l)
case USB_GET_STRING_DESC:
{
struct usb_string_desc *si = (struct usb_string_desc *)addr;
- err = usbd_get_string_desc(sc->sc_hdev.sc_parent->sc_udev,
+ err = usbd_get_string_desc(sc->sc_udev,
si->usd_string_index,
si->usd_language_id, &si->usd_desc, &size);
if (err)
diff --git a/sys/dev/usb/ukbd.c b/sys/dev/usb/ukbd.c
index 14df4d53730..463d7d89da3 100644
--- a/sys/dev/usb/ukbd.c
+++ b/sys/dev/usb/ukbd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ukbd.c,v 1.157 2022/01/08 17:34:14 riastradh Exp $ */
+/* $NetBSD: ukbd.c,v 1.158 2022/03/28 12:43:12 riastradh Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.157 2022/01/08 17:34:14 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.158 2022/03/28 12:43:12 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -236,6 +236,8 @@ Static const uint8_t ukbd_trtab[256] = {
struct ukbd_softc {
struct uhidev sc_hdev;
+ struct usbd_device *sc_udev;
+ struct usbd_interface *sc_iface;
struct ukbd_data sc_ndata;
struct ukbd_data sc_odata;
@@ -410,6 +412,8 @@ ukbd_attach(device_t parent, device_t self, void *aux)
sc->sc_hdev.sc_intr = ukbd_intr;
sc->sc_hdev.sc_parent = uha->parent;
sc->sc_hdev.sc_report_id = uha->reportid;
+ sc->sc_udev = uha->uiaa->uiaa_device;
+ sc->sc_iface = uha->uiaa->uiaa_iface;
sc->sc_flags = 0;
aprint_naive("\n");
@@ -427,7 +431,7 @@ ukbd_attach(device_t parent, device_t self, void *aux)
}
/* Quirks */
- qflags = usbd_get_quirks(uha->parent->sc_udev)->uq_flags;
+ qflags = usbd_get_quirks(sc->sc_udev)->uq_flags;
if (qflags & UQ_SPUR_BUT_UP)
sc->sc_flags |= FLAG_DEBOUNCE;
if (qflags & UQ_APPLE_ISO)
@@ -579,7 +583,7 @@ ukbd_detach(device_t self, int flags)
callout_halt(&sc->sc_delay, NULL);
callout_halt(&sc->sc_ledreset, NULL);
- usb_rem_task_wait(sc->sc_hdev.sc_parent->sc_udev, &sc->sc_ledtask,
+ usb_rem_task_wait(sc->sc_udev, &sc->sc_ledtask,
USB_TASKQ_DRIVER, NULL);
/* The console keyboard does not get a disable call, so check pipe. */
@@ -885,7 +889,7 @@ void
ukbd_set_leds(void *v, int leds)
{
struct ukbd_softc *sc = v;
- struct usbd_device *udev = sc->sc_hdev.sc_parent->sc_udev;
+ struct usbd_device *udev = sc->sc_udev;
DPRINTF(("%s: sc=%p leds=%d, sc_leds=%d\n", __func__,
sc, leds, sc->sc_leds));
@@ -995,7 +999,7 @@ ukbd_cngetc(void *v, u_int *type, int *data)
DPRINTFN(0,("%s: enter\n", __func__));
sc->sc_flags |= FLAG_POLLING;
if (sc->sc_npollchar <= 0)
- usbd_dopoll(sc->sc_hdev.sc_parent->sc_iface);
+ usbd_dopoll(sc->sc_iface);
sc->sc_flags &= ~FLAG_POLLING;
if (sc->sc_npollchar > 0) {
c = sc->sc_pollchars[0];
@@ -1021,7 +1025,8 @@ ukbd_cnpollc(void *v, int on)
DPRINTFN(2,("%s: sc=%p on=%d\n", __func__, v, on));
- usbd_interface2device_handle(sc->sc_hdev.sc_parent->sc_iface, &dev);
+ /* XXX Can this just use sc->sc_udev, or am I mistaken? */
+ usbd_interface2device_handle(sc->sc_iface, &dev);
if (on) {
sc->sc_spl = splusb();
pollenter++;
diff --git a/sys/dev/usb/ums.c b/sys/dev/usb/ums.c
index 0f49020b7e9..00829e31d3c 100644
--- a/sys/dev/usb/ums.c
+++ b/sys/dev/usb/ums.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ums.c,v 1.101 2021/10/01 21:14:06 macallan Exp $ */
+/* $NetBSD: ums.c,v 1.102 2022/03/28 12:43:12 riastradh Exp $ */
/*
* Copyright (c) 1998, 2017 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ums.c,v 1.101 2021/10/01 21:14:06 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ums.c,v 1.102 2022/03/28 12:43:12 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -76,6 +76,7 @@ int umsdebug = 0;
struct ums_softc {
struct uhidev sc_hdev;
+ struct usbd_device *sc_udev;
struct hidms sc_ms;
bool sc_alwayson;
@@ -149,8 +150,9 @@ ums_attach(device_t parent, device_t self, void *aux)
sc->sc_hdev.sc_intr = ums_intr;
sc->sc_hdev.sc_parent = uha->parent;
sc->sc_hdev.sc_report_id = uha->reportid;
+ sc->sc_udev = uha->uiaa->uiaa_device;
- quirks = usbd_get_quirks(uha->parent->sc_udev)->uq_flags;
+ quirks = usbd_get_quirks(sc->sc_udev)->uq_flags;
if (quirks & UQ_MS_REVZ)
sc->sc_ms.flags |= HIDMS_REVZ;
if (quirks & UQ_SPUR_BUT_UP)
diff --git a/sys/dev/usb/uthum.c b/sys/dev/usb/uthum.c
index 924a6586ad2..a23f058c128 100644
--- a/sys/dev/usb/uthum.c
+++ b/sys/dev/usb/uthum.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uthum.c,v 1.21 2021/06/13 09:28:23 mlelstv Exp $ */
+/* $NetBSD: uthum.c,v 1.22 2022/03/28 12:43:12 riastradh Exp $ */
/* $OpenBSD: uthum.c,v 1.6 2010/01/03 18:43:02 deraadt Exp $ */
/*
@@ -22,7 +22,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uthum.c,v 1.21 2021/06/13 09:28:23 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uthum.c,v 1.22 2022/03/28 12:43:12 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -130,7 +130,7 @@ uthum_attach(device_t parent, device_t self, void *aux)
{
struct uthum_softc *sc = device_private(self);
struct uhidev_attach_arg *uha = aux;
- struct usbd_device *dev = uha->parent->sc_udev;
+ struct usbd_device *dev = uha->uiaa->uiaa_device;
int size, repid;
void *desc;