usbnet drivers: Omit needless usbnet core lock and assertions.
During attach, the caller has exclusive access to the usbnet until usbnet_attach_ifp. At other times, register access is serialized either by the usbnet multicast lock or by IFNET_LOCK.
This commit is contained in:
parent
47bf81df8f
commit
5c509362df
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_aue.c,v 1.185 2022/03/03 05:54:21 riastradh Exp $ */
|
||||
/* $NetBSD: if_aue.c,v 1.186 2022/03/03 05:54:37 riastradh Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, 1999, 2000
|
||||
|
@ -76,7 +76,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.185 2022/03/03 05:54:21 riastradh Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.186 2022/03/03 05:54:37 riastradh Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_usb.h"
|
||||
|
@ -432,8 +432,6 @@ aue_read_mac(struct usbnet *un)
|
|||
int off = 0;
|
||||
int word;
|
||||
|
||||
usbnet_isowned_core(un);
|
||||
|
||||
AUEHIST_FUNC();
|
||||
AUEHIST_CALLARGS("aue%jd: enter",
|
||||
device_unit(un->un_dev), 0, 0, 0);
|
||||
|
@ -851,14 +849,10 @@ aue_attach(device_t parent, device_t self, void *aux)
|
|||
/* First level attach. */
|
||||
usbnet_attach(un, "auedet");
|
||||
|
||||
usbnet_lock_core(un);
|
||||
|
||||
/* Reset the adapter and get station address from the EEPROM. */
|
||||
aue_reset(sc);
|
||||
aue_read_mac(un);
|
||||
|
||||
usbnet_unlock_core(un);
|
||||
|
||||
usbnet_attach_ifp(un, IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST,
|
||||
0, &unm);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_axe.c,v 1.144 2022/03/03 05:54:21 riastradh Exp $ */
|
||||
/* $NetBSD: if_axe.c,v 1.145 2022/03/03 05:54:37 riastradh Exp $ */
|
||||
/* $OpenBSD: if_axe.c,v 1.137 2016/04/13 11:03:37 mpi Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -87,7 +87,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.144 2022/03/03 05:54:21 riastradh Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.145 2022/03/03 05:54:37 riastradh Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_usb.h"
|
||||
|
@ -513,8 +513,6 @@ static void
|
|||
axe_reset(struct usbnet *un)
|
||||
{
|
||||
|
||||
usbnet_isowned_core(un);
|
||||
|
||||
if (usbnet_isdying(un))
|
||||
return;
|
||||
|
||||
|
@ -930,10 +928,8 @@ axe_attach(device_t parent, device_t self, void *aux)
|
|||
usbnet_attach(un, "axedet");
|
||||
|
||||
/* We need the PHYID for init dance in some cases */
|
||||
usbnet_lock_core(un);
|
||||
if (axe_cmd(sc, AXE_CMD_READ_PHYID, 0, 0, &sc->axe_phyaddrs)) {
|
||||
aprint_error_dev(self, "failed to read phyaddrs\n");
|
||||
usbnet_unlock_core(un);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -963,13 +959,10 @@ axe_attach(device_t parent, device_t self, void *aux)
|
|||
} else {
|
||||
if (axe_cmd(sc, AXE_CMD_READ_IPG012, 0, 0, sc->axe_ipgs)) {
|
||||
aprint_error_dev(self, "failed to read ipg\n");
|
||||
usbnet_unlock_core(un);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
usbnet_unlock_core(un);
|
||||
|
||||
if (!AXE_IS_172(un))
|
||||
usbnet_ec(un)->ec_capabilities = ETHERCAP_VLAN_MTU;
|
||||
if (un->un_flags & AX772B) {
|
||||
|
@ -1218,8 +1211,6 @@ axe_uno_init(struct ifnet *ifp)
|
|||
struct axe_softc * const sc = usbnet_softc(un);
|
||||
int rxmode;
|
||||
|
||||
usbnet_isowned_core(un);
|
||||
|
||||
if (usbnet_isdying(un))
|
||||
return EIO;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_axen.c,v 1.88 2022/03/03 05:54:21 riastradh Exp $ */
|
||||
/* $NetBSD: if_axen.c,v 1.89 2022/03/03 05:54:37 riastradh Exp $ */
|
||||
/* $OpenBSD: if_axen.c,v 1.3 2013/10/21 10:10:22 yuo Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.88 2022/03/03 05:54:21 riastradh Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.89 2022/03/03 05:54:37 riastradh Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_usb.h"
|
||||
|
@ -295,7 +295,6 @@ allmulti:
|
|||
static void
|
||||
axen_reset(struct usbnet *un)
|
||||
{
|
||||
usbnet_isowned_core(un);
|
||||
if (usbnet_isdying(un))
|
||||
return;
|
||||
/* XXX What to reset? */
|
||||
|
@ -367,8 +366,6 @@ axen_ax88179_init(struct usbnet *un)
|
|||
uint16_t wval;
|
||||
uint8_t val;
|
||||
|
||||
usbnet_lock_core(un);
|
||||
|
||||
/* XXX: ? */
|
||||
axen_cmd(un, AXEN_CMD_MAC_READ, 1, AXEN_UNK_05, &val);
|
||||
DPRINTFN(5, ("AXEN_CMD_MAC_READ(0x05): 0x%02x\n", val));
|
||||
|
@ -451,7 +448,6 @@ axen_ax88179_init(struct usbnet *un)
|
|||
default:
|
||||
aprint_error_dev(un->un_dev, "unknown uplink bus:0x%02x\n",
|
||||
val);
|
||||
usbnet_unlock_core(un);
|
||||
return;
|
||||
}
|
||||
axen_cmd(un, AXEN_CMD_MAC_SET_RXSR, 5, AXEN_RX_BULKIN_QCTRL, &qctrl);
|
||||
|
@ -509,8 +505,6 @@ axen_ax88179_init(struct usbnet *un)
|
|||
axen_uno_mii_write_reg(un, un->un_phyno, 0x01, wval | 0x0080);
|
||||
axen_uno_mii_write_reg(un, un->un_phyno, 0x1F, 0x0000);
|
||||
#endif
|
||||
|
||||
usbnet_unlock_core(un);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -554,8 +548,6 @@ axen_uno_ioctl(struct ifnet *ifp, u_long cmd, void *data)
|
|||
{
|
||||
struct usbnet * const un = ifp->if_softc;
|
||||
|
||||
usbnet_lock_core(un);
|
||||
|
||||
switch (cmd) {
|
||||
case SIOCSIFCAP:
|
||||
axen_setoe_locked(un);
|
||||
|
@ -564,8 +556,6 @@ axen_uno_ioctl(struct ifnet *ifp, u_long cmd, void *data)
|
|||
break;
|
||||
}
|
||||
|
||||
usbnet_unlock_core(un);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -666,13 +656,10 @@ axen_attach(device_t parent, device_t self, void *aux)
|
|||
DPRINTF(("%s: phyno %d\n", device_xname(self), un->un_phyno));
|
||||
|
||||
/* Get station address. */
|
||||
usbnet_lock_core(un);
|
||||
if (axen_get_eaddr(un, &un->un_eaddr)) {
|
||||
usbnet_unlock_core(un);
|
||||
printf("EEPROM checksum error\n");
|
||||
return;
|
||||
}
|
||||
usbnet_unlock_core(un);
|
||||
|
||||
axen_ax88179_init(un);
|
||||
|
||||
|
@ -889,8 +876,6 @@ axen_uno_init(struct ifnet *ifp)
|
|||
uint16_t wval;
|
||||
uint8_t bval;
|
||||
|
||||
usbnet_isowned_core(un);
|
||||
|
||||
if (usbnet_isdying(un))
|
||||
return EIO;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_cue.c,v 1.101 2022/03/03 05:53:33 riastradh Exp $ */
|
||||
/* $NetBSD: if_cue.c,v 1.102 2022/03/03 05:54:37 riastradh Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, 1999, 2000
|
||||
|
@ -57,7 +57,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_cue.c,v 1.101 2022/03/03 05:53:33 riastradh Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_cue.c,v 1.102 2022/03/03 05:54:37 riastradh Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_inet.h"
|
||||
|
@ -545,8 +545,6 @@ cue_uno_tick(struct usbnet *un)
|
|||
{
|
||||
struct ifnet *ifp = usbnet_ifp(un);
|
||||
|
||||
usbnet_lock_core(un);
|
||||
|
||||
net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
|
||||
if (cue_csr_read_2(un, CUE_RX_FRAMEERR))
|
||||
if_statinc_ref(nsr, if_ierrors);
|
||||
|
@ -558,8 +556,6 @@ cue_uno_tick(struct usbnet *un)
|
|||
if_statadd_ref(nsr, if_collisions,
|
||||
cue_csr_read_2(un, CUE_TX_EXCESSCOLL));
|
||||
IF_STAT_PUTREF(ifp);
|
||||
|
||||
usbnet_unlock_core(un);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_mue.c,v 1.76 2022/03/03 05:54:21 riastradh Exp $ */
|
||||
/* $NetBSD: if_mue.c,v 1.77 2022/03/03 05:54:37 riastradh Exp $ */
|
||||
/* $OpenBSD: if_mue.c,v 1.3 2018/08/04 16:42:46 jsg Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -20,7 +20,7 @@
|
|||
/* Driver for Microchip LAN7500/LAN7800 chipsets. */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_mue.c,v 1.76 2022/03/03 05:54:21 riastradh Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_mue.c,v 1.77 2022/03/03 05:54:37 riastradh Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_usb.h"
|
||||
|
@ -1261,8 +1261,6 @@ mue_uno_ioctl(struct ifnet *ifp, u_long cmd, void *data)
|
|||
{
|
||||
struct usbnet * const un = ifp->if_softc;
|
||||
|
||||
usbnet_lock_core(un);
|
||||
|
||||
switch (cmd) {
|
||||
case SIOCSIFCAP:
|
||||
mue_sethwcsum_locked(un);
|
||||
|
@ -1274,8 +1272,6 @@ mue_uno_ioctl(struct ifnet *ifp, u_long cmd, void *data)
|
|||
break;
|
||||
}
|
||||
|
||||
usbnet_unlock_core(un);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_smsc.c,v 1.86 2022/03/03 05:54:21 riastradh Exp $ */
|
||||
/* $NetBSD: if_smsc.c,v 1.87 2022/03/03 05:54:37 riastradh Exp $ */
|
||||
|
||||
/* $OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $ */
|
||||
/* $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */
|
||||
|
@ -61,7 +61,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_smsc.c,v 1.86 2022/03/03 05:54:21 riastradh Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_smsc.c,v 1.87 2022/03/03 05:54:37 riastradh Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_usb.h"
|
||||
|
@ -539,7 +539,6 @@ smsc_reset(struct smsc_softc *sc)
|
|||
{
|
||||
struct usbnet * const un = &sc->smsc_un;
|
||||
|
||||
usbnet_isowned_core(un);
|
||||
if (usbnet_isdying(un))
|
||||
return;
|
||||
|
||||
|
@ -556,8 +555,6 @@ smsc_uno_init(struct ifnet *ifp)
|
|||
struct usbnet * const un = ifp->if_softc;
|
||||
struct smsc_softc * const sc = usbnet_softc(un);
|
||||
|
||||
usbnet_isowned_core(un);
|
||||
|
||||
if (usbnet_isdying(un))
|
||||
return EIO;
|
||||
|
||||
|
@ -591,8 +588,6 @@ smsc_chip_init(struct usbnet *un)
|
|||
int burst_cap;
|
||||
int err;
|
||||
|
||||
usbnet_isowned_core(un);
|
||||
|
||||
/* Enter H/W config mode */
|
||||
smsc_writereg(un, SMSC_HW_CFG, SMSC_HW_CFG_LRST);
|
||||
|
||||
|
@ -739,8 +734,6 @@ smsc_uno_ioctl(struct ifnet *ifp, u_long cmd, void *data)
|
|||
{
|
||||
struct usbnet * const un = ifp->if_softc;
|
||||
|
||||
usbnet_lock_core(un);
|
||||
|
||||
switch (cmd) {
|
||||
case SIOCSIFCAP:
|
||||
smsc_setoe_locked(un);
|
||||
|
@ -749,8 +742,6 @@ smsc_uno_ioctl(struct ifnet *ifp, u_long cmd, void *data)
|
|||
break;
|
||||
}
|
||||
|
||||
usbnet_unlock_core(un);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -859,7 +850,6 @@ smsc_attach(device_t parent, device_t self, void *aux)
|
|||
/* Setup some of the basics */
|
||||
un->un_phyno = 1;
|
||||
|
||||
usbnet_lock_core(un);
|
||||
/*
|
||||
* Attempt to get the mac address, if an EEPROM is not attached this
|
||||
* will just return FF:FF:FF:FF:FF:FF, so in such cases we invent a MAC
|
||||
|
@ -887,7 +877,6 @@ smsc_attach(device_t parent, device_t self, void *aux)
|
|||
un->un_eaddr[0] = (uint8_t)((mac_l) & 0xff);
|
||||
}
|
||||
}
|
||||
usbnet_unlock_core(un);
|
||||
|
||||
usbnet_attach_ifp(un, IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST,
|
||||
0, &unm);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_udav.c,v 1.91 2022/03/03 05:54:21 riastradh Exp $ */
|
||||
/* $NetBSD: if_udav.c,v 1.92 2022/03/03 05:54:37 riastradh Exp $ */
|
||||
/* $nabe: if_udav.c,v 1.3 2003/08/21 16:57:19 nabe Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -45,7 +45,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_udav.c,v 1.91 2022/03/03 05:54:21 riastradh Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_udav.c,v 1.92 2022/03/03 05:54:37 riastradh Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_usb.h"
|
||||
|
@ -238,14 +238,11 @@ udav_attach(device_t parent, device_t self, void *aux)
|
|||
|
||||
usbnet_attach(un, "udavdet");
|
||||
|
||||
usbnet_lock_core(un);
|
||||
|
||||
// /* reset the adapter */
|
||||
// udav_reset(un);
|
||||
|
||||
/* Get Ethernet Address */
|
||||
err = udav_csr_read(un, UDAV_PAR, un->un_eaddr, ETHER_ADDR_LEN);
|
||||
usbnet_unlock_core(un);
|
||||
if (err) {
|
||||
aprint_error_dev(self, "read MAC address failed\n");
|
||||
return;
|
||||
|
@ -523,7 +520,6 @@ udav_uno_init(struct ifnet *ifp)
|
|||
static void
|
||||
udav_reset(struct usbnet *un)
|
||||
{
|
||||
usbnet_isowned_core(un);
|
||||
|
||||
if (usbnet_isdying(un))
|
||||
return;
|
||||
|
@ -536,7 +532,6 @@ udav_reset(struct usbnet *un)
|
|||
static void
|
||||
udav_chip_init(struct usbnet *un)
|
||||
{
|
||||
usbnet_isowned_core(un);
|
||||
|
||||
/* Select PHY */
|
||||
#if 1
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_ure.c,v 1.51 2022/03/03 05:54:21 riastradh Exp $ */
|
||||
/* $NetBSD: if_ure.c,v 1.52 2022/03/03 05:54:37 riastradh Exp $ */
|
||||
/* $OpenBSD: if_ure.c,v 1.10 2018/11/02 21:32:30 jcs Exp $ */
|
||||
|
||||
/*-
|
||||
|
@ -30,7 +30,7 @@
|
|||
/* RealTek RTL8152/RTL8153 10/100/Gigabit USB Ethernet device */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_ure.c,v 1.51 2022/03/03 05:54:21 riastradh Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_ure.c,v 1.52 2022/03/03 05:54:37 riastradh Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_usb.h"
|
||||
|
@ -393,8 +393,6 @@ ure_reset(struct usbnet *un)
|
|||
{
|
||||
int i;
|
||||
|
||||
usbnet_isowned_core(un);
|
||||
|
||||
ure_write_1(un, URE_PLA_CR, URE_MCU_TYPE_PLA, URE_CR_RST);
|
||||
|
||||
for (i = 0; i < URE_TIMEOUT; i++) {
|
||||
|
@ -415,8 +413,6 @@ ure_uno_init(struct ifnet *ifp)
|
|||
struct usbnet * const un = ifp->if_softc;
|
||||
uint8_t eaddr[8];
|
||||
|
||||
usbnet_isowned_core(un);
|
||||
|
||||
if (usbnet_isdying(un))
|
||||
return EIO;
|
||||
|
||||
|
@ -899,7 +895,6 @@ ure_attach(device_t parent, device_t self, void *aux)
|
|||
(un->un_flags != 0) ? "" : "unknown ",
|
||||
ver);
|
||||
|
||||
usbnet_lock_core(un);
|
||||
if (un->un_flags & URE_FLAG_8152)
|
||||
ure_rtl8152_init(un);
|
||||
else
|
||||
|
@ -912,7 +907,6 @@ ure_attach(device_t parent, device_t self, void *aux)
|
|||
else
|
||||
ure_read_mem(un, URE_PLA_BACKUP, URE_MCU_TYPE_PLA, eaddr,
|
||||
sizeof(eaddr));
|
||||
usbnet_unlock_core(un);
|
||||
if (ETHER_IS_ZERO(eaddr)) {
|
||||
maclo = 0x00f2 | (cprng_strong32() & 0xffff0000);
|
||||
machi = cprng_strong32() & 0xffff;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_url.c,v 1.90 2022/03/03 05:54:21 riastradh Exp $ */
|
||||
/* $NetBSD: if_url.c,v 1.91 2022/03/03 05:54:37 riastradh Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001, 2002
|
||||
|
@ -44,7 +44,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1.90 2022/03/03 05:54:21 riastradh Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1.91 2022/03/03 05:54:37 riastradh Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_inet.h"
|
||||
|
@ -242,15 +242,12 @@ url_attach(device_t parent, device_t self, void *aux)
|
|||
/* Set these up now for url_mem(). */
|
||||
usbnet_attach(un, "urldet");
|
||||
|
||||
usbnet_lock_core(un);
|
||||
|
||||
/* reset the adapter */
|
||||
url_reset(un);
|
||||
|
||||
/* Get Ethernet Address */
|
||||
err = url_mem(un, URL_CMD_READMEM, URL_IDR0, (void *)un->un_eaddr,
|
||||
ETHER_ADDR_LEN);
|
||||
usbnet_unlock_core(un);
|
||||
if (err) {
|
||||
aprint_error_dev(self, "read MAC address failed\n");
|
||||
return;
|
||||
|
@ -373,8 +370,6 @@ url_uno_init(struct ifnet *ifp)
|
|||
|
||||
DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev), __func__));
|
||||
|
||||
usbnet_isowned_core(un);
|
||||
|
||||
if (usbnet_isdying(un))
|
||||
return EIO;
|
||||
|
||||
|
|
Loading…
Reference in New Issue