Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb usbnet: Make the tx/rx locks private to usbnet.c.
details: https://anonhg.NetBSD.org/src/rev/d9d04265779e
branches: trunk
changeset: 362524:d9d04265779e
user: riastradh <riastradh%NetBSD.org@localhost>
date: Thu Mar 03 05:52:20 2022 +0000
description:
usbnet: Make the tx/rx locks private to usbnet.c.
Suffice it for the drivers to know that uno_tx_prepare and
uno_rx_loop have exclusive access to the chain, and, for tx,
exclusive access to the mbuf.
diffstat:
sys/dev/usb/if_axe.c | 6 ++----
sys/dev/usb/if_cdce.c | 6 ++----
sys/dev/usb/usbnet.c | 45 ++++++++++++---------------------------------
sys/dev/usb/usbnet.h | 20 +-------------------
4 files changed, 17 insertions(+), 60 deletions(-)
diffs (170 lines):
diff -r fc04909ab574 -r d9d04265779e sys/dev/usb/if_axe.c
--- a/sys/dev/usb/if_axe.c Thu Mar 03 05:52:11 2022 +0000
+++ b/sys/dev/usb/if_axe.c Thu Mar 03 05:52:20 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_axe.c,v 1.137 2022/03/03 05:51:44 riastradh Exp $ */
+/* $NetBSD: if_axe.c,v 1.138 2022/03/03 05:52:20 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.137 2022/03/03 05:51:44 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.138 2022/03/03 05:52:20 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -1136,8 +1136,6 @@
size_t hdr_len = 0, tlr_len = 0;
int length, boundary;
- usbnet_isowned_tx(un);
-
if (!AXE_IS_172(un)) {
/*
* Copy the mbuf data into a contiguous buffer, leaving two
diff -r fc04909ab574 -r d9d04265779e sys/dev/usb/if_cdce.c
--- a/sys/dev/usb/if_cdce.c Thu Mar 03 05:52:11 2022 +0000
+++ b/sys/dev/usb/if_cdce.c Thu Mar 03 05:52:20 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_cdce.c,v 1.73 2022/03/03 05:50:22 riastradh Exp $ */
+/* $NetBSD: if_cdce.c,v 1.74 2022/03/03 05:52:20 riastradh Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000-2003 Bill Paul <wpaul%windriver.com@localhost>
@@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_cdce.c,v 1.73 2022/03/03 05:50:22 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cdce.c,v 1.74 2022/03/03 05:52:20 riastradh Exp $");
#include <sys/param.h>
@@ -277,8 +277,6 @@
{
struct ifnet *ifp = usbnet_ifp(un);
- usbnet_isowned_rx(un);
-
/* Strip off CRC added by Zaurus, if present */
if (un->un_flags & CDCE_ZAURUS && total_len > 4)
total_len -= 4;
diff -r fc04909ab574 -r d9d04265779e sys/dev/usb/usbnet.c
--- a/sys/dev/usb/usbnet.c Thu Mar 03 05:52:11 2022 +0000
+++ b/sys/dev/usb/usbnet.c Thu Mar 03 05:52:20 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usbnet.c,v 1.78 2022/03/03 05:52:11 riastradh Exp $ */
+/* $NetBSD: usbnet.c,v 1.79 2022/03/03 05:52:20 riastradh Exp $ */
/*
* Copyright (c) 2019 Matthew R. Green
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.78 2022/03/03 05:52:11 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.79 2022/03/03 05:52:20 riastradh Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -96,6 +96,9 @@
volatile unsigned usbnet_number;
+static void usbnet_isowned_rx(struct usbnet *);
+static void usbnet_isowned_tx(struct usbnet *);
+
static int usbnet_modcmd(modcmd_t, void *);
#ifdef USB_DEBUG
@@ -1323,46 +1326,22 @@
mutex_exit(&un->un_pri->unp_core_lock);
}
-kmutex_t *
+kmutex_t*
usbnet_mutex_core(struct usbnet *un)
{
return &un->un_pri->unp_core_lock;
}
-void
-usbnet_lock_rx(struct usbnet *un)
+static void
+usbnet_isowned_rx(struct usbnet *un)
{
- mutex_enter(&un->un_pri->unp_rxlock);
-}
-
-void
-usbnet_unlock_rx(struct usbnet *un)
-{
- mutex_exit(&un->un_pri->unp_rxlock);
+ KASSERT(mutex_owned(&un->un_pri->unp_rxlock));
}
-kmutex_t *
-usbnet_mutex_rx(struct usbnet *un)
-{
- return &un->un_pri->unp_rxlock;
-}
-
-void
-usbnet_lock_tx(struct usbnet *un)
+static void
+usbnet_isowned_tx(struct usbnet *un)
{
- mutex_enter(&un->un_pri->unp_txlock);
-}
-
-void
-usbnet_unlock_tx(struct usbnet *un)
-{
- mutex_exit(&un->un_pri->unp_txlock);
-}
-
-kmutex_t *
-usbnet_mutex_tx(struct usbnet *un)
-{
- return &un->un_pri->unp_txlock;
+ KASSERT(mutex_owned(&un->un_pri->unp_txlock));
}
/* Autoconf management. */
diff -r fc04909ab574 -r d9d04265779e sys/dev/usb/usbnet.h
--- a/sys/dev/usb/usbnet.h Thu Mar 03 05:52:11 2022 +0000
+++ b/sys/dev/usb/usbnet.h Thu Mar 03 05:52:20 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usbnet.h,v 1.25 2022/03/03 05:52:11 riastradh Exp $ */
+/* $NetBSD: usbnet.h,v 1.26 2022/03/03 05:52:20 riastradh Exp $ */
/*
* Copyright (c) 2019 Matthew R. Green
@@ -311,24 +311,6 @@
KASSERT(mutex_owned(usbnet_mutex_core(un)));
}
-void usbnet_lock_rx(struct usbnet *);
-void usbnet_unlock_rx(struct usbnet *);
-kmutex_t *usbnet_mutex_rx(struct usbnet *);
-static __inline__ void
-usbnet_isowned_rx(struct usbnet *un)
-{
- KASSERT(mutex_owned(usbnet_mutex_rx(un)));
-}
-
-void usbnet_lock_tx(struct usbnet *);
-void usbnet_unlock_tx(struct usbnet *);
-kmutex_t *usbnet_mutex_tx(struct usbnet *);
-static __inline__ void
-usbnet_isowned_tx(struct usbnet *un)
-{
- KASSERT(mutex_owned(usbnet_mutex_tx(un)));
-}
-
/*
* Endpoint / rx/tx chain management:
*
Home |
Main Index |
Thread Index |
Old Index