diff options
author | John Baldwin <jhb@FreeBSD.org> | 2009-11-06 14:52:37 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2009-11-06 14:52:37 +0000 |
commit | f1b211841d6c1455b797ac92ac7382c95ca543f7 (patch) | |
tree | 405feabf6b155b3619c54467a0316d713b9284ab /sys/dev/an/if_an.c | |
parent | 50c3239e85f6708f6bd3f2177c713159240e6cf1 (diff) | |
download | src-f1b211841d6c1455b797ac92ac7382c95ca543f7.tar.gz src-f1b211841d6c1455b797ac92ac7382c95ca543f7.zip |
Use device_printf() and if_printf() instead of printf() with an explicit
unit number and remove 'unit' members from softc.
Notes
Notes:
svn path=/head/; revision=198987
Diffstat (limited to 'sys/dev/an/if_an.c')
-rw-r--r-- | sys/dev/an/if_an.c | 129 |
1 files changed, 61 insertions, 68 deletions
diff --git a/sys/dev/an/if_an.c b/sys/dev/an/if_an.c index 1d22322d8f7e..7f8a2c27503f 100644 --- a/sys/dev/an/if_an.c +++ b/sys/dev/an/if_an.c @@ -349,7 +349,6 @@ an_probe(device_t dev) */ sc->an_bhandle = rman_get_bushandle(sc->port_res); sc->an_btag = rman_get_bustag(sc->port_res); - sc->an_unit = device_get_unit(dev); ssid.an_len = sizeof(ssid); ssid.an_type = AN_RID_SSIDLIST; @@ -600,8 +599,7 @@ an_init_mpi350_desc(struct an_softc *sc) cmd_struct.an_parm1 = AN_RX_DESC_OFFSET; cmd_struct.an_parm2 = AN_MAX_RX_DESC; if (an_cmd_struct(sc, &cmd_struct, &reply)) { - printf("an%d: failed to allocate RX descriptor\n", - sc->an_unit); + if_printf(sc->an_ifp, "failed to allocate RX descriptor\n"); return(EIO); } @@ -629,8 +627,7 @@ an_init_mpi350_desc(struct an_softc *sc) cmd_struct.an_parm1 = AN_TX_DESC_OFFSET; cmd_struct.an_parm2 = AN_MAX_TX_DESC; if (an_cmd_struct(sc, &cmd_struct, &reply)) { - printf("an%d: failed to allocate TX descriptor\n", - sc->an_unit); + if_printf(sc->an_ifp, "failed to allocate TX descriptor\n"); return(EIO); } @@ -659,8 +656,7 @@ an_init_mpi350_desc(struct an_softc *sc) cmd_struct.an_parm1 = AN_HOST_DESC_OFFSET; cmd_struct.an_parm2 = 1; if (an_cmd_struct(sc, &cmd_struct, &reply)) { - printf("an%d: failed to allocate host descriptor\n", - sc->an_unit); + if_printf(sc->an_ifp, "failed to allocate host descriptor\n"); return(EIO); } @@ -687,7 +683,7 @@ an_attach(struct an_softc *sc, int unit, int flags) ifp = sc->an_ifp = if_alloc(IFT_ETHER); if (ifp == NULL) { - printf("an%d: can not if_alloc()\n", sc->an_unit); + device_printf(sc->an_dev, "can not if_alloc()\n"); goto fail; } @@ -708,7 +704,7 @@ an_attach(struct an_softc *sc, int unit, int flags) /* Load factory config */ if (an_cmd(sc, AN_CMD_READCFG, 0)) { - printf("an%d: failed to load config data\n", sc->an_unit); + device_printf(sc->an_dev, "failed to load config data\n"); goto fail; } @@ -716,7 +712,7 @@ an_attach(struct an_softc *sc, int unit, int flags) sc->an_config.an_type = AN_RID_GENCONFIG; sc->an_config.an_len = sizeof(struct an_ltv_genconfig); if (an_read_record(sc, (struct an_ltv_gen *)&sc->an_config)) { - printf("an%d: read record failed\n", sc->an_unit); + device_printf(sc->an_dev, "read record failed\n"); goto fail; } @@ -724,7 +720,7 @@ an_attach(struct an_softc *sc, int unit, int flags) sc->an_caps.an_type = AN_RID_CAPABILITIES; sc->an_caps.an_len = sizeof(struct an_ltv_caps); if (an_read_record(sc, (struct an_ltv_gen *)&sc->an_caps)) { - printf("an%d: read record failed\n", sc->an_unit); + device_printf(sc->an_dev, "read record failed\n"); goto fail; } @@ -732,7 +728,7 @@ an_attach(struct an_softc *sc, int unit, int flags) sc->an_ssidlist.an_type = AN_RID_SSIDLIST; sc->an_ssidlist.an_len = sizeof(struct an_ltv_ssidlist_new); if (an_read_record(sc, (struct an_ltv_gen *)&sc->an_ssidlist)) { - printf("an%d: read record failed\n", sc->an_unit); + device_printf(sc->an_dev, "read record failed\n"); goto fail; } @@ -740,7 +736,7 @@ an_attach(struct an_softc *sc, int unit, int flags) sc->an_aplist.an_type = AN_RID_APLIST; sc->an_aplist.an_len = sizeof(struct an_ltv_aplist); if (an_read_record(sc, (struct an_ltv_gen *)&sc->an_aplist)) { - printf("an%d: read record failed\n", sc->an_unit); + device_printf(sc->an_dev, "read record failed\n"); goto fail; } @@ -751,19 +747,19 @@ an_attach(struct an_softc *sc, int unit, int flags) sc->an_rssimap.an_type = AN_RID_RSSI_MAP; sc->an_rssimap.an_len = sizeof(struct an_ltv_rssi_map); if (an_read_record(sc, (struct an_ltv_gen *)&sc->an_rssimap)) { - printf("an%d: unable to get RSSI <-> dBM map\n", sc->an_unit); + device_printf(sc->an_dev, + "unable to get RSSI <-> dBM map\n"); } else { - printf("an%d: got RSSI <-> dBM map\n", sc->an_unit); + device_printf(sc->an_dev, "got RSSI <-> dBM map\n"); sc->an_have_rssimap = 1; } } else { - printf("an%d: no RSSI <-> dBM map\n", sc->an_unit); + device_printf(sc->an_dev, "no RSSI <-> dBM map\n"); } #endif AN_UNLOCK(sc); ifp->if_softc = sc; - sc->an_unit = unit; if_initname(ifp, device_get_name(sc->an_dev), device_get_unit(sc->an_dev)); ifp->if_mtu = ETHERMTU; @@ -907,9 +903,9 @@ an_rxeof(struct an_softc *sc) + sizeof(rx_frame); /* Check for insane frame length */ if (len > sizeof(sc->buf_802_11)) { - printf("an%d: oversized packet " + if_printf(ifp, "oversized packet " "received (%d, %d)\n", - sc->an_unit, len, MCLBYTES); + len, MCLBYTES); ifp->if_ierrors++; return; } @@ -933,9 +929,9 @@ an_rxeof(struct an_softc *sc) + ieee80211_header_len; /* Check for insane frame length */ if (len > sizeof(sc->buf_802_11)) { - printf("an%d: oversized packet " + if_printf(ifp, "oversized packet " "received (%d, %d)\n", - sc->an_unit, len, MCLBYTES); + len, MCLBYTES); ifp->if_ierrors++; return; } @@ -993,9 +989,9 @@ an_rxeof(struct an_softc *sc) len = rx_frame_802_3.an_rx_802_3_payload_len; if (len > sizeof(sc->buf_802_11)) { m_freem(m); - printf("an%d: oversized packet " + if_printf(ifp, "oversized packet " "received (%d, %d)\n", - sc->an_unit, len, MCLBYTES); + len, MCLBYTES); ifp->if_ierrors++; return; } @@ -1073,9 +1069,9 @@ an_rxeof(struct an_softc *sc) len = an_rx_desc.an_len + 12; if (len > MCLBYTES) { m_freem(m); - printf("an%d: oversized packet " + if_printf(ifp, "oversized packet " "received (%d, %d)\n", - sc->an_unit, len, MCLBYTES); + len, MCLBYTES); ifp->if_ierrors++; return; } @@ -1116,9 +1112,8 @@ an_rxeof(struct an_softc *sc) ((u_int32_t *)(void *)&an_rx_desc)[i]); } else { - printf("an%d: Didn't get valid RX packet " + if_printf(ifp, "Didn't get valid RX packet " "%x %x %d\n", - sc->an_unit, an_rx_desc.an_done, an_rx_desc.an_valid, an_rx_desc.an_len); } @@ -1393,7 +1388,7 @@ an_reset(struct an_softc *sc) an_cmd(sc, AN_CMD_NOOP2, 0); if (an_cmd(sc, AN_CMD_FORCE_SYNCLOSS, 0) == ETIMEDOUT) - printf("an%d: reset failed\n", sc->an_unit); + if_printf(sc->an_ifp, "reset failed\n"); an_cmd(sc, AN_CMD_DISABLE, 0); @@ -1410,6 +1405,7 @@ an_read_record(struct an_softc *sc, struct an_ltv_gen *ltv) struct an_card_rid_desc an_rid_desc; struct an_command cmd; struct an_reply reply; + struct ifnet *ifp; u_int16_t *ptr; u_int8_t *ptr2; int i, len; @@ -1418,16 +1414,17 @@ an_read_record(struct an_softc *sc, struct an_ltv_gen *ltv) if (ltv->an_len < 4 || ltv->an_type == 0) return(EINVAL); + ifp = sc->an_ifp; if (!sc->mpi350){ /* Tell the NIC to enter record read mode. */ if (an_cmd(sc, AN_CMD_ACCESS|AN_ACCESS_READ, ltv->an_type)) { - printf("an%d: RID access failed\n", sc->an_unit); + if_printf(ifp, "RID access failed\n"); return(EIO); } /* Seek to the record. */ if (an_seek(sc, ltv->an_type, 0, AN_BAP1)) { - printf("an%d: seek to record failed\n", sc->an_unit); + if_printf(ifp, "seek to record failed\n"); return(EIO); } @@ -1439,8 +1436,8 @@ an_read_record(struct an_softc *sc, struct an_ltv_gen *ltv) */ len = CSR_READ_2(sc, AN_DATA1); if (len > (ltv->an_len - 2)) { - printf("an%d: record length mismatch -- expected %d, " - "got %d for Rid %x\n", sc->an_unit, + if_printf(ifp, "record length mismatch -- expected %d, " + "got %d for Rid %x\n", ltv->an_len - 2, len, ltv->an_type); len = ltv->an_len - 2; } else { @@ -1476,8 +1473,8 @@ an_read_record(struct an_softc *sc, struct an_ltv_gen *ltv) if (an_cmd_struct(sc, &cmd, &reply) || reply.an_status & AN_CMD_QUAL_MASK) { - printf("an%d: failed to read RID %x %x %x %x %x, %d\n", - sc->an_unit, ltv->an_type, + if_printf(ifp, "failed to read RID %x %x %x %x %x, %d\n", + ltv->an_type, reply.an_status, reply.an_resp0, reply.an_resp1, @@ -1493,8 +1490,8 @@ an_read_record(struct an_softc *sc, struct an_ltv_gen *ltv) len = an_rid_desc.an_len; if (len > (ltv->an_len - 2)) { - printf("an%d: record length mismatch -- expected %d, " - "got %d for Rid %x\n", sc->an_unit, + if_printf(ifp, "record length mismatch -- expected %d, " + "got %d for Rid %x\n", ltv->an_len - 2, len, ltv->an_type); len = ltv->an_len - 2; } else { @@ -1586,8 +1583,9 @@ an_write_record(struct an_softc *sc, struct an_ltv_gen *ltv) DELAY(100000); if ((i = an_cmd_struct(sc, &cmd, &reply))) { - printf("an%d: failed to write RID 1 %x %x %x %x %x, %d\n", - sc->an_unit, ltv->an_type, + if_printf(sc->an_ifp, + "failed to write RID 1 %x %x %x %x %x, %d\n", + ltv->an_type, reply.an_status, reply.an_resp0, reply.an_resp1, @@ -1598,8 +1596,9 @@ an_write_record(struct an_softc *sc, struct an_ltv_gen *ltv) if (reply.an_status & AN_CMD_QUAL_MASK) { - printf("an%d: failed to write RID 2 %x %x %x %x %x, %d\n", - sc->an_unit, ltv->an_type, + if_printf(sc->an_ifp, + "failed to write RID 2 %x %x %x %x %x, %d\n", + ltv->an_type, reply.an_status, reply.an_resp0, reply.an_resp1, @@ -1623,11 +1622,11 @@ an_dump_record(struct an_softc *sc, struct an_ltv_gen *ltv, char *string) char buf[17], temp; len = ltv->an_len - 4; - printf("an%d: RID %4x, Length %4d, Mode %s\n", - sc->an_unit, ltv->an_type, ltv->an_len - 4, string); + if_printf(sc->an_ifp, "RID %4x, Length %4d, Mode %s\n", + ltv->an_type, ltv->an_len - 4, string); if (an_dump == 1 || (an_dump == ltv->an_type)) { - printf("an%d:\t", sc->an_unit); + if_printf(sc->an_ifp, "\t"); bzero(buf,sizeof(buf)); ptr2 = (u_int8_t *)<v->an_val; @@ -1642,7 +1641,7 @@ an_dump_record(struct an_softc *sc, struct an_ltv_gen *ltv, char *string) if (++count == 16) { count = 0; printf("%s\n",buf); - printf("an%d:\t", sc->an_unit); + if_printf(sc->an_ifp, "\t"); bzero(buf,sizeof(buf)); } } @@ -1669,7 +1668,7 @@ an_seek(struct an_softc *sc, int id, int off, int chan) offreg = AN_OFF1; break; default: - printf("an%d: invalid data path: %x\n", sc->an_unit, chan); + if_printf(sc->an_ifp, "invalid data path: %x\n", chan); return(EIO); } @@ -1743,8 +1742,8 @@ an_alloc_nicmem(struct an_softc *sc, int len, int *id) int i; if (an_cmd(sc, AN_CMD_ALLOC_MEM, len)) { - printf("an%d: failed to allocate %d bytes on NIC\n", - sc->an_unit, len); + if_printf(sc->an_ifp, "failed to allocate %d bytes on NIC\n", + len); return(ENOMEM); } @@ -1863,7 +1862,7 @@ an_setdef(struct an_softc *sc, struct an_req *areq) } break; default: - printf("an%d: unknown RID: %x\n", sc->an_unit, areq->an_type); + if_printf(ifp, "unknown RID: %x\n", areq->an_type); return; } @@ -2653,8 +2652,7 @@ an_init(void *xsc) if (sc->mpi350) an_init_mpi350_desc(sc); if (an_init_tx_ring(sc)) { - printf("an%d: tx buffer allocation " - "failed\n", sc->an_unit); + if_printf(ifp, "tx buffer allocation failed\n"); AN_UNLOCK(sc); return; } @@ -2695,7 +2693,7 @@ an_init(void *xsc) sc->an_ssidlist.an_type = AN_RID_SSIDLIST; sc->an_ssidlist.an_len = sizeof(struct an_ltv_ssidlist_new); if (an_write_record(sc, (struct an_ltv_gen *)&sc->an_ssidlist)) { - printf("an%d: failed to set ssid list\n", sc->an_unit); + if_printf(ifp, "failed to set ssid list\n"); AN_UNLOCK(sc); return; } @@ -2704,7 +2702,7 @@ an_init(void *xsc) sc->an_aplist.an_type = AN_RID_APLIST; sc->an_aplist.an_len = sizeof(struct an_ltv_aplist); if (an_write_record(sc, (struct an_ltv_gen *)&sc->an_aplist)) { - printf("an%d: failed to set AP list\n", sc->an_unit); + if_printf(ifp, "failed to set AP list\n"); AN_UNLOCK(sc); return; } @@ -2713,14 +2711,14 @@ an_init(void *xsc) sc->an_config.an_len = sizeof(struct an_ltv_genconfig); sc->an_config.an_type = AN_RID_GENCONFIG; if (an_write_record(sc, (struct an_ltv_gen *)&sc->an_config)) { - printf("an%d: failed to set configuration\n", sc->an_unit); + if_printf(ifp, "failed to set configuration\n"); AN_UNLOCK(sc); return; } /* Enable the MAC */ if (an_cmd(sc, AN_CMD_ENABLE, 0)) { - printf("an%d: failed to enable MAC\n", sc->an_unit); + if_printf(ifp, "failed to enable MAC\n"); AN_UNLOCK(sc); return; } @@ -2827,7 +2825,7 @@ an_start(struct ifnet *ifp) sc->an_rdata.an_tx_ring[idx] = id; if (an_cmd(sc, AN_CMD_TX, id)) - printf("an%d: xmit failed\n", sc->an_unit); + if_printf(ifp, "xmit failed\n"); AN_INC(idx, AN_TX_RING_CNT); @@ -2976,7 +2974,7 @@ an_watchdog(struct ifnet *ifp) return; } - printf("an%d: device timeout\n", sc->an_unit); + if_printf(ifp, "device timeout\n"); an_reset(sc); if (sc->mpi350) @@ -3127,7 +3125,7 @@ an_cache_store(struct an_softc *sc, struct ether_header *eh, struct mbuf *m, } #ifdef SIGDEBUG - printf("an: q value %x (MSB=0x%x, LSB=0x%x) \n", + if_printf(sc->an_ifp, "q value %x (MSB=0x%x, LSB=0x%x) \n", rx_rssi & 0xffff, rx_rssi >> 8, rx_rssi & 0xff); #endif @@ -3567,8 +3565,7 @@ cmdreset(struct ifnet *ifp) an_cmd(sc, AN_CMD_DISABLE, 0); if (!(status = WaitBusy(ifp, AN_TIMEOUT))) { - printf("an%d: Waitbusy hang b4 RESET =%d\n", - sc->an_unit, status); + if_printf(ifp, "Waitbusy hang b4 RESET =%d\n", status); AN_UNLOCK(sc); return -EBUSY; } @@ -3578,8 +3575,7 @@ cmdreset(struct ifnet *ifp) if (!(status = WaitBusy(ifp, 100))) { - printf("an%d: Waitbusy hang AFTER RESET =%d\n", - sc->an_unit, status); + if_printf(ifp, "Waitbusy hang AFTER RESET =%d\n", status); AN_UNLOCK(sc); return -EBUSY; } @@ -3687,8 +3683,7 @@ flashpchar(struct ifnet *ifp, int byte, int dwelltime) /* timeout for busy clear wait */ if (waittime <= 0) { - printf("an%d: flash putchar busywait timeout! \n", - sc->an_unit); + if_printf(ifp, "flash putchar busywait timeout!\n"); return -1; } /* @@ -3774,8 +3769,7 @@ flashcard(struct ifnet *ifp, struct aironet_ioctl *l_ioctl) sc = ifp->if_softc; if (sc->mpi350) { - printf("an%d: flashing not supported on MPI 350 yet\n", - sc->an_unit); + if_printf(ifp, "flashing not supported on MPI 350 yet\n"); return(-1); } status = l_ioctl->command; @@ -3820,7 +3814,7 @@ flashcard(struct ifnet *ifp, struct aironet_ioctl *l_ioctl) break; case AIROFLPUTBUF: /* Send 32k to card */ if (l_ioctl->len > FLASH_SIZE) { - printf("an%d: Buffer to big, %x %x\n", sc->an_unit, + if_printf(ifp, "Buffer to big, %x %x\n", l_ioctl->len, FLASH_SIZE); return -EINVAL; } @@ -3837,8 +3831,7 @@ flashcard(struct ifnet *ifp, struct aironet_ioctl *l_ioctl) break; case AIRORESTART: if ((status = flashrestart(ifp)) != 0) { - printf("an%d: FLASHRESTART returned %d\n", - sc->an_unit, status); + if_printf(ifp, "FLASHRESTART returned %d\n", status); return -EIO; } else return 0; |