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

Commit 628f10ba authored by Stanislav Fomichev's avatar Stanislav Fomichev Committed by Greg Kroah-Hartman
Browse files

staging: brcm80211: replace broadcom specific byte swapping routines



HTON16/hton16 -> cpu_to_be16 (htons for networking code)
HTON32/hton32 -> cpu_to_be32 (htonl for networking code)
NTOH16/ntoh32 -> be16_to_cpu (ntohs for networking code)
NTOH32/ntoh32 -> be32_to_cpu (ntohl for networking code)
LTOH16/ltoh16 -> le16_to_cpu
LTOH32/ltoh32 -> le32_to_cpu
HTOL16/htol16 -> cpu_to_le16
HTOL32/htol32 -> cpu_to_le32

Signed-off-by: default avatarStanislav Fomichev <kernel@fomichev.me>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 1005f085
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -735,7 +735,7 @@ static int sdioh_sdmmc_get_cisaddr(sdioh_info_t *sd, u32 regaddr)
	}

	/* Only the lower 17-bits are valid */
	scratch = ltoh32(scratch);
	scratch = le32_to_cpu(scratch);
	scratch &= 0x0001FFFF;
	return scratch;
}
+15 −15
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ typedef struct dhd_prot {
static int dhdcdc_msg(dhd_pub_t *dhd)
{
	dhd_prot_t *prot = dhd->prot;
	int len = ltoh32(prot->msg.len) + sizeof(cdc_ioctl_t);
	int len = le32_to_cpu(prot->msg.len) + sizeof(cdc_ioctl_t);

	DHD_TRACE(("%s: Enter\n", __func__));

@@ -93,7 +93,7 @@ static int dhdcdc_cmplt(dhd_pub_t *dhd, u32 id, u32 len)
				  len + sizeof(cdc_ioctl_t));
		if (ret < 0)
			break;
	} while (CDC_IOC_ID(ltoh32(prot->msg.flags)) != id);
	} while (CDC_IOC_ID(le32_to_cpu(prot->msg.flags)) != id);

	return ret;
}
@@ -124,11 +124,11 @@ dhdcdc_query_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf, uint len)

	memset(msg, 0, sizeof(cdc_ioctl_t));

	msg->cmd = htol32(cmd);
	msg->len = htol32(len);
	msg->cmd = cpu_to_le32(cmd);
	msg->len = cpu_to_le32(len);
	msg->flags = (++prot->reqid << CDCF_IOC_ID_SHIFT);
	CDC_SET_IF_IDX(msg, ifidx);
	msg->flags = htol32(msg->flags);
	msg->flags = cpu_to_le32(msg->flags);

	if (buf)
		memcpy(prot->buf, buf, len);
@@ -146,7 +146,7 @@ dhdcdc_query_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf, uint len)
	if (ret < 0)
		goto done;

	flags = ltoh32(msg->flags);
	flags = le32_to_cpu(msg->flags);
	id = (flags & CDCF_IOC_ID_MASK) >> CDCF_IOC_ID_SHIFT;

	if ((id < prot->reqid) && (++retries < RETRIES))
@@ -170,7 +170,7 @@ dhdcdc_query_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf, uint len)

	/* Check the ERROR flag */
	if (flags & CDCF_IOC_ERROR) {
		ret = ltoh32(msg->status);
		ret = le32_to_cpu(msg->status);
		/* Cache error from dongle */
		dhd->dongle_error = ret;
	}
@@ -191,11 +191,11 @@ int dhdcdc_set_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf, uint len)

	memset(msg, 0, sizeof(cdc_ioctl_t));

	msg->cmd = htol32(cmd);
	msg->len = htol32(len);
	msg->cmd = cpu_to_le32(cmd);
	msg->len = cpu_to_le32(len);
	msg->flags = (++prot->reqid << CDCF_IOC_ID_SHIFT) | CDCF_IOC_SET;
	CDC_SET_IF_IDX(msg, ifidx);
	msg->flags = htol32(msg->flags);
	msg->flags = cpu_to_le32(msg->flags);

	if (buf)
		memcpy(prot->buf, buf, len);
@@ -208,7 +208,7 @@ int dhdcdc_set_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf, uint len)
	if (ret < 0)
		goto done;

	flags = ltoh32(msg->flags);
	flags = le32_to_cpu(msg->flags);
	id = (flags & CDCF_IOC_ID_MASK) >> CDCF_IOC_ID_SHIFT;

	if (id != prot->reqid) {
@@ -220,7 +220,7 @@ int dhdcdc_set_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf, uint len)

	/* Check the ERROR flag */
	if (flags & CDCF_IOC_ERROR) {
		ret = ltoh32(msg->status);
		ret = le32_to_cpu(msg->status);
		/* Cache error from dongle */
		dhd->dongle_error = ret;
	}
@@ -276,8 +276,8 @@ dhd_prot_ioctl(dhd_pub_t *dhd, int ifidx, wl_ioctl_t *ioc, void *buf, int len)
		ret = 0;
	else {
		cdc_ioctl_t *msg = &prot->msg;
		ioc->needed = ltoh32(msg->len);	/* len == needed when set/query
						 fails from dongle */
		/* len == needed when set/query fails from dongle */
		ioc->needed = le32_to_cpu(msg->len);
	}

	/* Intercept the wme_dp ioctl here */
@@ -287,7 +287,7 @@ dhd_prot_ioctl(dhd_pub_t *dhd, int ifidx, wl_ioctl_t *ioc, void *buf, int len)
		slen = strlen("wme_dp") + 1;
		if (len >= (int)(slen + sizeof(int)))
			memcpy(&val, (char *)buf + slen, sizeof(int));
		dhd->wme_dp = (u8) ltoh32(val);
		dhd->wme_dp = (u8) le32_to_cpu(val);
	}

	prot->pending = false;
+16 −16
Original line number Diff line number Diff line
@@ -577,12 +577,12 @@ static void wl_show_host_event(wl_event_msg_t *event, void *event_data)
		WLC_E_PFN_SCAN_COMPLETE, "SCAN_COMPLETE"}
	};
	uint event_type, flags, auth_type, datalen;
	event_type = ntoh32(event->event_type);
	flags = ntoh16(event->flags);
	status = ntoh32(event->status);
	reason = ntoh32(event->reason);
	auth_type = ntoh32(event->auth_type);
	datalen = ntoh32(event->datalen);
	event_type = be32_to_cpu(event->event_type);
	flags = be16_to_cpu(event->flags);
	status = be32_to_cpu(event->status);
	reason = be32_to_cpu(event->reason);
	auth_type = be32_to_cpu(event->auth_type);
	datalen = be32_to_cpu(event->datalen);
	/* debug dump of event messages */
	sprintf(eabuf, "%pM", event->addr);

@@ -750,24 +750,24 @@ static void wl_show_host_event(wl_event_msg_t *event, void *event_data)
			}

			/* There are 2 bytes available at the end of data */
			buf[MSGTRACE_HDRLEN + ntoh16(hdr.len)] = '\0';
			buf[MSGTRACE_HDRLEN + be16_to_cpu(hdr.len)] = '\0';

			if (ntoh32(hdr.discarded_bytes)
			    || ntoh32(hdr.discarded_printf)) {
			if (be32_to_cpu(hdr.discarded_bytes)
			    || be32_to_cpu(hdr.discarded_printf)) {
				DHD_ERROR(
				    ("\nWLC_E_TRACE: [Discarded traces in dongle -->"
				     "discarded_bytes %d discarded_printf %d]\n",
				     ntoh32(hdr.discarded_bytes),
				     ntoh32(hdr.discarded_printf)));
				     be32_to_cpu(hdr.discarded_bytes),
				     be32_to_cpu(hdr.discarded_printf)));
			}

			nblost = ntoh32(hdr.seqnum) - seqnum_prev - 1;
			nblost = be32_to_cpu(hdr.seqnum) - seqnum_prev - 1;
			if (nblost > 0) {
				DHD_ERROR(
				    ("\nWLC_E_TRACE: [Event lost --> seqnum %d nblost %d\n",
				     ntoh32(hdr.seqnum), nblost));
				     be32_to_cpu(hdr.seqnum), nblost));
			}
			seqnum_prev = ntoh32(hdr.seqnum);
			seqnum_prev = be32_to_cpu(hdr.seqnum);

			/* Display the trace buffer. Advance from \n to \n to
			 * avoid display big
@@ -788,7 +788,7 @@ static void wl_show_host_event(wl_event_msg_t *event, void *event_data)

	case WLC_E_RSSI:
		DHD_EVENT(("MACEVENT: %s %d\n", event_name,
			   ntoh32(*((int *)event_data))));
			   be32_to_cpu(*((int *)event_data))));
		break;

	default:
@@ -898,7 +898,7 @@ wl_host_event(struct dhd_info *dhd, int *ifidx, void *pktdata,
			temp = ntoh32_ua((void *)&event->event_type);
			DHD_TRACE(("Converted to WLC_E_LINK type %d\n", temp));

			temp = ntoh32(WLC_E_NDIS_LINK);
			temp = be32_to_cpu(WLC_E_NDIS_LINK);
			memcpy((void *)(&pvt_data->event.event_type), &temp,
			       sizeof(pvt_data->event.event_type));
		}
+11 −9
Original line number Diff line number Diff line
@@ -713,7 +713,7 @@ static void _dhd_set_multicast_list(dhd_info_t *dhd, int ifidx)
	strcpy(bufp, "mcast_list");
	bufp += strlen("mcast_list") + 1;

	cnt = htol32(cnt);
	cnt = cpu_to_le32(cnt);
	memcpy(bufp, &cnt, sizeof(cnt));
	bufp += sizeof(cnt);

@@ -752,7 +752,7 @@ static void _dhd_set_multicast_list(dhd_info_t *dhd, int ifidx)
			   dhd_ifname(&dhd->pub, ifidx)));
		return;
	}
	allmulti = htol32(allmulti);
	allmulti = cpu_to_le32(allmulti);

	if (!bcm_mkiovar
	    ("allmulti", (void *)&allmulti, sizeof(allmulti), buf, buflen)) {
@@ -772,7 +772,8 @@ static void _dhd_set_multicast_list(dhd_info_t *dhd, int ifidx)
	ret = dhd_prot_ioctl(&dhd->pub, ifidx, &ioc, ioc.buf, ioc.len);
	if (ret < 0) {
		DHD_ERROR(("%s: set allmulti %d failed\n",
			   dhd_ifname(&dhd->pub, ifidx), ltoh32(allmulti)));
			   dhd_ifname(&dhd->pub, ifidx),
			   le32_to_cpu(allmulti)));
	}

	kfree(buf);
@@ -781,7 +782,7 @@ static void _dhd_set_multicast_list(dhd_info_t *dhd, int ifidx)
		 driver does */

	allmulti = (dev->flags & IFF_PROMISC) ? true : false;
	allmulti = htol32(allmulti);
	allmulti = cpu_to_le32(allmulti);

	memset(&ioc, 0, sizeof(ioc));
	ioc.cmd = WLC_SET_PROMISC;
@@ -792,7 +793,8 @@ static void _dhd_set_multicast_list(dhd_info_t *dhd, int ifidx)
	ret = dhd_prot_ioctl(&dhd->pub, ifidx, &ioc, ioc.buf, ioc.len);
	if (ret < 0) {
		DHD_ERROR(("%s: set promisc %d failed\n",
			   dhd_ifname(&dhd->pub, ifidx), ltoh32(allmulti)));
			   dhd_ifname(&dhd->pub, ifidx),
			   le32_to_cpu(allmulti)));
	}
}

@@ -1028,7 +1030,7 @@ int dhd_sendpkt(dhd_pub_t *dhdp, int ifidx, struct sk_buff *pktbuf)

		if (is_multicast_ether_addr(eh->h_dest))
			dhdp->tx_multicast++;
		if (ntoh16(eh->h_proto) == ETH_P_PAE)
		if (ntohs(eh->h_proto) == ETH_P_PAE)
			atomic_inc(&dhd->pend_8021x_cnt);
	}

@@ -1208,7 +1210,7 @@ void dhd_rx_frame(dhd_pub_t *dhdp, int ifidx, struct sk_buff *pktbuf,
		skb_pull(skb, ETH_HLEN);

		/* Process special event packets and then discard them */
		if (ntoh16(skb->protocol) == ETH_P_BRCM)
		if (ntohs(skb->protocol) == ETH_P_BRCM)
			dhd_wl_host_event(dhd, &ifidx,
					  skb_mac_header(skb),
					  &event, &data);
@@ -1253,7 +1255,7 @@ void dhd_txcomplete(dhd_pub_t *dhdp, struct sk_buff *txp, bool success)
	dhd_prot_hdrpull(dhdp, &ifidx, txp);

	eh = (struct ethhdr *)(txp->data);
	type = ntoh16(eh->h_proto);
	type = ntohs(eh->h_proto);

	if (type == ETH_P_PAE)
		atomic_dec(&dhd->pend_8021x_cnt);
@@ -2749,7 +2751,7 @@ dhd_wl_host_event(dhd_info_t *dhd, int *ifidx, void *pktdata,
/* send up locally generated event */
void dhd_sendup_event(dhd_pub_t *dhdp, wl_event_msg_t *event, void *data)
{
	switch (ntoh32(event->event_type)) {
	switch (be32_to_cpu(event->event_type)) {
	default:
		break;
	}
+18 −18
Original line number Diff line number Diff line
@@ -966,8 +966,8 @@ static int dhdsdio_txpkt(dhd_bus_t *bus, struct sk_buff *pkt, uint chan,

	/* Hardware tag: 2 byte len followed by 2 byte ~len check (all LE) */
	len = (u16) (pkt->len);
	*(u16 *) frame = htol16(len);
	*(((u16 *) frame) + 1) = htol16(~len);
	*(u16 *) frame = cpu_to_le16(len);
	*(((u16 *) frame) + 1) = cpu_to_le16(~len);

	/* Software tag: channel, sequence number, data offset */
	swheader =
@@ -1281,8 +1281,8 @@ int dhd_bus_txctl(struct dhd_bus *bus, unsigned char *msg, uint msglen)
	dhdsdio_clkctl(bus, CLK_AVAIL, false);

	/* Hardware tag: 2 byte len followed by 2 byte ~len check (all LE) */
	*(u16 *) frame = htol16((u16) msglen);
	*(((u16 *) frame) + 1) = htol16(~msglen);
	*(u16 *) frame = cpu_to_le16((u16) msglen);
	*(((u16 *) frame) + 1) = cpu_to_le16(~msglen);

	/* Software tag: channel, sequence number, data offset */
	swheader =
@@ -1768,7 +1768,7 @@ static int dhdsdio_readshared(dhd_bus_t *bus, sdpcm_shared_t *sh)
	if (rv < 0)
		return rv;

	addr = ltoh32(addr);
	addr = le32_to_cpu(addr);

	DHD_INFO(("sdpcm_shared address 0x%08X\n", addr));

@@ -1789,13 +1789,13 @@ static int dhdsdio_readshared(dhd_bus_t *bus, sdpcm_shared_t *sh)
		return rv;

	/* Endianness */
	sh->flags = ltoh32(sh->flags);
	sh->trap_addr = ltoh32(sh->trap_addr);
	sh->assert_exp_addr = ltoh32(sh->assert_exp_addr);
	sh->assert_file_addr = ltoh32(sh->assert_file_addr);
	sh->assert_line = ltoh32(sh->assert_line);
	sh->console_addr = ltoh32(sh->console_addr);
	sh->msgtrace_addr = ltoh32(sh->msgtrace_addr);
	sh->flags = le32_to_cpu(sh->flags);
	sh->trap_addr = le32_to_cpu(sh->trap_addr);
	sh->assert_exp_addr = le32_to_cpu(sh->assert_exp_addr);
	sh->assert_file_addr = le32_to_cpu(sh->assert_file_addr);
	sh->assert_line = le32_to_cpu(sh->assert_line);
	sh->console_addr = le32_to_cpu(sh->console_addr);
	sh->msgtrace_addr = le32_to_cpu(sh->msgtrace_addr);

	if ((sh->flags & SDPCM_SHARED_VERSION_MASK) != SDPCM_SHARED_VERSION) {
		DHD_ERROR(("%s: sdpcm_shared version %d in dhd "
@@ -2008,13 +2008,13 @@ static int dhdsdio_readconsole(dhd_bus_t *bus)

	/* Allocate console buffer (one time only) */
	if (c->buf == NULL) {
		c->bufsize = ltoh32(c->log.buf_size);
		c->bufsize = le32_to_cpu(c->log.buf_size);
		c->buf = kmalloc(c->bufsize, GFP_ATOMIC);
		if (c->buf == NULL)
			return BCME_NOMEM;
	}

	idx = ltoh32(c->log.idx);
	idx = le32_to_cpu(c->log.idx);

	/* Protect against corrupt value */
	if (idx > c->bufsize)
@@ -2026,7 +2026,7 @@ static int dhdsdio_readconsole(dhd_bus_t *bus)
		return BCME_OK;

	/* Read the console buffer */
	addr = ltoh32(c->log.buf);
	addr = le32_to_cpu(c->log.buf);
	rv = dhdsdio_membytes(bus, false, addr, c->buf, c->bufsize);
	if (rv < 0)
		return rv;
@@ -2589,7 +2589,7 @@ static int dhdsdio_write_vars(dhd_bus_t *bus)
	} else {
		varsizew = varsize / 4;
		varsizew = (~varsizew << 16) | (varsizew & 0x0000FFFF);
		varsizew = htol32(varsizew);
		varsizew = cpu_to_le32(varsizew);
	}

	DHD_INFO(("New varsize is %d, length token=0x%08x\n", varsize,
@@ -4986,7 +4986,7 @@ extern int dhd_bus_console_in(dhd_pub_t *dhdp, unsigned char *msg, uint msglen)

	/* Zero cbuf_index */
	addr = bus->console_addr + offsetof(hndrte_cons_t, cbuf_idx);
	val = htol32(0);
	val = cpu_to_le32(0);
	rv = dhdsdio_membytes(bus, true, addr, (u8 *)&val, sizeof(val));
	if (rv < 0)
		goto done;
@@ -4999,7 +4999,7 @@ extern int dhd_bus_console_in(dhd_pub_t *dhdp, unsigned char *msg, uint msglen)

	/* Write length into vcons_in */
	addr = bus->console_addr + offsetof(hndrte_cons_t, vcons_in);
	val = htol32(msglen);
	val = cpu_to_le32(msglen);
	rv = dhdsdio_membytes(bus, true, addr, (u8 *)&val, sizeof(val));
	if (rv < 0)
		goto done;
Loading