Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7258416c authored by Solomon Peachy's avatar Solomon Peachy Committed by John W. Linville
Browse files

cw1200: Fix up a large pile of sparse warnings



Most of these relate to endianness problems, and are purely cosmetic.

But a couple of them were legit -- listen interval parsing and some of
the rate selection code would malfunction on BE systems.

There's still one cosmetic warning remaining, in the (admittedly) ugly
code in cw1200_spi.c.  It's there because the hardware needs 16-bit SPI
transfers, but many SPI controllers only operate 8 bits at a time.

If there's a cleaner way of handling this, I'm all ears.

Signed-off-by: default avatarSolomon Peachy <pizza@shaftnet.org>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 5d9e3bc2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -267,7 +267,7 @@ struct cw1200_common {
	struct delayed_work	bss_loss_work;
	spinlock_t		bss_loss_lock; /* Protect BSS loss state */
	int                     bss_loss_state;
	int                     bss_loss_confirm_id;
	u32                     bss_loss_confirm_id;
	int			delayed_link_loss;
	struct work_struct	bss_params_work;

+20 −12
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ static int cw1200_spi_memcpy_fromio(struct hwbus_priv *self,
				     void *dst, int count)
{
	int ret, i;
	uint16_t regaddr;
	u16 regaddr;
	struct spi_message      m;

	struct spi_transfer     t_addr = {
@@ -76,15 +76,18 @@ static int cw1200_spi_memcpy_fromio(struct hwbus_priv *self,
	regaddr = (SDIO_TO_SPI_ADDR(addr))<<12;
	regaddr |= SET_READ;
	regaddr |= (count>>1);
	regaddr = cpu_to_le16(regaddr);

#ifdef SPI_DEBUG
	pr_info("READ : %04d from 0x%02x (%04x)\n", count, addr,
		le16_to_cpu(regaddr));
	pr_info("READ : %04d from 0x%02x (%04x)\n", count, addr, regaddr);
#endif

	/* Header is LE16 */
	regaddr = cpu_to_le16(regaddr);

	/* We have to byteswap if the SPI bus is limited to 8b operation
	   or we are running on a Big Endian system
	*/
#if defined(__LITTLE_ENDIAN)
	/* We have to byteswap if the SPI bus is limited to 8b operation */
	if (self->func->bits_per_word == 8)
#endif
		regaddr = swab16(regaddr);
@@ -104,8 +107,10 @@ static int cw1200_spi_memcpy_fromio(struct hwbus_priv *self,
	printk("\n");
#endif

	/* We have to byteswap if the SPI bus is limited to 8b operation
	   or we are running on a Big Endian system
	*/
#if defined(__LITTLE_ENDIAN)
	/* We have to byteswap if the SPI bus is limited to 8b operation */
	if (self->func->bits_per_word == 8)
#endif
	{
@@ -122,7 +127,7 @@ static int cw1200_spi_memcpy_toio(struct hwbus_priv *self,
				   const void *src, int count)
{
	int rval, i;
	uint16_t regaddr;
	u16 regaddr;
	struct spi_transfer     t_addr = {
		.tx_buf         = &regaddr,
		.len            = sizeof(regaddr),
@@ -136,15 +141,18 @@ static int cw1200_spi_memcpy_toio(struct hwbus_priv *self,
	regaddr = (SDIO_TO_SPI_ADDR(addr))<<12;
	regaddr &= SET_WRITE;
	regaddr |= (count>>1);
	regaddr = cpu_to_le16(regaddr);

#ifdef SPI_DEBUG
	pr_info("WRITE: %04d  to  0x%02x (%04x)\n", count, addr,
		le16_to_cpu(regaddr));
	pr_info("WRITE: %04d  to  0x%02x (%04x)\n", count, addr, regaddr);
#endif

	/* Header is LE16 */
	regaddr = cpu_to_le16(regaddr);

	/* We have to byteswap if the SPI bus is limited to 8b operation
	   or we are running on a Big Endian system
	*/
#if defined(__LITTLE_ENDIAN)
	/* We have to byteswap if the SPI bus is limited to 8b operation */
	if (self->func->bits_per_word == 8)
#endif
	{
+10 −8
Original line number Diff line number Diff line
@@ -69,31 +69,33 @@ static int __cw1200_reg_write(struct cw1200_common *priv, u16 addr,
static inline int __cw1200_reg_read_32(struct cw1200_common *priv,
					u16 addr, u32 *val)
{
	int i = __cw1200_reg_read(priv, addr, val, sizeof(*val), 0);
	*val = le32_to_cpu(*val);
	__le32 tmp;
	int i = __cw1200_reg_read(priv, addr, &tmp, sizeof(tmp), 0);
	*val = le32_to_cpu(tmp);
	return i;
}

static inline int __cw1200_reg_write_32(struct cw1200_common *priv,
					u16 addr, u32 val)
{
	val = cpu_to_le32(val);
	return __cw1200_reg_write(priv, addr, &val, sizeof(val), 0);
	__le32 tmp = cpu_to_le32(val);
	return __cw1200_reg_write(priv, addr, &tmp, sizeof(tmp), 0);
}

static inline int __cw1200_reg_read_16(struct cw1200_common *priv,
					u16 addr, u16 *val)
{
	int i = __cw1200_reg_read(priv, addr, val, sizeof(*val), 0);
	*val = le16_to_cpu(*val);
	__le16 tmp;
	int i = __cw1200_reg_read(priv, addr, &tmp, sizeof(tmp), 0);
	*val = le16_to_cpu(tmp);
	return i;
}

static inline int __cw1200_reg_write_16(struct cw1200_common *priv,
					u16 addr, u16 val)
{
	val = cpu_to_le16(val);
	return __cw1200_reg_write(priv, addr, &val, sizeof(val), 0);
	__le16 tmp = cpu_to_le16(val);
	return __cw1200_reg_write(priv, addr, &tmp, sizeof(tmp), 0);
}

int cw1200_reg_read(struct cw1200_common *priv, u16 addr, void *buf,
+16 −15
Original line number Diff line number Diff line
@@ -169,35 +169,34 @@ int cw1200_reg_write(struct cw1200_common *priv, u16 addr,
static inline int cw1200_reg_read_16(struct cw1200_common *priv,
				     u16 addr, u16 *val)
{
	u32 tmp;
	__le32 tmp;
	int i;
	i = cw1200_reg_read(priv, addr, &tmp, sizeof(tmp));
	tmp = le32_to_cpu(tmp);
	*val = tmp & 0xffff;
	*val = le32_to_cpu(tmp) & 0xfffff;
	return i;
}

static inline int cw1200_reg_write_16(struct cw1200_common *priv,
				      u16 addr, u16 val)
{
	u32 tmp = val;
	tmp = cpu_to_le32(tmp);
	__le32 tmp = cpu_to_le32((u32)val);
	return cw1200_reg_write(priv, addr, &tmp, sizeof(tmp));
}

static inline int cw1200_reg_read_32(struct cw1200_common *priv,
				     u16 addr, u32 *val)
{
	int i = cw1200_reg_read(priv, addr, val, sizeof(*val));
	*val = le32_to_cpu(*val);
	__le32 tmp;
	int i = cw1200_reg_read(priv, addr, &tmp, sizeof(tmp));
	*val = le32_to_cpu(tmp);
	return i;
}

static inline int cw1200_reg_write_32(struct cw1200_common *priv,
				      u16 addr, u32 val)
{
	val = cpu_to_le32(val);
	return cw1200_reg_write(priv, addr, &val, sizeof(val));
	__le32 tmp = cpu_to_le32(val);
	return cw1200_reg_write(priv, addr, &tmp, sizeof(val));
}

int cw1200_indirect_read(struct cw1200_common *priv, u32 addr, void *buf,
@@ -224,22 +223,24 @@ static inline int cw1200_ahb_read(struct cw1200_common *priv, u32 addr,
static inline int cw1200_apb_read_32(struct cw1200_common *priv,
				     u32 addr, u32 *val)
{
	int i = cw1200_apb_read(priv, addr, val, sizeof(*val));
	*val = le32_to_cpu(*val);
	__le32 tmp;
	int i = cw1200_apb_read(priv, addr, &tmp, sizeof(tmp));
	*val = le32_to_cpu(tmp);
	return i;
}

static inline int cw1200_apb_write_32(struct cw1200_common *priv,
				      u32 addr, u32 val)
{
	val = cpu_to_le32(val);
	return cw1200_apb_write(priv, addr, &val, sizeof(val));
	__le32 tmp = cpu_to_le32(val);
	return cw1200_apb_write(priv, addr, &tmp, sizeof(val));
}
static inline int cw1200_ahb_read_32(struct cw1200_common *priv,
				     u32 addr, u32 *val)
{
	int i = cw1200_ahb_read(priv, addr, val, sizeof(*val));
	*val = le32_to_cpu(*val);
	__le32 tmp;
	int i = cw1200_ahb_read(priv, addr, &tmp, sizeof(tmp));
	*val = le32_to_cpu(tmp);
	return i;
}

+2 −2
Original line number Diff line number Diff line
@@ -238,8 +238,8 @@ static const struct ieee80211_ops cw1200_ops = {
	/*.cancel_remain_on_channel = cw1200_cancel_remain_on_channel,	*/
};

int cw1200_ba_rx_tids = -1;
int cw1200_ba_tx_tids = -1;
static int cw1200_ba_rx_tids = -1;
static int cw1200_ba_tx_tids = -1;
module_param(cw1200_ba_rx_tids, int, 0644);
module_param(cw1200_ba_tx_tids, int, 0644);
MODULE_PARM_DESC(cw1200_ba_rx_tids, "Block ACK RX TIDs");
Loading