Index: sys/net/if_media.c =================================================================== --- sys/net/if_media.c +++ sys/net/if_media.c @@ -69,6 +69,7 @@ * turn on implementation-level debug printfs. * Useful for debugging newly-ported drivers. */ +#define IFMEDIA_DEBUG 1 static struct ifmedia_entry *ifmedia_match(struct ifmedia *ifm, int flags, int mask); @@ -85,11 +86,8 @@ * Initialize if_media struct for a specific interface instance. */ void -ifmedia_init(ifm, dontcare_mask, change_callback, status_callback) - struct ifmedia *ifm; - int dontcare_mask; - ifm_change_cb_t change_callback; - ifm_stat_cb_t status_callback; +ifmedia_init(struct ifmedia *ifm, int dontcare_mask, + ifm_change_cb_t change_callback, ifm_stat_cb_t status_callback) { LIST_INIT(&ifm->ifm_list); @@ -101,13 +99,11 @@ } void -ifmedia_removeall(ifm) - struct ifmedia *ifm; +ifmedia_removeall(struct ifmedia *ifm) { struct ifmedia_entry *entry; - for (entry = LIST_FIRST(&ifm->ifm_list); entry; - entry = LIST_FIRST(&ifm->ifm_list)) { + while ((entry = LIST_FIRST(&ifm->ifm_list)) != NULL) { LIST_REMOVE(entry, ifm_list); free(entry, M_IFADDR); } @@ -119,11 +115,7 @@ * for a specific interface instance. */ void -ifmedia_add(ifm, mword, data, aux) - struct ifmedia *ifm; - int mword; - int data; - void *aux; +ifmedia_add(struct ifmedia *ifm, int mword, int data, void *aux) { struct ifmedia_entry *entry; @@ -133,7 +125,7 @@ printf("ifmedia_add: null ifm\n"); return; } - printf("Adding entry for "); + printf("Adding entry for (%#010x) ", mword); ifmedia_printword(mword); } #endif @@ -154,10 +146,7 @@ * supported media for a specific interface instance. */ void -ifmedia_list_add(ifm, lp, count) - struct ifmedia *ifm; - struct ifmedia_entry *lp; - int count; +ifmedia_list_add(struct ifmedia *ifm, struct ifmedia_entry *lp, int count) { int i; @@ -174,10 +163,7 @@ * media-change callback. */ void -ifmedia_set(ifm, target) - struct ifmedia *ifm; - int target; - +ifmedia_set(struct ifmedia *ifm, int target) { struct ifmedia_entry *match; @@ -219,18 +205,15 @@ * Device-independent media ioctl support function. */ int -ifmedia_ioctl(ifp, ifr, ifm, cmd) - struct ifnet *ifp; - struct ifreq *ifr; - struct ifmedia *ifm; - u_long cmd; +ifmedia_ioctl(struct ifnet *ifp, struct ifreq *ifr, struct ifmedia *ifm, + u_long cmd) { struct ifmedia_entry *match; struct ifmediareq *ifmr = (struct ifmediareq *) ifr; int error = 0; if (ifp == NULL || ifr == NULL || ifm == NULL) - return(EINVAL); + return (EINVAL); switch (cmd) { /* @@ -247,8 +230,8 @@ #ifdef IFMEDIA_DEBUG if (ifmedia_debug) { printf( - "ifmedia_ioctl: no media found for 0x%x\n", - newmedia); + "ifmedia_ioctl: no media found for %#010x mask %#010x\n", + newmedia, ifm->ifm_mask); } #endif return (ENXIO); @@ -260,10 +243,9 @@ * Keep going in case the connected media changed. * Similarly, if best match changed (kernel debugger?). */ - if ((IFM_SUBTYPE(newmedia) != IFM_AUTO) && - (newmedia == ifm->ifm_media) && - (match == ifm->ifm_cur)) - return 0; + if (IFM_SUBTYPE(newmedia) != IFM_AUTO && + newmedia == ifm->ifm_media && match == ifm->ifm_cur) + return (0); /* * We found a match, now make the driver switch to it. @@ -344,10 +326,7 @@ * */ static struct ifmedia_entry * -ifmedia_match(ifm, target, mask) - struct ifmedia *ifm; - int target; - int mask; +ifmedia_match(struct ifmedia *ifm, int target, int mask) { struct ifmedia_entry *match, *next; @@ -359,14 +338,14 @@ #if defined(IFMEDIA_DEBUG) || defined(DIAGNOSTIC) if (match) { printf("ifmedia_match: multiple match for " - "0x%x/0x%x\n", target, mask); + "%#010x/%#010x\n", target, mask); } #endif match = next; } } - return match; + return (match); } /* @@ -382,7 +361,8 @@ int i; for (i = 0; ifmedia_baudrate_descriptions[i].ifmb_word != 0; i++) { - if (IFM_TYPE_MATCH(mword, ifmedia_baudrate_descriptions[i].ifmb_word)) + if (IFM_TYPE_MATCH(mword, ifmedia_baudrate_descriptions[i]. + ifmb_word)) return (ifmedia_baudrate_descriptions[i].ifmb_baudrate); } @@ -453,8 +433,7 @@ * print a media word. */ static void -ifmedia_printword(ifmw) - int ifmw; +ifmedia_printword(int ifmw) { const struct ifmedia_description *desc; const struct ifmedia_type_to_subtype *ttos;