aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/wpi
diff options
context:
space:
mode:
authorAdrian Chadd <adrian@FreeBSD.org>2015-10-11 01:31:18 +0000
committerAdrian Chadd <adrian@FreeBSD.org>2015-10-11 01:31:18 +0000
commit525a3d47d855ee04056fbc7406631fbb14267493 (patch)
tree784d473e9511ce783ac4141d5a4f339be598cb30 /sys/dev/wpi
parente56bad4a94aff7e3e43200568b211de872a52aea (diff)
downloadsrc-525a3d47d855ee04056fbc7406631fbb14267493.tar.gz
src-525a3d47d855ee04056fbc7406631fbb14267493.zip
wpi(4): use more correct types.
This change fixes some amount of -Wsign-conversion and -Wconversion warnings and sets correct sizes for some variables (as a result, some loop counters were touched too). Submitted by: <s3erios@gmail.com> Differential Revision: https://reviews.freebsd.org/D3763
Notes
Notes: svn path=/head/; revision=289124
Diffstat (limited to 'sys/dev/wpi')
-rw-r--r--sys/dev/wpi/if_wpi.c104
-rw-r--r--sys/dev/wpi/if_wpireg.h2
-rw-r--r--sys/dev/wpi/if_wpivar.h16
3 files changed, 67 insertions, 55 deletions
diff --git a/sys/dev/wpi/if_wpi.c b/sys/dev/wpi/if_wpi.c
index a36c2ed404e2..dacee7d6056a 100644
--- a/sys/dev/wpi/if_wpi.c
+++ b/sys/dev/wpi/if_wpi.c
@@ -156,7 +156,7 @@ static void wpi_update_rx_ring_ps(struct wpi_softc *);
static void wpi_reset_rx_ring(struct wpi_softc *);
static void wpi_free_rx_ring(struct wpi_softc *);
static int wpi_alloc_tx_ring(struct wpi_softc *, struct wpi_tx_ring *,
- int);
+ uint8_t);
static void wpi_update_tx_ring(struct wpi_softc *, struct wpi_tx_ring *);
static void wpi_update_tx_ring_ps(struct wpi_softc *,
struct wpi_tx_ring *);
@@ -165,15 +165,14 @@ static void wpi_free_tx_ring(struct wpi_softc *, struct wpi_tx_ring *);
static int wpi_read_eeprom(struct wpi_softc *,
uint8_t macaddr[IEEE80211_ADDR_LEN]);
static uint32_t wpi_eeprom_channel_flags(struct wpi_eeprom_chan *);
-static void wpi_read_eeprom_band(struct wpi_softc *, int);
-static int wpi_read_eeprom_channels(struct wpi_softc *, int);
+static void wpi_read_eeprom_band(struct wpi_softc *, uint8_t);
+static int wpi_read_eeprom_channels(struct wpi_softc *, uint8_t);
static struct wpi_eeprom_chan *wpi_find_eeprom_channel(struct wpi_softc *,
struct ieee80211_channel *);
static int wpi_setregdomain(struct ieee80211com *,
struct ieee80211_regdomain *, int,
struct ieee80211_channel[]);
-static int wpi_read_eeprom_group(struct wpi_softc *, int);
-static int wpi_add_node_entry_adhoc(struct wpi_softc *);
+static int wpi_read_eeprom_group(struct wpi_softc *, uint8_t);
static struct ieee80211_node *wpi_node_alloc(struct ieee80211vap *,
const uint8_t mac[IEEE80211_ADDR_LEN]);
static void wpi_node_free(struct ieee80211_node *);
@@ -210,7 +209,8 @@ static void wpi_watchdog_rfkill(void *);
static void wpi_scan_timeout(void *);
static void wpi_tx_timeout(void *);
static void wpi_parent(struct ieee80211com *);
-static int wpi_cmd(struct wpi_softc *, int, const void *, size_t, int);
+static int wpi_cmd(struct wpi_softc *, uint8_t, const void *, uint16_t,
+ int);
static int wpi_mrr_setup(struct wpi_softc *);
static int wpi_add_node(struct wpi_softc *, struct ieee80211_node *);
static int wpi_add_broadcast_node(struct wpi_softc *, int);
@@ -257,7 +257,8 @@ static int wpi_key_set(struct ieee80211vap *,
static int wpi_key_delete(struct ieee80211vap *,
const struct ieee80211_key *);
static int wpi_post_alive(struct wpi_softc *);
-static int wpi_load_bootcode(struct wpi_softc *, const uint8_t *, int);
+static int wpi_load_bootcode(struct wpi_softc *, const uint8_t *,
+ uint32_t);
static int wpi_load_firmware(struct wpi_softc *);
static int wpi_read_firmware(struct wpi_softc *);
static void wpi_unload_firmware(struct wpi_softc *);
@@ -327,7 +328,8 @@ wpi_attach(device_t dev)
{
struct wpi_softc *sc = (struct wpi_softc *)device_get_softc(dev);
struct ieee80211com *ic;
- int i, error, rid;
+ uint8_t i;
+ int error, rid;
#ifdef WPI_DEBUG
int supportsa = 1;
const struct wpi_ident *ident;
@@ -387,10 +389,11 @@ wpi_attach(device_t dev)
sc->sc_st = rman_get_bustag(sc->mem);
sc->sc_sh = rman_get_bushandle(sc->mem);
- i = 1;
- rid = 0;
- if (pci_alloc_msi(dev, &i) == 0)
+ rid = 1;
+ if (pci_alloc_msi(dev, &rid) == 0)
rid = 1;
+ else
+ rid = 0;
/* Install interrupt handler. */
sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE |
(rid != 0 ? 0 : RF_SHAREABLE));
@@ -677,7 +680,7 @@ wpi_detach(device_t dev)
{
struct wpi_softc *sc = device_get_softc(dev);
struct ieee80211com *ic = &sc->sc_ic;
- int qid;
+ uint8_t qid;
DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_BEGIN, __func__);
@@ -828,9 +831,9 @@ wpi_prph_clrbits(struct wpi_softc *sc, uint32_t addr, uint32_t mask)
static __inline void
wpi_prph_write_region_4(struct wpi_softc *sc, uint32_t addr,
- const uint32_t *data, int count)
+ const uint32_t *data, uint32_t count)
{
- for (; count > 0; count--, data++, addr += 4)
+ for (; count != 0; count--, data++, addr += 4)
wpi_prph_write(sc, addr, *data);
}
@@ -1152,7 +1155,7 @@ wpi_free_rx_ring(struct wpi_softc *sc)
}
static int
-wpi_alloc_tx_ring(struct wpi_softc *sc, struct wpi_tx_ring *ring, int qid)
+wpi_alloc_tx_ring(struct wpi_softc *sc, struct wpi_tx_ring *ring, uint8_t qid)
{
bus_addr_t paddr;
bus_size_t size;
@@ -1332,7 +1335,8 @@ wpi_read_eeprom(struct wpi_softc *sc, uint8_t macaddr[IEEE80211_ADDR_LEN])
if ((error = res) != 0) \
goto fail; \
} while (0)
- int error, i;
+ uint8_t i;
+ int error;
DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_BEGIN, __func__);
@@ -1416,14 +1420,14 @@ wpi_eeprom_channel_flags(struct wpi_eeprom_chan *channel)
}
static void
-wpi_read_eeprom_band(struct wpi_softc *sc, int n)
+wpi_read_eeprom_band(struct wpi_softc *sc, uint8_t n)
{
struct ieee80211com *ic = &sc->sc_ic;
struct wpi_eeprom_chan *channels = sc->eeprom_channels[n];
const struct wpi_chan_band *band = &wpi_bands[n];
struct ieee80211_channel *c;
- uint8_t chan;
- int i, nflags;
+ uint32_t nflags;
+ uint8_t chan, i;
for (i = 0; i < band->nchan; i++) {
if (!(channels[i].flags & WPI_EEPROM_CHAN_VALID)) {
@@ -1473,7 +1477,7 @@ wpi_read_eeprom_band(struct wpi_softc *sc, int n)
* band and update net80211 with what we find.
*/
static int
-wpi_read_eeprom_channels(struct wpi_softc *sc, int n)
+wpi_read_eeprom_channels(struct wpi_softc *sc, uint8_t n)
{
struct ieee80211com *ic = &sc->sc_ic;
const struct wpi_chan_band *band = &wpi_bands[n];
@@ -1537,7 +1541,7 @@ wpi_setregdomain(struct ieee80211com *ic, struct ieee80211_regdomain *rd,
}
static int
-wpi_read_eeprom_group(struct wpi_softc *sc, int n)
+wpi_read_eeprom_group(struct wpi_softc *sc, uint8_t n)
{
struct wpi_power_group *group = &sc->groups[n];
struct wpi_eeprom_group rgroup;
@@ -1575,10 +1579,10 @@ wpi_read_eeprom_group(struct wpi_softc *sc, int n)
return 0;
}
-static int
+static __inline uint8_t
wpi_add_node_entry_adhoc(struct wpi_softc *sc)
{
- int newid = WPI_ID_IBSS_MIN;
+ uint8_t newid = WPI_ID_IBSS_MIN;
for (; newid <= WPI_ID_IBSS_MAX; newid++) {
if ((sc->nodesmsk & (1 << newid)) == 0) {
@@ -1590,7 +1594,7 @@ wpi_add_node_entry_adhoc(struct wpi_softc *sc)
return WPI_ID_UNDEFINED;
}
-static __inline int
+static __inline uint8_t
wpi_add_node_entry_sta(struct wpi_softc *sc)
{
sc->nodesmsk |= 1 << WPI_ID_BSS;
@@ -2585,7 +2589,9 @@ wpi_cmd2(struct wpi_softc *sc, struct wpi_buf *buf)
struct wpi_tx_ring *ring;
struct mbuf *m1;
bus_dma_segment_t *seg, segs[WPI_MAX_SCATTER];
- int error, i, hdrlen, nsegs, totlen, pad;
+ uint8_t pad;
+ uint16_t hdrlen;
+ int error, i, nsegs, totlen;
WPI_TXQ_LOCK(sc);
@@ -2730,9 +2736,9 @@ wpi_tx_data(struct wpi_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
struct wpi_buf tx_data;
struct wpi_cmd_data *tx = (struct wpi_cmd_data *)&tx_data.data;
uint32_t flags;
- uint16_t qos;
- uint8_t tid, type;
- int ac, error, swcrypt, rate, ismcast, totlen;
+ uint16_t ac, qos;
+ uint8_t tid, type, rate;
+ int error, swcrypt, ismcast, totlen;
wh = mtod(m, struct ieee80211_frame *);
type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK;
@@ -2896,8 +2902,8 @@ wpi_tx_data_raw(struct wpi_softc *sc, struct mbuf *m,
struct wpi_buf tx_data;
struct wpi_cmd_data *tx = (struct wpi_cmd_data *)&tx_data.data;
uint32_t flags;
- uint8_t type;
- int ac, rate, swcrypt, totlen;
+ uint8_t ac, type, rate;
+ int swcrypt, totlen;
wh = mtod(m, struct ieee80211_frame *);
type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK;
@@ -2991,7 +2997,7 @@ wpi_tx_data_raw(struct wpi_softc *sc, struct mbuf *m,
}
static __inline int
-wpi_tx_ring_is_full(struct wpi_softc *sc, int ac)
+wpi_tx_ring_is_full(struct wpi_softc *sc, uint16_t ac)
{
struct wpi_tx_ring *ring = &sc->txq[ac];
int retval;
@@ -3017,7 +3023,8 @@ wpi_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
{
struct ieee80211com *ic = ni->ni_ic;
struct wpi_softc *sc = ic->ic_softc;
- int ac, error = 0;
+ uint16_t ac;
+ int error = 0;
DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_BEGIN, __func__);
@@ -3064,7 +3071,8 @@ wpi_transmit(struct ieee80211com *ic, struct mbuf *m)
{
struct wpi_softc *sc = ic->ic_softc;
struct ieee80211_node *ni;
- int ac, error;
+ uint16_t ac;
+ int error;
WPI_TX_LOCK(sc);
DPRINTF(sc, WPI_DEBUG_XMIT, "%s: called\n", __func__);
@@ -3154,7 +3162,7 @@ wpi_parent(struct ieee80211com *ic)
* Send a command to the firmware.
*/
static int
-wpi_cmd(struct wpi_softc *sc, int code, const void *buf, size_t size,
+wpi_cmd(struct wpi_softc *sc, uint8_t code, const void *buf, uint16_t size,
int async)
{
struct wpi_tx_ring *ring = &sc->txq[WPI_CMD_QUEUE_NUM];
@@ -3163,7 +3171,8 @@ wpi_cmd(struct wpi_softc *sc, int code, const void *buf, size_t size,
struct wpi_tx_cmd *cmd;
struct mbuf *m;
bus_addr_t paddr;
- int totlen, error;
+ uint16_t totlen;
+ int error;
WPI_TXQ_LOCK(sc);
@@ -3182,7 +3191,7 @@ wpi_cmd(struct wpi_softc *sc, int code, const void *buf, size_t size,
if (async == 0)
WPI_LOCK_ASSERT(sc);
- DPRINTF(sc, WPI_DEBUG_CMD, "%s: cmd %s size %zu async %d\n",
+ DPRINTF(sc, WPI_DEBUG_CMD, "%s: cmd %s size %u async %d\n",
__func__, wpi_cmd_str(code), size, async);
desc = &ring->desc[ring->cur];
@@ -3258,7 +3267,8 @@ wpi_mrr_setup(struct wpi_softc *sc)
{
struct ieee80211com *ic = &sc->sc_ic;
struct wpi_mrr_setup mrr;
- int i, error;
+ uint8_t i;
+ int error;
/* CCK rates (not used with 802.11a). */
for (i = WPI_RIDX_CCK1; i <= WPI_RIDX_CCK11; i++) {
@@ -3715,8 +3725,8 @@ wpi_set_pslevel(struct wpi_softc *sc, uint8_t dtim, int level, int async)
{
struct wpi_pmgt_cmd cmd;
const struct wpi_pmgt *pmgt;
- uint32_t max, skip_dtim;
- uint32_t reg;
+ uint32_t max, reg;
+ uint8_t skip_dtim;
int i;
DPRINTF(sc, WPI_DEBUG_PWRSAVE,
@@ -3951,7 +3961,7 @@ wpi_limit_dwell(struct wpi_softc *sc, uint16_t dwell_time)
{
struct ieee80211com *ic = &sc->sc_ic;
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
- int bintval = 0;
+ uint16_t bintval = 0;
/* bintval is in TU (1.024mS) */
if (vap != NULL)
@@ -4015,9 +4025,9 @@ wpi_scan(struct wpi_softc *sc, struct ieee80211_channel *c)
struct wpi_scan_chan *chan;
struct ieee80211_frame *wh;
struct ieee80211_rateset *rs;
- uint16_t dwell_active, dwell_passive;
- uint8_t *buf, *frm;
- int bgscan, bintval, buflen, error, i, nssid;
+ uint16_t bintval, buflen, dwell_active, dwell_passive;
+ uint8_t *buf, *frm, i, nssid;
+ int bgscan, error;
DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_BEGIN, __func__);
@@ -4809,7 +4819,7 @@ wpi_post_alive(struct wpi_softc *sc)
* the NIC internal memory (no DMA transfer).
*/
static int
-wpi_load_bootcode(struct wpi_softc *sc, const uint8_t *ucode, int size)
+wpi_load_bootcode(struct wpi_softc *sc, const uint8_t *ucode, uint32_t size)
{
int error, ntries;
@@ -5159,7 +5169,8 @@ wpi_nic_config(struct wpi_softc *sc)
static int
wpi_hw_init(struct wpi_softc *sc)
{
- int chnl, ntries, error;
+ uint8_t chnl;
+ int ntries, error;
DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_BEGIN, __func__);
@@ -5274,7 +5285,8 @@ wpi_hw_init(struct wpi_softc *sc)
static void
wpi_hw_stop(struct wpi_softc *sc)
{
- int chnl, qid, ntries;
+ uint8_t chnl, qid;
+ int ntries;
DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_DOING, __func__);
diff --git a/sys/dev/wpi/if_wpireg.h b/sys/dev/wpi/if_wpireg.h
index b0aa35c992d5..f36dd2512473 100644
--- a/sys/dev/wpi/if_wpireg.h
+++ b/sys/dev/wpi/if_wpireg.h
@@ -978,7 +978,7 @@ static const struct wpi_pmgt {
uint32_t rxtimeout;
uint32_t txtimeout;
uint32_t intval[5];
- int skip_dtim;
+ uint8_t skip_dtim;
} wpi_pmgt[WPI_NDTIMRANGES][WPI_NPOWERLEVELS] = {
/* DTIM <= 10 */
{
diff --git a/sys/dev/wpi/if_wpivar.h b/sys/dev/wpi/if_wpivar.h
index 80195b59d16c..3969b09453c6 100644
--- a/sys/dev/wpi/if_wpivar.h
+++ b/sys/dev/wpi/if_wpivar.h
@@ -72,10 +72,10 @@ struct wpi_tx_ring {
struct wpi_tx_cmd *cmd;
struct wpi_tx_data data[WPI_TX_RING_COUNT];
bus_dma_tag_t data_dmat;
- int qid;
- int queued;
- int cur;
- int update;
+ uint8_t qid;
+ uint8_t cur;
+ int16_t queued;
+ int update:1;
};
struct wpi_rx_data {
@@ -88,7 +88,7 @@ struct wpi_rx_ring {
uint32_t *desc;
struct wpi_rx_data data[WPI_RX_RING_COUNT];
bus_dma_tag_t data_dmat;
- int cur;
+ uint16_t cur;
int update;
};
@@ -116,8 +116,8 @@ struct wpi_buf {
struct ieee80211_node *ni;
struct mbuf *m;
size_t size;
- int code;
- int ac;
+ uint8_t code;
+ uint16_t ac;
};
struct wpi_vap {
@@ -126,7 +126,7 @@ struct wpi_vap {
struct wpi_buf wv_bcbuf;
struct mtx wv_mtx;
- uint32_t wv_gtk;
+ uint8_t wv_gtk;
#define WPI_VAP_KEY(kid) (1 << kid)
int (*wv_newstate)(struct ieee80211vap *,