mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	Bluetooth: hci_sync: Convert MGMT_OP_SET_PHY_CONFIGURATION
mgmt-test paths: Set PHY 2m Success Set PHY coded Succcess Set PHY 1m 2m coded Succcess Set PHY 2m tx success Set PHY 2m rx success Set PHY Invalid Param Start Discovery - (2m, Scan Param) Start Discovery - (coded, Scan Param) Start Discovery - (1m, 2m, coded, Scan Param) Signed-off-by: Brian Gix <brian.gix@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
This commit is contained in:
		
							parent
							
								
									6f6ff38a1e
								
							
						
					
					
						commit
						71efbb08b5
					
				
					 1 changed files with 68 additions and 52 deletions
				
			
		| 
						 | 
				
			
			@ -3414,23 +3414,26 @@ int mgmt_phy_configuration_changed(struct hci_dev *hdev, struct sock *skip)
 | 
			
		|||
			  sizeof(ev), skip);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void set_default_phy_complete(struct hci_dev *hdev, u8 status,
 | 
			
		||||
				     u16 opcode, struct sk_buff *skb)
 | 
			
		||||
static void set_default_phy_complete(struct hci_dev *hdev, void *data, int err)
 | 
			
		||||
{
 | 
			
		||||
	struct mgmt_pending_cmd *cmd;
 | 
			
		||||
	struct mgmt_pending_cmd *cmd = data;
 | 
			
		||||
	struct sk_buff *skb = cmd->skb;
 | 
			
		||||
	u8 status = mgmt_status(err);
 | 
			
		||||
 | 
			
		||||
	bt_dev_dbg(hdev, "status 0x%02x", status);
 | 
			
		||||
	if (!status) {
 | 
			
		||||
		if (!skb)
 | 
			
		||||
			status = MGMT_STATUS_FAILED;
 | 
			
		||||
		else if (IS_ERR(skb))
 | 
			
		||||
			status = mgmt_status(PTR_ERR(skb));
 | 
			
		||||
		else
 | 
			
		||||
			status = mgmt_status(skb->data[0]);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	hci_dev_lock(hdev);
 | 
			
		||||
 | 
			
		||||
	cmd = pending_find(MGMT_OP_SET_PHY_CONFIGURATION, hdev);
 | 
			
		||||
	if (!cmd)
 | 
			
		||||
		goto unlock;
 | 
			
		||||
	bt_dev_dbg(hdev, "status %d", status);
 | 
			
		||||
 | 
			
		||||
	if (status) {
 | 
			
		||||
		mgmt_cmd_status(cmd->sk, hdev->id,
 | 
			
		||||
				MGMT_OP_SET_PHY_CONFIGURATION,
 | 
			
		||||
				mgmt_status(status));
 | 
			
		||||
				MGMT_OP_SET_PHY_CONFIGURATION, status);
 | 
			
		||||
	} else {
 | 
			
		||||
		mgmt_cmd_complete(cmd->sk, hdev->id,
 | 
			
		||||
				  MGMT_OP_SET_PHY_CONFIGURATION, 0,
 | 
			
		||||
| 
						 | 
				
			
			@ -3439,19 +3442,56 @@ static void set_default_phy_complete(struct hci_dev *hdev, u8 status,
 | 
			
		|||
		mgmt_phy_configuration_changed(hdev, cmd->sk);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	mgmt_pending_remove(cmd);
 | 
			
		||||
	if (skb && !IS_ERR(skb))
 | 
			
		||||
		kfree_skb(skb);
 | 
			
		||||
 | 
			
		||||
unlock:
 | 
			
		||||
	hci_dev_unlock(hdev);
 | 
			
		||||
	mgmt_pending_remove(cmd);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int set_default_phy_sync(struct hci_dev *hdev, void *data)
 | 
			
		||||
{
 | 
			
		||||
	struct mgmt_pending_cmd *cmd = data;
 | 
			
		||||
	struct mgmt_cp_set_phy_configuration *cp = cmd->param;
 | 
			
		||||
	struct hci_cp_le_set_default_phy cp_phy;
 | 
			
		||||
	u32 selected_phys = __le32_to_cpu(cp->selected_phys);
 | 
			
		||||
 | 
			
		||||
	memset(&cp_phy, 0, sizeof(cp_phy));
 | 
			
		||||
 | 
			
		||||
	if (!(selected_phys & MGMT_PHY_LE_TX_MASK))
 | 
			
		||||
		cp_phy.all_phys |= 0x01;
 | 
			
		||||
 | 
			
		||||
	if (!(selected_phys & MGMT_PHY_LE_RX_MASK))
 | 
			
		||||
		cp_phy.all_phys |= 0x02;
 | 
			
		||||
 | 
			
		||||
	if (selected_phys & MGMT_PHY_LE_1M_TX)
 | 
			
		||||
		cp_phy.tx_phys |= HCI_LE_SET_PHY_1M;
 | 
			
		||||
 | 
			
		||||
	if (selected_phys & MGMT_PHY_LE_2M_TX)
 | 
			
		||||
		cp_phy.tx_phys |= HCI_LE_SET_PHY_2M;
 | 
			
		||||
 | 
			
		||||
	if (selected_phys & MGMT_PHY_LE_CODED_TX)
 | 
			
		||||
		cp_phy.tx_phys |= HCI_LE_SET_PHY_CODED;
 | 
			
		||||
 | 
			
		||||
	if (selected_phys & MGMT_PHY_LE_1M_RX)
 | 
			
		||||
		cp_phy.rx_phys |= HCI_LE_SET_PHY_1M;
 | 
			
		||||
 | 
			
		||||
	if (selected_phys & MGMT_PHY_LE_2M_RX)
 | 
			
		||||
		cp_phy.rx_phys |= HCI_LE_SET_PHY_2M;
 | 
			
		||||
 | 
			
		||||
	if (selected_phys & MGMT_PHY_LE_CODED_RX)
 | 
			
		||||
		cp_phy.rx_phys |= HCI_LE_SET_PHY_CODED;
 | 
			
		||||
 | 
			
		||||
	cmd->skb =  __hci_cmd_sync(hdev, HCI_OP_LE_SET_DEFAULT_PHY,
 | 
			
		||||
				   sizeof(cp_phy), &cp_phy, HCI_CMD_TIMEOUT);
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int set_phy_configuration(struct sock *sk, struct hci_dev *hdev,
 | 
			
		||||
				 void *data, u16 len)
 | 
			
		||||
{
 | 
			
		||||
	struct mgmt_cp_set_phy_configuration *cp = data;
 | 
			
		||||
	struct hci_cp_le_set_default_phy cp_phy;
 | 
			
		||||
	struct mgmt_pending_cmd *cmd;
 | 
			
		||||
	struct hci_request req;
 | 
			
		||||
	u32 selected_phys, configurable_phys, supported_phys, unconfigure_phys;
 | 
			
		||||
	u16 pkt_type = (HCI_DH1 | HCI_DM1);
 | 
			
		||||
	bool changed = false;
 | 
			
		||||
| 
						 | 
				
			
			@ -3555,45 +3595,21 @@ static int set_phy_configuration(struct sock *sk, struct hci_dev *hdev,
 | 
			
		|||
 | 
			
		||||
	cmd = mgmt_pending_add(sk, MGMT_OP_SET_PHY_CONFIGURATION, hdev, data,
 | 
			
		||||
			       len);
 | 
			
		||||
	if (!cmd) {
 | 
			
		||||
	if (!cmd)
 | 
			
		||||
		err = -ENOMEM;
 | 
			
		||||
		goto unlock;
 | 
			
		||||
	else
 | 
			
		||||
		err = hci_cmd_sync_queue(hdev, set_default_phy_sync, cmd,
 | 
			
		||||
					 set_default_phy_complete);
 | 
			
		||||
 | 
			
		||||
	if (err < 0) {
 | 
			
		||||
		err = mgmt_cmd_status(sk, hdev->id,
 | 
			
		||||
				      MGMT_OP_SET_PHY_CONFIGURATION,
 | 
			
		||||
				      MGMT_STATUS_FAILED);
 | 
			
		||||
 | 
			
		||||
		if (cmd)
 | 
			
		||||
			mgmt_pending_remove(cmd);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	hci_req_init(&req, hdev);
 | 
			
		||||
 | 
			
		||||
	memset(&cp_phy, 0, sizeof(cp_phy));
 | 
			
		||||
 | 
			
		||||
	if (!(selected_phys & MGMT_PHY_LE_TX_MASK))
 | 
			
		||||
		cp_phy.all_phys |= 0x01;
 | 
			
		||||
 | 
			
		||||
	if (!(selected_phys & MGMT_PHY_LE_RX_MASK))
 | 
			
		||||
		cp_phy.all_phys |= 0x02;
 | 
			
		||||
 | 
			
		||||
	if (selected_phys & MGMT_PHY_LE_1M_TX)
 | 
			
		||||
		cp_phy.tx_phys |= HCI_LE_SET_PHY_1M;
 | 
			
		||||
 | 
			
		||||
	if (selected_phys & MGMT_PHY_LE_2M_TX)
 | 
			
		||||
		cp_phy.tx_phys |= HCI_LE_SET_PHY_2M;
 | 
			
		||||
 | 
			
		||||
	if (selected_phys & MGMT_PHY_LE_CODED_TX)
 | 
			
		||||
		cp_phy.tx_phys |= HCI_LE_SET_PHY_CODED;
 | 
			
		||||
 | 
			
		||||
	if (selected_phys & MGMT_PHY_LE_1M_RX)
 | 
			
		||||
		cp_phy.rx_phys |= HCI_LE_SET_PHY_1M;
 | 
			
		||||
 | 
			
		||||
	if (selected_phys & MGMT_PHY_LE_2M_RX)
 | 
			
		||||
		cp_phy.rx_phys |= HCI_LE_SET_PHY_2M;
 | 
			
		||||
 | 
			
		||||
	if (selected_phys & MGMT_PHY_LE_CODED_RX)
 | 
			
		||||
		cp_phy.rx_phys |= HCI_LE_SET_PHY_CODED;
 | 
			
		||||
 | 
			
		||||
	hci_req_add(&req, HCI_OP_LE_SET_DEFAULT_PHY, sizeof(cp_phy), &cp_phy);
 | 
			
		||||
 | 
			
		||||
	err = hci_req_run_skb(&req, set_default_phy_complete);
 | 
			
		||||
	if (err < 0)
 | 
			
		||||
		mgmt_pending_remove(cmd);
 | 
			
		||||
 | 
			
		||||
unlock:
 | 
			
		||||
	hci_dev_unlock(hdev);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue