Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb Remove some unnecessary bit shifts by using appr...
details: https://anonhg.NetBSD.org/src/rev/861411650ee6
branches: trunk
changeset: 933965:861411650ee6
user: skrll <skrll%NetBSD.org@localhost>
date: Mon Jun 01 10:25:00 2020 +0000
description:
Remove some unnecessary bit shifts by using appropriate read size
diffstat:
sys/dev/usb/xhci.c | 17 +++++++++++------
sys/dev/usb/xhcireg.h | 7 +++----
2 files changed, 14 insertions(+), 10 deletions(-)
diffs (73 lines):
diff -r 5a73211e28c3 -r 861411650ee6 sys/dev/usb/xhci.c
--- a/sys/dev/usb/xhci.c Mon Jun 01 08:59:00 2020 +0000
+++ b/sys/dev/usb/xhci.c Mon Jun 01 10:25:00 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xhci.c,v 1.129 2020/05/21 15:28:35 jakllsch Exp $ */
+/* $NetBSD: xhci.c,v 1.130 2020/06/01 10:25:00 skrll Exp $ */
/*
* Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.129 2020/05/21 15:28:35 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.130 2020/06/01 10:25:00 skrll Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -272,6 +272,12 @@
}
static inline uint32_t
+xhci_read_2(const struct xhci_softc * const sc, bus_size_t offset)
+{
+ return bus_space_read_2(sc->sc_iot, sc->sc_ioh, offset);
+}
+
+static inline uint32_t
xhci_read_4(const struct xhci_softc * const sc, bus_size_t offset)
{
return bus_space_read_4(sc->sc_iot, sc->sc_ioh, offset);
@@ -938,7 +944,7 @@
xhci_init(struct xhci_softc *sc)
{
bus_size_t bsz;
- uint32_t cap, hcs1, hcs2, hcs3, hcc, dboff, rtsoff, hcc2;
+ uint32_t hcs1, hcs2, hcs3, hcc, dboff, rtsoff, hcc2;
uint32_t pagesize, config;
int i = 0;
uint16_t hciversion;
@@ -959,9 +965,8 @@
sc->sc_bus2.ub_hcpriv = sc;
sc->sc_bus2.ub_dmatag = sc->sc_bus.ub_dmatag;
- cap = xhci_read_4(sc, XHCI_CAPLENGTH);
- caplength = XHCI_CAP_CAPLENGTH(cap);
- hciversion = XHCI_CAP_HCIVERSION(cap);
+ caplength = xhci_read_1(sc, XHCI_CAPLENGTH);
+ hciversion = xhci_read_2(sc, XHCI_HCIVERSION);
if (hciversion < XHCI_HCIVERSION_0_96 ||
hciversion >= 0x0200) {
diff -r 5a73211e28c3 -r 861411650ee6 sys/dev/usb/xhcireg.h
--- a/sys/dev/usb/xhcireg.h Mon Jun 01 08:59:00 2020 +0000
+++ b/sys/dev/usb/xhcireg.h Mon Jun 01 10:25:00 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xhcireg.h,v 1.14 2020/05/29 06:53:40 skrll Exp $ */
+/* $NetBSD: xhcireg.h,v 1.15 2020/06/01 10:25:00 skrll Exp $ */
/*-
* Copyright (c) 2010 Hans Petter Selasky. All rights reserved.
@@ -45,9 +45,8 @@
#define PCI_XHCI_INTEL_USB3PRM 0xdc /* Intel USB3 Port Routing Mask */
/* XHCI capability registers */
-#define XHCI_CAPLENGTH 0x00 /* RO capability */
-#define XHCI_CAP_CAPLENGTH(x) ((x) & 0xFF)
-#define XHCI_CAP_HCIVERSION(x) (((x) >> 16) & 0xFFFF) /* RO Interface version number */
+#define XHCI_CAPLENGTH 0x00 /* RO capability - 1 byte */
+#define XHCI_HCIVERSION 0x02 /* RO version - 2 bytes */
#define XHCI_HCIVERSION_0_9 0x0090 /* xHCI version 0.9 */
#define XHCI_HCIVERSION_0_96 0x0096 /* xHCI version 0.96 */
#define XHCI_HCIVERSION_1_0 0x0100 /* xHCI version 1.0 */
Home |
Main Index |
Thread Index |
Old Index