add prototypes, validate ifm_change and ifm_status vectors. NFC.

This commit is contained in:
mlelstv 2018-03-30 13:21:24 +00:00
parent 20bad51beb
commit ae07208ded
1 changed files with 19 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_media.c,v 1.35 2017/11/22 03:03:18 ozaki-r Exp $ */ /* $NetBSD: if_media.c,v 1.36 2018/03/30 13:21:24 mlelstv Exp $ */
/*- /*-
* Copyright (c) 1998 The NetBSD Foundation, Inc. * Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -76,7 +76,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.35 2017/11/22 03:03:18 ozaki-r Exp $"); __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.36 2018/03/30 13:21:24 mlelstv Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -89,6 +89,9 @@ __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.35 2017/11/22 03:03:18 ozaki-r Exp $"
#include <net/if_media.h> #include <net/if_media.h>
#include <net/netisr.h> #include <net/netisr.h>
static void ifmedia_status(struct ifmedia *, struct ifnet *, struct ifmediareq *);
static int _ifmedia_ioctl(struct ifnet *, struct ifreq *, struct ifmedia *, u_long);
/* /*
* Compile-time options: * Compile-time options:
* IFMEDIA_DEBUG: * IFMEDIA_DEBUG:
@ -122,9 +125,22 @@ ifmedia_init(struct ifmedia *ifm, int dontcare_mask,
int int
ifmedia_change(struct ifmedia *ifm, struct ifnet *ifp) ifmedia_change(struct ifmedia *ifm, struct ifnet *ifp)
{ {
if (ifm->ifm_change == NULL)
return -1;
return (*ifm->ifm_change)(ifp); return (*ifm->ifm_change)(ifp);
} }
static void
ifmedia_status(struct ifmedia *ifm, struct ifnet *ifp,
struct ifmediareq *ifmr)
{
if (ifm->ifm_status == NULL)
return;
(*ifm->ifm_status)(ifp, ifmr);
}
/* /*
* Add a media configuration to the list of supported media * Add a media configuration to the list of supported media
* for a specific interface instance. * for a specific interface instance.
@ -317,8 +333,7 @@ _ifmedia_ioctl(struct ifnet *ifp, struct ifreq *ifr, struct ifmedia *ifm,
ifm->ifm_cur->ifm_media : IFM_NONE; ifm->ifm_cur->ifm_media : IFM_NONE;
ifmr->ifm_mask = ifm->ifm_mask; ifmr->ifm_mask = ifm->ifm_mask;
ifmr->ifm_status = 0; ifmr->ifm_status = 0;
/* ifmedia_status */ ifmedia_status(ifm, ifp, ifmr);
(*ifm->ifm_status)(ifp, ifmr);
/* /*
* Count them so we know a-priori how much is the max we'll * Count them so we know a-priori how much is the max we'll