Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[Bluetooth]: Add endian annotations to the core

This patch adds the endian annotations to the Bluetooth core.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Marcel Holtmann and committed by
David S. Miller
1ebb9252 7ef934b3

+66 -66
+2 -2
drivers/bluetooth/bpa10x.c
··· 84 84 85 85 struct hci_vendor_hdr { 86 86 __u8 type; 87 - __u16 snum; 88 - __u16 dlen; 87 + __le16 snum; 88 + __le16 dlen; 89 89 } __attribute__ ((packed)); 90 90 91 91 static void bpa10x_recv_bulk(struct bpa10x_data *data, unsigned char *buf, int count)
+58 -58
include/net/bluetooth/hci.h
··· 184 184 struct hci_rp_read_loc_version { 185 185 __u8 status; 186 186 __u8 hci_ver; 187 - __u16 hci_rev; 187 + __le16 hci_rev; 188 188 __u8 lmp_ver; 189 - __u16 manufacturer; 190 - __u16 lmp_subver; 189 + __le16 manufacturer; 190 + __le16 lmp_subver; 191 191 } __attribute__ ((packed)); 192 192 193 193 #define OCF_READ_LOCAL_FEATURES 0x0003 ··· 199 199 #define OCF_READ_BUFFER_SIZE 0x0005 200 200 struct hci_rp_read_buffer_size { 201 201 __u8 status; 202 - __u16 acl_mtu; 202 + __le16 acl_mtu; 203 203 __u8 sco_mtu; 204 - __u16 acl_max_pkt; 205 - __u16 sco_max_pkt; 204 + __le16 acl_max_pkt; 205 + __le16 sco_max_pkt; 206 206 } __attribute__ ((packed)); 207 207 208 208 #define OCF_READ_BD_ADDR 0x0009 ··· 267 267 268 268 #define OCF_READ_VOICE_SETTING 0x0025 269 269 struct hci_rp_read_voice_setting { 270 - __u8 status; 271 - __u16 voice_setting; 270 + __u8 status; 271 + __le16 voice_setting; 272 272 } __attribute__ ((packed)); 273 273 274 274 #define OCF_WRITE_VOICE_SETTING 0x0026 275 275 struct hci_cp_write_voice_setting { 276 - __u16 voice_setting; 276 + __le16 voice_setting; 277 277 } __attribute__ ((packed)); 278 278 279 279 #define OCF_HOST_BUFFER_SIZE 0x0033 280 280 struct hci_cp_host_buffer_size { 281 - __u16 acl_mtu; 281 + __le16 acl_mtu; 282 282 __u8 sco_mtu; 283 - __u16 acl_max_pkt; 284 - __u16 sco_max_pkt; 283 + __le16 acl_max_pkt; 284 + __le16 sco_max_pkt; 285 285 } __attribute__ ((packed)); 286 286 287 287 /* Link Control */ ··· 289 289 #define OCF_CREATE_CONN 0x0005 290 290 struct hci_cp_create_conn { 291 291 bdaddr_t bdaddr; 292 - __u16 pkt_type; 292 + __le16 pkt_type; 293 293 __u8 pscan_rep_mode; 294 294 __u8 pscan_mode; 295 - __u16 clock_offset; 295 + __le16 clock_offset; 296 296 __u8 role_switch; 297 297 } __attribute__ ((packed)); 298 298 ··· 310 310 311 311 #define OCF_DISCONNECT 0x0006 312 312 struct hci_cp_disconnect { 313 - __u16 handle; 313 + __le16 handle; 314 314 __u8 reason; 315 315 } __attribute__ ((packed)); 316 316 317 317 #define OCF_ADD_SCO 0x0007 318 318 struct hci_cp_add_sco { 319 - __u16 handle; 320 - __u16 pkt_type; 319 + __le16 handle; 320 + __le16 pkt_type; 321 321 } __attribute__ ((packed)); 322 322 323 323 #define OCF_INQUIRY 0x0001 ··· 354 354 355 355 #define OCF_CHANGE_CONN_PTYPE 0x000F 356 356 struct hci_cp_change_conn_ptype { 357 - __u16 handle; 358 - __u16 pkt_type; 357 + __le16 handle; 358 + __le16 pkt_type; 359 359 } __attribute__ ((packed)); 360 360 361 361 #define OCF_AUTH_REQUESTED 0x0011 362 362 struct hci_cp_auth_requested { 363 - __u16 handle; 363 + __le16 handle; 364 364 } __attribute__ ((packed)); 365 365 366 366 #define OCF_SET_CONN_ENCRYPT 0x0013 367 367 struct hci_cp_set_conn_encrypt { 368 - __u16 handle; 368 + __le16 handle; 369 369 __u8 encrypt; 370 370 } __attribute__ ((packed)); 371 371 372 372 #define OCF_CHANGE_CONN_LINK_KEY 0x0015 373 373 struct hci_cp_change_conn_link_key { 374 - __u16 handle; 374 + __le16 handle; 375 375 } __attribute__ ((packed)); 376 376 377 377 #define OCF_READ_REMOTE_FEATURES 0x001B 378 378 struct hci_cp_read_rmt_features { 379 - __u16 handle; 379 + __le16 handle; 380 380 } __attribute__ ((packed)); 381 381 382 382 #define OCF_READ_REMOTE_VERSION 0x001D 383 383 struct hci_cp_read_rmt_version { 384 - __u16 handle; 384 + __le16 handle; 385 385 } __attribute__ ((packed)); 386 386 387 387 /* Link Policy */ 388 388 #define OGF_LINK_POLICY 0x02 389 389 #define OCF_ROLE_DISCOVERY 0x0009 390 390 struct hci_cp_role_discovery { 391 - __u16 handle; 391 + __le16 handle; 392 392 } __attribute__ ((packed)); 393 393 struct hci_rp_role_discovery { 394 394 __u8 status; 395 - __u16 handle; 395 + __le16 handle; 396 396 __u8 role; 397 397 } __attribute__ ((packed)); 398 398 399 399 #define OCF_READ_LINK_POLICY 0x000C 400 400 struct hci_cp_read_link_policy { 401 - __u16 handle; 401 + __le16 handle; 402 402 } __attribute__ ((packed)); 403 403 struct hci_rp_read_link_policy { 404 404 __u8 status; 405 - __u16 handle; 406 - __u16 policy; 405 + __le16 handle; 406 + __le16 policy; 407 407 } __attribute__ ((packed)); 408 408 409 409 #define OCF_SWITCH_ROLE 0x000B ··· 414 414 415 415 #define OCF_WRITE_LINK_POLICY 0x000D 416 416 struct hci_cp_write_link_policy { 417 - __u16 handle; 418 - __u16 policy; 417 + __le16 handle; 418 + __le16 policy; 419 419 } __attribute__ ((packed)); 420 420 struct hci_rp_write_link_policy { 421 421 __u8 status; 422 - __u16 handle; 422 + __le16 handle; 423 423 } __attribute__ ((packed)); 424 424 425 425 /* Status params */ ··· 441 441 __u8 pscan_period_mode; 442 442 __u8 pscan_mode; 443 443 __u8 dev_class[3]; 444 - __u16 clock_offset; 444 + __le16 clock_offset; 445 445 } __attribute__ ((packed)); 446 446 447 447 #define HCI_EV_INQUIRY_RESULT_WITH_RSSI 0x22 ··· 450 450 __u8 pscan_rep_mode; 451 451 __u8 pscan_period_mode; 452 452 __u8 dev_class[3]; 453 - __u16 clock_offset; 453 + __le16 clock_offset; 454 454 __s8 rssi; 455 455 } __attribute__ ((packed)); 456 456 struct inquiry_info_with_rssi_and_pscan_mode { ··· 459 459 __u8 pscan_period_mode; 460 460 __u8 pscan_mode; 461 461 __u8 dev_class[3]; 462 - __u16 clock_offset; 462 + __le16 clock_offset; 463 463 __s8 rssi; 464 464 } __attribute__ ((packed)); 465 465 ··· 469 469 __u8 pscan_rep_mode; 470 470 __u8 pscan_period_mode; 471 471 __u8 dev_class[3]; 472 - __u16 clock_offset; 472 + __le16 clock_offset; 473 473 __s8 rssi; 474 474 __u8 data[240]; 475 475 } __attribute__ ((packed)); ··· 477 477 #define HCI_EV_CONN_COMPLETE 0x03 478 478 struct hci_ev_conn_complete { 479 479 __u8 status; 480 - __u16 handle; 480 + __le16 handle; 481 481 bdaddr_t bdaddr; 482 482 __u8 link_type; 483 483 __u8 encr_mode; ··· 493 493 #define HCI_EV_DISCONN_COMPLETE 0x05 494 494 struct hci_ev_disconn_complete { 495 495 __u8 status; 496 - __u16 handle; 496 + __le16 handle; 497 497 __u8 reason; 498 498 } __attribute__ ((packed)); 499 499 500 500 #define HCI_EV_AUTH_COMPLETE 0x06 501 501 struct hci_ev_auth_complete { 502 502 __u8 status; 503 - __u16 handle; 503 + __le16 handle; 504 504 } __attribute__ ((packed)); 505 505 506 506 #define HCI_EV_ENCRYPT_CHANGE 0x08 507 507 struct hci_ev_encrypt_change { 508 508 __u8 status; 509 - __u16 handle; 509 + __le16 handle; 510 510 __u8 encrypt; 511 511 } __attribute__ ((packed)); 512 512 513 513 #define HCI_EV_CHANGE_CONN_LINK_KEY_COMPLETE 0x09 514 514 struct hci_ev_change_conn_link_key_complete { 515 515 __u8 status; 516 - __u16 handle; 516 + __le16 handle; 517 517 } __attribute__ ((packed)); 518 518 519 519 #define HCI_EV_QOS_SETUP_COMPLETE 0x0D ··· 526 526 } __attribute__ ((packed)); 527 527 struct hci_ev_qos_setup_complete { 528 528 __u8 status; 529 - __u16 handle; 529 + __le16 handle; 530 530 struct hci_qos qos; 531 531 } __attribute__ ((packed)); 532 532 533 533 #define HCI_EV_CMD_COMPLETE 0x0E 534 534 struct hci_ev_cmd_complete { 535 535 __u8 ncmd; 536 - __u16 opcode; 536 + __le16 opcode; 537 537 } __attribute__ ((packed)); 538 538 539 539 #define HCI_EV_CMD_STATUS 0x0F 540 540 struct hci_ev_cmd_status { 541 541 __u8 status; 542 542 __u8 ncmd; 543 - __u16 opcode; 543 + __le16 opcode; 544 544 } __attribute__ ((packed)); 545 545 546 546 #define HCI_EV_NUM_COMP_PKTS 0x13 ··· 559 559 #define HCI_EV_MODE_CHANGE 0x14 560 560 struct hci_ev_mode_change { 561 561 __u8 status; 562 - __u16 handle; 562 + __le16 handle; 563 563 __u8 mode; 564 - __u16 interval; 564 + __le16 interval; 565 565 } __attribute__ ((packed)); 566 566 567 567 #define HCI_EV_PIN_CODE_REQ 0x16 ··· 584 584 #define HCI_EV_RMT_FEATURES 0x0B 585 585 struct hci_ev_rmt_features { 586 586 __u8 status; 587 - __u16 handle; 587 + __le16 handle; 588 588 __u8 features[8]; 589 589 } __attribute__ ((packed)); 590 590 591 591 #define HCI_EV_RMT_VERSION 0x0C 592 592 struct hci_ev_rmt_version { 593 593 __u8 status; 594 - __u16 handle; 594 + __le16 handle; 595 595 __u8 lmp_ver; 596 - __u16 manufacturer; 597 - __u16 lmp_subver; 596 + __le16 manufacturer; 597 + __le16 lmp_subver; 598 598 } __attribute__ ((packed)); 599 599 600 600 #define HCI_EV_CLOCK_OFFSET 0x01C 601 601 struct hci_ev_clock_offset { 602 602 __u8 status; 603 - __u16 handle; 604 - __u16 clock_offset; 603 + __le16 handle; 604 + __le16 clock_offset; 605 605 } __attribute__ ((packed)); 606 606 607 607 #define HCI_EV_PSCAN_REP_MODE 0x20 ··· 638 638 #define HCI_SCO_HDR_SIZE 3 639 639 640 640 struct hci_command_hdr { 641 - __u16 opcode; /* OCF & OGF */ 641 + __le16 opcode; /* OCF & OGF */ 642 642 __u8 plen; 643 643 } __attribute__ ((packed)); 644 644 ··· 648 648 } __attribute__ ((packed)); 649 649 650 650 struct hci_acl_hdr { 651 - __u16 handle; /* Handle & Flags(PB, BC) */ 652 - __u16 dlen; 651 + __le16 handle; /* Handle & Flags(PB, BC) */ 652 + __le16 dlen; 653 653 } __attribute__ ((packed)); 654 654 655 655 struct hci_sco_hdr { 656 - __u16 handle; 656 + __le16 handle; 657 657 __u8 dlen; 658 658 } __attribute__ ((packed)); 659 659 660 660 /* Command opcode pack/unpack */ 661 - #define hci_opcode_pack(ogf, ocf) (__u16)((ocf & 0x03ff)|(ogf << 10)) 661 + #define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10)) 662 662 #define hci_opcode_ogf(op) (op >> 10) 663 663 #define hci_opcode_ocf(op) (op & 0x03ff) 664 664 665 665 /* ACL handle and flags pack/unpack */ 666 - #define hci_handle_pack(h, f) (__u16)((h & 0x0fff)|(f << 12)) 666 + #define hci_handle_pack(h, f) (__u16) ((h & 0x0fff)|(f << 12)) 667 667 #define hci_handle(h) (h & 0x0fff) 668 668 #define hci_flags(h) (h >> 12) 669 669
+1 -1
include/net/bluetooth/hci_core.h
··· 44 44 __u8 pscan_period_mode; 45 45 __u8 pscan_mode; 46 46 __u8 dev_class[3]; 47 - __u16 clock_offset; 47 + __le16 clock_offset; 48 48 __s8 rssi; 49 49 }; 50 50
+1 -1
net/bluetooth/hci_core.c
··· 183 183 static void hci_init_req(struct hci_dev *hdev, unsigned long opt) 184 184 { 185 185 struct sk_buff *skb; 186 - __u16 param; 186 + __le16 param; 187 187 188 188 BT_DBG("%s %ld", hdev->name, opt); 189 189
+3 -3
net/bluetooth/hci_event.c
··· 242 242 break; 243 243 244 244 status = *((__u8 *) skb->data); 245 - setting = __le16_to_cpu(get_unaligned((__u16 *) sent)); 245 + setting = __le16_to_cpu(get_unaligned((__le16 *) sent)); 246 246 247 247 if (!status && hdev->voice_setting != setting) { 248 248 hdev->voice_setting = setting; ··· 728 728 static inline void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *skb) 729 729 { 730 730 struct hci_ev_num_comp_pkts *ev = (struct hci_ev_num_comp_pkts *) skb->data; 731 - __u16 *ptr; 731 + __le16 *ptr; 732 732 int i; 733 733 734 734 skb_pull(skb, sizeof(*ev)); ··· 742 742 743 743 tasklet_disable(&hdev->tx_task); 744 744 745 - for (i = 0, ptr = (__u16 *) skb->data; i < ev->num_hndl; i++) { 745 + for (i = 0, ptr = (__le16 *) skb->data; i < ev->num_hndl; i++) { 746 746 struct hci_conn *conn; 747 747 __u16 handle, count; 748 748
+1 -1
net/bluetooth/hci_sock.c
··· 416 416 skb->dev = (void *) hdev; 417 417 418 418 if (bt_cb(skb)->pkt_type == HCI_COMMAND_PKT) { 419 - u16 opcode = __le16_to_cpu(get_unaligned((u16 *)skb->data)); 419 + u16 opcode = __le16_to_cpu(get_unaligned((__le16 *) skb->data)); 420 420 u16 ogf = hci_opcode_ogf(opcode); 421 421 u16 ocf = hci_opcode_ocf(opcode); 422 422