summaryrefslogtreecommitdiff
path: root/drivers/nfc
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2017-06-16 14:29:21 +0200
committerDavid S. Miller <davem@davemloft.net>2017-06-16 11:48:39 -0400
commit4df864c1d9afb46e2461a9f808d9f11a42d31bad (patch)
tree07e7b3d16b161e0d199c5b8116df277798566e4f /drivers/nfc
parent59ae1d127ac0ae404baf414c434ba2651b793f46 (diff)
networking: make skb_put & friends return void pointers
It seems like a historic accident that these return unsigned char *, and in many places that means casts are required, more often than not. Make these functions (skb_put, __skb_put and pskb_put) return void * and remove all the casts across the tree, adding a (u8 *) cast only where the unsigned char pointer was used directly, all done with the following spatch: @@ expression SKB, LEN; typedef u8; identifier fn = { skb_put, __skb_put }; @@ - *(fn(SKB, LEN)) + *(u8 *)fn(SKB, LEN) @@ expression E, SKB, LEN; identifier fn = { skb_put, __skb_put }; type T; @@ - E = ((T *)(fn(SKB, LEN))) + E = fn(SKB, LEN) which actually doesn't cover pskb_put since there are only three users overall. A handful of stragglers were converted manually, notably a macro in drivers/isdn/i4l/isdn_bsdcomp.c and, oddly enough, one of the many instances in net/bluetooth/hci_sock.c. In the former file, I also had to fix one whitespace problem spatch introduced. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/nfc')
-rw-r--r--drivers/nfc/fdp/i2c.c2
-rw-r--r--drivers/nfc/microread/i2c.c4
-rw-r--r--drivers/nfc/microread/microread.c4
-rw-r--r--drivers/nfc/nfcmrvl/fw_dnld.c6
-rw-r--r--drivers/nfc/pn533/pn533.c32
-rw-r--r--drivers/nfc/pn544/i2c.c6
-rw-r--r--drivers/nfc/port100.c4
-rw-r--r--drivers/nfc/st21nfca/i2c.c6
-rw-r--r--drivers/nfc/st95hf/core.c2
9 files changed, 33 insertions, 33 deletions
diff --git a/drivers/nfc/fdp/i2c.c b/drivers/nfc/fdp/i2c.c
index 0877e2283f35..97f003e84381 100644
--- a/drivers/nfc/fdp/i2c.c
+++ b/drivers/nfc/fdp/i2c.c
@@ -86,7 +86,7 @@ static void fdp_nci_i2c_add_len_lrc(struct sk_buff *skb)
for (i = 0; i < len + 2; i++)
lrc ^= skb->data[i];
- *skb_put(skb, 1) = lrc;
+ *(u8 *)skb_put(skb, 1) = lrc;
}
static void fdp_nci_i2c_remove_len_lrc(struct sk_buff *skb)
diff --git a/drivers/nfc/microread/i2c.c b/drivers/nfc/microread/i2c.c
index e0e8afd27849..8e328c36a816 100644
--- a/drivers/nfc/microread/i2c.c
+++ b/drivers/nfc/microread/i2c.c
@@ -75,7 +75,7 @@ static void microread_i2c_add_len_crc(struct sk_buff *skb)
for (i = 0; i < skb->len; i++)
crc = crc ^ skb->data[i];
- *skb_put(skb, 1) = crc;
+ *(u8 *)skb_put(skb, 1) = crc;
}
static void microread_i2c_remove_len_crc(struct sk_buff *skb)
@@ -173,7 +173,7 @@ static int microread_i2c_read(struct microread_i2c_phy *phy,
goto flush;
}
- *skb_put(*skb, 1) = len;
+ *(u8 *)skb_put(*skb, 1) = len;
r = i2c_master_recv(client, skb_put(*skb, len), len);
if (r != len) {
diff --git a/drivers/nfc/microread/microread.c b/drivers/nfc/microread/microread.c
index f454dc68cc03..9d0dd1be0923 100644
--- a/drivers/nfc/microread/microread.c
+++ b/drivers/nfc/microread/microread.c
@@ -441,8 +441,8 @@ static int microread_im_transceive(struct nfc_hci_dev *hdev,
crc = crc_ccitt(0xffff, skb->data, skb->len);
crc = ~crc;
- *skb_put(skb, 1) = crc & 0xff;
- *skb_put(skb, 1) = crc >> 8;
+ *(u8 *)skb_put(skb, 1) = crc & 0xff;
+ *(u8 *)skb_put(skb, 1) = crc >> 8;
break;
case MICROREAD_GATE_ID_MREAD_NFC_T3:
control_bits = 0xDB;
diff --git a/drivers/nfc/nfcmrvl/fw_dnld.c b/drivers/nfc/nfcmrvl/fw_dnld.c
index 7c710458568e..788599de9d8a 100644
--- a/drivers/nfc/nfcmrvl/fw_dnld.c
+++ b/drivers/nfc/nfcmrvl/fw_dnld.c
@@ -92,7 +92,7 @@ static struct sk_buff *alloc_lc_skb(struct nfcmrvl_private *priv, uint8_t plen)
return NULL;
}
- hdr = (struct nci_data_hdr *) skb_put(skb, NCI_DATA_HDR_SIZE);
+ hdr = skb_put(skb, NCI_DATA_HDR_SIZE);
hdr->conn_id = NCI_CORE_LC_CONNID_PROP_FW_DL;
hdr->rfu = 0;
hdr->plen = plen;
@@ -292,7 +292,7 @@ static int process_state_fw_dnld(struct nfcmrvl_private *priv,
out_skb = alloc_lc_skb(priv, 1);
if (!out_skb)
return -ENOMEM;
- *skb_put(out_skb, 1) = 0xBF;
+ *(u8 *)skb_put(out_skb, 1) = 0xBF;
nci_send_frame(priv->ndev, out_skb);
priv->fw_dnld.substate = SUBSTATE_WAIT_NACK_CREDIT;
return 0;
@@ -301,7 +301,7 @@ static int process_state_fw_dnld(struct nfcmrvl_private *priv,
out_skb = alloc_lc_skb(priv, 1);
if (!out_skb)
return -ENOMEM;
- *skb_put(out_skb, 1) = HELPER_ACK_PACKET_FORMAT;
+ *(u8 *)skb_put(out_skb, 1) = HELPER_ACK_PACKET_FORMAT;
nci_send_frame(priv->ndev, out_skb);
priv->fw_dnld.substate = SUBSTATE_WAIT_ACK_CREDIT;
break;
diff --git a/drivers/nfc/pn533/pn533.c b/drivers/nfc/pn533/pn533.c
index 9200bb308e42..68a3cd0287f6 100644
--- a/drivers/nfc/pn533/pn533.c
+++ b/drivers/nfc/pn533/pn533.c
@@ -1032,7 +1032,7 @@ static struct sk_buff *pn533_alloc_poll_tg_frame(struct pn533 *dev)
return NULL;
/* DEP support only */
- *skb_put(skb, 1) = PN533_INIT_TARGET_DEP;
+ *(u8 *)skb_put(skb, 1) = PN533_INIT_TARGET_DEP;
/* MIFARE params */
skb_put_data(skb, mifare_params, 6);
@@ -1046,12 +1046,12 @@ static struct sk_buff *pn533_alloc_poll_tg_frame(struct pn533 *dev)
memcpy(nfcid3, felica, 8);
/* General bytes */
- *skb_put(skb, 1) = gbytes_len;
+ *(u8 *)skb_put(skb, 1) = gbytes_len;
gb = skb_put_data(skb, gbytes, gbytes_len);
/* Len Tk */
- *skb_put(skb, 1) = 0;
+ *(u8 *)skb_put(skb, 1) = 0;
return skb;
}
@@ -1280,8 +1280,8 @@ static void pn533_wq_rf(struct work_struct *work)
if (!skb)
return;
- *skb_put(skb, 1) = PN533_CFGITEM_RF_FIELD;
- *skb_put(skb, 1) = PN533_CFGITEM_RF_FIELD_AUTO_RFCA;
+ *(u8 *)skb_put(skb, 1) = PN533_CFGITEM_RF_FIELD;
+ *(u8 *)skb_put(skb, 1) = PN533_CFGITEM_RF_FIELD_AUTO_RFCA;
rc = pn533_send_cmd_async(dev, PN533_CMD_RF_CONFIGURATION, skb,
pn533_rf_complete, NULL);
@@ -1375,8 +1375,8 @@ static int pn533_poll_dep(struct nfc_dev *nfc_dev)
if (!skb)
return -ENOMEM;
- *skb_put(skb, 1) = 0x01; /* Active */
- *skb_put(skb, 1) = 0x02; /* 424 kbps */
+ *(u8 *)skb_put(skb, 1) = 0x01; /* Active */
+ *(u8 *)skb_put(skb, 1) = 0x02; /* 424 kbps */
next = skb_put(skb, 1); /* Next */
*next = 0;
@@ -1620,8 +1620,8 @@ static int pn533_activate_target_nfcdep(struct pn533 *dev)
if (!skb)
return -ENOMEM;
- *skb_put(skb, sizeof(u8)) = 1; /* TG */
- *skb_put(skb, sizeof(u8)) = 0; /* Next */
+ *(u8 *)skb_put(skb, sizeof(u8)) = 1; /* TG */
+ *(u8 *)skb_put(skb, sizeof(u8)) = 0; /* Next */
resp = pn533_send_cmd_sync(dev, PN533_CMD_IN_ATR, skb);
if (IS_ERR(resp))
@@ -1737,7 +1737,7 @@ static void pn533_deactivate_target(struct nfc_dev *nfc_dev,
if (!skb)
return;
- *skb_put(skb, 1) = 1; /* TG*/
+ *(u8 *)skb_put(skb, 1) = 1; /* TG*/
rc = pn533_send_cmd_async(dev, PN533_CMD_IN_RELEASE, skb,
pn533_deactivate_target_complete, NULL);
@@ -1848,8 +1848,8 @@ static int pn533_dep_link_up(struct nfc_dev *nfc_dev, struct nfc_target *target,
if (!skb)
return -ENOMEM;
- *skb_put(skb, 1) = !comm_mode; /* ActPass */
- *skb_put(skb, 1) = 0x02; /* 424 kbps */
+ *(u8 *)skb_put(skb, 1) = !comm_mode; /* ActPass */
+ *(u8 *)skb_put(skb, 1) = 0x02; /* 424 kbps */
next = skb_put(skb, 1); /* Next */
*next = 0;
@@ -2274,7 +2274,7 @@ static void pn533_wq_mi_recv(struct work_struct *work)
break;
}
default:
- *skb_put(skb, sizeof(u8)) = 1; /*TG*/
+ *(u8 *)skb_put(skb, sizeof(u8)) = 1; /*TG*/
rc = pn533_send_cmd_direct_async(dev,
PN533_CMD_IN_DATA_EXCHANGE,
@@ -2370,7 +2370,7 @@ static int pn533_set_configuration(struct pn533 *dev, u8 cfgitem, u8 *cfgdata,
if (!skb)
return -ENOMEM;
- *skb_put(skb, sizeof(cfgitem)) = cfgitem;
+ *(u8 *)skb_put(skb, sizeof(cfgitem)) = cfgitem;
skb_put_data(skb, cfgdata, cfgdata_len);
resp = pn533_send_cmd_sync(dev, PN533_CMD_RF_CONFIGURATION, skb);
@@ -2415,7 +2415,7 @@ static int pn533_pasori_fw_reset(struct pn533 *dev)
if (!skb)
return -ENOMEM;
- *skb_put(skb, sizeof(u8)) = 0x1;
+ *(u8 *)skb_put(skb, sizeof(u8)) = 0x1;
resp = pn533_send_cmd_sync(dev, 0x18, skb);
if (IS_ERR(resp))
@@ -2454,7 +2454,7 @@ static int pn532_sam_configuration(struct nfc_dev *nfc_dev)
if (!skb)
return -ENOMEM;
- *skb_put(skb, 1) = 0x01;
+ *(u8 *)skb_put(skb, 1) = 0x01;
resp = pn533_send_cmd_sync(dev, PN533_CMD_SAM_CONFIGURATION, skb);
if (IS_ERR(resp))
diff --git a/drivers/nfc/pn544/i2c.c b/drivers/nfc/pn544/i2c.c
index 71ac0836c9f4..dc1e3768cee6 100644
--- a/drivers/nfc/pn544/i2c.c
+++ b/drivers/nfc/pn544/i2c.c
@@ -287,8 +287,8 @@ static void pn544_hci_i2c_add_len_crc(struct sk_buff *skb)
crc = crc_ccitt(0xffff, skb->data, skb->len);
crc = ~crc;
- *skb_put(skb, 1) = crc & 0xff;
- *skb_put(skb, 1) = crc >> 8;
+ *(u8 *)skb_put(skb, 1) = crc & 0xff;
+ *(u8 *)skb_put(skb, 1) = crc >> 8;
}
static void pn544_hci_i2c_remove_len_crc(struct sk_buff *skb)
@@ -391,7 +391,7 @@ static int pn544_hci_i2c_read(struct pn544_i2c_phy *phy, struct sk_buff **skb)
goto flush;
}
- *skb_put(*skb, 1) = len;
+ *(u8 *)skb_put(*skb, 1) = len;
r = i2c_master_recv(client, skb_put(*skb, len), len);
if (r != len) {
diff --git a/drivers/nfc/port100.c b/drivers/nfc/port100.c
index e1260da73d45..5fa3cf0fabd6 100644
--- a/drivers/nfc/port100.c
+++ b/drivers/nfc/port100.c
@@ -991,7 +991,7 @@ static int port100_set_command_type(struct port100 *dev, u8 command_type)
if (!skb)
return -ENOMEM;
- *skb_put(skb, sizeof(u8)) = command_type;
+ *(u8 *)skb_put(skb, sizeof(u8)) = command_type;
resp = port100_send_cmd_sync(dev, PORT100_CMD_SET_COMMAND_TYPE, skb);
if (IS_ERR(resp))
@@ -1059,7 +1059,7 @@ static int port100_switch_rf(struct nfc_digital_dev *ddev, bool on)
if (!skb)
return -ENOMEM;
- *skb_put(skb, 1) = on ? 1 : 0;
+ *(u8 *)skb_put(skb, 1) = on ? 1 : 0;
/* Cancel the last command if the device is being switched off */
if (!on)
diff --git a/drivers/nfc/st21nfca/i2c.c b/drivers/nfc/st21nfca/i2c.c
index 94d0b913b627..c36f0e0afdfd 100644
--- a/drivers/nfc/st21nfca/i2c.c
+++ b/drivers/nfc/st21nfca/i2c.c
@@ -177,10 +177,10 @@ static void st21nfca_hci_add_len_crc(struct sk_buff *skb)
crc = ~crc;
tmp = crc & 0x00ff;
- *skb_put(skb, 1) = tmp;
+ *(u8 *)skb_put(skb, 1) = tmp;
tmp = (crc >> 8) & 0x00ff;
- *skb_put(skb, 1) = tmp;
+ *(u8 *)skb_put(skb, 1) = tmp;
}
static void st21nfca_hci_remove_len_crc(struct sk_buff *skb)
@@ -214,7 +214,7 @@ static int st21nfca_hci_i2c_write(void *phy_id, struct sk_buff *skb)
st21nfca_hci_add_len_crc(skb);
/* add ST21NFCA_SOF_EOF on tail */
- *skb_put(skb, 1) = ST21NFCA_SOF_EOF;
+ *(u8 *)skb_put(skb, 1) = ST21NFCA_SOF_EOF;
/* add ST21NFCA_SOF_EOF on head */
*skb_push(skb, 1) = ST21NFCA_SOF_EOF;
diff --git a/drivers/nfc/st95hf/core.c b/drivers/nfc/st95hf/core.c
index c2840e412962..168adcc46cb8 100644
--- a/drivers/nfc/st95hf/core.c
+++ b/drivers/nfc/st95hf/core.c
@@ -949,7 +949,7 @@ static int st95hf_in_send_cmd(struct nfc_digital_dev *ddev,
switch (stcontext->current_rf_tech) {
case NFC_DIGITAL_RF_TECH_106A:
len_data_to_tag = skb->len + 1;
- *skb_put(skb, 1) = stcontext->sendrcv_trflag;
+ *(u8 *)skb_put(skb, 1) = stcontext->sendrcv_trflag;
break;
case NFC_DIGITAL_RF_TECH_106B:
case NFC_DIGITAL_RF_TECH_ISO15693: