Skip to content

Commit

Permalink
wireless: Remove casts to same type
Browse files Browse the repository at this point in the history
Adding casts of objects to the same type is unnecessary
and confusing for a human reader.

For example, this cast:

        int y;
        int *p = (int *)&y;

I used the coccinelle script below to find and remove these
unnecessary casts.  I manually removed the conversions this
script produces of casts with __force, __iomem and __user.

@@
type T;
T *p;
@@

-       (T *)p
+       p

Neatened the mwifiex_deauthenticate_infra function which
was doing odd things with array pointers and not using
is_zero_ether_addr.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Joe Perches authored and David S. Miller committed Jun 6, 2012
1 parent 6469933 commit 2c20889
Show file tree
Hide file tree
Showing 55 changed files with 198 additions and 247 deletions.
3 changes: 1 addition & 2 deletions drivers/net/wireless/adm8211.c
Original file line number Diff line number Diff line change
Expand Up @@ -1738,8 +1738,7 @@ static int adm8211_alloc_rings(struct ieee80211_hw *dev)
return -ENOMEM;
}

priv->tx_ring = (struct adm8211_desc *)(priv->rx_ring +
priv->rx_ring_size);
priv->tx_ring = priv->rx_ring + priv->rx_ring_size;
priv->tx_ring_dma = priv->rx_ring_dma +
sizeof(struct adm8211_desc) * priv->rx_ring_size;

Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/airo.c
Original file line number Diff line number Diff line change
Expand Up @@ -1997,7 +1997,7 @@ static int mpi_send_packet (struct net_device *dev)
* ------------------------------------------------
*/

memcpy((char *)ai->txfids[0].virtual_host_addr,
memcpy(ai->txfids[0].virtual_host_addr,
(char *)&wifictlhdr8023, sizeof(wifictlhdr8023));

payloadLen = (__le16 *)(ai->txfids[0].virtual_host_addr +
Expand Down Expand Up @@ -4212,7 +4212,7 @@ static int PC4500_writerid(struct airo_info *ai, u16 rid,
airo_print_err(ai->dev->name, "%s: len=%d", __func__, len);
rc = -1;
} else {
memcpy((char *)ai->config_desc.virtual_host_addr,
memcpy(ai->config_desc.virtual_host_addr,
pBuf, len);

rc = issuecommand(ai, &cmd, &rsp);
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -3178,7 +3178,7 @@ static int ar9300_compress_decision(struct ath_hw *ah,
mdata_size, length);
return -1;
}
memcpy(mptr, (u8 *) (word + COMP_HDR_LEN), length);
memcpy(mptr, word + COMP_HDR_LEN, length);
ath_dbg(common, EEPROM,
"restored eeprom %d: uncompressed, length %d\n",
it, length);
Expand All @@ -3199,7 +3199,7 @@ static int ar9300_compress_decision(struct ath_hw *ah,
"restore eeprom %d: block, reference %d, length %d\n",
it, reference, length);
ar9300_uncompress_block(ah, mptr, mdata_size,
(u8 *) (word + COMP_HDR_LEN), length);
(word + COMP_HDR_LEN), length);
break;
default:
ath_dbg(common, EEPROM, "unknown compression code %d\n", code);
Expand Down
3 changes: 1 addition & 2 deletions drivers/net/wireless/ath/ath9k/eeprom_4k.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,7 @@ static int ath9k_hw_4k_check_eeprom(struct ath_hw *ah)
{
#define EEPROM_4K_SIZE (sizeof(struct ar5416_eeprom_4k) / sizeof(u16))
struct ath_common *common = ath9k_hw_common(ah);
struct ar5416_eeprom_4k *eep =
(struct ar5416_eeprom_4k *) &ah->eeprom.map4k;
struct ar5416_eeprom_4k *eep = &ah->eeprom.map4k;
u16 *eepdata, temp, magic, magic2;
u32 sum = 0, el;
bool need_swap = false;
Expand Down
3 changes: 1 addition & 2 deletions drivers/net/wireless/ath/ath9k/eeprom_def.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,7 @@ static u32 ath9k_hw_def_dump_eeprom(struct ath_hw *ah, bool dump_base_hdr,

static int ath9k_hw_def_check_eeprom(struct ath_hw *ah)
{
struct ar5416_eeprom_def *eep =
(struct ar5416_eeprom_def *) &ah->eeprom.def;
struct ar5416_eeprom_def *eep = &ah->eeprom.def;
struct ath_common *common = ath9k_hw_common(ah);
u16 *eepdata, temp, magic, magic2;
u32 sum = 0, el;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/ath/carl9170/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ int carl9170_reboot(struct ar9170 *ar)
if (!cmd)
return -ENOMEM;

err = __carl9170_exec_cmd(ar, (struct carl9170_cmd *)cmd, true);
err = __carl9170_exec_cmd(ar, cmd, true);
return err;
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/ath/carl9170/rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ static void carl9170_cmd_callback(struct ar9170 *ar, u32 len, void *buffer)

void carl9170_handle_command_response(struct ar9170 *ar, void *buf, u32 len)
{
struct carl9170_rsp *cmd = (void *) buf;
struct carl9170_rsp *cmd = buf;
struct ieee80211_vif *vif;

if (carl9170_check_sequence(ar, cmd->hdr.seq))
Expand Down Expand Up @@ -520,7 +520,7 @@ static u8 *carl9170_find_ie(u8 *data, unsigned int len, u8 ie)
*/
static void carl9170_ps_beacon(struct ar9170 *ar, void *data, unsigned int len)
{
struct ieee80211_hdr *hdr = (void *) data;
struct ieee80211_hdr *hdr = data;
struct ieee80211_tim_ie *tim_ie;
u8 *tim;
u8 tim_len;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/atmel.c
Original file line number Diff line number Diff line change
Expand Up @@ -2952,10 +2952,10 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
/* current AP address - only in reassoc frame */
if (is_reassoc) {
memcpy(body.ap, priv->CurrentBSSID, 6);
ssid_el_p = (u8 *)&body.ssid_el_id;
ssid_el_p = &body.ssid_el_id;
bodysize = 18 + priv->SSID_size;
} else {
ssid_el_p = (u8 *)&body.ap[0];
ssid_el_p = &body.ap[0];
bodysize = 12 + priv->SSID_size;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/b43legacy/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct b43legacy_dmadesc32 *op32_idx2desc(struct b43legacy_dmaring *ring,
desc = ring->descbase;
desc = &(desc[slot]);

return (struct b43legacy_dmadesc32 *)desc;
return desc;
}

static void op32_fill_descriptor(struct b43legacy_dmaring *ring,
Expand Down
6 changes: 2 additions & 4 deletions drivers/net/wireless/b43legacy/xmit.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,7 @@ static int generate_txhdr_fw3(struct b43legacy_wldev *dev,
b43legacy_generate_plcp_hdr((struct b43legacy_plcp_hdr4 *)
(&txhdr->plcp), plcp_fragment_len,
rate);
b43legacy_generate_plcp_hdr((struct b43legacy_plcp_hdr4 *)
(&txhdr->plcp_fb), plcp_fragment_len,
b43legacy_generate_plcp_hdr(&txhdr->plcp_fb, plcp_fragment_len,
rate_fb->hw_value);

/* PHY TX Control word */
Expand Down Expand Up @@ -340,8 +339,7 @@ static int generate_txhdr_fw3(struct b43legacy_wldev *dev,
b43legacy_generate_plcp_hdr((struct b43legacy_plcp_hdr4 *)
(&txhdr->rts_plcp),
len, rts_rate);
b43legacy_generate_plcp_hdr((struct b43legacy_plcp_hdr4 *)
(&txhdr->rts_plcp_fb),
b43legacy_generate_plcp_hdr(&txhdr->rts_plcp_fb,
len, rts_rate_fb);
hdr = (struct ieee80211_hdr *)(&txhdr->rts_frame);
txhdr->rts_dur_fb = hdr->duration_id;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -2502,7 +2502,7 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus)
int ret, i;

ret = brcmf_sdcard_send_buf(bus->sdiodev, bus->sdiodev->sbwad,
SDIO_FUNC_2, F2SYNC, (u8 *) bus->ctrl_frame_buf,
SDIO_FUNC_2, F2SYNC, bus->ctrl_frame_buf,
(u32) bus->ctrl_frame_len);

if (ret < 0) {
Expand Down Expand Up @@ -3327,7 +3327,7 @@ static int brcmf_sdbrcm_download_nvram(struct brcmf_sdio *bus)
len = brcmf_sdbrcm_get_image(memblock, MEMBLOCK, bus);

if (len > 0 && len < MEMBLOCK) {
bufp = (char *)memblock;
bufp = memblock;
bufp[len] = 0;
len = brcmf_process_nvram_vars(bufp, len);
bufp += len;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/brcm80211/brcmsmac/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,7 @@ void dma_walk_packets(struct dma_pub *dmah, void (*callback_fnc)
struct ieee80211_tx_info *tx_info;

while (i != end) {
skb = (struct sk_buff *)di->txp[i];
skb = di->txp[i];
if (skb != NULL) {
tx_info = (struct ieee80211_tx_info *)skb->cb;
(callback_fnc)(tx_info, arg_a);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/brcm80211/brcmsmac/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -8318,7 +8318,7 @@ brcms_c_attach(struct brcms_info *wl, struct bcma_device *core, uint unit,
struct brcms_pub *pub;

/* allocate struct brcms_c_info state and its substructures */
wlc = (struct brcms_c_info *) brcms_c_attach_malloc(unit, &err, 0);
wlc = brcms_c_attach_malloc(unit, &err, 0);
if (wlc == NULL)
goto fail;
wlc->wiphy = wl->wiphy;
Expand Down
3 changes: 1 addition & 2 deletions drivers/net/wireless/hostap/hostap_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ static int prism2_stats_proc_read(char *page, char **start, off_t off,
{
char *p = page;
local_info_t *local = (local_info_t *) data;
struct comm_tallies_sums *sums = (struct comm_tallies_sums *)
&local->comm_tallies;
struct comm_tallies_sums *sums = &local->comm_tallies;

if (off != 0) {
*eof = 1;
Expand Down
4 changes: 1 addition & 3 deletions drivers/net/wireless/ipw2x00/ipw2200.c
Original file line number Diff line number Diff line change
Expand Up @@ -7069,9 +7069,7 @@ static int ipw_qos_activate(struct ipw_priv *priv,
}

IPW_DEBUG_QOS("QoS sending IPW_CMD_QOS_PARAMETERS\n");
err = ipw_send_qos_params_command(priv,
(struct libipw_qos_parameters *)
&(qos_parameters[0]));
err = ipw_send_qos_params_command(priv, &qos_parameters[0]);
if (err)
IPW_DEBUG_QOS("QoS IPW_CMD_QOS_PARAMETERS failed\n");

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/iwlwifi/iwl-testmode.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ static void iwl_testmode_ucode_rx_pkt(struct iwl_priv *priv,
void *data;
int length;

data = (void *)rxb_addr(rxb);
data = rxb_addr(rxb);
length = get_event_length(rxb);

if (!data || length == 0)
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
Original file line number Diff line number Diff line change
Expand Up @@ -1354,7 +1354,7 @@ static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb,
DMA_BIDIRECTIONAL);

trace_iwlwifi_dev_tx(trans->dev,
&((struct iwl_tfd *)txq->tfds)[txq->q.write_ptr],
&txq->tfds[txq->q.write_ptr],
sizeof(struct iwl_tfd),
&dev_cmd->hdr, firstlen,
skb->data + hdr_len, secondlen);
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/libertas/debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ static ssize_t lbs_rdmac_write(struct file *file,
res = -EFAULT;
goto out_unlock;
}
priv->mac_offset = simple_strtoul((char *)buf, NULL, 16);
priv->mac_offset = simple_strtoul(buf, NULL, 16);
res = count;
out_unlock:
free_page(addr);
Expand Down Expand Up @@ -565,7 +565,7 @@ static ssize_t lbs_rdbbp_write(struct file *file,
res = -EFAULT;
goto out_unlock;
}
priv->bbp_offset = simple_strtoul((char *)buf, NULL, 16);
priv->bbp_offset = simple_strtoul(buf, NULL, 16);
res = count;
out_unlock:
free_page(addr);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/libertas/if_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ static int if_usb_probe(struct usb_interface *intf,
static void if_usb_disconnect(struct usb_interface *intf)
{
struct if_usb_card *cardp = usb_get_intfdata(intf);
struct lbs_private *priv = (struct lbs_private *) cardp->priv;
struct lbs_private *priv = cardp->priv;

lbs_deb_enter(LBS_DEB_MAIN);

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/libertas_tf/if_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ lbtf_deb_leave(LBTF_DEB_MAIN);
static void if_usb_disconnect(struct usb_interface *intf)
{
struct if_usb_card *cardp = usb_get_intfdata(intf);
struct lbtf_private *priv = (struct lbtf_private *) cardp->priv;
struct lbtf_private *priv = cardp->priv;

lbtf_deb_enter(LBTF_DEB_MAIN);

Expand Down
14 changes: 5 additions & 9 deletions drivers/net/wireless/mwifiex/11n.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ int mwifiex_ret_11n_delba(struct mwifiex_private *priv,
{
int tid;
struct mwifiex_tx_ba_stream_tbl *tx_ba_tbl;
struct host_cmd_ds_11n_delba *del_ba =
(struct host_cmd_ds_11n_delba *) &resp->params.del_ba;
struct host_cmd_ds_11n_delba *del_ba = &resp->params.del_ba;
uint16_t del_ba_param_set = le16_to_cpu(del_ba->del_ba_param_set);

tid = del_ba_param_set >> DELBA_TID_POS;
Expand Down Expand Up @@ -147,8 +146,7 @@ int mwifiex_ret_11n_addba_req(struct mwifiex_private *priv,
struct host_cmd_ds_command *resp)
{
int tid;
struct host_cmd_ds_11n_addba_rsp *add_ba_rsp =
(struct host_cmd_ds_11n_addba_rsp *) &resp->params.add_ba_rsp;
struct host_cmd_ds_11n_addba_rsp *add_ba_rsp = &resp->params.add_ba_rsp;
struct mwifiex_tx_ba_stream_tbl *tx_ba_tbl;

add_ba_rsp->ssn = cpu_to_le16((le16_to_cpu(add_ba_rsp->ssn))
Expand Down Expand Up @@ -412,7 +410,7 @@ mwifiex_cmd_append_11n_tlv(struct mwifiex_private *priv,

memcpy((u8 *) bss_co_2040 +
sizeof(struct mwifiex_ie_types_header),
(u8 *) bss_desc->bcn_bss_co_2040 +
bss_desc->bcn_bss_co_2040 +
sizeof(struct ieee_types_header),
le16_to_cpu(bss_co_2040->header.len));

Expand All @@ -426,10 +424,8 @@ mwifiex_cmd_append_11n_tlv(struct mwifiex_private *priv,
ext_cap->header.type = cpu_to_le16(WLAN_EID_EXT_CAPABILITY);
ext_cap->header.len = cpu_to_le16(sizeof(ext_cap->ext_cap));

memcpy((u8 *) ext_cap +
sizeof(struct mwifiex_ie_types_header),
(u8 *) bss_desc->bcn_ext_cap +
sizeof(struct ieee_types_header),
memcpy((u8 *)ext_cap + sizeof(struct mwifiex_ie_types_header),
bss_desc->bcn_ext_cap + sizeof(struct ieee_types_header),
le16_to_cpu(ext_cap->header.len));

*buffer += sizeof(struct mwifiex_ie_types_extcap);
Expand Down
3 changes: 1 addition & 2 deletions drivers/net/wireless/mwifiex/11n.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ static inline u8 mwifiex_space_avail_for_new_ba_stream(
priv = adapter->priv[i];
if (priv)
ba_stream_num += mwifiex_wmm_list_len(
(struct list_head *)
&priv->tx_ba_stream_tbl_ptr);
&priv->tx_ba_stream_tbl_ptr);
}

return ((ba_stream_num <
Expand Down
18 changes: 5 additions & 13 deletions drivers/net/wireless/mwifiex/11n_rxreorder.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,7 @@ mwifiex_11n_create_rx_reorder_tbl(struct mwifiex_private *priv, u8 *ta,
*/
int mwifiex_cmd_11n_addba_req(struct host_cmd_ds_command *cmd, void *data_buf)
{
struct host_cmd_ds_11n_addba_req *add_ba_req =
(struct host_cmd_ds_11n_addba_req *)
&cmd->params.add_ba_req;
struct host_cmd_ds_11n_addba_req *add_ba_req = &cmd->params.add_ba_req;

cmd->command = cpu_to_le16(HostCmd_CMD_11N_ADDBA_REQ);
cmd->size = cpu_to_le16(sizeof(*add_ba_req) + S_DS_GEN);
Expand All @@ -320,9 +318,7 @@ int mwifiex_cmd_11n_addba_rsp_gen(struct mwifiex_private *priv,
struct host_cmd_ds_11n_addba_req
*cmd_addba_req)
{
struct host_cmd_ds_11n_addba_rsp *add_ba_rsp =
(struct host_cmd_ds_11n_addba_rsp *)
&cmd->params.add_ba_rsp;
struct host_cmd_ds_11n_addba_rsp *add_ba_rsp = &cmd->params.add_ba_rsp;
u8 tid;
int win_size;
uint16_t block_ack_param_set;
Expand Down Expand Up @@ -367,8 +363,7 @@ int mwifiex_cmd_11n_addba_rsp_gen(struct mwifiex_private *priv,
*/
int mwifiex_cmd_11n_delba(struct host_cmd_ds_command *cmd, void *data_buf)
{
struct host_cmd_ds_11n_delba *del_ba = (struct host_cmd_ds_11n_delba *)
&cmd->params.del_ba;
struct host_cmd_ds_11n_delba *del_ba = &cmd->params.del_ba;

cmd->command = cpu_to_le16(HostCmd_CMD_11N_DELBA);
cmd->size = cpu_to_le16(sizeof(*del_ba) + S_DS_GEN);
Expand Down Expand Up @@ -398,8 +393,7 @@ int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *priv,
int start_win, end_win, win_size;
u16 pkt_index;

tbl = mwifiex_11n_get_rx_reorder_tbl((struct mwifiex_private *) priv,
tid, ta);
tbl = mwifiex_11n_get_rx_reorder_tbl(priv, tid, ta);
if (!tbl) {
if (pkt_type != PKT_TYPE_BAR)
mwifiex_process_rx_packet(priv->adapter, payload);
Expand Down Expand Up @@ -520,9 +514,7 @@ mwifiex_del_ba_tbl(struct mwifiex_private *priv, int tid, u8 *peer_mac,
int mwifiex_ret_11n_addba_resp(struct mwifiex_private *priv,
struct host_cmd_ds_command *resp)
{
struct host_cmd_ds_11n_addba_rsp *add_ba_rsp =
(struct host_cmd_ds_11n_addba_rsp *)
&resp->params.add_ba_rsp;
struct host_cmd_ds_11n_addba_rsp *add_ba_rsp = &resp->params.add_ba_rsp;
int tid, win_size;
struct mwifiex_rx_reorder_tbl *tbl;
uint16_t block_ack_param_set;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/mwifiex/cfg80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -1703,7 +1703,7 @@ int mwifiex_register_cfg80211(struct mwifiex_adapter *adapter)
wdev_priv = wiphy_priv(wiphy);
*(unsigned long *)wdev_priv = (unsigned long)adapter;

set_wiphy_dev(wiphy, (struct device *)priv->adapter->dev);
set_wiphy_dev(wiphy, priv->adapter->dev);

ret = wiphy_register(wiphy);
if (ret < 0) {
Expand Down
20 changes: 7 additions & 13 deletions drivers/net/wireless/mwifiex/join.c
Original file line number Diff line number Diff line change
Expand Up @@ -1349,22 +1349,16 @@ static int mwifiex_deauthenticate_infra(struct mwifiex_private *priv, u8 *mac)
{
u8 mac_address[ETH_ALEN];
int ret;
u8 zero_mac[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 };

if (mac) {
if (!memcmp(mac, zero_mac, sizeof(zero_mac)))
memcpy((u8 *) &mac_address,
(u8 *) &priv->curr_bss_params.bss_descriptor.
mac_address, ETH_ALEN);
else
memcpy((u8 *) &mac_address, (u8 *) mac, ETH_ALEN);
} else {
memcpy((u8 *) &mac_address, (u8 *) &priv->curr_bss_params.
bss_descriptor.mac_address, ETH_ALEN);
}
if (!mac || is_zero_ether_addr(mac))
memcpy(mac_address,
priv->curr_bss_params.bss_descriptor.mac_address,
ETH_ALEN);
else
memcpy(mac_address, mac, ETH_ALEN);

ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_DEAUTHENTICATE,
HostCmd_ACT_GEN_SET, 0, &mac_address);
HostCmd_ACT_GEN_SET, 0, mac_address);

return ret;
}
Expand Down
Loading

0 comments on commit 2c20889

Please sign in to comment.