Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net remove unnecessary lock in sppp_mediastatus() as it ...



details:   https://anonhg.NetBSD.org/src/rev/ac3a784de9e3
branches:  trunk
changeset: 1007970:ac3a784de9e3
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Fri Mar 06 10:26:59 2020 +0000

description:
remove unnecessary lock in sppp_mediastatus() as it doesn't touch struct sppp.

ok'ed by yamaguchi@n.o.

diffstat:

 sys/net/if_spppsubr.c |  15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)

diffs (43 lines):

diff -r 01ebfd7c3a8c -r ac3a784de9e3 sys/net/if_spppsubr.c
--- a/sys/net/if_spppsubr.c     Fri Mar 06 04:54:08 2020 +0000
+++ b/sys/net/if_spppsubr.c     Fri Mar 06 10:26:59 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_spppsubr.c,v 1.186 2020/02/04 05:46:32 thorpej Exp $         */
+/*     $NetBSD: if_spppsubr.c,v 1.187 2020/03/06 10:26:59 knakahara Exp $       */
 
 /*
  * Synchronous PPP/Cisco link level subroutines.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.186 2020/02/04 05:46:32 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.187 2020/03/06 10:26:59 knakahara Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -972,11 +972,10 @@
 static void
 sppp_mediastatus(struct ifnet *ifp, struct ifmediareq *imr)
 {
-       struct sppp *sp = (struct sppp *)ifp;
-
-       SPPP_LOCK(sp, RW_WRITER);
-
-       switch (ifp->if_link_state) {
+       int link_state;
+
+       link_state = atomic_load_relaxed(&ifp->if_link_state);
+       switch (link_state) {
        case LINK_STATE_UP:
                imr->ifm_status = IFM_AVALID | IFM_ACTIVE;
                break;
@@ -988,8 +987,6 @@
                imr->ifm_status = 0;
                break;
        }
-
-       SPPP_UNLOCK(sp);
 }
 
 void



Home | Main Index | Thread Index | Old Index