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

[Bluetooth] Switch from OGF+OCF to using only opcodes

The Bluetooth HCI commands are divided into logical OGF groups for
easier identification of their purposes. While this still makes sense
for the written specification, its makes the code only more complex
and harder to read. So instead of using separate OGF and OCF values
to identify the commands, use a common 16-bit opcode that combines
both values. As a side effect this also reduces the complexity of
OGF and OCF calculations during command header parsing.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

authored by

Marcel Holtmann and committed by
David S. Miller
a9de9248 55b70a03

+1589 -1306
+2 -1
drivers/bluetooth/hci_bcsp.c
··· 237 237 if (hciextn && chan == 5) { 238 238 struct hci_command_hdr *hdr = (struct hci_command_hdr *) data; 239 239 240 - if (hci_opcode_ogf(__le16_to_cpu(hdr->opcode)) == OGF_VENDOR_CMD) { 240 + /* Vendor specific commands */ 241 + if (hci_opcode_ogf(__le16_to_cpu(hdr->opcode)) == 0x3f) { 241 242 u8 desc = *(data + HCI_COMMAND_HDR_SIZE); 242 243 if ((desc & 0xf0) == 0xc0) { 243 244 data += HCI_COMMAND_HDR_SIZE + 1;
+491 -393
include/net/bluetooth/hci.h
··· 200 200 #define HCI_LM_SECURE 0x0020 201 201 202 202 /* ----- HCI Commands ---- */ 203 - /* OGF & OCF values */ 204 - 205 - /* Informational Parameters */ 206 - #define OGF_INFO_PARAM 0x04 207 - 208 - #define OCF_READ_LOCAL_VERSION 0x0001 209 - struct hci_rp_read_loc_version { 210 - __u8 status; 211 - __u8 hci_ver; 212 - __le16 hci_rev; 213 - __u8 lmp_ver; 214 - __le16 manufacturer; 215 - __le16 lmp_subver; 203 + #define HCI_OP_INQUIRY 0x0401 204 + struct hci_cp_inquiry { 205 + __u8 lap[3]; 206 + __u8 length; 207 + __u8 num_rsp; 216 208 } __attribute__ ((packed)); 217 209 218 - #define OCF_READ_LOCAL_FEATURES 0x0003 219 - struct hci_rp_read_local_features { 220 - __u8 status; 221 - __u8 features[8]; 210 + #define HCI_OP_INQUIRY_CANCEL 0x0402 211 + 212 + #define HCI_OP_EXIT_PERIODIC_INQ 0x0404 213 + 214 + #define HCI_OP_CREATE_CONN 0x0405 215 + struct hci_cp_create_conn { 216 + bdaddr_t bdaddr; 217 + __le16 pkt_type; 218 + __u8 pscan_rep_mode; 219 + __u8 pscan_mode; 220 + __le16 clock_offset; 221 + __u8 role_switch; 222 222 } __attribute__ ((packed)); 223 223 224 - #define OCF_READ_BUFFER_SIZE 0x0005 225 - struct hci_rp_read_buffer_size { 226 - __u8 status; 227 - __le16 acl_mtu; 228 - __u8 sco_mtu; 229 - __le16 acl_max_pkt; 230 - __le16 sco_max_pkt; 224 + #define HCI_OP_DISCONNECT 0x0406 225 + struct hci_cp_disconnect { 226 + __le16 handle; 227 + __u8 reason; 231 228 } __attribute__ ((packed)); 232 229 233 - #define OCF_READ_BD_ADDR 0x0009 234 - struct hci_rp_read_bd_addr { 235 - __u8 status; 230 + #define HCI_OP_ADD_SCO 0x0407 231 + struct hci_cp_add_sco { 232 + __le16 handle; 233 + __le16 pkt_type; 234 + } __attribute__ ((packed)); 235 + 236 + #define HCI_OP_CREATE_CONN_CANCEL 0x0408 237 + struct hci_cp_create_conn_cancel { 236 238 bdaddr_t bdaddr; 237 239 } __attribute__ ((packed)); 238 240 239 - /* Host Controller and Baseband */ 240 - #define OGF_HOST_CTL 0x03 241 - #define OCF_RESET 0x0003 242 - #define OCF_READ_AUTH_ENABLE 0x001F 243 - #define OCF_WRITE_AUTH_ENABLE 0x0020 244 - #define AUTH_DISABLED 0x00 245 - #define AUTH_ENABLED 0x01 241 + #define HCI_OP_ACCEPT_CONN_REQ 0x0409 242 + struct hci_cp_accept_conn_req { 243 + bdaddr_t bdaddr; 244 + __u8 role; 245 + } __attribute__ ((packed)); 246 246 247 - #define OCF_READ_ENCRYPT_MODE 0x0021 248 - #define OCF_WRITE_ENCRYPT_MODE 0x0022 249 - #define ENCRYPT_DISABLED 0x00 250 - #define ENCRYPT_P2P 0x01 251 - #define ENCRYPT_BOTH 0x02 247 + #define HCI_OP_REJECT_CONN_REQ 0x040a 248 + struct hci_cp_reject_conn_req { 249 + bdaddr_t bdaddr; 250 + __u8 reason; 251 + } __attribute__ ((packed)); 252 252 253 - #define OCF_WRITE_CA_TIMEOUT 0x0016 254 - #define OCF_WRITE_PG_TIMEOUT 0x0018 253 + #define HCI_OP_LINK_KEY_REPLY 0x040b 254 + struct hci_cp_link_key_reply { 255 + bdaddr_t bdaddr; 256 + __u8 link_key[16]; 257 + } __attribute__ ((packed)); 255 258 256 - #define OCF_WRITE_SCAN_ENABLE 0x001A 257 - #define SCAN_DISABLED 0x00 258 - #define SCAN_INQUIRY 0x01 259 - #define SCAN_PAGE 0x02 259 + #define HCI_OP_LINK_KEY_NEG_REPLY 0x040c 260 + struct hci_cp_link_key_neg_reply { 261 + bdaddr_t bdaddr; 262 + } __attribute__ ((packed)); 260 263 261 - #define OCF_SET_EVENT_FLT 0x0005 264 + #define HCI_OP_PIN_CODE_REPLY 0x040d 265 + struct hci_cp_pin_code_reply { 266 + bdaddr_t bdaddr; 267 + __u8 pin_len; 268 + __u8 pin_code[16]; 269 + } __attribute__ ((packed)); 270 + 271 + #define HCI_OP_PIN_CODE_NEG_REPLY 0x040e 272 + struct hci_cp_pin_code_neg_reply { 273 + bdaddr_t bdaddr; 274 + } __attribute__ ((packed)); 275 + 276 + #define HCI_OP_CHANGE_CONN_PTYPE 0x040f 277 + struct hci_cp_change_conn_ptype { 278 + __le16 handle; 279 + __le16 pkt_type; 280 + } __attribute__ ((packed)); 281 + 282 + #define HCI_OP_AUTH_REQUESTED 0x0411 283 + struct hci_cp_auth_requested { 284 + __le16 handle; 285 + } __attribute__ ((packed)); 286 + 287 + #define HCI_OP_SET_CONN_ENCRYPT 0x0413 288 + struct hci_cp_set_conn_encrypt { 289 + __le16 handle; 290 + __u8 encrypt; 291 + } __attribute__ ((packed)); 292 + 293 + #define HCI_OP_CHANGE_CONN_LINK_KEY 0x0415 294 + struct hci_cp_change_conn_link_key { 295 + __le16 handle; 296 + } __attribute__ ((packed)); 297 + 298 + #define HCI_OP_REMOTE_NAME_REQ 0x0419 299 + struct hci_cp_remote_name_req { 300 + bdaddr_t bdaddr; 301 + __u8 pscan_rep_mode; 302 + __u8 pscan_mode; 303 + __le16 clock_offset; 304 + } __attribute__ ((packed)); 305 + 306 + #define HCI_OP_REMOTE_NAME_REQ_CANCEL 0x041a 307 + struct hci_cp_remote_name_req_cancel { 308 + bdaddr_t bdaddr; 309 + } __attribute__ ((packed)); 310 + 311 + #define HCI_OP_READ_REMOTE_FEATURES 0x041b 312 + struct hci_cp_read_remote_features { 313 + __le16 handle; 314 + } __attribute__ ((packed)); 315 + 316 + #define HCI_OP_READ_REMOTE_EXT_FEATURES 0x041c 317 + struct hci_cp_read_remote_ext_features { 318 + __le16 handle; 319 + __u8 page; 320 + } __attribute__ ((packed)); 321 + 322 + #define HCI_OP_READ_REMOTE_VERSION 0x041d 323 + struct hci_cp_read_remote_version { 324 + __le16 handle; 325 + } __attribute__ ((packed)); 326 + 327 + #define HCI_OP_SETUP_SYNC_CONN 0x0428 328 + struct hci_cp_setup_sync_conn { 329 + __le16 handle; 330 + __le32 tx_bandwidth; 331 + __le32 rx_bandwidth; 332 + __le16 max_latency; 333 + __le16 voice_setting; 334 + __u8 retrans_effort; 335 + __le16 pkt_type; 336 + } __attribute__ ((packed)); 337 + 338 + #define HCI_OP_ACCEPT_SYNC_CONN_REQ 0x0429 339 + struct hci_cp_accept_sync_conn_req { 340 + bdaddr_t bdaddr; 341 + __le32 tx_bandwidth; 342 + __le32 rx_bandwidth; 343 + __le16 max_latency; 344 + __le16 content_format; 345 + __u8 retrans_effort; 346 + __le16 pkt_type; 347 + } __attribute__ ((packed)); 348 + 349 + #define HCI_OP_REJECT_SYNC_CONN_REQ 0x042a 350 + struct hci_cp_reject_sync_conn_req { 351 + bdaddr_t bdaddr; 352 + __u8 reason; 353 + } __attribute__ ((packed)); 354 + 355 + #define HCI_OP_SNIFF_MODE 0x0803 356 + struct hci_cp_sniff_mode { 357 + __le16 handle; 358 + __le16 max_interval; 359 + __le16 min_interval; 360 + __le16 attempt; 361 + __le16 timeout; 362 + } __attribute__ ((packed)); 363 + 364 + #define HCI_OP_EXIT_SNIFF_MODE 0x0804 365 + struct hci_cp_exit_sniff_mode { 366 + __le16 handle; 367 + } __attribute__ ((packed)); 368 + 369 + #define HCI_OP_ROLE_DISCOVERY 0x0809 370 + struct hci_cp_role_discovery { 371 + __le16 handle; 372 + } __attribute__ ((packed)); 373 + struct hci_rp_role_discovery { 374 + __u8 status; 375 + __le16 handle; 376 + __u8 role; 377 + } __attribute__ ((packed)); 378 + 379 + #define HCI_OP_SWITCH_ROLE 0x080b 380 + struct hci_cp_switch_role { 381 + bdaddr_t bdaddr; 382 + __u8 role; 383 + } __attribute__ ((packed)); 384 + 385 + #define HCI_OP_READ_LINK_POLICY 0x080c 386 + struct hci_cp_read_link_policy { 387 + __le16 handle; 388 + } __attribute__ ((packed)); 389 + struct hci_rp_read_link_policy { 390 + __u8 status; 391 + __le16 handle; 392 + __le16 policy; 393 + } __attribute__ ((packed)); 394 + 395 + #define HCI_OP_WRITE_LINK_POLICY 0x080d 396 + struct hci_cp_write_link_policy { 397 + __le16 handle; 398 + __le16 policy; 399 + } __attribute__ ((packed)); 400 + struct hci_rp_write_link_policy { 401 + __u8 status; 402 + __le16 handle; 403 + } __attribute__ ((packed)); 404 + 405 + #define HCI_OP_SNIFF_SUBRATE 0x0811 406 + struct hci_cp_sniff_subrate { 407 + __le16 handle; 408 + __le16 max_latency; 409 + __le16 min_remote_timeout; 410 + __le16 min_local_timeout; 411 + } __attribute__ ((packed)); 412 + 413 + #define HCI_OP_SET_EVENT_MASK 0x0c01 414 + struct hci_cp_set_event_mask { 415 + __u8 mask[8]; 416 + } __attribute__ ((packed)); 417 + 418 + #define HCI_OP_RESET 0x0c03 419 + 420 + #define HCI_OP_SET_EVENT_FLT 0x0c05 262 421 struct hci_cp_set_event_flt { 263 422 __u8 flt_type; 264 423 __u8 cond_type; ··· 438 279 #define HCI_CONN_SETUP_AUTO_OFF 0x01 439 280 #define HCI_CONN_SETUP_AUTO_ON 0x02 440 281 441 - #define OCF_READ_CLASS_OF_DEV 0x0023 442 - struct hci_rp_read_dev_class { 282 + #define HCI_OP_WRITE_LOCAL_NAME 0x0c13 283 + struct hci_cp_write_local_name { 284 + __u8 name[248]; 285 + } __attribute__ ((packed)); 286 + 287 + #define HCI_OP_READ_LOCAL_NAME 0x0c14 288 + struct hci_rp_read_local_name { 289 + __u8 status; 290 + __u8 name[248]; 291 + } __attribute__ ((packed)); 292 + 293 + #define HCI_OP_WRITE_CA_TIMEOUT 0x0c16 294 + 295 + #define HCI_OP_WRITE_PG_TIMEOUT 0x0c18 296 + 297 + #define HCI_OP_WRITE_SCAN_ENABLE 0x0c1a 298 + #define SCAN_DISABLED 0x00 299 + #define SCAN_INQUIRY 0x01 300 + #define SCAN_PAGE 0x02 301 + 302 + #define HCI_OP_READ_AUTH_ENABLE 0x0c1f 303 + 304 + #define HCI_OP_WRITE_AUTH_ENABLE 0x0c20 305 + #define AUTH_DISABLED 0x00 306 + #define AUTH_ENABLED 0x01 307 + 308 + #define HCI_OP_READ_ENCRYPT_MODE 0x0c21 309 + 310 + #define HCI_OP_WRITE_ENCRYPT_MODE 0x0c22 311 + #define ENCRYPT_DISABLED 0x00 312 + #define ENCRYPT_P2P 0x01 313 + #define ENCRYPT_BOTH 0x02 314 + 315 + #define HCI_OP_READ_CLASS_OF_DEV 0x0c23 316 + struct hci_rp_read_class_of_dev { 443 317 __u8 status; 444 318 __u8 dev_class[3]; 445 319 } __attribute__ ((packed)); 446 320 447 - #define OCF_WRITE_CLASS_OF_DEV 0x0024 448 - struct hci_cp_write_dev_class { 321 + #define HCI_OP_WRITE_CLASS_OF_DEV 0x0c24 322 + struct hci_cp_write_class_of_dev { 449 323 __u8 dev_class[3]; 450 324 } __attribute__ ((packed)); 451 325 452 - #define OCF_READ_VOICE_SETTING 0x0025 326 + #define HCI_OP_READ_VOICE_SETTING 0x0c25 453 327 struct hci_rp_read_voice_setting { 454 328 __u8 status; 455 329 __le16 voice_setting; 456 330 } __attribute__ ((packed)); 457 331 458 - #define OCF_WRITE_VOICE_SETTING 0x0026 332 + #define HCI_OP_WRITE_VOICE_SETTING 0x0c26 459 333 struct hci_cp_write_voice_setting { 460 334 __le16 voice_setting; 461 335 } __attribute__ ((packed)); 462 336 463 - #define OCF_HOST_BUFFER_SIZE 0x0033 337 + #define HCI_OP_HOST_BUFFER_SIZE 0x0c33 464 338 struct hci_cp_host_buffer_size { 465 339 __le16 acl_mtu; 466 340 __u8 sco_mtu; ··· 501 309 __le16 sco_max_pkt; 502 310 } __attribute__ ((packed)); 503 311 504 - /* Link Control */ 505 - #define OGF_LINK_CTL 0x01 506 - 507 - #define OCF_CREATE_CONN 0x0005 508 - struct hci_cp_create_conn { 509 - bdaddr_t bdaddr; 510 - __le16 pkt_type; 511 - __u8 pscan_rep_mode; 512 - __u8 pscan_mode; 513 - __le16 clock_offset; 514 - __u8 role_switch; 515 - } __attribute__ ((packed)); 516 - 517 - #define OCF_CREATE_CONN_CANCEL 0x0008 518 - struct hci_cp_create_conn_cancel { 519 - bdaddr_t bdaddr; 520 - } __attribute__ ((packed)); 521 - 522 - #define OCF_ACCEPT_CONN_REQ 0x0009 523 - struct hci_cp_accept_conn_req { 524 - bdaddr_t bdaddr; 525 - __u8 role; 526 - } __attribute__ ((packed)); 527 - 528 - #define OCF_REJECT_CONN_REQ 0x000a 529 - struct hci_cp_reject_conn_req { 530 - bdaddr_t bdaddr; 531 - __u8 reason; 532 - } __attribute__ ((packed)); 533 - 534 - #define OCF_DISCONNECT 0x0006 535 - struct hci_cp_disconnect { 536 - __le16 handle; 537 - __u8 reason; 538 - } __attribute__ ((packed)); 539 - 540 - #define OCF_ADD_SCO 0x0007 541 - struct hci_cp_add_sco { 542 - __le16 handle; 543 - __le16 pkt_type; 544 - } __attribute__ ((packed)); 545 - 546 - #define OCF_INQUIRY 0x0001 547 - struct hci_cp_inquiry { 548 - __u8 lap[3]; 549 - __u8 length; 550 - __u8 num_rsp; 551 - } __attribute__ ((packed)); 552 - 553 - #define OCF_INQUIRY_CANCEL 0x0002 554 - 555 - #define OCF_EXIT_PERIODIC_INQ 0x0004 556 - 557 - #define OCF_LINK_KEY_REPLY 0x000B 558 - struct hci_cp_link_key_reply { 559 - bdaddr_t bdaddr; 560 - __u8 link_key[16]; 561 - } __attribute__ ((packed)); 562 - 563 - #define OCF_LINK_KEY_NEG_REPLY 0x000C 564 - struct hci_cp_link_key_neg_reply { 565 - bdaddr_t bdaddr; 566 - } __attribute__ ((packed)); 567 - 568 - #define OCF_PIN_CODE_REPLY 0x000D 569 - struct hci_cp_pin_code_reply { 570 - bdaddr_t bdaddr; 571 - __u8 pin_len; 572 - __u8 pin_code[16]; 573 - } __attribute__ ((packed)); 574 - 575 - #define OCF_PIN_CODE_NEG_REPLY 0x000E 576 - struct hci_cp_pin_code_neg_reply { 577 - bdaddr_t bdaddr; 578 - } __attribute__ ((packed)); 579 - 580 - #define OCF_CHANGE_CONN_PTYPE 0x000F 581 - struct hci_cp_change_conn_ptype { 582 - __le16 handle; 583 - __le16 pkt_type; 584 - } __attribute__ ((packed)); 585 - 586 - #define OCF_AUTH_REQUESTED 0x0011 587 - struct hci_cp_auth_requested { 588 - __le16 handle; 589 - } __attribute__ ((packed)); 590 - 591 - #define OCF_SET_CONN_ENCRYPT 0x0013 592 - struct hci_cp_set_conn_encrypt { 593 - __le16 handle; 594 - __u8 encrypt; 595 - } __attribute__ ((packed)); 596 - 597 - #define OCF_CHANGE_CONN_LINK_KEY 0x0015 598 - struct hci_cp_change_conn_link_key { 599 - __le16 handle; 600 - } __attribute__ ((packed)); 601 - 602 - #define OCF_READ_REMOTE_FEATURES 0x001B 603 - struct hci_cp_read_remote_features { 604 - __le16 handle; 605 - } __attribute__ ((packed)); 606 - 607 - #define OCF_READ_REMOTE_VERSION 0x001D 608 - struct hci_cp_read_remote_version { 609 - __le16 handle; 610 - } __attribute__ ((packed)); 611 - 612 - /* Link Policy */ 613 - #define OGF_LINK_POLICY 0x02 614 - 615 - #define OCF_SNIFF_MODE 0x0003 616 - struct hci_cp_sniff_mode { 617 - __le16 handle; 618 - __le16 max_interval; 619 - __le16 min_interval; 620 - __le16 attempt; 621 - __le16 timeout; 622 - } __attribute__ ((packed)); 623 - 624 - #define OCF_EXIT_SNIFF_MODE 0x0004 625 - struct hci_cp_exit_sniff_mode { 626 - __le16 handle; 627 - } __attribute__ ((packed)); 628 - 629 - #define OCF_ROLE_DISCOVERY 0x0009 630 - struct hci_cp_role_discovery { 631 - __le16 handle; 632 - } __attribute__ ((packed)); 633 - struct hci_rp_role_discovery { 312 + #define HCI_OP_READ_LOCAL_VERSION 0x1001 313 + struct hci_rp_read_local_version { 634 314 __u8 status; 635 - __le16 handle; 636 - __u8 role; 315 + __u8 hci_ver; 316 + __le16 hci_rev; 317 + __u8 lmp_ver; 318 + __le16 manufacturer; 319 + __le16 lmp_subver; 637 320 } __attribute__ ((packed)); 638 321 639 - #define OCF_READ_LINK_POLICY 0x000C 640 - struct hci_cp_read_link_policy { 641 - __le16 handle; 642 - } __attribute__ ((packed)); 643 - struct hci_rp_read_link_policy { 322 + #define HCI_OP_READ_LOCAL_COMMANDS 0x1002 323 + struct hci_rp_read_local_commands { 644 324 __u8 status; 645 - __le16 handle; 646 - __le16 policy; 325 + __u8 commands[64]; 647 326 } __attribute__ ((packed)); 648 327 649 - #define OCF_SWITCH_ROLE 0x000B 650 - struct hci_cp_switch_role { 328 + #define HCI_OP_READ_LOCAL_FEATURES 0x1003 329 + struct hci_rp_read_local_features { 330 + __u8 status; 331 + __u8 features[8]; 332 + } __attribute__ ((packed)); 333 + 334 + #define HCI_OP_READ_LOCAL_EXT_FEATURES 0x1004 335 + struct hci_rp_read_local_ext_features { 336 + __u8 status; 337 + __u8 page; 338 + __u8 max_page; 339 + __u8 features[8]; 340 + } __attribute__ ((packed)); 341 + 342 + #define HCI_OP_READ_BUFFER_SIZE 0x1005 343 + struct hci_rp_read_buffer_size { 344 + __u8 status; 345 + __le16 acl_mtu; 346 + __u8 sco_mtu; 347 + __le16 acl_max_pkt; 348 + __le16 sco_max_pkt; 349 + } __attribute__ ((packed)); 350 + 351 + #define HCI_OP_READ_BD_ADDR 0x1009 352 + struct hci_rp_read_bd_addr { 353 + __u8 status; 651 354 bdaddr_t bdaddr; 652 - __u8 role; 653 355 } __attribute__ ((packed)); 654 - 655 - #define OCF_WRITE_LINK_POLICY 0x000D 656 - struct hci_cp_write_link_policy { 657 - __le16 handle; 658 - __le16 policy; 659 - } __attribute__ ((packed)); 660 - struct hci_rp_write_link_policy { 661 - __u8 status; 662 - __le16 handle; 663 - } __attribute__ ((packed)); 664 - 665 - #define OCF_SNIFF_SUBRATE 0x0011 666 - struct hci_cp_sniff_subrate { 667 - __le16 handle; 668 - __le16 max_latency; 669 - __le16 min_remote_timeout; 670 - __le16 min_local_timeout; 671 - } __attribute__ ((packed)); 672 - 673 - /* Status params */ 674 - #define OGF_STATUS_PARAM 0x05 675 - 676 - /* Testing commands */ 677 - #define OGF_TESTING_CMD 0x3E 678 - 679 - /* Vendor specific commands */ 680 - #define OGF_VENDOR_CMD 0x3F 681 356 682 357 /* ---- HCI Events ---- */ 683 - #define HCI_EV_INQUIRY_COMPLETE 0x01 358 + #define HCI_EV_INQUIRY_COMPLETE 0x01 684 359 685 - #define HCI_EV_INQUIRY_RESULT 0x02 360 + #define HCI_EV_INQUIRY_RESULT 0x02 686 361 struct inquiry_info { 687 362 bdaddr_t bdaddr; 688 363 __u8 pscan_rep_mode; ··· 557 498 __u8 pscan_mode; 558 499 __u8 dev_class[3]; 559 500 __le16 clock_offset; 501 + } __attribute__ ((packed)); 502 + 503 + #define HCI_EV_CONN_COMPLETE 0x03 504 + struct hci_ev_conn_complete { 505 + __u8 status; 506 + __le16 handle; 507 + bdaddr_t bdaddr; 508 + __u8 link_type; 509 + __u8 encr_mode; 510 + } __attribute__ ((packed)); 511 + 512 + #define HCI_EV_CONN_REQUEST 0x04 513 + struct hci_ev_conn_request { 514 + bdaddr_t bdaddr; 515 + __u8 dev_class[3]; 516 + __u8 link_type; 517 + } __attribute__ ((packed)); 518 + 519 + #define HCI_EV_DISCONN_COMPLETE 0x05 520 + struct hci_ev_disconn_complete { 521 + __u8 status; 522 + __le16 handle; 523 + __u8 reason; 524 + } __attribute__ ((packed)); 525 + 526 + #define HCI_EV_AUTH_COMPLETE 0x06 527 + struct hci_ev_auth_complete { 528 + __u8 status; 529 + __le16 handle; 530 + } __attribute__ ((packed)); 531 + 532 + #define HCI_EV_REMOTE_NAME 0x07 533 + struct hci_ev_remote_name { 534 + __u8 status; 535 + bdaddr_t bdaddr; 536 + __u8 name[248]; 537 + } __attribute__ ((packed)); 538 + 539 + #define HCI_EV_ENCRYPT_CHANGE 0x08 540 + struct hci_ev_encrypt_change { 541 + __u8 status; 542 + __le16 handle; 543 + __u8 encrypt; 544 + } __attribute__ ((packed)); 545 + 546 + #define HCI_EV_CHANGE_LINK_KEY_COMPLETE 0x09 547 + struct hci_ev_change_link_key_complete { 548 + __u8 status; 549 + __le16 handle; 550 + } __attribute__ ((packed)); 551 + 552 + #define HCI_EV_REMOTE_FEATURES 0x0b 553 + struct hci_ev_remote_features { 554 + __u8 status; 555 + __le16 handle; 556 + __u8 features[8]; 557 + } __attribute__ ((packed)); 558 + 559 + #define HCI_EV_REMOTE_VERSION 0x0c 560 + struct hci_ev_remote_version { 561 + __u8 status; 562 + __le16 handle; 563 + __u8 lmp_ver; 564 + __le16 manufacturer; 565 + __le16 lmp_subver; 566 + } __attribute__ ((packed)); 567 + 568 + #define HCI_EV_QOS_SETUP_COMPLETE 0x0d 569 + struct hci_qos { 570 + __u8 service_type; 571 + __u32 token_rate; 572 + __u32 peak_bandwidth; 573 + __u32 latency; 574 + __u32 delay_variation; 575 + } __attribute__ ((packed)); 576 + struct hci_ev_qos_setup_complete { 577 + __u8 status; 578 + __le16 handle; 579 + struct hci_qos qos; 580 + } __attribute__ ((packed)); 581 + 582 + #define HCI_EV_CMD_COMPLETE 0x0e 583 + struct hci_ev_cmd_complete { 584 + __u8 ncmd; 585 + __le16 opcode; 586 + } __attribute__ ((packed)); 587 + 588 + #define HCI_EV_CMD_STATUS 0x0f 589 + struct hci_ev_cmd_status { 590 + __u8 status; 591 + __u8 ncmd; 592 + __le16 opcode; 593 + } __attribute__ ((packed)); 594 + 595 + #define HCI_EV_ROLE_CHANGE 0x12 596 + struct hci_ev_role_change { 597 + __u8 status; 598 + bdaddr_t bdaddr; 599 + __u8 role; 600 + } __attribute__ ((packed)); 601 + 602 + #define HCI_EV_NUM_COMP_PKTS 0x13 603 + struct hci_ev_num_comp_pkts { 604 + __u8 num_hndl; 605 + /* variable length part */ 606 + } __attribute__ ((packed)); 607 + 608 + #define HCI_EV_MODE_CHANGE 0x14 609 + struct hci_ev_mode_change { 610 + __u8 status; 611 + __le16 handle; 612 + __u8 mode; 613 + __le16 interval; 614 + } __attribute__ ((packed)); 615 + 616 + #define HCI_EV_PIN_CODE_REQ 0x16 617 + struct hci_ev_pin_code_req { 618 + bdaddr_t bdaddr; 619 + } __attribute__ ((packed)); 620 + 621 + #define HCI_EV_LINK_KEY_REQ 0x17 622 + struct hci_ev_link_key_req { 623 + bdaddr_t bdaddr; 624 + } __attribute__ ((packed)); 625 + 626 + #define HCI_EV_LINK_KEY_NOTIFY 0x18 627 + struct hci_ev_link_key_notify { 628 + bdaddr_t bdaddr; 629 + __u8 link_key[16]; 630 + __u8 key_type; 631 + } __attribute__ ((packed)); 632 + 633 + #define HCI_EV_CLOCK_OFFSET 0x1c 634 + struct hci_ev_clock_offset { 635 + __u8 status; 636 + __le16 handle; 637 + __le16 clock_offset; 638 + } __attribute__ ((packed)); 639 + 640 + #define HCI_EV_PSCAN_REP_MODE 0x20 641 + struct hci_ev_pscan_rep_mode { 642 + bdaddr_t bdaddr; 643 + __u8 pscan_rep_mode; 560 644 } __attribute__ ((packed)); 561 645 562 646 #define HCI_EV_INQUIRY_RESULT_WITH_RSSI 0x22 ··· 721 519 __s8 rssi; 722 520 } __attribute__ ((packed)); 723 521 724 - #define HCI_EV_EXTENDED_INQUIRY_RESULT 0x2F 522 + #define HCI_EV_REMOTE_EXT_FEATURES 0x23 523 + struct hci_ev_remote_ext_features { 524 + __u8 status; 525 + __le16 handle; 526 + __u8 page; 527 + __u8 max_page; 528 + __u8 features[8]; 529 + } __attribute__ ((packed)); 530 + 531 + #define HCI_EV_SYNC_CONN_COMPLETE 0x2c 532 + struct hci_ev_sync_conn_complete { 533 + __u8 status; 534 + __le16 handle; 535 + bdaddr_t bdaddr; 536 + __u8 link_type; 537 + __u8 tx_interval; 538 + __u8 retrans_window; 539 + __le16 rx_pkt_len; 540 + __le16 tx_pkt_len; 541 + __u8 air_mode; 542 + } __attribute__ ((packed)); 543 + 544 + #define HCI_EV_SYNC_CONN_CHANGED 0x2d 545 + struct hci_ev_sync_conn_changed { 546 + __u8 status; 547 + __le16 handle; 548 + __u8 tx_interval; 549 + __u8 retrans_window; 550 + __le16 rx_pkt_len; 551 + __le16 tx_pkt_len; 552 + } __attribute__ ((packed)); 553 + 554 + #define HCI_EV_SNIFF_SUBRATE 0x2e 555 + struct hci_ev_sniff_subrate { 556 + __u8 status; 557 + __le16 handle; 558 + __le16 max_tx_latency; 559 + __le16 max_rx_latency; 560 + __le16 max_remote_timeout; 561 + __le16 max_local_timeout; 562 + } __attribute__ ((packed)); 563 + 564 + #define HCI_EV_EXTENDED_INQUIRY_RESULT 0x2f 725 565 struct extended_inquiry_info { 726 566 bdaddr_t bdaddr; 727 567 __u8 pscan_rep_mode; ··· 774 530 __u8 data[240]; 775 531 } __attribute__ ((packed)); 776 532 777 - #define HCI_EV_CONN_COMPLETE 0x03 778 - struct hci_ev_conn_complete { 779 - __u8 status; 780 - __le16 handle; 781 - bdaddr_t bdaddr; 782 - __u8 link_type; 783 - __u8 encr_mode; 784 - } __attribute__ ((packed)); 785 - 786 - #define HCI_EV_CONN_REQUEST 0x04 787 - struct hci_ev_conn_request { 788 - bdaddr_t bdaddr; 789 - __u8 dev_class[3]; 790 - __u8 link_type; 791 - } __attribute__ ((packed)); 792 - 793 - #define HCI_EV_DISCONN_COMPLETE 0x05 794 - struct hci_ev_disconn_complete { 795 - __u8 status; 796 - __le16 handle; 797 - __u8 reason; 798 - } __attribute__ ((packed)); 799 - 800 - #define HCI_EV_AUTH_COMPLETE 0x06 801 - struct hci_ev_auth_complete { 802 - __u8 status; 803 - __le16 handle; 804 - } __attribute__ ((packed)); 805 - 806 - #define HCI_EV_ENCRYPT_CHANGE 0x08 807 - struct hci_ev_encrypt_change { 808 - __u8 status; 809 - __le16 handle; 810 - __u8 encrypt; 811 - } __attribute__ ((packed)); 812 - 813 - #define HCI_EV_CHANGE_CONN_LINK_KEY_COMPLETE 0x09 814 - struct hci_ev_change_conn_link_key_complete { 815 - __u8 status; 816 - __le16 handle; 817 - } __attribute__ ((packed)); 818 - 819 - #define HCI_EV_QOS_SETUP_COMPLETE 0x0D 820 - struct hci_qos { 821 - __u8 service_type; 822 - __u32 token_rate; 823 - __u32 peak_bandwidth; 824 - __u32 latency; 825 - __u32 delay_variation; 826 - } __attribute__ ((packed)); 827 - struct hci_ev_qos_setup_complete { 828 - __u8 status; 829 - __le16 handle; 830 - struct hci_qos qos; 831 - } __attribute__ ((packed)); 832 - 833 - #define HCI_EV_CMD_COMPLETE 0x0E 834 - struct hci_ev_cmd_complete { 835 - __u8 ncmd; 836 - __le16 opcode; 837 - } __attribute__ ((packed)); 838 - 839 - #define HCI_EV_CMD_STATUS 0x0F 840 - struct hci_ev_cmd_status { 841 - __u8 status; 842 - __u8 ncmd; 843 - __le16 opcode; 844 - } __attribute__ ((packed)); 845 - 846 - #define HCI_EV_NUM_COMP_PKTS 0x13 847 - struct hci_ev_num_comp_pkts { 848 - __u8 num_hndl; 849 - /* variable length part */ 850 - } __attribute__ ((packed)); 851 - 852 - #define HCI_EV_ROLE_CHANGE 0x12 853 - struct hci_ev_role_change { 854 - __u8 status; 855 - bdaddr_t bdaddr; 856 - __u8 role; 857 - } __attribute__ ((packed)); 858 - 859 - #define HCI_EV_MODE_CHANGE 0x14 860 - struct hci_ev_mode_change { 861 - __u8 status; 862 - __le16 handle; 863 - __u8 mode; 864 - __le16 interval; 865 - } __attribute__ ((packed)); 866 - 867 - #define HCI_EV_PIN_CODE_REQ 0x16 868 - struct hci_ev_pin_code_req { 869 - bdaddr_t bdaddr; 870 - } __attribute__ ((packed)); 871 - 872 - #define HCI_EV_LINK_KEY_REQ 0x17 873 - struct hci_ev_link_key_req { 874 - bdaddr_t bdaddr; 875 - } __attribute__ ((packed)); 876 - 877 - #define HCI_EV_LINK_KEY_NOTIFY 0x18 878 - struct hci_ev_link_key_notify { 879 - bdaddr_t bdaddr; 880 - __u8 link_key[16]; 881 - __u8 key_type; 882 - } __attribute__ ((packed)); 883 - 884 - #define HCI_EV_REMOTE_FEATURES 0x0B 885 - struct hci_ev_remote_features { 886 - __u8 status; 887 - __le16 handle; 888 - __u8 features[8]; 889 - } __attribute__ ((packed)); 890 - 891 - #define HCI_EV_REMOTE_VERSION 0x0C 892 - struct hci_ev_remote_version { 893 - __u8 status; 894 - __le16 handle; 895 - __u8 lmp_ver; 896 - __le16 manufacturer; 897 - __le16 lmp_subver; 898 - } __attribute__ ((packed)); 899 - 900 - #define HCI_EV_CLOCK_OFFSET 0x01C 901 - struct hci_ev_clock_offset { 902 - __u8 status; 903 - __le16 handle; 904 - __le16 clock_offset; 905 - } __attribute__ ((packed)); 906 - 907 - #define HCI_EV_PSCAN_REP_MODE 0x20 908 - struct hci_ev_pscan_rep_mode { 909 - bdaddr_t bdaddr; 910 - __u8 pscan_rep_mode; 911 - } __attribute__ ((packed)); 912 - 913 - #define HCI_EV_SNIFF_SUBRATE 0x2E 914 - struct hci_ev_sniff_subrate { 915 - __u8 status; 916 - __le16 handle; 917 - __le16 max_tx_latency; 918 - __le16 max_rx_latency; 919 - __le16 max_remote_timeout; 920 - __le16 max_local_timeout; 921 - } __attribute__ ((packed)); 922 - 923 533 /* Internal events generated by Bluetooth stack */ 924 - #define HCI_EV_STACK_INTERNAL 0xFD 534 + #define HCI_EV_STACK_INTERNAL 0xfd 925 535 struct hci_ev_stack_internal { 926 536 __u16 type; 927 537 __u8 data[0]; 928 538 } __attribute__ ((packed)); 929 539 930 - #define HCI_EV_SI_DEVICE 0x01 540 + #define HCI_EV_SI_DEVICE 0x01 931 541 struct hci_ev_si_device { 932 542 __u16 event; 933 543 __u16 dev_id; ··· 802 704 #define HCI_SCO_HDR_SIZE 3 803 705 804 706 struct hci_command_hdr { 805 - __le16 opcode; /* OCF & OGF */ 707 + __le16 opcode; /* OCF & OGF */ 806 708 __u8 plen; 807 709 } __attribute__ ((packed)); 808 710 809 711 struct hci_event_hdr { 810 - __u8 evt; 811 - __u8 plen; 712 + __u8 evt; 713 + __u8 plen; 812 714 } __attribute__ ((packed)); 813 715 814 716 struct hci_acl_hdr { 815 - __le16 handle; /* Handle & Flags(PB, BC) */ 816 - __le16 dlen; 717 + __le16 handle; /* Handle & Flags(PB, BC) */ 718 + __le16 dlen; 817 719 } __attribute__ ((packed)); 818 720 819 721 struct hci_sco_hdr { 820 - __le16 handle; 821 - __u8 dlen; 722 + __le16 handle; 723 + __u8 dlen; 822 724 } __attribute__ ((packed)); 823 725 824 726 #ifdef __KERNEL__ 825 727 #include <linux/skbuff.h> 826 728 static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb) 827 729 { 828 - return (struct hci_event_hdr *)skb->data; 730 + return (struct hci_event_hdr *) skb->data; 829 731 } 830 732 831 733 static inline struct hci_acl_hdr *hci_acl_hdr(const struct sk_buff *skb) 832 734 { 833 - return (struct hci_acl_hdr *)skb->data; 735 + return (struct hci_acl_hdr *) skb->data; 834 736 } 835 737 836 738 static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb) 837 739 { 838 - return (struct hci_sco_hdr *)skb->data; 740 + return (struct hci_sco_hdr *) skb->data; 839 741 } 840 742 #endif 841 743 ··· 869 771 struct hci_filter { 870 772 unsigned long type_mask; 871 773 unsigned long event_mask[2]; 872 - __le16 opcode; 774 + __le16 opcode; 873 775 }; 874 776 875 777 struct hci_ufilter { 876 - __u32 type_mask; 877 - __u32 event_mask[2]; 878 - __le16 opcode; 778 + __u32 type_mask; 779 + __u32 event_mask[2]; 780 + __le16 opcode; 879 781 }; 880 782 881 783 #define HCI_FLT_TYPE_BITS 31 ··· 923 825 struct hci_conn_info { 924 826 __u16 handle; 925 827 bdaddr_t bdaddr; 926 - __u8 type; 927 - __u8 out; 928 - __u16 state; 929 - __u32 link_mode; 828 + __u8 type; 829 + __u8 out; 830 + __u16 state; 831 + __u32 link_mode; 930 832 }; 931 833 932 834 struct hci_dev_req { 933 - __u16 dev_id; 934 - __u32 dev_opt; 835 + __u16 dev_id; 836 + __u32 dev_opt; 935 837 }; 936 838 937 839 struct hci_dev_list_req {
+8 -4
include/net/bluetooth/hci_core.h
··· 71 71 __u16 id; 72 72 __u8 type; 73 73 bdaddr_t bdaddr; 74 + __u8 dev_name[248]; 75 + __u8 dev_class[3]; 74 76 __u8 features[8]; 77 + __u8 commands[64]; 75 78 __u8 hci_ver; 76 79 __u16 hci_rev; 77 80 __u16 manufacturer; ··· 315 312 void hci_add_sco(struct hci_conn *conn, __u16 handle); 316 313 317 314 struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst); 318 - int hci_conn_del(struct hci_conn *conn); 319 - void hci_conn_hash_flush(struct hci_dev *hdev); 315 + int hci_conn_del(struct hci_conn *conn); 316 + void hci_conn_hash_flush(struct hci_dev *hdev); 317 + void hci_conn_check_pending(struct hci_dev *hdev); 320 318 321 319 struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *src); 322 320 int hci_conn_auth(struct hci_conn *conn); ··· 621 617 int hci_register_notifier(struct notifier_block *nb); 622 618 int hci_unregister_notifier(struct notifier_block *nb); 623 619 624 - int hci_send_cmd(struct hci_dev *hdev, __u16 ogf, __u16 ocf, __u32 plen, void *param); 620 + int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, void *param); 625 621 int hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags); 626 622 int hci_send_sco(struct hci_conn *conn, struct sk_buff *skb); 627 623 628 - void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 ogf, __u16 ocf); 624 + void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 opcode); 629 625 630 626 void hci_si_event(struct hci_dev *hdev, int type, int dlen, void *data); 631 627
+27 -16
net/bluetooth/hci_conn.c
··· 82 82 else 83 83 cp.role_switch = 0x00; 84 84 85 - hci_send_cmd(hdev, OGF_LINK_CTL, OCF_CREATE_CONN, sizeof(cp), &cp); 85 + hci_send_cmd(hdev, HCI_OP_CREATE_CONN, sizeof(cp), &cp); 86 86 } 87 87 88 88 static void hci_acl_connect_cancel(struct hci_conn *conn) ··· 95 95 return; 96 96 97 97 bacpy(&cp.bdaddr, &conn->dst); 98 - hci_send_cmd(conn->hdev, OGF_LINK_CTL, 99 - OCF_CREATE_CONN_CANCEL, sizeof(cp), &cp); 98 + hci_send_cmd(conn->hdev, HCI_OP_CREATE_CONN_CANCEL, sizeof(cp), &cp); 100 99 } 101 100 102 101 void hci_acl_disconn(struct hci_conn *conn, __u8 reason) ··· 108 109 109 110 cp.handle = cpu_to_le16(conn->handle); 110 111 cp.reason = reason; 111 - hci_send_cmd(conn->hdev, OGF_LINK_CTL, 112 - OCF_DISCONNECT, sizeof(cp), &cp); 112 + hci_send_cmd(conn->hdev, HCI_OP_DISCONNECT, sizeof(cp), &cp); 113 113 } 114 114 115 115 void hci_add_sco(struct hci_conn *conn, __u16 handle) ··· 124 126 cp.handle = cpu_to_le16(handle); 125 127 cp.pkt_type = cpu_to_le16(hdev->pkt_type & SCO_PTYPE_MASK); 126 128 127 - hci_send_cmd(hdev, OGF_LINK_CTL, OCF_ADD_SCO, sizeof(cp), &cp); 129 + hci_send_cmd(hdev, HCI_OP_ADD_SCO, sizeof(cp), &cp); 128 130 } 129 131 130 132 static void hci_conn_timeout(unsigned long arg) ··· 346 348 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->pend)) { 347 349 struct hci_cp_auth_requested cp; 348 350 cp.handle = cpu_to_le16(conn->handle); 349 - hci_send_cmd(conn->hdev, OGF_LINK_CTL, OCF_AUTH_REQUESTED, sizeof(cp), &cp); 351 + hci_send_cmd(conn->hdev, HCI_OP_AUTH_REQUESTED, sizeof(cp), &cp); 350 352 } 351 353 return 0; 352 354 } ··· 367 369 struct hci_cp_set_conn_encrypt cp; 368 370 cp.handle = cpu_to_le16(conn->handle); 369 371 cp.encrypt = 1; 370 - hci_send_cmd(conn->hdev, OGF_LINK_CTL, OCF_SET_CONN_ENCRYPT, sizeof(cp), &cp); 372 + hci_send_cmd(conn->hdev, HCI_OP_SET_CONN_ENCRYPT, sizeof(cp), &cp); 371 373 } 372 374 return 0; 373 375 } ··· 381 383 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->pend)) { 382 384 struct hci_cp_change_conn_link_key cp; 383 385 cp.handle = cpu_to_le16(conn->handle); 384 - hci_send_cmd(conn->hdev, OGF_LINK_CTL, OCF_CHANGE_CONN_LINK_KEY, sizeof(cp), &cp); 386 + hci_send_cmd(conn->hdev, HCI_OP_CHANGE_CONN_LINK_KEY, sizeof(cp), &cp); 385 387 } 386 388 return 0; 387 389 } ··· 399 401 struct hci_cp_switch_role cp; 400 402 bacpy(&cp.bdaddr, &conn->dst); 401 403 cp.role = role; 402 - hci_send_cmd(conn->hdev, OGF_LINK_POLICY, OCF_SWITCH_ROLE, sizeof(cp), &cp); 404 + hci_send_cmd(conn->hdev, HCI_OP_SWITCH_ROLE, sizeof(cp), &cp); 403 405 } 404 406 return 0; 405 407 } ··· 421 423 if (!test_and_set_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->pend)) { 422 424 struct hci_cp_exit_sniff_mode cp; 423 425 cp.handle = cpu_to_le16(conn->handle); 424 - hci_send_cmd(hdev, OGF_LINK_POLICY, 425 - OCF_EXIT_SNIFF_MODE, sizeof(cp), &cp); 426 + hci_send_cmd(hdev, HCI_OP_EXIT_SNIFF_MODE, sizeof(cp), &cp); 426 427 } 427 428 428 429 timer: ··· 452 455 cp.max_latency = cpu_to_le16(0); 453 456 cp.min_remote_timeout = cpu_to_le16(0); 454 457 cp.min_local_timeout = cpu_to_le16(0); 455 - hci_send_cmd(hdev, OGF_LINK_POLICY, 456 - OCF_SNIFF_SUBRATE, sizeof(cp), &cp); 458 + hci_send_cmd(hdev, HCI_OP_SNIFF_SUBRATE, sizeof(cp), &cp); 457 459 } 458 460 459 461 if (!test_and_set_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->pend)) { ··· 462 466 cp.min_interval = cpu_to_le16(hdev->sniff_min_interval); 463 467 cp.attempt = cpu_to_le16(4); 464 468 cp.timeout = cpu_to_le16(1); 465 - hci_send_cmd(hdev, OGF_LINK_POLICY, 466 - OCF_SNIFF_MODE, sizeof(cp), &cp); 469 + hci_send_cmd(hdev, HCI_OP_SNIFF_MODE, sizeof(cp), &cp); 467 470 } 468 471 } 469 472 ··· 486 491 hci_proto_disconn_ind(c, 0x16); 487 492 hci_conn_del(c); 488 493 } 494 + } 495 + 496 + /* Check pending connect attempts */ 497 + void hci_conn_check_pending(struct hci_dev *hdev) 498 + { 499 + struct hci_conn *conn; 500 + 501 + BT_DBG("hdev %s", hdev->name); 502 + 503 + hci_dev_lock(hdev); 504 + 505 + conn = hci_conn_hash_lookup_state(hdev, ACL_LINK, BT_CONNECT2); 506 + if (conn) 507 + hci_acl_connect(conn); 508 + 509 + hci_dev_unlock(hdev); 489 510 } 490 511 491 512 int hci_get_conn_list(void __user *arg)
+27 -21
net/bluetooth/hci_core.c
··· 176 176 BT_DBG("%s %ld", hdev->name, opt); 177 177 178 178 /* Reset device */ 179 - hci_send_cmd(hdev, OGF_HOST_CTL, OCF_RESET, 0, NULL); 179 + hci_send_cmd(hdev, HCI_OP_RESET, 0, NULL); 180 180 } 181 181 182 182 static void hci_init_req(struct hci_dev *hdev, unsigned long opt) ··· 202 202 203 203 /* Reset */ 204 204 if (test_bit(HCI_QUIRK_RESET_ON_INIT, &hdev->quirks)) 205 - hci_send_cmd(hdev, OGF_HOST_CTL, OCF_RESET, 0, NULL); 205 + hci_send_cmd(hdev, HCI_OP_RESET, 0, NULL); 206 206 207 207 /* Read Local Supported Features */ 208 - hci_send_cmd(hdev, OGF_INFO_PARAM, OCF_READ_LOCAL_FEATURES, 0, NULL); 208 + hci_send_cmd(hdev, HCI_OP_READ_LOCAL_FEATURES, 0, NULL); 209 209 210 210 /* Read Local Version */ 211 - hci_send_cmd(hdev, OGF_INFO_PARAM, OCF_READ_LOCAL_VERSION, 0, NULL); 211 + hci_send_cmd(hdev, HCI_OP_READ_LOCAL_VERSION, 0, NULL); 212 212 213 213 /* Read Buffer Size (ACL mtu, max pkt, etc.) */ 214 - hci_send_cmd(hdev, OGF_INFO_PARAM, OCF_READ_BUFFER_SIZE, 0, NULL); 214 + hci_send_cmd(hdev, HCI_OP_READ_BUFFER_SIZE, 0, NULL); 215 215 216 216 #if 0 217 217 /* Host buffer size */ ··· 221 221 cp.sco_mtu = HCI_MAX_SCO_SIZE; 222 222 cp.acl_max_pkt = cpu_to_le16(0xffff); 223 223 cp.sco_max_pkt = cpu_to_le16(0xffff); 224 - hci_send_cmd(hdev, OGF_HOST_CTL, OCF_HOST_BUFFER_SIZE, sizeof(cp), &cp); 224 + hci_send_cmd(hdev, HCI_OP_HOST_BUFFER_SIZE, sizeof(cp), &cp); 225 225 } 226 226 #endif 227 227 228 228 /* Read BD Address */ 229 - hci_send_cmd(hdev, OGF_INFO_PARAM, OCF_READ_BD_ADDR, 0, NULL); 229 + hci_send_cmd(hdev, HCI_OP_READ_BD_ADDR, 0, NULL); 230 + 231 + /* Read Class of Device */ 232 + hci_send_cmd(hdev, HCI_OP_READ_CLASS_OF_DEV, 0, NULL); 233 + 234 + /* Read Local Name */ 235 + hci_send_cmd(hdev, HCI_OP_READ_LOCAL_NAME, 0, NULL); 230 236 231 237 /* Read Voice Setting */ 232 - hci_send_cmd(hdev, OGF_HOST_CTL, OCF_READ_VOICE_SETTING, 0, NULL); 238 + hci_send_cmd(hdev, HCI_OP_READ_VOICE_SETTING, 0, NULL); 233 239 234 240 /* Optional initialization */ 235 241 236 242 /* Clear Event Filters */ 237 243 flt_type = HCI_FLT_CLEAR_ALL; 238 - hci_send_cmd(hdev, OGF_HOST_CTL, OCF_SET_EVENT_FLT, 1, &flt_type); 244 + hci_send_cmd(hdev, HCI_OP_SET_EVENT_FLT, 1, &flt_type); 239 245 240 246 /* Page timeout ~20 secs */ 241 247 param = cpu_to_le16(0x8000); 242 - hci_send_cmd(hdev, OGF_HOST_CTL, OCF_WRITE_PG_TIMEOUT, 2, &param); 248 + hci_send_cmd(hdev, HCI_OP_WRITE_PG_TIMEOUT, 2, &param); 243 249 244 250 /* Connection accept timeout ~20 secs */ 245 251 param = cpu_to_le16(0x7d00); 246 - hci_send_cmd(hdev, OGF_HOST_CTL, OCF_WRITE_CA_TIMEOUT, 2, &param); 252 + hci_send_cmd(hdev, HCI_OP_WRITE_CA_TIMEOUT, 2, &param); 247 253 } 248 254 249 255 static void hci_scan_req(struct hci_dev *hdev, unsigned long opt) ··· 259 253 BT_DBG("%s %x", hdev->name, scan); 260 254 261 255 /* Inquiry and Page scans */ 262 - hci_send_cmd(hdev, OGF_HOST_CTL, OCF_WRITE_SCAN_ENABLE, 1, &scan); 256 + hci_send_cmd(hdev, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan); 263 257 } 264 258 265 259 static void hci_auth_req(struct hci_dev *hdev, unsigned long opt) ··· 269 263 BT_DBG("%s %x", hdev->name, auth); 270 264 271 265 /* Authentication */ 272 - hci_send_cmd(hdev, OGF_HOST_CTL, OCF_WRITE_AUTH_ENABLE, 1, &auth); 266 + hci_send_cmd(hdev, HCI_OP_WRITE_AUTH_ENABLE, 1, &auth); 273 267 } 274 268 275 269 static void hci_encrypt_req(struct hci_dev *hdev, unsigned long opt) ··· 279 273 BT_DBG("%s %x", hdev->name, encrypt); 280 274 281 275 /* Authentication */ 282 - hci_send_cmd(hdev, OGF_HOST_CTL, OCF_WRITE_ENCRYPT_MODE, 1, &encrypt); 276 + hci_send_cmd(hdev, HCI_OP_WRITE_ENCRYPT_MODE, 1, &encrypt); 283 277 } 284 278 285 279 /* Get HCI device by index. ··· 390 384 memcpy(&cp.lap, &ir->lap, 3); 391 385 cp.length = ir->length; 392 386 cp.num_rsp = ir->num_rsp; 393 - hci_send_cmd(hdev, OGF_LINK_CTL, OCF_INQUIRY, sizeof(cp), &cp); 387 + hci_send_cmd(hdev, HCI_OP_INQUIRY, sizeof(cp), &cp); 394 388 } 395 389 396 390 int hci_inquiry(void __user *arg) ··· 1117 1111 } 1118 1112 1119 1113 /* Send HCI command */ 1120 - int hci_send_cmd(struct hci_dev *hdev, __u16 ogf, __u16 ocf, __u32 plen, void *param) 1114 + int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, void *param) 1121 1115 { 1122 1116 int len = HCI_COMMAND_HDR_SIZE + plen; 1123 1117 struct hci_command_hdr *hdr; 1124 1118 struct sk_buff *skb; 1125 1119 1126 - BT_DBG("%s ogf 0x%x ocf 0x%x plen %d", hdev->name, ogf, ocf, plen); 1120 + BT_DBG("%s opcode 0x%x plen %d", hdev->name, opcode, plen); 1127 1121 1128 1122 skb = bt_skb_alloc(len, GFP_ATOMIC); 1129 1123 if (!skb) { ··· 1132 1126 } 1133 1127 1134 1128 hdr = (struct hci_command_hdr *) skb_put(skb, HCI_COMMAND_HDR_SIZE); 1135 - hdr->opcode = cpu_to_le16(hci_opcode_pack(ogf, ocf)); 1129 + hdr->opcode = cpu_to_le16(opcode); 1136 1130 hdr->plen = plen; 1137 1131 1138 1132 if (plen) ··· 1149 1143 } 1150 1144 1151 1145 /* Get data from the previously sent command */ 1152 - void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 ogf, __u16 ocf) 1146 + void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 opcode) 1153 1147 { 1154 1148 struct hci_command_hdr *hdr; 1155 1149 ··· 1158 1152 1159 1153 hdr = (void *) hdev->sent_cmd->data; 1160 1154 1161 - if (hdr->opcode != cpu_to_le16(hci_opcode_pack(ogf, ocf))) 1155 + if (hdr->opcode != cpu_to_le16(opcode)) 1162 1156 return NULL; 1163 1157 1164 - BT_DBG("%s ogf 0x%x ocf 0x%x", hdev->name, ogf, ocf); 1158 + BT_DBG("%s opcode 0x%x", hdev->name, opcode); 1165 1159 1166 1160 return hdev->sent_cmd->data + HCI_COMMAND_HDR_SIZE; 1167 1161 }
+996 -870
net/bluetooth/hci_event.c
··· 52 52 53 53 /* Handle HCI Event packets */ 54 54 55 - /* Command Complete OGF LINK_CTL */ 56 - static void hci_cc_link_ctl(struct hci_dev *hdev, __u16 ocf, struct sk_buff *skb) 55 + static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb) 57 56 { 58 - __u8 status; 59 - struct hci_conn *pend; 57 + __u8 status = *((__u8 *) skb->data); 60 58 61 - BT_DBG("%s ocf 0x%x", hdev->name, ocf); 59 + BT_DBG("%s status 0x%x", hdev->name, status); 62 60 63 - switch (ocf) { 64 - case OCF_INQUIRY_CANCEL: 65 - case OCF_EXIT_PERIODIC_INQ: 66 - status = *((__u8 *) skb->data); 61 + if (status) 62 + return; 67 63 68 - if (status) { 69 - BT_DBG("%s Inquiry cancel error: status 0x%x", hdev->name, status); 70 - } else { 71 - clear_bit(HCI_INQUIRY, &hdev->flags); 72 - hci_req_complete(hdev, status); 73 - } 64 + clear_bit(HCI_INQUIRY, &hdev->flags); 74 65 75 - hci_dev_lock(hdev); 66 + hci_req_complete(hdev, status); 76 67 77 - pend = hci_conn_hash_lookup_state(hdev, ACL_LINK, BT_CONNECT2); 78 - if (pend) 79 - hci_acl_connect(pend); 80 - 81 - hci_dev_unlock(hdev); 82 - 83 - break; 84 - 85 - default: 86 - BT_DBG("%s Command complete: ogf LINK_CTL ocf %x", hdev->name, ocf); 87 - break; 88 - } 68 + hci_conn_check_pending(hdev); 89 69 } 90 70 91 - /* Command Complete OGF LINK_POLICY */ 92 - static void hci_cc_link_policy(struct hci_dev *hdev, __u16 ocf, struct sk_buff *skb) 71 + static void hci_cc_exit_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb) 93 72 { 73 + __u8 status = *((__u8 *) skb->data); 74 + 75 + BT_DBG("%s status 0x%x", hdev->name, status); 76 + 77 + if (status) 78 + return; 79 + 80 + clear_bit(HCI_INQUIRY, &hdev->flags); 81 + 82 + hci_conn_check_pending(hdev); 83 + } 84 + 85 + static void hci_cc_remote_name_req_cancel(struct hci_dev *hdev, struct sk_buff *skb) 86 + { 87 + BT_DBG("%s", hdev->name); 88 + } 89 + 90 + static void hci_cc_role_discovery(struct hci_dev *hdev, struct sk_buff *skb) 91 + { 92 + struct hci_rp_role_discovery *rp = (void *) skb->data; 94 93 struct hci_conn *conn; 95 - struct hci_rp_role_discovery *rd; 96 - struct hci_rp_write_link_policy *lp; 97 - void *sent; 98 94 99 - BT_DBG("%s ocf 0x%x", hdev->name, ocf); 95 + BT_DBG("%s status 0x%x", hdev->name, rp->status); 100 96 101 - switch (ocf) { 102 - case OCF_ROLE_DISCOVERY: 103 - rd = (void *) skb->data; 97 + if (rp->status) 98 + return; 104 99 105 - if (rd->status) 106 - break; 100 + hci_dev_lock(hdev); 107 101 108 - hci_dev_lock(hdev); 109 - 110 - conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rd->handle)); 111 - if (conn) { 112 - if (rd->role) 113 - conn->link_mode &= ~HCI_LM_MASTER; 114 - else 115 - conn->link_mode |= HCI_LM_MASTER; 116 - } 117 - 118 - hci_dev_unlock(hdev); 119 - break; 120 - 121 - case OCF_WRITE_LINK_POLICY: 122 - sent = hci_sent_cmd_data(hdev, OGF_LINK_POLICY, OCF_WRITE_LINK_POLICY); 123 - if (!sent) 124 - break; 125 - 126 - lp = (struct hci_rp_write_link_policy *) skb->data; 127 - 128 - if (lp->status) 129 - break; 130 - 131 - hci_dev_lock(hdev); 132 - 133 - conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(lp->handle)); 134 - if (conn) { 135 - __le16 policy = get_unaligned((__le16 *) (sent + 2)); 136 - conn->link_policy = __le16_to_cpu(policy); 137 - } 138 - 139 - hci_dev_unlock(hdev); 140 - break; 141 - 142 - default: 143 - BT_DBG("%s: Command complete: ogf LINK_POLICY ocf %x", 144 - hdev->name, ocf); 145 - break; 102 + conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); 103 + if (conn) { 104 + if (rp->role) 105 + conn->link_mode &= ~HCI_LM_MASTER; 106 + else 107 + conn->link_mode |= HCI_LM_MASTER; 146 108 } 109 + 110 + hci_dev_unlock(hdev); 147 111 } 148 112 149 - /* Command Complete OGF HOST_CTL */ 150 - static void hci_cc_host_ctl(struct hci_dev *hdev, __u16 ocf, struct sk_buff *skb) 113 + static void hci_cc_write_link_policy(struct hci_dev *hdev, struct sk_buff *skb) 151 114 { 152 - __u8 status, param; 115 + struct hci_rp_write_link_policy *rp = (void *) skb->data; 116 + struct hci_conn *conn; 117 + void *sent; 118 + 119 + BT_DBG("%s status 0x%x", hdev->name, rp->status); 120 + 121 + if (rp->status) 122 + return; 123 + 124 + sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LINK_POLICY); 125 + if (!sent) 126 + return; 127 + 128 + hci_dev_lock(hdev); 129 + 130 + conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(rp->handle)); 131 + if (conn) { 132 + __le16 policy = get_unaligned((__le16 *) (sent + 2)); 133 + conn->link_policy = __le16_to_cpu(policy); 134 + } 135 + 136 + hci_dev_unlock(hdev); 137 + } 138 + 139 + static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb) 140 + { 141 + __u8 status = *((__u8 *) skb->data); 142 + 143 + BT_DBG("%s status 0x%x", hdev->name, status); 144 + 145 + hci_req_complete(hdev, status); 146 + } 147 + 148 + static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb) 149 + { 150 + __u8 status = *((__u8 *) skb->data); 151 + void *sent; 152 + 153 + BT_DBG("%s status 0x%x", hdev->name, status); 154 + 155 + sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LOCAL_NAME); 156 + if (!sent) 157 + return; 158 + 159 + if (!status) 160 + memcpy(hdev->dev_name, sent, 248); 161 + } 162 + 163 + static void hci_cc_read_local_name(struct hci_dev *hdev, struct sk_buff *skb) 164 + { 165 + struct hci_rp_read_local_name *rp = (void *) skb->data; 166 + 167 + BT_DBG("%s status 0x%x", hdev->name, rp->status); 168 + 169 + if (rp->status) 170 + return; 171 + 172 + memcpy(hdev->dev_name, rp->name, 248); 173 + } 174 + 175 + static void hci_cc_write_auth_enable(struct hci_dev *hdev, struct sk_buff *skb) 176 + { 177 + __u8 status = *((__u8 *) skb->data); 178 + void *sent; 179 + 180 + BT_DBG("%s status 0x%x", hdev->name, status); 181 + 182 + sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_AUTH_ENABLE); 183 + if (!sent) 184 + return; 185 + 186 + if (!status) { 187 + __u8 param = *((__u8 *) sent); 188 + 189 + if (param == AUTH_ENABLED) 190 + set_bit(HCI_AUTH, &hdev->flags); 191 + else 192 + clear_bit(HCI_AUTH, &hdev->flags); 193 + } 194 + 195 + hci_req_complete(hdev, status); 196 + } 197 + 198 + static void hci_cc_write_encrypt_mode(struct hci_dev *hdev, struct sk_buff *skb) 199 + { 200 + __u8 status = *((__u8 *) skb->data); 201 + void *sent; 202 + 203 + BT_DBG("%s status 0x%x", hdev->name, status); 204 + 205 + sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_ENCRYPT_MODE); 206 + if (!sent) 207 + return; 208 + 209 + if (!status) { 210 + __u8 param = *((__u8 *) sent); 211 + 212 + if (param) 213 + set_bit(HCI_ENCRYPT, &hdev->flags); 214 + else 215 + clear_bit(HCI_ENCRYPT, &hdev->flags); 216 + } 217 + 218 + hci_req_complete(hdev, status); 219 + } 220 + 221 + static void hci_cc_write_scan_enable(struct hci_dev *hdev, struct sk_buff *skb) 222 + { 223 + __u8 status = *((__u8 *) skb->data); 224 + void *sent; 225 + 226 + BT_DBG("%s status 0x%x", hdev->name, status); 227 + 228 + sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_SCAN_ENABLE); 229 + if (!sent) 230 + return; 231 + 232 + if (!status) { 233 + __u8 param = *((__u8 *) sent); 234 + 235 + clear_bit(HCI_PSCAN, &hdev->flags); 236 + clear_bit(HCI_ISCAN, &hdev->flags); 237 + 238 + if (param & SCAN_INQUIRY) 239 + set_bit(HCI_ISCAN, &hdev->flags); 240 + 241 + if (param & SCAN_PAGE) 242 + set_bit(HCI_PSCAN, &hdev->flags); 243 + } 244 + 245 + hci_req_complete(hdev, status); 246 + } 247 + 248 + static void hci_cc_read_class_of_dev(struct hci_dev *hdev, struct sk_buff *skb) 249 + { 250 + struct hci_rp_read_class_of_dev *rp = (void *) skb->data; 251 + 252 + BT_DBG("%s status 0x%x", hdev->name, rp->status); 253 + 254 + if (rp->status) 255 + return; 256 + 257 + memcpy(hdev->dev_class, rp->dev_class, 3); 258 + 259 + BT_DBG("%s class 0x%.2x%.2x%.2x", hdev->name, 260 + hdev->dev_class[2], hdev->dev_class[1], hdev->dev_class[0]); 261 + } 262 + 263 + static void hci_cc_write_class_of_dev(struct hci_dev *hdev, struct sk_buff *skb) 264 + { 265 + __u8 status = *((__u8 *) skb->data); 266 + void *sent; 267 + 268 + BT_DBG("%s status 0x%x", hdev->name, status); 269 + 270 + sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_CLASS_OF_DEV); 271 + if (!sent) 272 + return; 273 + 274 + if (!status) 275 + memcpy(hdev->dev_class, sent, 3); 276 + } 277 + 278 + static void hci_cc_read_voice_setting(struct hci_dev *hdev, struct sk_buff *skb) 279 + { 280 + struct hci_rp_read_voice_setting *rp = (void *) skb->data; 153 281 __u16 setting; 154 - struct hci_rp_read_voice_setting *vs; 282 + 283 + BT_DBG("%s status 0x%x", hdev->name, rp->status); 284 + 285 + if (rp->status) 286 + return; 287 + 288 + setting = __le16_to_cpu(rp->voice_setting); 289 + 290 + if (hdev->voice_setting == setting ) 291 + return; 292 + 293 + hdev->voice_setting = setting; 294 + 295 + BT_DBG("%s voice setting 0x%04x", hdev->name, setting); 296 + 297 + if (hdev->notify) { 298 + tasklet_disable(&hdev->tx_task); 299 + hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING); 300 + tasklet_enable(&hdev->tx_task); 301 + } 302 + } 303 + 304 + static void hci_cc_write_voice_setting(struct hci_dev *hdev, struct sk_buff *skb) 305 + { 306 + __u8 status = *((__u8 *) skb->data); 155 307 void *sent; 156 308 157 - BT_DBG("%s ocf 0x%x", hdev->name, ocf); 309 + BT_DBG("%s status 0x%x", hdev->name, status); 158 310 159 - switch (ocf) { 160 - case OCF_RESET: 161 - status = *((__u8 *) skb->data); 162 - hci_req_complete(hdev, status); 163 - break; 311 + sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_VOICE_SETTING); 312 + if (!sent) 313 + return; 164 314 165 - case OCF_SET_EVENT_FLT: 166 - status = *((__u8 *) skb->data); 167 - if (status) { 168 - BT_DBG("%s SET_EVENT_FLT failed %d", hdev->name, status); 169 - } else { 170 - BT_DBG("%s SET_EVENT_FLT succeseful", hdev->name); 171 - } 172 - break; 315 + if (!status) { 316 + __u16 setting = __le16_to_cpu(get_unaligned((__le16 *) sent)); 173 317 174 - case OCF_WRITE_AUTH_ENABLE: 175 - sent = hci_sent_cmd_data(hdev, OGF_HOST_CTL, OCF_WRITE_AUTH_ENABLE); 176 - if (!sent) 177 - break; 178 - 179 - status = *((__u8 *) skb->data); 180 - param = *((__u8 *) sent); 181 - 182 - if (!status) { 183 - if (param == AUTH_ENABLED) 184 - set_bit(HCI_AUTH, &hdev->flags); 185 - else 186 - clear_bit(HCI_AUTH, &hdev->flags); 187 - } 188 - hci_req_complete(hdev, status); 189 - break; 190 - 191 - case OCF_WRITE_ENCRYPT_MODE: 192 - sent = hci_sent_cmd_data(hdev, OGF_HOST_CTL, OCF_WRITE_ENCRYPT_MODE); 193 - if (!sent) 194 - break; 195 - 196 - status = *((__u8 *) skb->data); 197 - param = *((__u8 *) sent); 198 - 199 - if (!status) { 200 - if (param) 201 - set_bit(HCI_ENCRYPT, &hdev->flags); 202 - else 203 - clear_bit(HCI_ENCRYPT, &hdev->flags); 204 - } 205 - hci_req_complete(hdev, status); 206 - break; 207 - 208 - case OCF_WRITE_CA_TIMEOUT: 209 - status = *((__u8 *) skb->data); 210 - if (status) { 211 - BT_DBG("%s OCF_WRITE_CA_TIMEOUT failed %d", hdev->name, status); 212 - } else { 213 - BT_DBG("%s OCF_WRITE_CA_TIMEOUT succeseful", hdev->name); 214 - } 215 - break; 216 - 217 - case OCF_WRITE_PG_TIMEOUT: 218 - status = *((__u8 *) skb->data); 219 - if (status) { 220 - BT_DBG("%s OCF_WRITE_PG_TIMEOUT failed %d", hdev->name, status); 221 - } else { 222 - BT_DBG("%s: OCF_WRITE_PG_TIMEOUT succeseful", hdev->name); 223 - } 224 - break; 225 - 226 - case OCF_WRITE_SCAN_ENABLE: 227 - sent = hci_sent_cmd_data(hdev, OGF_HOST_CTL, OCF_WRITE_SCAN_ENABLE); 228 - if (!sent) 229 - break; 230 - 231 - status = *((__u8 *) skb->data); 232 - param = *((__u8 *) sent); 233 - 234 - BT_DBG("param 0x%x", param); 235 - 236 - if (!status) { 237 - clear_bit(HCI_PSCAN, &hdev->flags); 238 - clear_bit(HCI_ISCAN, &hdev->flags); 239 - if (param & SCAN_INQUIRY) 240 - set_bit(HCI_ISCAN, &hdev->flags); 241 - 242 - if (param & SCAN_PAGE) 243 - set_bit(HCI_PSCAN, &hdev->flags); 244 - } 245 - hci_req_complete(hdev, status); 246 - break; 247 - 248 - case OCF_READ_VOICE_SETTING: 249 - vs = (struct hci_rp_read_voice_setting *) skb->data; 250 - 251 - if (vs->status) { 252 - BT_DBG("%s READ_VOICE_SETTING failed %d", hdev->name, vs->status); 253 - break; 254 - } 255 - 256 - setting = __le16_to_cpu(vs->voice_setting); 257 - 258 - if (hdev->voice_setting != setting ) { 318 + if (hdev->voice_setting != setting) { 259 319 hdev->voice_setting = setting; 260 320 261 - BT_DBG("%s: voice setting 0x%04x", hdev->name, setting); 321 + BT_DBG("%s voice setting 0x%04x", hdev->name, setting); 262 322 263 323 if (hdev->notify) { 264 324 tasklet_disable(&hdev->tx_task); ··· 326 266 tasklet_enable(&hdev->tx_task); 327 267 } 328 268 } 329 - break; 330 - 331 - case OCF_WRITE_VOICE_SETTING: 332 - sent = hci_sent_cmd_data(hdev, OGF_HOST_CTL, OCF_WRITE_VOICE_SETTING); 333 - if (!sent) 334 - break; 335 - 336 - status = *((__u8 *) skb->data); 337 - setting = __le16_to_cpu(get_unaligned((__le16 *) sent)); 338 - 339 - if (!status && hdev->voice_setting != setting) { 340 - hdev->voice_setting = setting; 341 - 342 - BT_DBG("%s: voice setting 0x%04x", hdev->name, setting); 343 - 344 - if (hdev->notify) { 345 - tasklet_disable(&hdev->tx_task); 346 - hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING); 347 - tasklet_enable(&hdev->tx_task); 348 - } 349 - } 350 - hci_req_complete(hdev, status); 351 - break; 352 - 353 - case OCF_HOST_BUFFER_SIZE: 354 - status = *((__u8 *) skb->data); 355 - if (status) { 356 - BT_DBG("%s OCF_BUFFER_SIZE failed %d", hdev->name, status); 357 - hci_req_complete(hdev, status); 358 - } 359 - break; 360 - 361 - default: 362 - BT_DBG("%s Command complete: ogf HOST_CTL ocf %x", hdev->name, ocf); 363 - break; 364 269 } 365 270 } 366 271 367 - /* Command Complete OGF INFO_PARAM */ 368 - static void hci_cc_info_param(struct hci_dev *hdev, __u16 ocf, struct sk_buff *skb) 272 + static void hci_cc_host_buffer_size(struct hci_dev *hdev, struct sk_buff *skb) 369 273 { 370 - struct hci_rp_read_loc_version *lv; 371 - struct hci_rp_read_local_features *lf; 372 - struct hci_rp_read_buffer_size *bs; 373 - struct hci_rp_read_bd_addr *ba; 274 + __u8 status = *((__u8 *) skb->data); 374 275 375 - BT_DBG("%s ocf 0x%x", hdev->name, ocf); 276 + BT_DBG("%s status 0x%x", hdev->name, status); 376 277 377 - switch (ocf) { 378 - case OCF_READ_LOCAL_VERSION: 379 - lv = (struct hci_rp_read_loc_version *) skb->data; 380 - 381 - if (lv->status) { 382 - BT_DBG("%s READ_LOCAL_VERSION failed %d", hdev->name, lf->status); 383 - break; 384 - } 385 - 386 - hdev->hci_ver = lv->hci_ver; 387 - hdev->hci_rev = btohs(lv->hci_rev); 388 - hdev->manufacturer = btohs(lv->manufacturer); 389 - 390 - BT_DBG("%s: manufacturer %d hci_ver %d hci_rev %d", hdev->name, 391 - hdev->manufacturer, hdev->hci_ver, hdev->hci_rev); 392 - 393 - break; 394 - 395 - case OCF_READ_LOCAL_FEATURES: 396 - lf = (struct hci_rp_read_local_features *) skb->data; 397 - 398 - if (lf->status) { 399 - BT_DBG("%s READ_LOCAL_FEATURES failed %d", hdev->name, lf->status); 400 - break; 401 - } 402 - 403 - memcpy(hdev->features, lf->features, sizeof(hdev->features)); 404 - 405 - /* Adjust default settings according to features 406 - * supported by device. */ 407 - if (hdev->features[0] & LMP_3SLOT) 408 - hdev->pkt_type |= (HCI_DM3 | HCI_DH3); 409 - 410 - if (hdev->features[0] & LMP_5SLOT) 411 - hdev->pkt_type |= (HCI_DM5 | HCI_DH5); 412 - 413 - if (hdev->features[1] & LMP_HV2) { 414 - hdev->pkt_type |= (HCI_HV2); 415 - hdev->esco_type |= (ESCO_HV2); 416 - } 417 - 418 - if (hdev->features[1] & LMP_HV3) { 419 - hdev->pkt_type |= (HCI_HV3); 420 - hdev->esco_type |= (ESCO_HV3); 421 - } 422 - 423 - if (hdev->features[3] & LMP_ESCO) 424 - hdev->esco_type |= (ESCO_EV3); 425 - 426 - if (hdev->features[4] & LMP_EV4) 427 - hdev->esco_type |= (ESCO_EV4); 428 - 429 - if (hdev->features[4] & LMP_EV5) 430 - hdev->esco_type |= (ESCO_EV5); 431 - 432 - BT_DBG("%s: features 0x%x 0x%x 0x%x", hdev->name, 433 - lf->features[0], lf->features[1], lf->features[2]); 434 - 435 - break; 436 - 437 - case OCF_READ_BUFFER_SIZE: 438 - bs = (struct hci_rp_read_buffer_size *) skb->data; 439 - 440 - if (bs->status) { 441 - BT_DBG("%s READ_BUFFER_SIZE failed %d", hdev->name, bs->status); 442 - hci_req_complete(hdev, bs->status); 443 - break; 444 - } 445 - 446 - hdev->acl_mtu = __le16_to_cpu(bs->acl_mtu); 447 - hdev->sco_mtu = bs->sco_mtu; 448 - hdev->acl_pkts = __le16_to_cpu(bs->acl_max_pkt); 449 - hdev->sco_pkts = __le16_to_cpu(bs->sco_max_pkt); 450 - 451 - if (test_bit(HCI_QUIRK_FIXUP_BUFFER_SIZE, &hdev->quirks)) { 452 - hdev->sco_mtu = 64; 453 - hdev->sco_pkts = 8; 454 - } 455 - 456 - hdev->acl_cnt = hdev->acl_pkts; 457 - hdev->sco_cnt = hdev->sco_pkts; 458 - 459 - BT_DBG("%s mtu: acl %d, sco %d max_pkt: acl %d, sco %d", hdev->name, 460 - hdev->acl_mtu, hdev->sco_mtu, hdev->acl_pkts, hdev->sco_pkts); 461 - break; 462 - 463 - case OCF_READ_BD_ADDR: 464 - ba = (struct hci_rp_read_bd_addr *) skb->data; 465 - 466 - if (!ba->status) { 467 - bacpy(&hdev->bdaddr, &ba->bdaddr); 468 - } else { 469 - BT_DBG("%s: READ_BD_ADDR failed %d", hdev->name, ba->status); 470 - } 471 - 472 - hci_req_complete(hdev, ba->status); 473 - break; 474 - 475 - default: 476 - BT_DBG("%s Command complete: ogf INFO_PARAM ocf %x", hdev->name, ocf); 477 - break; 478 - } 278 + hci_req_complete(hdev, status); 479 279 } 480 280 481 - /* Command Status OGF LINK_CTL */ 281 + static void hci_cc_read_local_version(struct hci_dev *hdev, struct sk_buff *skb) 282 + { 283 + struct hci_rp_read_local_version *rp = (void *) skb->data; 284 + 285 + BT_DBG("%s status 0x%x", hdev->name, rp->status); 286 + 287 + if (rp->status) 288 + return; 289 + 290 + hdev->hci_ver = rp->hci_ver; 291 + hdev->hci_rev = btohs(rp->hci_rev); 292 + hdev->manufacturer = btohs(rp->manufacturer); 293 + 294 + BT_DBG("%s manufacturer %d hci ver %d:%d", hdev->name, 295 + hdev->manufacturer, 296 + hdev->hci_ver, hdev->hci_rev); 297 + } 298 + 299 + static void hci_cc_read_local_commands(struct hci_dev *hdev, struct sk_buff *skb) 300 + { 301 + struct hci_rp_read_local_commands *rp = (void *) skb->data; 302 + 303 + BT_DBG("%s status 0x%x", hdev->name, rp->status); 304 + 305 + if (rp->status) 306 + return; 307 + 308 + memcpy(hdev->commands, rp->commands, sizeof(hdev->commands)); 309 + } 310 + 311 + static void hci_cc_read_local_features(struct hci_dev *hdev, struct sk_buff *skb) 312 + { 313 + struct hci_rp_read_local_features *rp = (void *) skb->data; 314 + 315 + BT_DBG("%s status 0x%x", hdev->name, rp->status); 316 + 317 + if (rp->status) 318 + return; 319 + 320 + memcpy(hdev->features, rp->features, 8); 321 + 322 + /* Adjust default settings according to features 323 + * supported by device. */ 324 + 325 + if (hdev->features[0] & LMP_3SLOT) 326 + hdev->pkt_type |= (HCI_DM3 | HCI_DH3); 327 + 328 + if (hdev->features[0] & LMP_5SLOT) 329 + hdev->pkt_type |= (HCI_DM5 | HCI_DH5); 330 + 331 + if (hdev->features[1] & LMP_HV2) { 332 + hdev->pkt_type |= (HCI_HV2); 333 + hdev->esco_type |= (ESCO_HV2); 334 + } 335 + 336 + if (hdev->features[1] & LMP_HV3) { 337 + hdev->pkt_type |= (HCI_HV3); 338 + hdev->esco_type |= (ESCO_HV3); 339 + } 340 + 341 + if (hdev->features[3] & LMP_ESCO) 342 + hdev->esco_type |= (ESCO_EV3); 343 + 344 + if (hdev->features[4] & LMP_EV4) 345 + hdev->esco_type |= (ESCO_EV4); 346 + 347 + if (hdev->features[4] & LMP_EV5) 348 + hdev->esco_type |= (ESCO_EV5); 349 + 350 + BT_DBG("%s features 0x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x", hdev->name, 351 + hdev->features[0], hdev->features[1], 352 + hdev->features[2], hdev->features[3], 353 + hdev->features[4], hdev->features[5], 354 + hdev->features[6], hdev->features[7]); 355 + } 356 + 357 + static void hci_cc_read_buffer_size(struct hci_dev *hdev, struct sk_buff *skb) 358 + { 359 + struct hci_rp_read_buffer_size *rp = (void *) skb->data; 360 + 361 + BT_DBG("%s status 0x%x", hdev->name, rp->status); 362 + 363 + if (rp->status) 364 + return; 365 + 366 + hdev->acl_mtu = __le16_to_cpu(rp->acl_mtu); 367 + hdev->sco_mtu = rp->sco_mtu; 368 + hdev->acl_pkts = __le16_to_cpu(rp->acl_max_pkt); 369 + hdev->sco_pkts = __le16_to_cpu(rp->sco_max_pkt); 370 + 371 + if (test_bit(HCI_QUIRK_FIXUP_BUFFER_SIZE, &hdev->quirks)) { 372 + hdev->sco_mtu = 64; 373 + hdev->sco_pkts = 8; 374 + } 375 + 376 + hdev->acl_cnt = hdev->acl_pkts; 377 + hdev->sco_cnt = hdev->sco_pkts; 378 + 379 + BT_DBG("%s acl mtu %d:%d sco mtu %d:%d", hdev->name, 380 + hdev->acl_mtu, hdev->acl_pkts, 381 + hdev->sco_mtu, hdev->sco_pkts); 382 + } 383 + 384 + static void hci_cc_read_bd_addr(struct hci_dev *hdev, struct sk_buff *skb) 385 + { 386 + struct hci_rp_read_bd_addr *rp = (void *) skb->data; 387 + 388 + BT_DBG("%s status 0x%x", hdev->name, rp->status); 389 + 390 + if (!rp->status) 391 + bacpy(&hdev->bdaddr, &rp->bdaddr); 392 + 393 + hci_req_complete(hdev, rp->status); 394 + } 395 + 396 + static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status) 397 + { 398 + BT_DBG("%s status 0x%x", hdev->name, status); 399 + 400 + if (status) { 401 + hci_req_complete(hdev, status); 402 + 403 + hci_conn_check_pending(hdev); 404 + } else 405 + set_bit(HCI_INQUIRY, &hdev->flags); 406 + } 407 + 482 408 static inline void hci_cs_create_conn(struct hci_dev *hdev, __u8 status) 483 409 { 410 + struct hci_cp_create_conn *cp; 484 411 struct hci_conn *conn; 485 - struct hci_cp_create_conn *cp = hci_sent_cmd_data(hdev, OGF_LINK_CTL, OCF_CREATE_CONN); 486 412 413 + BT_DBG("%s status 0x%x", hdev->name, status); 414 + 415 + cp = hci_sent_cmd_data(hdev, HCI_OP_CREATE_CONN); 487 416 if (!cp) 488 417 return; 489 418 ··· 480 431 481 432 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); 482 433 483 - BT_DBG("%s status 0x%x bdaddr %s conn %p", hdev->name, 484 - status, batostr(&cp->bdaddr), conn); 434 + BT_DBG("%s bdaddr %s conn %p", hdev->name, batostr(&cp->bdaddr), conn); 485 435 486 436 if (status) { 487 437 if (conn && conn->state == BT_CONNECT) { ··· 505 457 hci_dev_unlock(hdev); 506 458 } 507 459 508 - static void hci_cs_link_ctl(struct hci_dev *hdev, __u16 ocf, __u8 status) 460 + static void hci_cs_add_sco(struct hci_dev *hdev, __u8 status) 509 461 { 510 - BT_DBG("%s ocf 0x%x", hdev->name, ocf); 462 + struct hci_cp_add_sco *cp; 463 + struct hci_conn *acl, *sco; 464 + __u16 handle; 511 465 512 - switch (ocf) { 513 - case OCF_CREATE_CONN: 514 - hci_cs_create_conn(hdev, status); 515 - break; 466 + if (!status) 467 + return; 516 468 517 - case OCF_ADD_SCO: 518 - if (status) { 519 - struct hci_conn *acl, *sco; 520 - struct hci_cp_add_sco *cp = hci_sent_cmd_data(hdev, OGF_LINK_CTL, OCF_ADD_SCO); 521 - __u16 handle; 469 + BT_DBG("%s status 0x%x", hdev->name, status); 522 470 523 - if (!cp) 524 - break; 471 + cp = hci_sent_cmd_data(hdev, HCI_OP_ADD_SCO); 472 + if (!cp) 473 + return; 525 474 526 - handle = __le16_to_cpu(cp->handle); 475 + handle = __le16_to_cpu(cp->handle); 527 476 528 - BT_DBG("%s Add SCO error: handle %d status 0x%x", hdev->name, handle, status); 529 - 530 - hci_dev_lock(hdev); 531 - 532 - acl = hci_conn_hash_lookup_handle(hdev, handle); 533 - if (acl && (sco = acl->link)) { 534 - sco->state = BT_CLOSED; 535 - 536 - hci_proto_connect_cfm(sco, status); 537 - hci_conn_del(sco); 538 - } 539 - 540 - hci_dev_unlock(hdev); 541 - } 542 - break; 543 - 544 - case OCF_INQUIRY: 545 - if (status) { 546 - BT_DBG("%s Inquiry error: status 0x%x", hdev->name, status); 547 - hci_req_complete(hdev, status); 548 - } else { 549 - set_bit(HCI_INQUIRY, &hdev->flags); 550 - } 551 - break; 552 - 553 - default: 554 - BT_DBG("%s Command status: ogf LINK_CTL ocf %x status %d", 555 - hdev->name, ocf, status); 556 - break; 557 - } 558 - } 559 - 560 - /* Command Status OGF LINK_POLICY */ 561 - static void hci_cs_link_policy(struct hci_dev *hdev, __u16 ocf, __u8 status) 562 - { 563 - BT_DBG("%s ocf 0x%x", hdev->name, ocf); 564 - 565 - switch (ocf) { 566 - case OCF_SNIFF_MODE: 567 - if (status) { 568 - struct hci_conn *conn; 569 - struct hci_cp_sniff_mode *cp = hci_sent_cmd_data(hdev, OGF_LINK_POLICY, OCF_SNIFF_MODE); 570 - 571 - if (!cp) 572 - break; 573 - 574 - hci_dev_lock(hdev); 575 - 576 - conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); 577 - if (conn) { 578 - clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->pend); 579 - } 580 - 581 - hci_dev_unlock(hdev); 582 - } 583 - break; 584 - 585 - case OCF_EXIT_SNIFF_MODE: 586 - if (status) { 587 - struct hci_conn *conn; 588 - struct hci_cp_exit_sniff_mode *cp = hci_sent_cmd_data(hdev, OGF_LINK_POLICY, OCF_EXIT_SNIFF_MODE); 589 - 590 - if (!cp) 591 - break; 592 - 593 - hci_dev_lock(hdev); 594 - 595 - conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); 596 - if (conn) { 597 - clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->pend); 598 - } 599 - 600 - hci_dev_unlock(hdev); 601 - } 602 - break; 603 - 604 - default: 605 - BT_DBG("%s Command status: ogf LINK_POLICY ocf %x", hdev->name, ocf); 606 - break; 607 - } 608 - } 609 - 610 - /* Command Status OGF HOST_CTL */ 611 - static void hci_cs_host_ctl(struct hci_dev *hdev, __u16 ocf, __u8 status) 612 - { 613 - BT_DBG("%s ocf 0x%x", hdev->name, ocf); 614 - 615 - switch (ocf) { 616 - default: 617 - BT_DBG("%s Command status: ogf HOST_CTL ocf %x", hdev->name, ocf); 618 - break; 619 - } 620 - } 621 - 622 - /* Command Status OGF INFO_PARAM */ 623 - static void hci_cs_info_param(struct hci_dev *hdev, __u16 ocf, __u8 status) 624 - { 625 - BT_DBG("%s: hci_cs_info_param: ocf 0x%x", hdev->name, ocf); 626 - 627 - switch (ocf) { 628 - default: 629 - BT_DBG("%s Command status: ogf INFO_PARAM ocf %x", hdev->name, ocf); 630 - break; 631 - } 632 - } 633 - 634 - /* Inquiry Complete */ 635 - static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) 636 - { 637 - __u8 status = *((__u8 *) skb->data); 638 - struct hci_conn *pend; 639 - 640 - BT_DBG("%s status %d", hdev->name, status); 641 - 642 - clear_bit(HCI_INQUIRY, &hdev->flags); 643 - hci_req_complete(hdev, status); 477 + BT_DBG("%s handle %d", hdev->name, handle); 644 478 645 479 hci_dev_lock(hdev); 646 480 647 - pend = hci_conn_hash_lookup_state(hdev, ACL_LINK, BT_CONNECT2); 648 - if (pend) 649 - hci_acl_connect(pend); 481 + acl = hci_conn_hash_lookup_handle(hdev, handle); 482 + if (acl && (sco = acl->link)) { 483 + sco->state = BT_CLOSED; 484 + 485 + hci_proto_connect_cfm(sco, status); 486 + hci_conn_del(sco); 487 + } 650 488 651 489 hci_dev_unlock(hdev); 652 490 } 653 491 654 - /* Inquiry Result */ 492 + static void hci_cs_remote_name_req(struct hci_dev *hdev, __u8 status) 493 + { 494 + BT_DBG("%s status 0x%x", hdev->name, status); 495 + } 496 + 497 + static void hci_cs_setup_sync_conn(struct hci_dev *hdev, __u8 status) 498 + { 499 + BT_DBG("%s status 0x%x", hdev->name, status); 500 + } 501 + 502 + static void hci_cs_sniff_mode(struct hci_dev *hdev, __u8 status) 503 + { 504 + struct hci_cp_sniff_mode *cp; 505 + struct hci_conn *conn; 506 + 507 + BT_DBG("%s status 0x%x", hdev->name, status); 508 + 509 + if (!status) 510 + return; 511 + 512 + cp = hci_sent_cmd_data(hdev, HCI_OP_SNIFF_MODE); 513 + if (!cp) 514 + return; 515 + 516 + hci_dev_lock(hdev); 517 + 518 + conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); 519 + if (conn) 520 + clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->pend); 521 + 522 + hci_dev_unlock(hdev); 523 + } 524 + 525 + static void hci_cs_exit_sniff_mode(struct hci_dev *hdev, __u8 status) 526 + { 527 + struct hci_cp_exit_sniff_mode *cp; 528 + struct hci_conn *conn; 529 + 530 + BT_DBG("%s status 0x%x", hdev->name, status); 531 + 532 + if (!status) 533 + return; 534 + 535 + cp = hci_sent_cmd_data(hdev, HCI_OP_EXIT_SNIFF_MODE); 536 + if (!cp) 537 + return; 538 + 539 + hci_dev_lock(hdev); 540 + 541 + conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle)); 542 + if (conn) 543 + clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->pend); 544 + 545 + hci_dev_unlock(hdev); 546 + } 547 + 548 + static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) 549 + { 550 + __u8 status = *((__u8 *) skb->data); 551 + 552 + BT_DBG("%s status %d", hdev->name, status); 553 + 554 + clear_bit(HCI_INQUIRY, &hdev->flags); 555 + 556 + hci_req_complete(hdev, status); 557 + 558 + hci_conn_check_pending(hdev); 559 + } 560 + 655 561 static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb) 656 562 { 657 563 struct inquiry_data data; 658 - struct inquiry_info *info = (struct inquiry_info *) (skb->data + 1); 564 + struct inquiry_info *info = (void *) (skb->data + 1); 659 565 int num_rsp = *((__u8 *) skb->data); 660 566 661 567 BT_DBG("%s num_rsp %d", hdev->name, num_rsp); ··· 634 632 hci_dev_unlock(hdev); 635 633 } 636 634 637 - /* Inquiry Result With RSSI */ 638 - static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct sk_buff *skb) 635 + static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) 639 636 { 640 - struct inquiry_data data; 641 - int num_rsp = *((__u8 *) skb->data); 637 + struct hci_ev_conn_complete *ev = (void *) skb->data; 638 + struct hci_conn *conn; 642 639 643 - BT_DBG("%s num_rsp %d", hdev->name, num_rsp); 644 - 645 - if (!num_rsp) 646 - return; 640 + BT_DBG("%s", hdev->name); 647 641 648 642 hci_dev_lock(hdev); 649 643 650 - if ((skb->len - 1) / num_rsp != sizeof(struct inquiry_info_with_rssi)) { 651 - struct inquiry_info_with_rssi_and_pscan_mode *info = 652 - (struct inquiry_info_with_rssi_and_pscan_mode *) (skb->data + 1); 644 + conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); 645 + if (!conn) 646 + goto unlock; 653 647 654 - for (; num_rsp; num_rsp--) { 655 - bacpy(&data.bdaddr, &info->bdaddr); 656 - data.pscan_rep_mode = info->pscan_rep_mode; 657 - data.pscan_period_mode = info->pscan_period_mode; 658 - data.pscan_mode = info->pscan_mode; 659 - memcpy(data.dev_class, info->dev_class, 3); 660 - data.clock_offset = info->clock_offset; 661 - data.rssi = info->rssi; 662 - info++; 663 - hci_inquiry_cache_update(hdev, &data); 648 + if (!ev->status) { 649 + conn->handle = __le16_to_cpu(ev->handle); 650 + conn->state = BT_CONNECTED; 651 + 652 + if (test_bit(HCI_AUTH, &hdev->flags)) 653 + conn->link_mode |= HCI_LM_AUTH; 654 + 655 + if (test_bit(HCI_ENCRYPT, &hdev->flags)) 656 + conn->link_mode |= HCI_LM_ENCRYPT; 657 + 658 + /* Get remote features */ 659 + if (conn->type == ACL_LINK) { 660 + struct hci_cp_read_remote_features cp; 661 + cp.handle = ev->handle; 662 + hci_send_cmd(hdev, HCI_OP_READ_REMOTE_FEATURES, sizeof(cp), &cp); 664 663 } 665 - } else { 666 - struct inquiry_info_with_rssi *info = 667 - (struct inquiry_info_with_rssi *) (skb->data + 1); 668 664 669 - for (; num_rsp; num_rsp--) { 670 - bacpy(&data.bdaddr, &info->bdaddr); 671 - data.pscan_rep_mode = info->pscan_rep_mode; 672 - data.pscan_period_mode = info->pscan_period_mode; 673 - data.pscan_mode = 0x00; 674 - memcpy(data.dev_class, info->dev_class, 3); 675 - data.clock_offset = info->clock_offset; 676 - data.rssi = info->rssi; 677 - info++; 678 - hci_inquiry_cache_update(hdev, &data); 665 + /* Set link policy */ 666 + if (conn->type == ACL_LINK && hdev->link_policy) { 667 + struct hci_cp_write_link_policy cp; 668 + cp.handle = ev->handle; 669 + cp.policy = cpu_to_le16(hdev->link_policy); 670 + hci_send_cmd(hdev, HCI_OP_WRITE_LINK_POLICY, sizeof(cp), &cp); 671 + } 672 + 673 + /* Set packet type for incoming connection */ 674 + if (!conn->out) { 675 + struct hci_cp_change_conn_ptype cp; 676 + cp.handle = ev->handle; 677 + cp.pkt_type = (conn->type == ACL_LINK) ? 678 + cpu_to_le16(hdev->pkt_type & ACL_PTYPE_MASK): 679 + cpu_to_le16(hdev->pkt_type & SCO_PTYPE_MASK); 680 + 681 + hci_send_cmd(hdev, HCI_OP_CHANGE_CONN_PTYPE, sizeof(cp), &cp); 682 + } else { 683 + /* Update disconnect timer */ 684 + hci_conn_hold(conn); 685 + hci_conn_put(conn); 686 + } 687 + } else 688 + conn->state = BT_CLOSED; 689 + 690 + if (conn->type == ACL_LINK) { 691 + struct hci_conn *sco = conn->link; 692 + if (sco) { 693 + if (!ev->status) 694 + hci_add_sco(sco, conn->handle); 695 + else { 696 + hci_proto_connect_cfm(sco, ev->status); 697 + hci_conn_del(sco); 698 + } 679 699 } 680 700 } 681 701 702 + hci_proto_connect_cfm(conn, ev->status); 703 + if (ev->status) 704 + hci_conn_del(conn); 705 + 706 + unlock: 682 707 hci_dev_unlock(hdev); 708 + 709 + hci_conn_check_pending(hdev); 683 710 } 684 711 685 - /* Extended Inquiry Result */ 686 - static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb) 687 - { 688 - struct inquiry_data data; 689 - struct extended_inquiry_info *info = (struct extended_inquiry_info *) (skb->data + 1); 690 - int num_rsp = *((__u8 *) skb->data); 691 - 692 - BT_DBG("%s num_rsp %d", hdev->name, num_rsp); 693 - 694 - if (!num_rsp) 695 - return; 696 - 697 - hci_dev_lock(hdev); 698 - 699 - for (; num_rsp; num_rsp--) { 700 - bacpy(&data.bdaddr, &info->bdaddr); 701 - data.pscan_rep_mode = info->pscan_rep_mode; 702 - data.pscan_period_mode = info->pscan_period_mode; 703 - data.pscan_mode = 0x00; 704 - memcpy(data.dev_class, info->dev_class, 3); 705 - data.clock_offset = info->clock_offset; 706 - data.rssi = info->rssi; 707 - info++; 708 - hci_inquiry_cache_update(hdev, &data); 709 - } 710 - 711 - hci_dev_unlock(hdev); 712 - } 713 - 714 - /* Connect Request */ 715 712 static inline void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb) 716 713 { 717 - struct hci_ev_conn_request *ev = (struct hci_ev_conn_request *) skb->data; 714 + struct hci_ev_conn_request *ev = (void *) skb->data; 718 715 int mask = hdev->link_mode; 719 716 720 - BT_DBG("%s Connection request: %s type 0x%x", hdev->name, 721 - batostr(&ev->bdaddr), ev->link_type); 717 + BT_DBG("%s bdaddr %s type 0x%x", hdev->name, 718 + batostr(&ev->bdaddr), ev->link_type); 722 719 723 720 mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ev->link_type); 724 721 ··· 746 745 else 747 746 cp.role = 0x01; /* Remain slave */ 748 747 749 - hci_send_cmd(hdev, OGF_LINK_CTL, 750 - OCF_ACCEPT_CONN_REQ, sizeof(cp), &cp); 748 + hci_send_cmd(hdev, HCI_OP_ACCEPT_CONN_REQ, sizeof(cp), &cp); 751 749 } else { 752 750 /* Connection rejected */ 753 751 struct hci_cp_reject_conn_req cp; 754 752 755 753 bacpy(&cp.bdaddr, &ev->bdaddr); 756 754 cp.reason = 0x0f; 757 - hci_send_cmd(hdev, OGF_LINK_CTL, 758 - OCF_REJECT_CONN_REQ, sizeof(cp), &cp); 755 + hci_send_cmd(hdev, HCI_OP_REJECT_CONN_REQ, sizeof(cp), &cp); 759 756 } 760 757 } 761 758 762 - /* Connect Complete */ 763 - static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) 764 - { 765 - struct hci_ev_conn_complete *ev = (struct hci_ev_conn_complete *) skb->data; 766 - struct hci_conn *conn, *pend; 767 - 768 - BT_DBG("%s", hdev->name); 769 - 770 - hci_dev_lock(hdev); 771 - 772 - conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); 773 - if (!conn) { 774 - hci_dev_unlock(hdev); 775 - return; 776 - } 777 - 778 - if (!ev->status) { 779 - conn->handle = __le16_to_cpu(ev->handle); 780 - conn->state = BT_CONNECTED; 781 - 782 - if (test_bit(HCI_AUTH, &hdev->flags)) 783 - conn->link_mode |= HCI_LM_AUTH; 784 - 785 - if (test_bit(HCI_ENCRYPT, &hdev->flags)) 786 - conn->link_mode |= HCI_LM_ENCRYPT; 787 - 788 - /* Get remote features */ 789 - if (conn->type == ACL_LINK) { 790 - struct hci_cp_read_remote_features cp; 791 - cp.handle = ev->handle; 792 - hci_send_cmd(hdev, OGF_LINK_CTL, 793 - OCF_READ_REMOTE_FEATURES, sizeof(cp), &cp); 794 - } 795 - 796 - /* Set link policy */ 797 - if (conn->type == ACL_LINK && hdev->link_policy) { 798 - struct hci_cp_write_link_policy cp; 799 - cp.handle = ev->handle; 800 - cp.policy = cpu_to_le16(hdev->link_policy); 801 - hci_send_cmd(hdev, OGF_LINK_POLICY, 802 - OCF_WRITE_LINK_POLICY, sizeof(cp), &cp); 803 - } 804 - 805 - /* Set packet type for incoming connection */ 806 - if (!conn->out) { 807 - struct hci_cp_change_conn_ptype cp; 808 - cp.handle = ev->handle; 809 - cp.pkt_type = (conn->type == ACL_LINK) ? 810 - cpu_to_le16(hdev->pkt_type & ACL_PTYPE_MASK): 811 - cpu_to_le16(hdev->pkt_type & SCO_PTYPE_MASK); 812 - 813 - hci_send_cmd(hdev, OGF_LINK_CTL, 814 - OCF_CHANGE_CONN_PTYPE, sizeof(cp), &cp); 815 - } else { 816 - /* Update disconnect timer */ 817 - hci_conn_hold(conn); 818 - hci_conn_put(conn); 819 - } 820 - } else 821 - conn->state = BT_CLOSED; 822 - 823 - if (conn->type == ACL_LINK) { 824 - struct hci_conn *sco = conn->link; 825 - if (sco) { 826 - if (!ev->status) 827 - hci_add_sco(sco, conn->handle); 828 - else { 829 - hci_proto_connect_cfm(sco, ev->status); 830 - hci_conn_del(sco); 831 - } 832 - } 833 - } 834 - 835 - hci_proto_connect_cfm(conn, ev->status); 836 - if (ev->status) 837 - hci_conn_del(conn); 838 - 839 - pend = hci_conn_hash_lookup_state(hdev, ACL_LINK, BT_CONNECT2); 840 - if (pend) 841 - hci_acl_connect(pend); 842 - 843 - hci_dev_unlock(hdev); 844 - } 845 - 846 - /* Disconnect Complete */ 847 759 static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) 848 760 { 849 - struct hci_ev_disconn_complete *ev = (struct hci_ev_disconn_complete *) skb->data; 761 + struct hci_ev_disconn_complete *ev = (void *) skb->data; 850 762 struct hci_conn *conn; 851 763 852 764 BT_DBG("%s status %d", hdev->name, ev->status); ··· 779 865 hci_dev_unlock(hdev); 780 866 } 781 867 782 - /* Number of completed packets */ 868 + static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) 869 + { 870 + struct hci_ev_auth_complete *ev = (void *) skb->data; 871 + struct hci_conn *conn; 872 + 873 + BT_DBG("%s status %d", hdev->name, ev->status); 874 + 875 + hci_dev_lock(hdev); 876 + 877 + conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); 878 + if (conn) { 879 + if (!ev->status) 880 + conn->link_mode |= HCI_LM_AUTH; 881 + 882 + clear_bit(HCI_CONN_AUTH_PEND, &conn->pend); 883 + 884 + hci_auth_cfm(conn, ev->status); 885 + 886 + if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) { 887 + if (!ev->status) { 888 + struct hci_cp_set_conn_encrypt cp; 889 + cp.handle = cpu_to_le16(conn->handle); 890 + cp.encrypt = 1; 891 + hci_send_cmd(conn->hdev, 892 + HCI_OP_SET_CONN_ENCRYPT, sizeof(cp), &cp); 893 + } else { 894 + clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend); 895 + hci_encrypt_cfm(conn, ev->status, 0x00); 896 + } 897 + } 898 + } 899 + 900 + hci_dev_unlock(hdev); 901 + } 902 + 903 + static inline void hci_remote_name_evt(struct hci_dev *hdev, struct sk_buff *skb) 904 + { 905 + BT_DBG("%s", hdev->name); 906 + 907 + hci_conn_check_pending(hdev); 908 + } 909 + 910 + static inline void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff *skb) 911 + { 912 + struct hci_ev_encrypt_change *ev = (void *) skb->data; 913 + struct hci_conn *conn; 914 + 915 + BT_DBG("%s status %d", hdev->name, ev->status); 916 + 917 + hci_dev_lock(hdev); 918 + 919 + conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); 920 + if (conn) { 921 + if (!ev->status) { 922 + if (ev->encrypt) 923 + conn->link_mode |= HCI_LM_ENCRYPT; 924 + else 925 + conn->link_mode &= ~HCI_LM_ENCRYPT; 926 + } 927 + 928 + clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend); 929 + 930 + hci_encrypt_cfm(conn, ev->status, ev->encrypt); 931 + } 932 + 933 + hci_dev_unlock(hdev); 934 + } 935 + 936 + static inline void hci_change_link_key_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) 937 + { 938 + struct hci_ev_change_link_key_complete *ev = (void *) skb->data; 939 + struct hci_conn *conn; 940 + 941 + BT_DBG("%s status %d", hdev->name, ev->status); 942 + 943 + hci_dev_lock(hdev); 944 + 945 + conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); 946 + if (conn) { 947 + if (!ev->status) 948 + conn->link_mode |= HCI_LM_SECURE; 949 + 950 + clear_bit(HCI_CONN_AUTH_PEND, &conn->pend); 951 + 952 + hci_key_change_cfm(conn, ev->status); 953 + } 954 + 955 + hci_dev_unlock(hdev); 956 + } 957 + 958 + static inline void hci_remote_features_evt(struct hci_dev *hdev, struct sk_buff *skb) 959 + { 960 + struct hci_ev_remote_features *ev = (void *) skb->data; 961 + struct hci_conn *conn; 962 + 963 + BT_DBG("%s status %d", hdev->name, ev->status); 964 + 965 + if (ev->status) 966 + return; 967 + 968 + hci_dev_lock(hdev); 969 + 970 + conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); 971 + if (conn) 972 + memcpy(conn->features, ev->features, 8); 973 + 974 + hci_dev_unlock(hdev); 975 + } 976 + 977 + static inline void hci_remote_version_evt(struct hci_dev *hdev, struct sk_buff *skb) 978 + { 979 + BT_DBG("%s", hdev->name); 980 + } 981 + 982 + static inline void hci_qos_setup_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) 983 + { 984 + BT_DBG("%s", hdev->name); 985 + } 986 + 987 + static inline void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) 988 + { 989 + struct hci_ev_cmd_complete *ev = (void *) skb->data; 990 + __u16 opcode; 991 + 992 + skb_pull(skb, sizeof(*ev)); 993 + 994 + opcode = __le16_to_cpu(ev->opcode); 995 + 996 + switch (opcode) { 997 + case HCI_OP_INQUIRY_CANCEL: 998 + hci_cc_inquiry_cancel(hdev, skb); 999 + break; 1000 + 1001 + case HCI_OP_EXIT_PERIODIC_INQ: 1002 + hci_cc_exit_periodic_inq(hdev, skb); 1003 + break; 1004 + 1005 + case HCI_OP_REMOTE_NAME_REQ_CANCEL: 1006 + hci_cc_remote_name_req_cancel(hdev, skb); 1007 + break; 1008 + 1009 + case HCI_OP_ROLE_DISCOVERY: 1010 + hci_cc_role_discovery(hdev, skb); 1011 + break; 1012 + 1013 + case HCI_OP_WRITE_LINK_POLICY: 1014 + hci_cc_write_link_policy(hdev, skb); 1015 + break; 1016 + 1017 + case HCI_OP_RESET: 1018 + hci_cc_reset(hdev, skb); 1019 + break; 1020 + 1021 + case HCI_OP_WRITE_LOCAL_NAME: 1022 + hci_cc_write_local_name(hdev, skb); 1023 + break; 1024 + 1025 + case HCI_OP_READ_LOCAL_NAME: 1026 + hci_cc_read_local_name(hdev, skb); 1027 + break; 1028 + 1029 + case HCI_OP_WRITE_AUTH_ENABLE: 1030 + hci_cc_write_auth_enable(hdev, skb); 1031 + break; 1032 + 1033 + case HCI_OP_WRITE_ENCRYPT_MODE: 1034 + hci_cc_write_encrypt_mode(hdev, skb); 1035 + break; 1036 + 1037 + case HCI_OP_WRITE_SCAN_ENABLE: 1038 + hci_cc_write_scan_enable(hdev, skb); 1039 + break; 1040 + 1041 + case HCI_OP_READ_CLASS_OF_DEV: 1042 + hci_cc_read_class_of_dev(hdev, skb); 1043 + break; 1044 + 1045 + case HCI_OP_WRITE_CLASS_OF_DEV: 1046 + hci_cc_write_class_of_dev(hdev, skb); 1047 + break; 1048 + 1049 + case HCI_OP_READ_VOICE_SETTING: 1050 + hci_cc_read_voice_setting(hdev, skb); 1051 + break; 1052 + 1053 + case HCI_OP_WRITE_VOICE_SETTING: 1054 + hci_cc_write_voice_setting(hdev, skb); 1055 + break; 1056 + 1057 + case HCI_OP_HOST_BUFFER_SIZE: 1058 + hci_cc_host_buffer_size(hdev, skb); 1059 + break; 1060 + 1061 + case HCI_OP_READ_LOCAL_VERSION: 1062 + hci_cc_read_local_version(hdev, skb); 1063 + break; 1064 + 1065 + case HCI_OP_READ_LOCAL_COMMANDS: 1066 + hci_cc_read_local_commands(hdev, skb); 1067 + break; 1068 + 1069 + case HCI_OP_READ_LOCAL_FEATURES: 1070 + hci_cc_read_local_features(hdev, skb); 1071 + break; 1072 + 1073 + case HCI_OP_READ_BUFFER_SIZE: 1074 + hci_cc_read_buffer_size(hdev, skb); 1075 + break; 1076 + 1077 + case HCI_OP_READ_BD_ADDR: 1078 + hci_cc_read_bd_addr(hdev, skb); 1079 + break; 1080 + 1081 + default: 1082 + BT_DBG("%s opcode 0x%x", hdev->name, opcode); 1083 + break; 1084 + } 1085 + 1086 + if (ev->ncmd) { 1087 + atomic_set(&hdev->cmd_cnt, 1); 1088 + if (!skb_queue_empty(&hdev->cmd_q)) 1089 + hci_sched_cmd(hdev); 1090 + } 1091 + } 1092 + 1093 + static inline void hci_cmd_status_evt(struct hci_dev *hdev, struct sk_buff *skb) 1094 + { 1095 + struct hci_ev_cmd_status *ev = (void *) skb->data; 1096 + __u16 opcode; 1097 + 1098 + skb_pull(skb, sizeof(*ev)); 1099 + 1100 + opcode = __le16_to_cpu(ev->opcode); 1101 + 1102 + switch (opcode) { 1103 + case HCI_OP_INQUIRY: 1104 + hci_cs_inquiry(hdev, ev->status); 1105 + break; 1106 + 1107 + case HCI_OP_CREATE_CONN: 1108 + hci_cs_create_conn(hdev, ev->status); 1109 + break; 1110 + 1111 + case HCI_OP_ADD_SCO: 1112 + hci_cs_add_sco(hdev, ev->status); 1113 + break; 1114 + 1115 + case HCI_OP_REMOTE_NAME_REQ: 1116 + hci_cs_remote_name_req(hdev, ev->status); 1117 + break; 1118 + 1119 + case HCI_OP_SETUP_SYNC_CONN: 1120 + hci_cs_setup_sync_conn(hdev, ev->status); 1121 + break; 1122 + 1123 + case HCI_OP_SNIFF_MODE: 1124 + hci_cs_sniff_mode(hdev, ev->status); 1125 + break; 1126 + 1127 + case HCI_OP_EXIT_SNIFF_MODE: 1128 + hci_cs_exit_sniff_mode(hdev, ev->status); 1129 + break; 1130 + 1131 + default: 1132 + BT_DBG("%s opcode 0x%x", hdev->name, opcode); 1133 + break; 1134 + } 1135 + 1136 + if (ev->ncmd) { 1137 + atomic_set(&hdev->cmd_cnt, 1); 1138 + if (!skb_queue_empty(&hdev->cmd_q)) 1139 + hci_sched_cmd(hdev); 1140 + } 1141 + } 1142 + 1143 + static inline void hci_role_change_evt(struct hci_dev *hdev, struct sk_buff *skb) 1144 + { 1145 + struct hci_ev_role_change *ev = (void *) skb->data; 1146 + struct hci_conn *conn; 1147 + 1148 + BT_DBG("%s status %d", hdev->name, ev->status); 1149 + 1150 + hci_dev_lock(hdev); 1151 + 1152 + conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); 1153 + if (conn) { 1154 + if (!ev->status) { 1155 + if (ev->role) 1156 + conn->link_mode &= ~HCI_LM_MASTER; 1157 + else 1158 + conn->link_mode |= HCI_LM_MASTER; 1159 + } 1160 + 1161 + clear_bit(HCI_CONN_RSWITCH_PEND, &conn->pend); 1162 + 1163 + hci_role_switch_cfm(conn, ev->status, ev->role); 1164 + } 1165 + 1166 + hci_dev_unlock(hdev); 1167 + } 1168 + 783 1169 static inline void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *skb) 784 1170 { 785 - struct hci_ev_num_comp_pkts *ev = (struct hci_ev_num_comp_pkts *) skb->data; 1171 + struct hci_ev_num_comp_pkts *ev = (void *) skb->data; 786 1172 __le16 *ptr; 787 1173 int i; 788 1174 ··· 1117 903 } 1118 904 } 1119 905 } 906 + 1120 907 hci_sched_tx(hdev); 1121 908 1122 909 tasklet_enable(&hdev->tx_task); 1123 910 } 1124 911 1125 - /* Role Change */ 1126 - static inline void hci_role_change_evt(struct hci_dev *hdev, struct sk_buff *skb) 1127 - { 1128 - struct hci_ev_role_change *ev = (struct hci_ev_role_change *) skb->data; 1129 - struct hci_conn *conn; 1130 - 1131 - BT_DBG("%s status %d", hdev->name, ev->status); 1132 - 1133 - hci_dev_lock(hdev); 1134 - 1135 - conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); 1136 - if (conn) { 1137 - if (!ev->status) { 1138 - if (ev->role) 1139 - conn->link_mode &= ~HCI_LM_MASTER; 1140 - else 1141 - conn->link_mode |= HCI_LM_MASTER; 1142 - } 1143 - 1144 - clear_bit(HCI_CONN_RSWITCH_PEND, &conn->pend); 1145 - 1146 - hci_role_switch_cfm(conn, ev->status, ev->role); 1147 - } 1148 - 1149 - hci_dev_unlock(hdev); 1150 - } 1151 - 1152 - /* Mode Change */ 1153 912 static inline void hci_mode_change_evt(struct hci_dev *hdev, struct sk_buff *skb) 1154 913 { 1155 - struct hci_ev_mode_change *ev = (struct hci_ev_mode_change *) skb->data; 914 + struct hci_ev_mode_change *ev = (void *) skb->data; 1156 915 struct hci_conn *conn; 1157 916 1158 917 BT_DBG("%s status %d", hdev->name, ev->status); ··· 1148 961 hci_dev_unlock(hdev); 1149 962 } 1150 963 1151 - /* Authentication Complete */ 1152 - static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) 1153 - { 1154 - struct hci_ev_auth_complete *ev = (struct hci_ev_auth_complete *) skb->data; 1155 - struct hci_conn *conn; 1156 - 1157 - BT_DBG("%s status %d", hdev->name, ev->status); 1158 - 1159 - hci_dev_lock(hdev); 1160 - 1161 - conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); 1162 - if (conn) { 1163 - if (!ev->status) 1164 - conn->link_mode |= HCI_LM_AUTH; 1165 - 1166 - clear_bit(HCI_CONN_AUTH_PEND, &conn->pend); 1167 - 1168 - hci_auth_cfm(conn, ev->status); 1169 - 1170 - if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) { 1171 - if (!ev->status) { 1172 - struct hci_cp_set_conn_encrypt cp; 1173 - cp.handle = cpu_to_le16(conn->handle); 1174 - cp.encrypt = 1; 1175 - hci_send_cmd(conn->hdev, OGF_LINK_CTL, 1176 - OCF_SET_CONN_ENCRYPT, sizeof(cp), &cp); 1177 - } else { 1178 - clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend); 1179 - hci_encrypt_cfm(conn, ev->status, 0x00); 1180 - } 1181 - } 1182 - } 1183 - 1184 - hci_dev_unlock(hdev); 1185 - } 1186 - 1187 - /* Encryption Change */ 1188 - static inline void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff *skb) 1189 - { 1190 - struct hci_ev_encrypt_change *ev = (struct hci_ev_encrypt_change *) skb->data; 1191 - struct hci_conn *conn; 1192 - 1193 - BT_DBG("%s status %d", hdev->name, ev->status); 1194 - 1195 - hci_dev_lock(hdev); 1196 - 1197 - conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); 1198 - if (conn) { 1199 - if (!ev->status) { 1200 - if (ev->encrypt) 1201 - conn->link_mode |= HCI_LM_ENCRYPT; 1202 - else 1203 - conn->link_mode &= ~HCI_LM_ENCRYPT; 1204 - } 1205 - 1206 - clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend); 1207 - 1208 - hci_encrypt_cfm(conn, ev->status, ev->encrypt); 1209 - } 1210 - 1211 - hci_dev_unlock(hdev); 1212 - } 1213 - 1214 - /* Change Connection Link Key Complete */ 1215 - static inline void hci_change_conn_link_key_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) 1216 - { 1217 - struct hci_ev_change_conn_link_key_complete *ev = (struct hci_ev_change_conn_link_key_complete *) skb->data; 1218 - struct hci_conn *conn; 1219 - 1220 - BT_DBG("%s status %d", hdev->name, ev->status); 1221 - 1222 - hci_dev_lock(hdev); 1223 - 1224 - conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); 1225 - if (conn) { 1226 - if (!ev->status) 1227 - conn->link_mode |= HCI_LM_SECURE; 1228 - 1229 - clear_bit(HCI_CONN_AUTH_PEND, &conn->pend); 1230 - 1231 - hci_key_change_cfm(conn, ev->status); 1232 - } 1233 - 1234 - hci_dev_unlock(hdev); 1235 - } 1236 - 1237 - /* Pin Code Request*/ 1238 964 static inline void hci_pin_code_request_evt(struct hci_dev *hdev, struct sk_buff *skb) 1239 965 { 966 + BT_DBG("%s", hdev->name); 1240 967 } 1241 968 1242 - /* Link Key Request */ 1243 969 static inline void hci_link_key_request_evt(struct hci_dev *hdev, struct sk_buff *skb) 1244 970 { 971 + BT_DBG("%s", hdev->name); 1245 972 } 1246 973 1247 - /* Link Key Notification */ 1248 974 static inline void hci_link_key_notify_evt(struct hci_dev *hdev, struct sk_buff *skb) 1249 975 { 976 + BT_DBG("%s", hdev->name); 1250 977 } 1251 978 1252 - /* Remote Features */ 1253 - static inline void hci_remote_features_evt(struct hci_dev *hdev, struct sk_buff *skb) 1254 - { 1255 - struct hci_ev_remote_features *ev = (struct hci_ev_remote_features *) skb->data; 1256 - struct hci_conn *conn; 1257 - 1258 - BT_DBG("%s status %d", hdev->name, ev->status); 1259 - 1260 - hci_dev_lock(hdev); 1261 - 1262 - conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); 1263 - if (conn && !ev->status) { 1264 - memcpy(conn->features, ev->features, sizeof(conn->features)); 1265 - } 1266 - 1267 - hci_dev_unlock(hdev); 1268 - } 1269 - 1270 - /* Clock Offset */ 1271 979 static inline void hci_clock_offset_evt(struct hci_dev *hdev, struct sk_buff *skb) 1272 980 { 1273 - struct hci_ev_clock_offset *ev = (struct hci_ev_clock_offset *) skb->data; 981 + struct hci_ev_clock_offset *ev = (void *) skb->data; 1274 982 struct hci_conn *conn; 1275 983 1276 984 BT_DBG("%s status %d", hdev->name, ev->status); ··· 1185 1103 hci_dev_unlock(hdev); 1186 1104 } 1187 1105 1188 - /* Page Scan Repetition Mode */ 1189 1106 static inline void hci_pscan_rep_mode_evt(struct hci_dev *hdev, struct sk_buff *skb) 1190 1107 { 1191 - struct hci_ev_pscan_rep_mode *ev = (struct hci_ev_pscan_rep_mode *) skb->data; 1108 + struct hci_ev_pscan_rep_mode *ev = (void *) skb->data; 1192 1109 struct inquiry_entry *ie; 1193 1110 1194 1111 BT_DBG("%s", hdev->name); ··· 1202 1121 hci_dev_unlock(hdev); 1203 1122 } 1204 1123 1205 - /* Sniff Subrate */ 1124 + static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct sk_buff *skb) 1125 + { 1126 + struct inquiry_data data; 1127 + int num_rsp = *((__u8 *) skb->data); 1128 + 1129 + BT_DBG("%s num_rsp %d", hdev->name, num_rsp); 1130 + 1131 + if (!num_rsp) 1132 + return; 1133 + 1134 + hci_dev_lock(hdev); 1135 + 1136 + if ((skb->len - 1) / num_rsp != sizeof(struct inquiry_info_with_rssi)) { 1137 + struct inquiry_info_with_rssi_and_pscan_mode *info = (void *) (skb->data + 1); 1138 + 1139 + for (; num_rsp; num_rsp--) { 1140 + bacpy(&data.bdaddr, &info->bdaddr); 1141 + data.pscan_rep_mode = info->pscan_rep_mode; 1142 + data.pscan_period_mode = info->pscan_period_mode; 1143 + data.pscan_mode = info->pscan_mode; 1144 + memcpy(data.dev_class, info->dev_class, 3); 1145 + data.clock_offset = info->clock_offset; 1146 + data.rssi = info->rssi; 1147 + info++; 1148 + hci_inquiry_cache_update(hdev, &data); 1149 + } 1150 + } else { 1151 + struct inquiry_info_with_rssi *info = (void *) (skb->data + 1); 1152 + 1153 + for (; num_rsp; num_rsp--) { 1154 + bacpy(&data.bdaddr, &info->bdaddr); 1155 + data.pscan_rep_mode = info->pscan_rep_mode; 1156 + data.pscan_period_mode = info->pscan_period_mode; 1157 + data.pscan_mode = 0x00; 1158 + memcpy(data.dev_class, info->dev_class, 3); 1159 + data.clock_offset = info->clock_offset; 1160 + data.rssi = info->rssi; 1161 + info++; 1162 + hci_inquiry_cache_update(hdev, &data); 1163 + } 1164 + } 1165 + 1166 + hci_dev_unlock(hdev); 1167 + } 1168 + 1169 + static inline void hci_remote_ext_features_evt(struct hci_dev *hdev, struct sk_buff *skb) 1170 + { 1171 + BT_DBG("%s", hdev->name); 1172 + } 1173 + 1174 + static inline void hci_sync_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) 1175 + { 1176 + BT_DBG("%s", hdev->name); 1177 + } 1178 + 1179 + static inline void hci_sync_conn_changed_evt(struct hci_dev *hdev, struct sk_buff *skb) 1180 + { 1181 + BT_DBG("%s", hdev->name); 1182 + } 1183 + 1206 1184 static inline void hci_sniff_subrate_evt(struct hci_dev *hdev, struct sk_buff *skb) 1207 1185 { 1208 - struct hci_ev_sniff_subrate *ev = (struct hci_ev_sniff_subrate *) skb->data; 1186 + struct hci_ev_sniff_subrate *ev = (void *) skb->data; 1209 1187 struct hci_conn *conn; 1210 1188 1211 1189 BT_DBG("%s status %d", hdev->name, ev->status); ··· 1278 1138 hci_dev_unlock(hdev); 1279 1139 } 1280 1140 1141 + static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb) 1142 + { 1143 + struct inquiry_data data; 1144 + struct extended_inquiry_info *info = (void *) (skb->data + 1); 1145 + int num_rsp = *((__u8 *) skb->data); 1146 + 1147 + BT_DBG("%s num_rsp %d", hdev->name, num_rsp); 1148 + 1149 + if (!num_rsp) 1150 + return; 1151 + 1152 + hci_dev_lock(hdev); 1153 + 1154 + for (; num_rsp; num_rsp--) { 1155 + bacpy(&data.bdaddr, &info->bdaddr); 1156 + data.pscan_rep_mode = info->pscan_rep_mode; 1157 + data.pscan_period_mode = info->pscan_period_mode; 1158 + data.pscan_mode = 0x00; 1159 + memcpy(data.dev_class, info->dev_class, 3); 1160 + data.clock_offset = info->clock_offset; 1161 + data.rssi = info->rssi; 1162 + info++; 1163 + hci_inquiry_cache_update(hdev, &data); 1164 + } 1165 + 1166 + hci_dev_unlock(hdev); 1167 + } 1168 + 1281 1169 void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) 1282 1170 { 1283 - struct hci_event_hdr *hdr = (struct hci_event_hdr *) skb->data; 1284 - struct hci_ev_cmd_complete *ec; 1285 - struct hci_ev_cmd_status *cs; 1286 - u16 opcode, ocf, ogf; 1171 + struct hci_event_hdr *hdr = (void *) skb->data; 1172 + __u8 event = hdr->evt; 1287 1173 1288 1174 skb_pull(skb, HCI_EVENT_HDR_SIZE); 1289 1175 1290 - BT_DBG("%s evt 0x%x", hdev->name, hdr->evt); 1291 - 1292 - switch (hdr->evt) { 1293 - case HCI_EV_NUM_COMP_PKTS: 1294 - hci_num_comp_pkts_evt(hdev, skb); 1295 - break; 1296 - 1176 + switch (event) { 1297 1177 case HCI_EV_INQUIRY_COMPLETE: 1298 1178 hci_inquiry_complete_evt(hdev, skb); 1299 1179 break; ··· 1322 1162 hci_inquiry_result_evt(hdev, skb); 1323 1163 break; 1324 1164 1325 - case HCI_EV_INQUIRY_RESULT_WITH_RSSI: 1326 - hci_inquiry_result_with_rssi_evt(hdev, skb); 1327 - break; 1328 - 1329 - case HCI_EV_EXTENDED_INQUIRY_RESULT: 1330 - hci_extended_inquiry_result_evt(hdev, skb); 1165 + case HCI_EV_CONN_COMPLETE: 1166 + hci_conn_complete_evt(hdev, skb); 1331 1167 break; 1332 1168 1333 1169 case HCI_EV_CONN_REQUEST: 1334 1170 hci_conn_request_evt(hdev, skb); 1335 1171 break; 1336 1172 1337 - case HCI_EV_CONN_COMPLETE: 1338 - hci_conn_complete_evt(hdev, skb); 1339 - break; 1340 - 1341 1173 case HCI_EV_DISCONN_COMPLETE: 1342 1174 hci_disconn_complete_evt(hdev, skb); 1343 - break; 1344 - 1345 - case HCI_EV_ROLE_CHANGE: 1346 - hci_role_change_evt(hdev, skb); 1347 - break; 1348 - 1349 - case HCI_EV_MODE_CHANGE: 1350 - hci_mode_change_evt(hdev, skb); 1351 1175 break; 1352 1176 1353 1177 case HCI_EV_AUTH_COMPLETE: 1354 1178 hci_auth_complete_evt(hdev, skb); 1355 1179 break; 1356 1180 1181 + case HCI_EV_REMOTE_NAME: 1182 + hci_remote_name_evt(hdev, skb); 1183 + break; 1184 + 1357 1185 case HCI_EV_ENCRYPT_CHANGE: 1358 1186 hci_encrypt_change_evt(hdev, skb); 1359 1187 break; 1360 1188 1361 - case HCI_EV_CHANGE_CONN_LINK_KEY_COMPLETE: 1362 - hci_change_conn_link_key_complete_evt(hdev, skb); 1189 + case HCI_EV_CHANGE_LINK_KEY_COMPLETE: 1190 + hci_change_link_key_complete_evt(hdev, skb); 1191 + break; 1192 + 1193 + case HCI_EV_REMOTE_FEATURES: 1194 + hci_remote_features_evt(hdev, skb); 1195 + break; 1196 + 1197 + case HCI_EV_REMOTE_VERSION: 1198 + hci_remote_version_evt(hdev, skb); 1199 + break; 1200 + 1201 + case HCI_EV_QOS_SETUP_COMPLETE: 1202 + hci_qos_setup_complete_evt(hdev, skb); 1203 + break; 1204 + 1205 + case HCI_EV_CMD_COMPLETE: 1206 + hci_cmd_complete_evt(hdev, skb); 1207 + break; 1208 + 1209 + case HCI_EV_CMD_STATUS: 1210 + hci_cmd_status_evt(hdev, skb); 1211 + break; 1212 + 1213 + case HCI_EV_ROLE_CHANGE: 1214 + hci_role_change_evt(hdev, skb); 1215 + break; 1216 + 1217 + case HCI_EV_NUM_COMP_PKTS: 1218 + hci_num_comp_pkts_evt(hdev, skb); 1219 + break; 1220 + 1221 + case HCI_EV_MODE_CHANGE: 1222 + hci_mode_change_evt(hdev, skb); 1363 1223 break; 1364 1224 1365 1225 case HCI_EV_PIN_CODE_REQ: ··· 1394 1214 hci_link_key_notify_evt(hdev, skb); 1395 1215 break; 1396 1216 1397 - case HCI_EV_REMOTE_FEATURES: 1398 - hci_remote_features_evt(hdev, skb); 1399 - break; 1400 - 1401 1217 case HCI_EV_CLOCK_OFFSET: 1402 1218 hci_clock_offset_evt(hdev, skb); 1403 1219 break; ··· 1402 1226 hci_pscan_rep_mode_evt(hdev, skb); 1403 1227 break; 1404 1228 1229 + case HCI_EV_INQUIRY_RESULT_WITH_RSSI: 1230 + hci_inquiry_result_with_rssi_evt(hdev, skb); 1231 + break; 1232 + 1233 + case HCI_EV_REMOTE_EXT_FEATURES: 1234 + hci_remote_ext_features_evt(hdev, skb); 1235 + break; 1236 + 1237 + case HCI_EV_SYNC_CONN_COMPLETE: 1238 + hci_sync_conn_complete_evt(hdev, skb); 1239 + break; 1240 + 1241 + case HCI_EV_SYNC_CONN_CHANGED: 1242 + hci_sync_conn_changed_evt(hdev, skb); 1243 + break; 1244 + 1405 1245 case HCI_EV_SNIFF_SUBRATE: 1406 1246 hci_sniff_subrate_evt(hdev, skb); 1407 1247 break; 1408 1248 1409 - case HCI_EV_CMD_STATUS: 1410 - cs = (struct hci_ev_cmd_status *) skb->data; 1411 - skb_pull(skb, sizeof(cs)); 1412 - 1413 - opcode = __le16_to_cpu(cs->opcode); 1414 - ogf = hci_opcode_ogf(opcode); 1415 - ocf = hci_opcode_ocf(opcode); 1416 - 1417 - switch (ogf) { 1418 - case OGF_INFO_PARAM: 1419 - hci_cs_info_param(hdev, ocf, cs->status); 1420 - break; 1421 - 1422 - case OGF_HOST_CTL: 1423 - hci_cs_host_ctl(hdev, ocf, cs->status); 1424 - break; 1425 - 1426 - case OGF_LINK_CTL: 1427 - hci_cs_link_ctl(hdev, ocf, cs->status); 1428 - break; 1429 - 1430 - case OGF_LINK_POLICY: 1431 - hci_cs_link_policy(hdev, ocf, cs->status); 1432 - break; 1433 - 1434 - default: 1435 - BT_DBG("%s Command Status OGF %x", hdev->name, ogf); 1436 - break; 1437 - } 1438 - 1439 - if (cs->ncmd) { 1440 - atomic_set(&hdev->cmd_cnt, 1); 1441 - if (!skb_queue_empty(&hdev->cmd_q)) 1442 - hci_sched_cmd(hdev); 1443 - } 1249 + case HCI_EV_EXTENDED_INQUIRY_RESULT: 1250 + hci_extended_inquiry_result_evt(hdev, skb); 1444 1251 break; 1445 1252 1446 - case HCI_EV_CMD_COMPLETE: 1447 - ec = (struct hci_ev_cmd_complete *) skb->data; 1448 - skb_pull(skb, sizeof(*ec)); 1449 - 1450 - opcode = __le16_to_cpu(ec->opcode); 1451 - ogf = hci_opcode_ogf(opcode); 1452 - ocf = hci_opcode_ocf(opcode); 1453 - 1454 - switch (ogf) { 1455 - case OGF_INFO_PARAM: 1456 - hci_cc_info_param(hdev, ocf, skb); 1457 - break; 1458 - 1459 - case OGF_HOST_CTL: 1460 - hci_cc_host_ctl(hdev, ocf, skb); 1461 - break; 1462 - 1463 - case OGF_LINK_CTL: 1464 - hci_cc_link_ctl(hdev, ocf, skb); 1465 - break; 1466 - 1467 - case OGF_LINK_POLICY: 1468 - hci_cc_link_policy(hdev, ocf, skb); 1469 - break; 1470 - 1471 - default: 1472 - BT_DBG("%s Command Completed OGF %x", hdev->name, ogf); 1473 - break; 1474 - } 1475 - 1476 - if (ec->ncmd) { 1477 - atomic_set(&hdev->cmd_cnt, 1); 1478 - if (!skb_queue_empty(&hdev->cmd_q)) 1479 - hci_sched_cmd(hdev); 1480 - } 1253 + default: 1254 + BT_DBG("%s event 0x%x", hdev->name, event); 1481 1255 break; 1482 1256 } 1483 1257
+1 -1
net/bluetooth/hci_sock.c
··· 451 451 goto drop; 452 452 } 453 453 454 - if (test_bit(HCI_RAW, &hdev->flags) || (ogf == OGF_VENDOR_CMD)) { 454 + if (test_bit(HCI_RAW, &hdev->flags) || (ogf == 0x3f)) { 455 455 skb_queue_tail(&hdev->raw_q, skb); 456 456 hci_sched_tx(hdev); 457 457 } else {
+37
net/bluetooth/hci_sysfs.c
··· 41 41 return sprintf(buf, "%s\n", typetostr(hdev->type)); 42 42 } 43 43 44 + static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf) 45 + { 46 + struct hci_dev *hdev = dev_get_drvdata(dev); 47 + char name[249]; 48 + int i; 49 + 50 + for (i = 0; i < 248; i++) 51 + name[i] = hdev->dev_name[i]; 52 + 53 + name[248] = '\0'; 54 + return sprintf(buf, "%s\n", name); 55 + } 56 + 57 + static ssize_t show_class(struct device *dev, struct device_attribute *attr, char *buf) 58 + { 59 + struct hci_dev *hdev = dev_get_drvdata(dev); 60 + return sprintf(buf, "0x%.2x%.2x%.2x\n", 61 + hdev->dev_class[2], hdev->dev_class[1], hdev->dev_class[0]); 62 + } 63 + 44 64 static ssize_t show_address(struct device *dev, struct device_attribute *attr, char *buf) 45 65 { 46 66 struct hci_dev *hdev = dev_get_drvdata(dev); 47 67 bdaddr_t bdaddr; 48 68 baswap(&bdaddr, &hdev->bdaddr); 49 69 return sprintf(buf, "%s\n", batostr(&bdaddr)); 70 + } 71 + 72 + static ssize_t show_features(struct device *dev, struct device_attribute *attr, char *buf) 73 + { 74 + struct hci_dev *hdev = dev_get_drvdata(dev); 75 + 76 + return sprintf(buf, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n", 77 + hdev->features[0], hdev->features[1], 78 + hdev->features[2], hdev->features[3], 79 + hdev->features[4], hdev->features[5], 80 + hdev->features[6], hdev->features[7]); 50 81 } 51 82 52 83 static ssize_t show_manufacturer(struct device *dev, struct device_attribute *attr, char *buf) ··· 201 170 } 202 171 203 172 static DEVICE_ATTR(type, S_IRUGO, show_type, NULL); 173 + static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); 174 + static DEVICE_ATTR(class, S_IRUGO, show_class, NULL); 204 175 static DEVICE_ATTR(address, S_IRUGO, show_address, NULL); 176 + static DEVICE_ATTR(features, S_IRUGO, show_features, NULL); 205 177 static DEVICE_ATTR(manufacturer, S_IRUGO, show_manufacturer, NULL); 206 178 static DEVICE_ATTR(hci_version, S_IRUGO, show_hci_version, NULL); 207 179 static DEVICE_ATTR(hci_revision, S_IRUGO, show_hci_revision, NULL); ··· 219 185 220 186 static struct device_attribute *bt_attrs[] = { 221 187 &dev_attr_type, 188 + &dev_attr_name, 189 + &dev_attr_class, 222 190 &dev_attr_address, 191 + &dev_attr_features, 223 192 &dev_attr_manufacturer, 224 193 &dev_attr_hci_version, 225 194 &dev_attr_hci_revision,