Module Name: src Committed By: riastradh Date: Thu Mar 3 05:51:44 UTC 2022
Modified Files: src/sys/dev/usb: if_axe.c if_axen.c if_smsc.c if_udav.c if_url.c Log Message: usbnet drivers: No need for usbnet_busy during attach. usbnet_detach cannot run until the attach routine has finished (unless a driver goes out of its way to tie its shoelaces together and explicitly call it during the attach routine, which none of them do), so there is no need to hang onto a reference count that we release before attach returns. To generate a diff of this commit: cvs rdiff -u -r1.136 -r1.137 src/sys/dev/usb/if_axe.c cvs rdiff -u -r1.79 -r1.80 src/sys/dev/usb/if_axen.c cvs rdiff -u -r1.77 -r1.78 src/sys/dev/usb/if_smsc.c cvs rdiff -u -r1.83 -r1.84 src/sys/dev/usb/if_udav.c src/sys/dev/usb/if_url.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/usb/if_axe.c diff -u src/sys/dev/usb/if_axe.c:1.136 src/sys/dev/usb/if_axe.c:1.137 --- src/sys/dev/usb/if_axe.c:1.136 Thu Mar 3 05:51:27 2022 +++ src/sys/dev/usb/if_axe.c Thu Mar 3 05:51:44 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: if_axe.c,v 1.136 2022/03/03 05:51:27 riastradh Exp $ */ +/* $NetBSD: if_axe.c,v 1.137 2022/03/03 05:51:44 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.136 2022/03/03 05:51:27 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.137 2022/03/03 05:51:44 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -930,10 +930,8 @@ axe_attach(device_t parent, device_t sel /* We need the PHYID for init dance in some cases */ usbnet_lock_core(un); - usbnet_busy(un); if (axe_cmd(sc, AXE_CMD_READ_PHYID, 0, 0, &sc->axe_phyaddrs)) { aprint_error_dev(self, "failed to read phyaddrs\n"); - usbnet_unbusy(un); usbnet_unlock_core(un); return; } @@ -964,13 +962,11 @@ axe_attach(device_t parent, device_t sel } else { if (axe_cmd(sc, AXE_CMD_READ_IPG012, 0, 0, sc->axe_ipgs)) { aprint_error_dev(self, "failed to read ipg\n"); - usbnet_unbusy(un); usbnet_unlock_core(un); return; } } - usbnet_unbusy(un); usbnet_unlock_core(un); if (!AXE_IS_172(un)) Index: src/sys/dev/usb/if_axen.c diff -u src/sys/dev/usb/if_axen.c:1.79 src/sys/dev/usb/if_axen.c:1.80 --- src/sys/dev/usb/if_axen.c:1.79 Thu Mar 3 05:51:35 2022 +++ src/sys/dev/usb/if_axen.c Thu Mar 3 05:51:44 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: if_axen.c,v 1.79 2022/03/03 05:51:35 riastradh Exp $ */ +/* $NetBSD: if_axen.c,v 1.80 2022/03/03 05:51:44 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.79 2022/03/03 05:51:35 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.80 2022/03/03 05:51:44 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -368,7 +368,6 @@ axen_ax88179_init(struct usbnet *un) uint8_t val; usbnet_lock_core(un); - usbnet_busy(un); /* XXX: ? */ axen_cmd(un, AXEN_CMD_MAC_READ, 1, AXEN_UNK_05, &val); @@ -452,7 +451,6 @@ axen_ax88179_init(struct usbnet *un) default: aprint_error_dev(un->un_dev, "unknown uplink bus:0x%02x\n", val); - usbnet_unbusy(un); usbnet_unlock_core(un); return; } @@ -512,7 +510,6 @@ axen_ax88179_init(struct usbnet *un) usbnet_mii_writereg(un->un_dev, un->un_phyno, 0x1F, 0x0000); #endif - usbnet_unbusy(un); usbnet_unlock_core(un); } @@ -682,14 +679,11 @@ axen_attach(device_t parent, device_t se /* Get station address. */ usbnet_lock_core(un); - usbnet_busy(un); if (axen_get_eaddr(un, &un->un_eaddr)) { - usbnet_unbusy(un); usbnet_unlock_core(un); printf("EEPROM checksum error\n"); return; } - usbnet_unbusy(un); usbnet_unlock_core(un); axen_ax88179_init(un); Index: src/sys/dev/usb/if_smsc.c diff -u src/sys/dev/usb/if_smsc.c:1.77 src/sys/dev/usb/if_smsc.c:1.78 --- src/sys/dev/usb/if_smsc.c:1.77 Thu Mar 3 05:51:35 2022 +++ src/sys/dev/usb/if_smsc.c Thu Mar 3 05:51:44 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: if_smsc.c,v 1.77 2022/03/03 05:51:35 riastradh Exp $ */ +/* $NetBSD: if_smsc.c,v 1.78 2022/03/03 05:51:44 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.77 2022/03/03 05:51:35 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_smsc.c,v 1.78 2022/03/03 05:51:44 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -884,7 +884,6 @@ smsc_attach(device_t parent, device_t se un->un_phyno = 1; usbnet_lock_core(un); - usbnet_busy(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 @@ -912,7 +911,6 @@ smsc_attach(device_t parent, device_t se un->un_eaddr[0] = (uint8_t)((mac_l) & 0xff); } } - usbnet_unbusy(un); usbnet_unlock_core(un); usbnet_attach_ifp(un, IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST, Index: src/sys/dev/usb/if_udav.c diff -u src/sys/dev/usb/if_udav.c:1.83 src/sys/dev/usb/if_udav.c:1.84 --- src/sys/dev/usb/if_udav.c:1.83 Thu Mar 3 05:51:27 2022 +++ src/sys/dev/usb/if_udav.c Thu Mar 3 05:51:44 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: if_udav.c,v 1.83 2022/03/03 05:51:27 riastradh Exp $ */ +/* $NetBSD: if_udav.c,v 1.84 2022/03/03 05:51:44 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.83 2022/03/03 05:51:27 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_udav.c,v 1.84 2022/03/03 05:51:44 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -240,14 +240,12 @@ udav_attach(device_t parent, device_t se usbnet_attach(un, "udavdet"); usbnet_lock_core(un); - usbnet_busy(un); // /* reset the adapter */ // udav_reset(un); /* Get Ethernet Address */ err = udav_csr_read(un, UDAV_PAR, un->un_eaddr, ETHER_ADDR_LEN); - usbnet_unbusy(un); usbnet_unlock_core(un); if (err) { aprint_error_dev(self, "read MAC address failed\n"); Index: src/sys/dev/usb/if_url.c diff -u src/sys/dev/usb/if_url.c:1.83 src/sys/dev/usb/if_url.c:1.84 --- src/sys/dev/usb/if_url.c:1.83 Thu Mar 3 05:51:27 2022 +++ src/sys/dev/usb/if_url.c Thu Mar 3 05:51:44 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: if_url.c,v 1.83 2022/03/03 05:51:27 riastradh Exp $ */ +/* $NetBSD: if_url.c,v 1.84 2022/03/03 05:51:44 riastradh Exp $ */ /* * Copyright (c) 2001, 2002 @@ -44,7 +44,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1.83 2022/03/03 05:51:27 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1.84 2022/03/03 05:51:44 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -244,7 +244,6 @@ url_attach(device_t parent, device_t sel usbnet_attach(un, "urldet"); usbnet_lock_core(un); - usbnet_busy(un); /* reset the adapter */ url_reset(un); @@ -252,7 +251,6 @@ url_attach(device_t parent, device_t sel /* Get Ethernet Address */ err = url_mem(un, URL_CMD_READMEM, URL_IDR0, (void *)un->un_eaddr, ETHER_ADDR_LEN); - usbnet_unbusy(un); usbnet_unlock_core(un); if (err) { aprint_error_dev(self, "read MAC address failed\n");