Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci Reduce wpi(4) diff to OpenBSD circa September 20...
details: https://anonhg.NetBSD.org/src/rev/4cc2026e062d
branches: trunk
changeset: 330330:4cc2026e062d
user: jakllsch <jakllsch%NetBSD.org@localhost>
date: Sat Jul 05 17:18:11 2014 +0000
description:
Reduce wpi(4) diff to OpenBSD circa September 2007; mostly by following KNF.
The only functional changes in this commit are some %d to %u debugging printf
format specifier adjustments so as to match the OpenBSD code.
diffstat:
sys/dev/pci/if_wpi.c | 493 ++++++++++++++++++++++++++------------------------
1 files changed, 254 insertions(+), 239 deletions(-)
diffs (truncated from 1218 to 300 lines):
diff -r 25684b910d26 -r 4cc2026e062d sys/dev/pci/if_wpi.c
--- a/sys/dev/pci/if_wpi.c Sat Jul 05 11:13:13 2014 +0000
+++ b/sys/dev/pci/if_wpi.c Sat Jul 05 17:18:11 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_wpi.c,v 1.60 2014/07/02 00:04:18 jakllsch Exp $ */
+/* $NetBSD: if_wpi.c,v 1.61 2014/07/05 17:18:11 jakllsch Exp $ */
/*-
* Copyright (c) 2006, 2007
@@ -18,7 +18,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wpi.c,v 1.60 2014/07/02 00:04:18 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wpi.c,v 1.61 2014/07/05 17:18:11 jakllsch Exp $");
/*
* Driver for Intel PRO/Wireless 3945ABG 802.11 network adapters.
@@ -56,29 +56,20 @@
#include <net/if_media.h>
#include <net/if_types.h>
-#include <net80211/ieee80211_var.h>
-#include <net80211/ieee80211_amrr.h>
-#include <net80211/ieee80211_radiotap.h>
-
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/in_var.h>
#include <netinet/ip.h>
+#include <net80211/ieee80211_var.h>
+#include <net80211/ieee80211_amrr.h>
+#include <net80211/ieee80211_radiotap.h>
+
#include <dev/firmload.h>
#include <dev/pci/if_wpireg.h>
#include <dev/pci/if_wpivar.h>
-#ifdef WPI_DEBUG
-#define DPRINTF(x) if (wpi_debug > 0) printf x
-#define DPRINTFN(n, x) if (wpi_debug >= (n)) printf x
-int wpi_debug = 1;
-#else
-#define DPRINTF(x)
-#define DPRINTFN(n, x)
-#endif
-
static const char wpi_firmware_name[] = "iwlwifi-3945.ucode";
static once_t wpi_firmware_init;
static kmutex_t wpi_firmware_mutex;
@@ -86,83 +77,92 @@
static uint8_t *wpi_firmware_image;
static size_t wpi_firmware_size;
-static int wpi_match(device_t, cfdata_t, void *);
-static void wpi_attach(device_t, device_t, void *);
-static int wpi_detach(device_t , int);
-static int wpi_dma_contig_alloc(bus_dma_tag_t, struct wpi_dma_info *,
- void **, bus_size_t, bus_size_t, int);
-static void wpi_dma_contig_free(struct wpi_dma_info *);
-static int wpi_alloc_shared(struct wpi_softc *);
-static void wpi_free_shared(struct wpi_softc *);
-static int wpi_alloc_fwmem(struct wpi_softc *);
-static void wpi_free_fwmem(struct wpi_softc *);
-static struct wpi_rbuf *wpi_alloc_rbuf(struct wpi_softc *);
-static void wpi_free_rbuf(struct mbuf *, void *, size_t, void *);
-static int wpi_alloc_rpool(struct wpi_softc *);
-static void wpi_free_rpool(struct wpi_softc *);
-static int wpi_alloc_rx_ring(struct wpi_softc *, struct wpi_rx_ring *);
-static void wpi_reset_rx_ring(struct wpi_softc *, struct wpi_rx_ring *);
-static void wpi_free_rx_ring(struct wpi_softc *, struct wpi_rx_ring *);
-static int wpi_alloc_tx_ring(struct wpi_softc *, struct wpi_tx_ring *, int,
- int);
-static void wpi_reset_tx_ring(struct wpi_softc *, struct wpi_tx_ring *);
-static void wpi_free_tx_ring(struct wpi_softc *, struct wpi_tx_ring *);
-static struct ieee80211_node * wpi_node_alloc(struct ieee80211_node_table *);
-static void wpi_newassoc(struct ieee80211_node *, int);
-static int wpi_media_change(struct ifnet *);
-static int wpi_newstate(struct ieee80211com *, enum ieee80211_state, int);
+static int wpi_match(device_t, cfdata_t, void *);
+static void wpi_attach(device_t, device_t, void *);
+static int wpi_detach(device_t , int);
+static int wpi_dma_contig_alloc(bus_dma_tag_t, struct wpi_dma_info *,
+ void **, bus_size_t, bus_size_t, int);
+static void wpi_dma_contig_free(struct wpi_dma_info *);
+static int wpi_alloc_shared(struct wpi_softc *);
+static void wpi_free_shared(struct wpi_softc *);
+static int wpi_alloc_fwmem(struct wpi_softc *);
+static void wpi_free_fwmem(struct wpi_softc *);
+static struct wpi_rbuf *wpi_alloc_rbuf(struct wpi_softc *);
+static void wpi_free_rbuf(struct mbuf *, void *, size_t, void *);
+static int wpi_alloc_rpool(struct wpi_softc *);
+static void wpi_free_rpool(struct wpi_softc *);
+static int wpi_alloc_rx_ring(struct wpi_softc *, struct wpi_rx_ring *);
+static void wpi_reset_rx_ring(struct wpi_softc *, struct wpi_rx_ring *);
+static void wpi_free_rx_ring(struct wpi_softc *, struct wpi_rx_ring *);
+static int wpi_alloc_tx_ring(struct wpi_softc *, struct wpi_tx_ring *,
+ int, int);
+static void wpi_reset_tx_ring(struct wpi_softc *, struct wpi_tx_ring *);
+static void wpi_free_tx_ring(struct wpi_softc *, struct wpi_tx_ring *);
+static struct ieee80211_node * wpi_node_alloc(struct ieee80211_node_table *);
+static void wpi_newassoc(struct ieee80211_node *, int);
+static int wpi_media_change(struct ifnet *);
+static int wpi_newstate(struct ieee80211com *, enum ieee80211_state, int);
static void wpi_fix_channel(struct ieee80211com *, struct mbuf *);
-static void wpi_mem_lock(struct wpi_softc *);
-static void wpi_mem_unlock(struct wpi_softc *);
-static uint32_t wpi_mem_read(struct wpi_softc *, uint16_t);
-static void wpi_mem_write(struct wpi_softc *, uint16_t, uint32_t);
-static void wpi_mem_write_region_4(struct wpi_softc *, uint16_t,
- const uint32_t *, int);
-static int wpi_read_prom_data(struct wpi_softc *, uint32_t, void *, int);
-static int wpi_load_microcode(struct wpi_softc *, const uint8_t *, int);
-static int wpi_cache_firmware(struct wpi_softc *);
-static void wpi_release_firmware(void);
-static int wpi_load_firmware(struct wpi_softc *);
-static void wpi_calib_timeout(void *);
-static void wpi_iter_func(void *, struct ieee80211_node *);
-static void wpi_power_calibration(struct wpi_softc *, int);
-static void wpi_rx_intr(struct wpi_softc *, struct wpi_rx_desc *,
- struct wpi_rx_data *);
-static void wpi_tx_intr(struct wpi_softc *, struct wpi_rx_desc *);
-static void wpi_cmd_intr(struct wpi_softc *, struct wpi_rx_desc *);
-static void wpi_notif_intr(struct wpi_softc *);
-static int wpi_intr(void *);
-static void wpi_read_eeprom(struct wpi_softc *);
-static void wpi_read_eeprom_channels(struct wpi_softc *, int);
-static void wpi_read_eeprom_group(struct wpi_softc *, int);
-static uint8_t wpi_plcp_signal(int);
-static int wpi_tx_data(struct wpi_softc *, struct mbuf *,
- struct ieee80211_node *, int);
-static void wpi_start(struct ifnet *);
-static void wpi_watchdog(struct ifnet *);
-static int wpi_ioctl(struct ifnet *, u_long, void *);
-static int wpi_cmd(struct wpi_softc *, int, const void *, int, int);
-static int wpi_wme_update(struct ieee80211com *);
-static int wpi_mrr_setup(struct wpi_softc *);
-static void wpi_set_led(struct wpi_softc *, uint8_t, uint8_t, uint8_t);
-static void wpi_enable_tsf(struct wpi_softc *, struct ieee80211_node *);
-static int wpi_set_txpower(struct wpi_softc *,
- struct ieee80211_channel *, int);
-static int wpi_get_power_index(struct wpi_softc *,
- struct wpi_power_group *, struct ieee80211_channel *, int);
-static int wpi_setup_beacon(struct wpi_softc *, struct ieee80211_node *);
-static int wpi_auth(struct wpi_softc *);
-static int wpi_scan(struct wpi_softc *, uint16_t);
-static int wpi_config(struct wpi_softc *);
-static void wpi_stop_master(struct wpi_softc *);
-static int wpi_power_up(struct wpi_softc *);
-static int wpi_reset(struct wpi_softc *);
-static void wpi_hw_config(struct wpi_softc *);
-static int wpi_init(struct ifnet *);
-static void wpi_stop(struct ifnet *, int);
-static bool wpi_resume(device_t, const pmf_qual_t *);
+static void wpi_mem_lock(struct wpi_softc *);
+static void wpi_mem_unlock(struct wpi_softc *);
+static uint32_t wpi_mem_read(struct wpi_softc *, uint16_t);
+static void wpi_mem_write(struct wpi_softc *, uint16_t, uint32_t);
+static void wpi_mem_write_region_4(struct wpi_softc *, uint16_t,
+ const uint32_t *, int);
+static int wpi_read_prom_data(struct wpi_softc *, uint32_t, void *, int);
+static int wpi_load_microcode(struct wpi_softc *, const uint8_t *, int);
+static int wpi_cache_firmware(struct wpi_softc *);
+static void wpi_release_firmware(void);
+static int wpi_load_firmware(struct wpi_softc *);
+static void wpi_calib_timeout(void *);
+static void wpi_iter_func(void *, struct ieee80211_node *);
+static void wpi_power_calibration(struct wpi_softc *, int);
+static void wpi_rx_intr(struct wpi_softc *, struct wpi_rx_desc *,
+ struct wpi_rx_data *);
+static void wpi_tx_intr(struct wpi_softc *, struct wpi_rx_desc *);
+static void wpi_cmd_intr(struct wpi_softc *, struct wpi_rx_desc *);
+static void wpi_notif_intr(struct wpi_softc *);
+static int wpi_intr(void *);
+static void wpi_read_eeprom(struct wpi_softc *);
+static void wpi_read_eeprom_channels(struct wpi_softc *, int);
+static void wpi_read_eeprom_group(struct wpi_softc *, int);
+static uint8_t wpi_plcp_signal(int);
+static int wpi_tx_data(struct wpi_softc *, struct mbuf *,
+ struct ieee80211_node *, int);
+static void wpi_start(struct ifnet *);
+static void wpi_watchdog(struct ifnet *);
+static int wpi_ioctl(struct ifnet *, u_long, void *);
+static int wpi_cmd(struct wpi_softc *, int, const void *, int, int);
+static int wpi_wme_update(struct ieee80211com *);
+static int wpi_mrr_setup(struct wpi_softc *);
+static void wpi_set_led(struct wpi_softc *, uint8_t, uint8_t, uint8_t);
+static void wpi_enable_tsf(struct wpi_softc *, struct ieee80211_node *);
+static int wpi_set_txpower(struct wpi_softc *,
+ struct ieee80211_channel *, int);
+static int wpi_get_power_index(struct wpi_softc *,
+ struct wpi_power_group *, struct ieee80211_channel *, int);
+static int wpi_setup_beacon(struct wpi_softc *, struct ieee80211_node *);
+static int wpi_auth(struct wpi_softc *);
+static int wpi_scan(struct wpi_softc *, uint16_t);
+static int wpi_config(struct wpi_softc *);
+static void wpi_stop_master(struct wpi_softc *);
+static int wpi_power_up(struct wpi_softc *);
+static int wpi_reset(struct wpi_softc *);
+static void wpi_hw_config(struct wpi_softc *);
+static int wpi_init(struct ifnet *);
+static void wpi_stop(struct ifnet *, int);
+static bool wpi_resume(device_t, const pmf_qual_t *);
static int wpi_getrfkill(struct wpi_softc *);
-static void wpi_sysctlattach(struct wpi_softc *);
+static void wpi_sysctlattach(struct wpi_softc *);
+
+#ifdef WPI_DEBUG
+#define DPRINTF(x) do { if (wpi_debug > 0) printf x; } while (0)
+#define DPRINTFN(n, x) do { if (wpi_debug >= (n)) printf x; } while (0)
+int wpi_debug = 1;
+#else
+#define DPRINTF(x)
+#define DPRINTFN(n, x)
+#endif
CFATTACH_DECL_NEW(wpi, sizeof (struct wpi_softc), wpi_match, wpi_attach,
wpi_detach, NULL);
@@ -205,7 +205,7 @@
bus_space_handle_t memh;
pci_intr_handle_t ih;
pcireg_t data;
- int error, ac;
+ int ac, error;
char intrbuf[PCI_INTRSTR_LEN];
RUN_ONCE(&wpi_firmware_init, wpi_attach_once);
@@ -253,7 +253,10 @@
}
aprint_normal_dev(self, "interrupting at %s\n", intrstr);
- if (wpi_reset(sc) != 0) {
+ /*
+ * Put adapter into a known state.
+ */
+ if ((error = wpi_reset(sc)) != 0) {
aprint_error_dev(self, "could not reset adapter\n");
return;
}
@@ -261,8 +264,10 @@
/*
* Allocate DMA memory for firmware transfers.
*/
- if ((error = wpi_alloc_fwmem(sc)) != 0)
+ if ((error = wpi_alloc_fwmem(sc)) != 0) {
+ aprint_error_dev(self, "could not allocate firmware memory\n");
return;
+ }
/*
* Allocate shared page and Tx/Rx rings.
@@ -278,9 +283,11 @@
}
for (ac = 0; ac < 4; ac++) {
- error = wpi_alloc_tx_ring(sc, &sc->txq[ac], WPI_TX_RING_COUNT, ac);
+ error = wpi_alloc_tx_ring(sc, &sc->txq[ac], WPI_TX_RING_COUNT,
+ ac);
if (error != 0) {
- aprint_error_dev(self, "could not allocate Tx ring %d\n", ac);
+ aprint_error_dev(self,
+ "could not allocate Tx ring %d\n", ac);
goto fail3;
}
}
@@ -291,14 +298,15 @@
goto fail3;
}
- if (wpi_alloc_rx_ring(sc, &sc->rxq) != 0) {
+ error = wpi_alloc_rx_ring(sc, &sc->rxq);
+ if (error != 0) {
aprint_error_dev(self, "could not allocate Rx ring\n");
goto fail4;
}
ic->ic_ifp = ifp;
- ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */
- ic->ic_opmode = IEEE80211_M_STA; /* default to BSS mode */
+ ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */
+ ic->ic_opmode = IEEE80211_M_STA; /* default to BSS mode */
ic->ic_state = IEEE80211_S_INIT;
/* set device capabilities */
@@ -369,9 +377,10 @@
return;
-fail4: wpi_free_tx_ring(sc, &sc->cmdq);
-fail3: while (--ac >= 0)
- wpi_free_tx_ring(sc, &sc->txq[ac]);
+ /* free allocated memory if something failed during attachment */
+fail4: wpi_free_tx_ring(sc, &sc->cmdq);
+fail3: while (--ac >= 0)
+ wpi_free_tx_ring(sc, &sc->txq[ac]);
wpi_free_rpool(sc);
fail2: wpi_free_shared(sc);
fail1: wpi_free_fwmem(sc);
Home |
Main Index |
Thread Index |
Old Index