mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
parent
59ae1d127a
commit
4df864c1d9
145 changed files with 486 additions and 547 deletions
|
|
@ -448,7 +448,7 @@ static void bluecard_receive(struct bluecard_info *info,
|
|||
|
||||
} else {
|
||||
|
||||
*skb_put(info->rx_skb, 1) = buf[i];
|
||||
*(u8 *)skb_put(info->rx_skb, 1) = buf[i];
|
||||
info->rx_count--;
|
||||
|
||||
if (info->rx_count == 0) {
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@ static void bt3c_receive(struct bt3c_info *info)
|
|||
|
||||
__u8 x = inb(iobase + DATA_L);
|
||||
|
||||
*skb_put(info->rx_skb, 1) = x;
|
||||
*(u8 *)skb_put(info->rx_skb, 1) = x;
|
||||
inb(iobase + DATA_H);
|
||||
info->rx_count--;
|
||||
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ static int btmrvl_send_sync_cmd(struct btmrvl_private *priv, u16 opcode,
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
hdr = (struct hci_command_hdr *)skb_put(skb, HCI_COMMAND_HDR_SIZE);
|
||||
hdr = skb_put(skb, HCI_COMMAND_HDR_SIZE);
|
||||
hdr->opcode = cpu_to_le16(opcode);
|
||||
hdr->plen = len;
|
||||
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ static void btuart_receive(struct btuart_info *info)
|
|||
|
||||
} else {
|
||||
|
||||
*skb_put(info->rx_skb, 1) = inb(iobase + UART_RX);
|
||||
*(u8 *)skb_put(info->rx_skb, 1) = inb(iobase + UART_RX);
|
||||
info->rx_count--;
|
||||
|
||||
if (info->rx_count == 0) {
|
||||
|
|
|
|||
|
|
@ -1836,15 +1836,15 @@ static int inject_cmd_complete(struct hci_dev *hdev, __u16 opcode)
|
|||
if (!skb)
|
||||
return -ENOMEM;
|
||||
|
||||
hdr = (struct hci_event_hdr *)skb_put(skb, sizeof(*hdr));
|
||||
hdr = skb_put(skb, sizeof(*hdr));
|
||||
hdr->evt = HCI_EV_CMD_COMPLETE;
|
||||
hdr->plen = sizeof(*evt) + 1;
|
||||
|
||||
evt = (struct hci_ev_cmd_complete *)skb_put(skb, sizeof(*evt));
|
||||
evt = skb_put(skb, sizeof(*evt));
|
||||
evt->ncmd = 0x01;
|
||||
evt->opcode = cpu_to_le16(opcode);
|
||||
|
||||
*skb_put(skb, 1) = 0x00;
|
||||
*(u8 *)skb_put(skb, 1) = 0x00;
|
||||
|
||||
hci_skb_pkt_type(skb) = HCI_EVENT_PKT;
|
||||
|
||||
|
|
@ -2767,8 +2767,8 @@ static struct urb *alloc_diag_urb(struct hci_dev *hdev, bool enable)
|
|||
return ERR_PTR(-ENOMEM);
|
||||
}
|
||||
|
||||
*skb_put(skb, 1) = 0xf0;
|
||||
*skb_put(skb, 1) = enable;
|
||||
*(u8 *)skb_put(skb, 1) = 0xf0;
|
||||
*(u8 *)skb_put(skb, 1) = enable;
|
||||
|
||||
pipe = usb_sndbulkpipe(data->udev, data->diag_tx_ep->bEndpointAddress);
|
||||
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ static void dtl1_receive(struct dtl1_info *info)
|
|||
}
|
||||
}
|
||||
|
||||
*skb_put(info->rx_skb, 1) = inb(iobase + UART_RX);
|
||||
*(u8 *)skb_put(info->rx_skb, 1) = inb(iobase + UART_RX);
|
||||
nsh = (struct nsh *)info->rx_skb->data;
|
||||
|
||||
info->rx_count--;
|
||||
|
|
@ -414,7 +414,7 @@ static int dtl1_hci_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
|
|||
skb_reserve(s, NSHL);
|
||||
skb_copy_from_linear_data(skb, skb_put(s, skb->len), skb->len);
|
||||
if (skb->len & 0x0001)
|
||||
*skb_put(s, 1) = 0; /* PAD */
|
||||
*(u8 *)skb_put(s, 1) = 0; /* PAD */
|
||||
|
||||
/* Prepend skb with Nokia frame header and queue */
|
||||
memcpy(skb_push(s, NSHL), &nsh, NSHL);
|
||||
|
|
|
|||
|
|
@ -262,9 +262,9 @@ static int bcm_set_diag(struct hci_dev *hdev, bool enable)
|
|||
if (!skb)
|
||||
return -ENOMEM;
|
||||
|
||||
*skb_put(skb, 1) = BCM_LM_DIAG_PKT;
|
||||
*skb_put(skb, 1) = 0xf0;
|
||||
*skb_put(skb, 1) = enable;
|
||||
*(u8 *)skb_put(skb, 1) = BCM_LM_DIAG_PKT;
|
||||
*(u8 *)skb_put(skb, 1) = 0xf0;
|
||||
*(u8 *)skb_put(skb, 1) = enable;
|
||||
|
||||
skb_queue_tail(&bcm->txq, skb);
|
||||
hci_uart_tx_wakeup(hu);
|
||||
|
|
|
|||
|
|
@ -462,15 +462,15 @@ static int inject_cmd_complete(struct hci_dev *hdev, __u16 opcode)
|
|||
if (!skb)
|
||||
return -ENOMEM;
|
||||
|
||||
hdr = (struct hci_event_hdr *)skb_put(skb, sizeof(*hdr));
|
||||
hdr = skb_put(skb, sizeof(*hdr));
|
||||
hdr->evt = HCI_EV_CMD_COMPLETE;
|
||||
hdr->plen = sizeof(*evt) + 1;
|
||||
|
||||
evt = (struct hci_ev_cmd_complete *)skb_put(skb, sizeof(*evt));
|
||||
evt = skb_put(skb, sizeof(*evt));
|
||||
evt->ncmd = 0x01;
|
||||
evt->opcode = cpu_to_le16(opcode);
|
||||
|
||||
*skb_put(skb, 1) = 0x00;
|
||||
*(u8 *)skb_put(skb, 1) = 0x00;
|
||||
|
||||
hci_skb_pkt_type(skb) = HCI_EVENT_PKT;
|
||||
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ static int send_hcill_cmd(u8 cmd, struct hci_uart *hu)
|
|||
}
|
||||
|
||||
/* prepare packet */
|
||||
hcill_packet = (struct hcill_cmd *) skb_put(skb, 1);
|
||||
hcill_packet = skb_put(skb, 1);
|
||||
hcill_packet->cmd = cmd;
|
||||
|
||||
/* send packet */
|
||||
|
|
|
|||
|
|
@ -246,9 +246,9 @@ static int nokia_send_alive_packet(struct hci_uart *hu)
|
|||
hci_skb_pkt_type(skb) = HCI_NOKIA_ALIVE_PKT;
|
||||
memset(skb->data, 0x00, len);
|
||||
|
||||
hdr = (struct hci_nokia_alive_hdr *)skb_put(skb, sizeof(*hdr));
|
||||
hdr = skb_put(skb, sizeof(*hdr));
|
||||
hdr->dlen = sizeof(*pkt);
|
||||
pkt = (struct hci_nokia_alive_pkt *)skb_put(skb, sizeof(*pkt));
|
||||
pkt = skb_put(skb, sizeof(*pkt));
|
||||
pkt->mid = NOKIA_ALIVE_REQ;
|
||||
|
||||
nokia_enqueue(hu, skb);
|
||||
|
|
@ -285,10 +285,10 @@ static int nokia_send_negotiation(struct hci_uart *hu)
|
|||
|
||||
hci_skb_pkt_type(skb) = HCI_NOKIA_NEG_PKT;
|
||||
|
||||
neg_hdr = (struct hci_nokia_neg_hdr *)skb_put(skb, sizeof(*neg_hdr));
|
||||
neg_hdr = skb_put(skb, sizeof(*neg_hdr));
|
||||
neg_hdr->dlen = sizeof(*neg_cmd);
|
||||
|
||||
neg_cmd = (struct hci_nokia_neg_cmd *)skb_put(skb, sizeof(*neg_cmd));
|
||||
neg_cmd = skb_put(skb, sizeof(*neg_cmd));
|
||||
neg_cmd->ack = NOKIA_NEG_REQ;
|
||||
neg_cmd->baud = cpu_to_le16(baud);
|
||||
neg_cmd->unused1 = 0x0000;
|
||||
|
|
@ -532,7 +532,7 @@ static int nokia_enqueue(struct hci_uart *hu, struct sk_buff *skb)
|
|||
err = skb_pad(skb, 1);
|
||||
if (err)
|
||||
return err;
|
||||
*skb_put(skb, 1) = 0x00;
|
||||
*(u8 *)skb_put(skb, 1) = 0x00;
|
||||
}
|
||||
|
||||
skb_queue_tail(&btdev->txq, skb);
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ static int send_hci_ibs_cmd(u8 cmd, struct hci_uart *hu)
|
|||
}
|
||||
|
||||
/* Assign HCI_IBS type */
|
||||
*skb_put(skb, 1) = cmd;
|
||||
*(u8 *)skb_put(skb, 1) = cmd;
|
||||
|
||||
skb_queue_tail(&qca->txq, skb);
|
||||
|
||||
|
|
|
|||
|
|
@ -146,8 +146,8 @@ static int __vhci_create_device(struct vhci_data *data, __u8 opcode)
|
|||
|
||||
hci_skb_pkt_type(skb) = HCI_VENDOR_PKT;
|
||||
|
||||
*skb_put(skb, 1) = 0xff;
|
||||
*skb_put(skb, 1) = opcode;
|
||||
*(u8 *)skb_put(skb, 1) = 0xff;
|
||||
*(u8 *)skb_put(skb, 1) = opcode;
|
||||
put_unaligned_le16(hdev->id, skb_put(skb, 2));
|
||||
skb_queue_tail(&data->readq, skb);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue