Thu Mar 3 05:48:14 2022 UTC ()
usbnet: Remove usbnet_set_dying.

Not necessary for the one caller that did it (url(4)): usbnet_detach
handles failed attach just fine without it.


(riastradh)
diff -r1.77 -r1.78 src/sys/dev/usb/if_url.c
diff -r1.54 -r1.55 src/sys/dev/usb/usbnet.c
diff -r1.22 -r1.23 src/sys/dev/usb/usbnet.h

cvs diff -r1.77 -r1.78 src/sys/dev/usb/if_url.c (expand / switch to unified diff)

--- src/sys/dev/usb/if_url.c 2020/04/02 04:09:36 1.77
+++ src/sys/dev/usb/if_url.c 2022/03/03 05:48:14 1.78
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_url.c,v 1.77 2020/04/02 04:09:36 nisimura Exp $ */ 1/* $NetBSD: if_url.c,v 1.78 2022/03/03 05:48:14 riastradh Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001, 2002 4 * Copyright (c) 2001, 2002
5 * Shingo WATANABE <nabe@nabechan.org>. All rights reserved. 5 * Shingo WATANABE <nabe@nabechan.org>. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -34,27 +34,27 @@ @@ -34,27 +34,27 @@
34 * The RTL8150L(Realtek USB to fast ethernet controller) spec can be found at 34 * The RTL8150L(Realtek USB to fast ethernet controller) spec can be found at
35 * ftp://ftp.realtek.com.tw/lancard/data_sheet/8150/8150v14.pdf 35 * ftp://ftp.realtek.com.tw/lancard/data_sheet/8150/8150v14.pdf
36 * ftp://152.104.125.40/lancard/data_sheet/8150/8150v14.pdf 36 * ftp://152.104.125.40/lancard/data_sheet/8150/8150v14.pdf
37 */ 37 */
38 38
39/* 39/*
40 * TODO: 40 * TODO:
41 * Interrupt Endpoint support 41 * Interrupt Endpoint support
42 * External PHYs 42 * External PHYs
43 * powerhook() support? 43 * powerhook() support?
44 */ 44 */
45 45
46#include <sys/cdefs.h> 46#include <sys/cdefs.h>
47__KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1.77 2020/04/02 04:09:36 nisimura Exp $"); 47__KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1.78 2022/03/03 05:48:14 riastradh Exp $");
48 48
49#ifdef _KERNEL_OPT 49#ifdef _KERNEL_OPT
50#include "opt_inet.h" 50#include "opt_inet.h"
51#include "opt_usb.h" 51#include "opt_usb.h"
52#endif 52#endif
53 53
54#include <sys/param.h> 54#include <sys/param.h>
55 55
56#include <net/if_ether.h> 56#include <net/if_ether.h>
57#ifdef INET 57#ifdef INET
58#include <netinet/in.h> 58#include <netinet/in.h>
59#include <netinet/if_inarp.h> 59#include <netinet/if_inarp.h>
60#endif 60#endif
@@ -246,38 +246,32 @@ url_attach(device_t parent, device_t sel @@ -246,38 +246,32 @@ url_attach(device_t parent, device_t sel
246 usbnet_lock_core(un); 246 usbnet_lock_core(un);
247 usbnet_busy(un); 247 usbnet_busy(un);
248 248
249 /* reset the adapter */ 249 /* reset the adapter */
250 url_reset(un); 250 url_reset(un);
251 251
252 /* Get Ethernet Address */ 252 /* Get Ethernet Address */
253 err = url_mem(un, URL_CMD_READMEM, URL_IDR0, (void *)un->un_eaddr, 253 err = url_mem(un, URL_CMD_READMEM, URL_IDR0, (void *)un->un_eaddr,
254 ETHER_ADDR_LEN); 254 ETHER_ADDR_LEN);
255 usbnet_unbusy(un); 255 usbnet_unbusy(un);
256 usbnet_unlock_core(un); 256 usbnet_unlock_core(un);
257 if (err) { 257 if (err) {
258 aprint_error_dev(self, "read MAC address failed\n"); 258 aprint_error_dev(self, "read MAC address failed\n");
259 goto bad; 259 return;
260 } 260 }
261 261
262 /* initialize interface information */ 262 /* initialize interface information */
263 usbnet_attach_ifp(un, IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST, 263 usbnet_attach_ifp(un, IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST,
264 0, &unm); 264 0, &unm);
265 
266 return; 
267 
268 bad: 
269 usbnet_set_dying(un, true); 
270 return; 
271} 265}
272 266
273/* read/write memory */ 267/* read/write memory */
274static int 268static int
275url_mem(struct usbnet *un, int cmd, int offset, void *buf, int len) 269url_mem(struct usbnet *un, int cmd, int offset, void *buf, int len)
276{ 270{
277 usb_device_request_t req; 271 usb_device_request_t req;
278 usbd_status err; 272 usbd_status err;
279 273
280 usbnet_isowned_core(un); 274 usbnet_isowned_core(un);
281 275
282 DPRINTFN(0x200, 276 DPRINTFN(0x200,
283 ("%s: %s: enter\n", device_xname(un->un_dev), __func__)); 277 ("%s: %s: enter\n", device_xname(un->un_dev), __func__));

cvs diff -r1.54 -r1.55 src/sys/dev/usb/usbnet.c (expand / switch to unified diff)

--- src/sys/dev/usb/usbnet.c 2022/03/03 05:47:58 1.54
+++ src/sys/dev/usb/usbnet.c 2022/03/03 05:48:14 1.55
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: usbnet.c,v 1.54 2022/03/03 05:47:58 riastradh Exp $ */ 1/* $NetBSD: usbnet.c,v 1.55 2022/03/03 05:48:14 riastradh Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2019 Matthew R. Green 4 * Copyright (c) 2019 Matthew R. Green
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -21,27 +21,27 @@ @@ -21,27 +21,27 @@
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE. 26 * SUCH DAMAGE.
27 */ 27 */
28 28
29/* 29/*
30 * Common code shared between USB network drivers. 30 * Common code shared between USB network drivers.
31 */ 31 */
32 32
33#include <sys/cdefs.h> 33#include <sys/cdefs.h>
34__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.54 2022/03/03 05:47:58 riastradh Exp $"); 34__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.55 2022/03/03 05:48:14 riastradh Exp $");
35 35
36#include <sys/param.h> 36#include <sys/param.h>
37#include <sys/kernel.h> 37#include <sys/kernel.h>
38#include <sys/kmem.h> 38#include <sys/kmem.h>
39#include <sys/module.h> 39#include <sys/module.h>
40#include <sys/atomic.h> 40#include <sys/atomic.h>
41 41
42#include <dev/usb/usbnet.h> 42#include <dev/usb/usbnet.h>
43#include <dev/usb/usbhist.h> 43#include <dev/usb/usbhist.h>
44 44
45struct usbnet_cdata { 45struct usbnet_cdata {
46 struct usbnet_chain *uncd_tx_chain; 46 struct usbnet_chain *uncd_tx_chain;
47 struct usbnet_chain *uncd_rx_chain; 47 struct usbnet_chain *uncd_rx_chain;
@@ -1278,32 +1278,26 @@ usbnet_if_init(struct ifnet *ifp) @@ -1278,32 +1278,26 @@ usbnet_if_init(struct ifnet *ifp)
1278 1278
1279 return uno_init(un, ifp); 1279 return uno_init(un, ifp);
1280} 1280}
1281 1281
1282 1282
1283/* Various accessors. */ 1283/* Various accessors. */
1284 1284
1285void 1285void
1286usbnet_set_link(struct usbnet *un, bool link) 1286usbnet_set_link(struct usbnet *un, bool link)
1287{ 1287{
1288 un->un_pri->unp_link = link; 1288 un->un_pri->unp_link = link;
1289} 1289}
1290 1290
1291void 
1292usbnet_set_dying(struct usbnet *un, bool link) 
1293{ 
1294 un->un_pri->unp_dying = link; 
1295} 
1296 
1297struct ifnet * 1291struct ifnet *
1298usbnet_ifp(struct usbnet *un) 1292usbnet_ifp(struct usbnet *un)
1299{ 1293{
1300 return &un->un_pri->unp_ec.ec_if; 1294 return &un->un_pri->unp_ec.ec_if;
1301} 1295}
1302 1296
1303struct ethercom * 1297struct ethercom *
1304usbnet_ec(struct usbnet *un) 1298usbnet_ec(struct usbnet *un)
1305{ 1299{
1306 return &un->un_pri->unp_ec; 1300 return &un->un_pri->unp_ec;
1307} 1301}
1308 1302
1309struct mii_data * 1303struct mii_data *

cvs diff -r1.22 -r1.23 src/sys/dev/usb/usbnet.h (expand / switch to unified diff)

--- src/sys/dev/usb/usbnet.h 2021/12/11 19:24:21 1.22
+++ src/sys/dev/usb/usbnet.h 2022/03/03 05:48:14 1.23
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: usbnet.h,v 1.22 2021/12/11 19:24:21 mrg Exp $ */ 1/* $NetBSD: usbnet.h,v 1.23 2022/03/03 05:48:14 riastradh Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2019 Matthew R. Green 4 * Copyright (c) 2019 Matthew R. Green
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -274,27 +274,26 @@ struct usbnet { @@ -274,27 +274,26 @@ struct usbnet {
274 * This section is for driver to use, not touched by usbnet. 274 * This section is for driver to use, not touched by usbnet.
275 */ 275 */
276 unsigned un_flags; 276 unsigned un_flags;
277 277
278 /* 278 /*
279 * This section is private to usbnet. Don't touch. 279 * This section is private to usbnet. Don't touch.
280 */ 280 */
281 struct usbnet_private *un_pri; 281 struct usbnet_private *un_pri;
282}; 282};
283 283
284/* Various accessors. */ 284/* Various accessors. */
285 285
286void usbnet_set_link(struct usbnet *, bool); 286void usbnet_set_link(struct usbnet *, bool);
287void usbnet_set_dying(struct usbnet *, bool); 
288 287
289struct ifnet *usbnet_ifp(struct usbnet *); 288struct ifnet *usbnet_ifp(struct usbnet *);
290struct ethercom *usbnet_ec(struct usbnet *); 289struct ethercom *usbnet_ec(struct usbnet *);
291struct mii_data *usbnet_mii(struct usbnet *); 290struct mii_data *usbnet_mii(struct usbnet *);
292krndsource_t *usbnet_rndsrc(struct usbnet *); 291krndsource_t *usbnet_rndsrc(struct usbnet *);
293void *usbnet_softc(struct usbnet *); 292void *usbnet_softc(struct usbnet *);
294 293
295bool usbnet_havelink(struct usbnet *); 294bool usbnet_havelink(struct usbnet *);
296bool usbnet_isdying(struct usbnet *); 295bool usbnet_isdying(struct usbnet *);
297 296
298 297
299/* 298/*
300 * Locking. Note that the isowned() are implemented here so that 299 * Locking. Note that the isowned() are implemented here so that