Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb uhidev(9): Get the device and interface through ...
details: https://anonhg.NetBSD.org/src/rev/4a3fc3e6a6d5
branches: trunk
changeset: 364537:4a3fc3e6a6d5
user: riastradh <riastradh%NetBSD.org@localhost>
date: Mon Mar 28 12:43:12 2022 +0000
description:
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:
sys/arch/macppc/dev/pbms.c | 9 ++++++---
sys/dev/usb/uatp.c | 18 ++++++++++--------
sys/dev/usb/uhid.c | 15 +++++++++------
sys/dev/usb/ukbd.c | 19 ++++++++++++-------
sys/dev/usb/ums.c | 8 +++++---
sys/dev/usb/uthum.c | 6 +++---
6 files changed, 45 insertions(+), 30 deletions(-)
diffs (truncated from 314 to 300 lines):
diff -r 855c6263c2f9 -r 4a3fc3e6a6d5 sys/arch/macppc/dev/pbms.c
--- a/sys/arch/macppc/dev/pbms.c Mon Mar 28 12:43:03 2022 +0000
+++ b/sys/arch/macppc/dev/pbms.c Mon Mar 28 12:43:12 2022 +0000
@@ -1,4 +1,4 @@
-/* $Id: pbms.c,v 1.19 2021/08/07 16:18:57 thorpej Exp $ */
+/* $Id: pbms.c,v 1.20 2022/03/28 12:43:12 riastradh Exp $ */
/*
* Copyright (c) 2005, Johan Wallén
@@ -307,7 +307,8 @@
* we expect.
*/
if (uha->uiaa->uiaa_proto == UIPROTO_MOUSE &&
- (udd = usbd_get_device_descriptor(uha->parent->sc_udev)) != NULL) {
+ ((udd = usbd_get_device_descriptor(uha->uiaa->uiaa_device))
+ != NULL)) {
vendor = UGETW(udd->idVendor);
product = UGETW(udd->idProduct);
for (i = 0; i < PBMS_NUM_DEVICES; i++) {
@@ -329,6 +330,7 @@
struct uhidev_attach_arg *uha = aux;
struct pbms_dev *pd;
struct pbms_softc *sc = device_private(self);
+ struct usbd_device *udev;
usb_device_descriptor_t *udd;
int i;
uint16_t vendor, product;
@@ -341,7 +343,8 @@
sc->sc_datalen = PBMS_DATA_LEN;
/* Fill in device-specific parameters. */
- if ((udd = usbd_get_device_descriptor(uha->parent->sc_udev)) != NULL) {
+ udev = uha->uiaa->uiaa_udevice;
+ if ((udd = usbd_get_device_descriptor(udev)) != NULL) {
product = UGETW(udd->idProduct);
vendor = UGETW(udd->idVendor);
for (i = 0; i < PBMS_NUM_DEVICES; i++) {
diff -r 855c6263c2f9 -r 4a3fc3e6a6d5 sys/dev/usb/uatp.c
--- a/sys/dev/usb/uatp.c Mon Mar 28 12:43:03 2022 +0000
+++ b/sys/dev/usb/uatp.c Mon Mar 28 12:43:12 2022 +0000
@@ -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 @@
};
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 @@
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 @@
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 @@
{
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 @@
{
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 -r 855c6263c2f9 -r 4a3fc3e6a6d5 sys/dev/usb/uhid.c
--- a/sys/dev/usb/uhid.c Mon Mar 28 12:43:03 2022 +0000
+++ b/sys/dev/usb/uhid.c Mon Mar 28 12:43:12 2022 +0000
@@ -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 @@
struct uhid_softc {
struct uhidev sc_hdev;
+ struct usbd_device *sc_udev;
kmutex_t sc_lock;
kcondvar_t sc_cv;
@@ -181,6 +182,8 @@
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 @@
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 @@
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 -r 855c6263c2f9 -r 4a3fc3e6a6d5 sys/dev/usb/ukbd.c
--- a/sys/dev/usb/ukbd.c Mon Mar 28 12:43:03 2022 +0000
+++ b/sys/dev/usb/ukbd.c Mon Mar 28 12:43:12 2022 +0000
@@ -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 @@
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 @@
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 @@
}
/* 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 @@
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 @@
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 @@
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 @@
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 -r 855c6263c2f9 -r 4a3fc3e6a6d5 sys/dev/usb/ums.c
--- a/sys/dev/usb/ums.c Mon Mar 28 12:43:03 2022 +0000
+++ b/sys/dev/usb/ums.c Mon Mar 28 12:43:12 2022 +0000
@@ -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 @@
struct ums_softc {
struct uhidev sc_hdev;
+ struct usbd_device *sc_udev;
struct hidms sc_ms;
bool sc_alwayson;
@@ -149,8 +150,9 @@
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 -r 855c6263c2f9 -r 4a3fc3e6a6d5 sys/dev/usb/uthum.c
--- a/sys/dev/usb/uthum.c Mon Mar 28 12:43:03 2022 +0000
+++ b/sys/dev/usb/uthum.c Mon Mar 28 12:43:12 2022 +0000
@@ -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>
Home |
Main Index |
Thread Index |
Old Index