Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 Oct 2015 01:31:18 +0000 (UTC)
From:      Adrian Chadd <adrian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r289124 - head/sys/dev/wpi
Message-ID:  <201510110131.t9B1VI7N023041@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: adrian
Date: Sun Oct 11 01:31:18 2015
New Revision: 289124
URL: https://svnweb.freebsd.org/changeset/base/289124

Log:
  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

Modified:
  head/sys/dev/wpi/if_wpi.c
  head/sys/dev/wpi/if_wpireg.h
  head/sys/dev/wpi/if_wpivar.h

Modified: head/sys/dev/wpi/if_wpi.c
==============================================================================
--- head/sys/dev/wpi/if_wpi.c	Sat Oct 10 23:31:47 2015	(r289123)
+++ head/sys/dev/wpi/if_wpi.c	Sun Oct 11 01:31:18 2015	(r289124)
@@ -156,7 +156,7 @@ static void	wpi_update_rx_ring_ps(struct
 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_
 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 ieee80211v
 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, u
 
 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, ui
 	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_eepr
 }
 
 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 *s
  * 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
 }
 
 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 *
 	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_soft
 	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 wp
 	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
 	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, st
 	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, st
 }
 
 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 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, st
 {
 	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, 
 	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, 
 	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, ui
 {
 	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, ui
 {
 	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 ie
 	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__);
 

Modified: head/sys/dev/wpi/if_wpireg.h
==============================================================================
--- head/sys/dev/wpi/if_wpireg.h	Sat Oct 10 23:31:47 2015	(r289123)
+++ head/sys/dev/wpi/if_wpireg.h	Sun Oct 11 01:31:18 2015	(r289124)
@@ -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 */
 	{

Modified: head/sys/dev/wpi/if_wpivar.h
==============================================================================
--- head/sys/dev/wpi/if_wpivar.h	Sat Oct 10 23:31:47 2015	(r289123)
+++ head/sys/dev/wpi/if_wpivar.h	Sun Oct 11 01:31:18 2015	(r289124)
@@ -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 *,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201510110131.t9B1VI7N023041>