Commit 02211edc authored by Ajay Singh's avatar Ajay Singh Committed by Greg Kroah-Hartman
Browse files

staging: wilc1000: fix endianness warnings reported by sparse

This patch fixes the sparse warnings by making use of le32_to_cpus() &
cpu_to_le32s() conversion API's.
Remove the unnecessary byte-order conversion in
wilc_wlan_parse_response_frame() as the data is copied using individual
byte operation.

Also added the byte-order conversion for 'header' in
wilc_wfi_monitor_rx() & wilc_wfi_p2p_rx() as received in LE byte-order.

The link [1] contains the details of discussion related to this patch.

[1]. https://patchwork.kernel.org/patch/10436791/



Signed-off-by: default avatarAjay Singh <ajay.kathat@microchip.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 41203a45
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ void wilc_wfi_monitor_rx(u8 *buff, u32 size)

	/* Get WILC header */
	memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET);
	le32_to_cpus(&header);
	/*
	 * The packet offset field contain info about what type of management
	 * the frame we are dealing with and ack status
+2 −2
Original line number Diff line number Diff line
@@ -384,7 +384,7 @@ static int sdio_write_reg(struct wilc *wilc, u32 addr, u32 data)
	struct sdio_func *func = dev_to_sdio_func(wilc->dev);
	int ret;

	data = cpu_to_le32(data);
	cpu_to_le32s(&data);

	if (addr >= 0xf0 && addr <= 0xff) {
		struct sdio_cmd52 cmd;
@@ -563,7 +563,7 @@ static int sdio_read_reg(struct wilc *wilc, u32 addr, u32 *data)
		}
	}

	*data = cpu_to_le32(*data);
	le32_to_cpus(*data);

	return 1;

+4 −4
Original line number Diff line number Diff line
@@ -678,7 +678,7 @@ static int spi_internal_write(struct wilc *wilc, u32 adr, u32 dat)
	struct spi_device *spi = to_spi_device(wilc->dev);
	int result;

	dat = cpu_to_le32(dat);
	cpu_to_le32s(&dat);
	result = spi_cmd_complete(wilc, CMD_INTERNAL_WRITE, adr, (u8 *)&dat, 4,
				  0);
	if (result != N_OK)
@@ -699,7 +699,7 @@ static int spi_internal_read(struct wilc *wilc, u32 adr, u32 *data)
		return 0;
	}

	*data = cpu_to_le32(*data);
	le32_to_cpus(*data);

	return 1;
}
@@ -717,7 +717,7 @@ static int wilc_spi_write_reg(struct wilc *wilc, u32 addr, u32 data)
	u8 cmd = CMD_SINGLE_WRITE;
	u8 clockless = 0;

	data = cpu_to_le32(data);
	cpu_to_le32s(&data);
	if (addr < 0x30) {
		/* Clockless register */
		cmd = CMD_INTERNAL_WRITE;
@@ -778,7 +778,7 @@ static int wilc_spi_read_reg(struct wilc *wilc, u32 addr, u32 *data)
		return 0;
	}

	*data = cpu_to_le32(*data);
	le32_to_cpus(*data);

	return 1;
}
+4 −2
Original line number Diff line number Diff line
@@ -1364,9 +1364,10 @@ void wilc_wfi_p2p_rx(struct net_device *dev, u8 *buff, u32 size)
	struct host_if_drv *wfi_drv = priv->hif_drv;
	u32 header, pkt_offset;
	s32 freq;
	__le16 fc;

	memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET);

	le32_to_cpus(&header);
	pkt_offset = GET_PKT_OFFSET(header);

	if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {
@@ -1383,7 +1384,8 @@ void wilc_wfi_p2p_rx(struct net_device *dev, u8 *buff, u32 size)

	freq = ieee80211_channel_to_frequency(curr_channel, NL80211_BAND_2GHZ);

	if (!ieee80211_is_action(buff[FRAME_TYPE_ID])) {
	fc = ((struct ieee80211_hdr *)buff)->frame_control;
	if (!ieee80211_is_action(fc)) {
		cfg80211_rx_mgmt(priv->wdev, freq, 0, buff, size, 0);
		return;
	}
+6 −6
Original line number Diff line number Diff line
@@ -536,7 +536,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count)
			vmm_table[i] = vmm_sz / 4;
			if (tqe->type == WILC_CFG_PKT)
				vmm_table[i] |= BIT(10);
			vmm_table[i] = cpu_to_le32(vmm_table[i]);
			cpu_to_le32s(&vmm_table[i]);

			i++;
			sum += vmm_sz;
@@ -639,7 +639,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count)
		if (vmm_table[i] == 0)
			break;

		vmm_table[i] = cpu_to_le32(vmm_table[i]);
		le32_to_cpus(&vmm_table[i]);
		vmm_sz = (vmm_table[i] & 0x3ff);
		vmm_sz *= 4;
		header = (tqe->type << 31) |
@@ -650,7 +650,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count)
		else
			header &= ~BIT(30);

		header = cpu_to_le32(header);
		cpu_to_le32s(&header);
		memcpy(&txb[offset], &header, 4);
		if (tqe->type == WILC_CFG_PKT) {
			buffer_offset = ETH_CONFIG_PKT_HDR_OFFSET;
@@ -705,7 +705,7 @@ static void wilc_wlan_handle_rx_buff(struct wilc *wilc, u8 *buffer, int size)
	do {
		buff_ptr = buffer + offset;
		memcpy(&header, buff_ptr, 4);
		header = cpu_to_le32(header);
		le32_to_cpus(&header);

		is_cfg_packet = (header >> 31) & 0x1;
		pkt_offset = (header >> 22) & 0x1ff;
@@ -880,8 +880,8 @@ int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer,
	do {
		memcpy(&addr, &buffer[offset], 4);
		memcpy(&size, &buffer[offset + 4], 4);
		addr = cpu_to_le32(addr);
		size = cpu_to_le32(size);
		le32_to_cpus(&addr);
		le32_to_cpus(&size);
		acquire_bus(wilc, ACQUIRE_ONLY);
		offset += 8;
		while (((int)size) && (offset < buffer_size)) {
Loading