Skip to content

Commit 618e8bc

Browse files
committed
Bluetooth: Use new hci_skb_pkt_* wrappers for drivers
The new hci_skb_pkt_* wrappers are mainly intented for drivers to require less knowledge about bt_cb(sbk) handling. So after converting the core packet handling, convert all drivers. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
1 parent d79f34e commit 618e8bc

21 files changed

+127
-116
lines changed

drivers/bluetooth/bfusb.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ static inline int bfusb_recv_block(struct bfusb_data *data, int hdr, unsigned ch
324324
return -ENOMEM;
325325
}
326326

327-
bt_cb(skb)->pkt_type = pkt_type;
327+
hci_skb_pkt_type(skb) = pkt_type;
328328

329329
data->reassembly = skb;
330330
} else {
@@ -469,9 +469,10 @@ static int bfusb_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
469469
unsigned char buf[3];
470470
int sent = 0, size, count;
471471

472-
BT_DBG("hdev %p skb %p type %d len %d", hdev, skb, bt_cb(skb)->pkt_type, skb->len);
472+
BT_DBG("hdev %p skb %p type %d len %d", hdev, skb,
473+
hci_skb_pkt_type(skb), skb->len);
473474

474-
switch (bt_cb(skb)->pkt_type) {
475+
switch (hci_skb_pkt_type(skb)) {
475476
case HCI_COMMAND_PKT:
476477
hdev->stat.cmd_tx++;
477478
break;
@@ -484,7 +485,7 @@ static int bfusb_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
484485
}
485486

486487
/* Prepend skb with frame type */
487-
memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1);
488+
memcpy(skb_push(skb, 1), &hci_skb_pkt_type(skb), 1);
488489

489490
count = skb->len;
490491

drivers/bluetooth/bluecard_cs.c

+13-12
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ static void bluecard_write_wakeup(struct bluecard_info *info)
261261
if (!skb)
262262
break;
263263

264-
if (bt_cb(skb)->pkt_type & 0x80) {
264+
if (hci_skb_pkt_type(skb) & 0x80) {
265265
/* Disable RTS */
266266
info->ctrl_reg |= REG_CONTROL_RTS;
267267
outb(info->ctrl_reg, iobase + REG_CONTROL);
@@ -279,13 +279,13 @@ static void bluecard_write_wakeup(struct bluecard_info *info)
279279
/* Mark the buffer as dirty */
280280
clear_bit(ready_bit, &(info->tx_state));
281281

282-
if (bt_cb(skb)->pkt_type & 0x80) {
282+
if (hci_skb_pkt_type(skb) & 0x80) {
283283
DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq);
284284
DEFINE_WAIT(wait);
285285

286286
unsigned char baud_reg;
287287

288-
switch (bt_cb(skb)->pkt_type) {
288+
switch (hci_skb_pkt_type(skb)) {
289289
case PKT_BAUD_RATE_460800:
290290
baud_reg = REG_CONTROL_BAUD_RATE_460800;
291291
break;
@@ -402,9 +402,9 @@ static void bluecard_receive(struct bluecard_info *info,
402402

403403
if (info->rx_state == RECV_WAIT_PACKET_TYPE) {
404404

405-
bt_cb(info->rx_skb)->pkt_type = buf[i];
405+
hci_skb_pkt_type(info->rx_skb) = buf[i];
406406

407-
switch (bt_cb(info->rx_skb)->pkt_type) {
407+
switch (hci_skb_pkt_type(info->rx_skb)) {
408408

409409
case 0x00:
410410
/* init packet */
@@ -436,7 +436,8 @@ static void bluecard_receive(struct bluecard_info *info,
436436

437437
default:
438438
/* unknown packet */
439-
BT_ERR("Unknown HCI packet with type 0x%02x received", bt_cb(info->rx_skb)->pkt_type);
439+
BT_ERR("Unknown HCI packet with type 0x%02x received",
440+
hci_skb_pkt_type(info->rx_skb));
440441
info->hdev->stat.err_rx++;
441442

442443
kfree_skb(info->rx_skb);
@@ -578,21 +579,21 @@ static int bluecard_hci_set_baud_rate(struct hci_dev *hdev, int baud)
578579
switch (baud) {
579580
case 460800:
580581
cmd[4] = 0x00;
581-
bt_cb(skb)->pkt_type = PKT_BAUD_RATE_460800;
582+
hci_skb_pkt_type(skb) = PKT_BAUD_RATE_460800;
582583
break;
583584
case 230400:
584585
cmd[4] = 0x01;
585-
bt_cb(skb)->pkt_type = PKT_BAUD_RATE_230400;
586+
hci_skb_pkt_type(skb) = PKT_BAUD_RATE_230400;
586587
break;
587588
case 115200:
588589
cmd[4] = 0x02;
589-
bt_cb(skb)->pkt_type = PKT_BAUD_RATE_115200;
590+
hci_skb_pkt_type(skb) = PKT_BAUD_RATE_115200;
590591
break;
591592
case 57600:
592593
/* Fall through... */
593594
default:
594595
cmd[4] = 0x03;
595-
bt_cb(skb)->pkt_type = PKT_BAUD_RATE_57600;
596+
hci_skb_pkt_type(skb) = PKT_BAUD_RATE_57600;
596597
break;
597598
}
598599

@@ -660,7 +661,7 @@ static int bluecard_hci_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
660661
{
661662
struct bluecard_info *info = hci_get_drvdata(hdev);
662663

663-
switch (bt_cb(skb)->pkt_type) {
664+
switch (hci_skb_pkt_type(skb)) {
664665
case HCI_COMMAND_PKT:
665666
hdev->stat.cmd_tx++;
666667
break;
@@ -673,7 +674,7 @@ static int bluecard_hci_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
673674
}
674675

675676
/* Prepend skb with frame type */
676-
memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1);
677+
memcpy(skb_push(skb, 1), &hci_skb_pkt_type(skb), 1);
677678
skb_queue_tail(&(info->txq), skb);
678679

679680
bluecard_write_wakeup(info);

drivers/bluetooth/bpa10x.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,9 @@ static int bpa10x_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
295295
return -ENOMEM;
296296

297297
/* Prepend skb with frame type */
298-
*skb_push(skb, 1) = bt_cb(skb)->pkt_type;
298+
*skb_push(skb, 1) = hci_skb_pkt_type(skb);
299299

300-
switch (bt_cb(skb)->pkt_type) {
300+
switch (hci_skb_pkt_type(skb)) {
301301
case HCI_COMMAND_PKT:
302302
dr = kmalloc(sizeof(*dr), GFP_ATOMIC);
303303
if (!dr) {

drivers/bluetooth/bt3c_cs.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,10 @@ static void bt3c_receive(struct bt3c_info *info)
246246

247247
if (info->rx_state == RECV_WAIT_PACKET_TYPE) {
248248

249-
bt_cb(info->rx_skb)->pkt_type = inb(iobase + DATA_L);
249+
hci_skb_pkt_type(info->rx_skb) = inb(iobase + DATA_L);
250250
inb(iobase + DATA_H);
251251

252-
switch (bt_cb(info->rx_skb)->pkt_type) {
252+
switch (hci_skb_pkt_type(info->rx_skb)) {
253253

254254
case HCI_EVENT_PKT:
255255
info->rx_state = RECV_WAIT_EVENT_HEADER;
@@ -268,7 +268,8 @@ static void bt3c_receive(struct bt3c_info *info)
268268

269269
default:
270270
/* Unknown packet */
271-
BT_ERR("Unknown HCI packet with type 0x%02x received", bt_cb(info->rx_skb)->pkt_type);
271+
BT_ERR("Unknown HCI packet with type 0x%02x received",
272+
hci_skb_pkt_type(info->rx_skb));
272273
info->hdev->stat.err_rx++;
273274

274275
kfree_skb(info->rx_skb);
@@ -411,7 +412,7 @@ static int bt3c_hci_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
411412
struct bt3c_info *info = hci_get_drvdata(hdev);
412413
unsigned long flags;
413414

414-
switch (bt_cb(skb)->pkt_type) {
415+
switch (hci_skb_pkt_type(skb)) {
415416
case HCI_COMMAND_PKT:
416417
hdev->stat.cmd_tx++;
417418
break;
@@ -424,7 +425,7 @@ static int bt3c_hci_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
424425
}
425426

426427
/* Prepend skb with frame type */
427-
memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1);
428+
memcpy(skb_push(skb, 1), &hci_skb_pkt_type(skb), 1);
428429
skb_queue_tail(&(info->txq), skb);
429430

430431
spin_lock_irqsave(&(info->lock), flags);

drivers/bluetooth/btmrvl_main.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ static int btmrvl_send_sync_cmd(struct btmrvl_private *priv, u16 opcode,
196196
if (len)
197197
memcpy(skb_put(skb, len), param, len);
198198

199-
bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT;
199+
hci_skb_pkt_type(skb) = MRVL_VENDOR_PKT;
200200

201201
skb_queue_head(&priv->adapter->tx_queue, skb);
202202

@@ -387,7 +387,7 @@ static int btmrvl_tx_pkt(struct btmrvl_private *priv, struct sk_buff *skb)
387387
skb->data[0] = (skb->len & 0x0000ff);
388388
skb->data[1] = (skb->len & 0x00ff00) >> 8;
389389
skb->data[2] = (skb->len & 0xff0000) >> 16;
390-
skb->data[3] = bt_cb(skb)->pkt_type;
390+
skb->data[3] = hci_skb_pkt_type(skb);
391391

392392
if (priv->hw_host_to_card)
393393
ret = priv->hw_host_to_card(priv, skb->data, skb->len);
@@ -434,9 +434,9 @@ static int btmrvl_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
434434
{
435435
struct btmrvl_private *priv = hci_get_drvdata(hdev);
436436

437-
BT_DBG("type=%d, len=%d", skb->pkt_type, skb->len);
437+
BT_DBG("type=%d, len=%d", hci_skb_pkt_type(skb), skb->len);
438438

439-
switch (bt_cb(skb)->pkt_type) {
439+
switch (hci_skb_pkt_type(skb)) {
440440
case HCI_COMMAND_PKT:
441441
hdev->stat.cmd_tx++;
442442
break;

drivers/bluetooth/btmrvl_sdio.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ static int btmrvl_sdio_card_to_host(struct btmrvl_private *priv)
698698
case HCI_ACLDATA_PKT:
699699
case HCI_SCODATA_PKT:
700700
case HCI_EVENT_PKT:
701-
bt_cb(skb)->pkt_type = type;
701+
hci_skb_pkt_type(skb) = type;
702702
skb_put(skb, buf_len);
703703
skb_pull(skb, SDIO_HEADER_LEN);
704704

@@ -713,7 +713,7 @@ static int btmrvl_sdio_card_to_host(struct btmrvl_private *priv)
713713
break;
714714

715715
case MRVL_VENDOR_PKT:
716-
bt_cb(skb)->pkt_type = HCI_VENDOR_PKT;
716+
hci_skb_pkt_type(skb) = HCI_VENDOR_PKT;
717717
skb_put(skb, buf_len);
718718
skb_pull(skb, SDIO_HEADER_LEN);
719719

drivers/bluetooth/btsdio.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static int btsdio_tx_packet(struct btsdio_data *data, struct sk_buff *skb)
8686
skb->data[0] = (skb->len & 0x0000ff);
8787
skb->data[1] = (skb->len & 0x00ff00) >> 8;
8888
skb->data[2] = (skb->len & 0xff0000) >> 16;
89-
skb->data[3] = bt_cb(skb)->pkt_type;
89+
skb->data[3] = hci_skb_pkt_type(skb);
9090

9191
err = sdio_writesb(data->func, REG_TDAT, skb->data, skb->len);
9292
if (err < 0) {
@@ -158,7 +158,7 @@ static int btsdio_rx_packet(struct btsdio_data *data)
158158

159159
data->hdev->stat.byte_rx += len;
160160

161-
bt_cb(skb)->pkt_type = hdr[3];
161+
hci_skb_pkt_type(skb) = hdr[3];
162162

163163
err = hci_recv_frame(data->hdev, skb);
164164
if (err < 0)
@@ -252,7 +252,7 @@ static int btsdio_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
252252

253253
BT_DBG("%s", hdev->name);
254254

255-
switch (bt_cb(skb)->pkt_type) {
255+
switch (hci_skb_pkt_type(skb)) {
256256
case HCI_COMMAND_PKT:
257257
hdev->stat.cmd_tx++;
258258
break;

drivers/bluetooth/btuart_cs.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@ static void btuart_receive(struct btuart_info *info)
200200

201201
if (info->rx_state == RECV_WAIT_PACKET_TYPE) {
202202

203-
bt_cb(info->rx_skb)->pkt_type = inb(iobase + UART_RX);
203+
hci_skb_pkt_type(info->rx_skb) = inb(iobase + UART_RX);
204204

205-
switch (bt_cb(info->rx_skb)->pkt_type) {
205+
switch (hci_skb_pkt_type(info->rx_skb)) {
206206

207207
case HCI_EVENT_PKT:
208208
info->rx_state = RECV_WAIT_EVENT_HEADER;
@@ -221,7 +221,8 @@ static void btuart_receive(struct btuart_info *info)
221221

222222
default:
223223
/* Unknown packet */
224-
BT_ERR("Unknown HCI packet with type 0x%02x received", bt_cb(info->rx_skb)->pkt_type);
224+
BT_ERR("Unknown HCI packet with type 0x%02x received",
225+
hci_skb_pkt_type(info->rx_skb));
225226
info->hdev->stat.err_rx++;
226227

227228
kfree_skb(info->rx_skb);
@@ -424,7 +425,7 @@ static int btuart_hci_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
424425
{
425426
struct btuart_info *info = hci_get_drvdata(hdev);
426427

427-
switch (bt_cb(skb)->pkt_type) {
428+
switch (hci_skb_pkt_type(skb)) {
428429
case HCI_COMMAND_PKT:
429430
hdev->stat.cmd_tx++;
430431
break;
@@ -437,7 +438,7 @@ static int btuart_hci_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
437438
}
438439

439440
/* Prepend skb with frame type */
440-
memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1);
441+
memcpy(skb_push(skb, 1), &hci_skb_pkt_type(skb), 1);
441442
skb_queue_tail(&(info->txq), skb);
442443

443444
btuart_write_wakeup(info);

0 commit comments

Comments
 (0)