@@ -275,14 +275,12 @@ static struct bt_hfp_ag_call *get_new_call(struct bt_hfp_ag *ag, const char *num
275
275
call = & ag -> calls [index ];
276
276
277
277
if (!atomic_test_and_set_bit (call -> flags , BT_HFP_AG_CALL_IN_USING )) {
278
- hfp_ag_lock (ag );
279
278
/* Copy number to ag->number including null-character */
280
279
strcpy (call -> number , number );
281
280
call -> type = type ;
282
281
call -> ag = ag ;
283
282
k_work_init_delayable (& call -> deferred_work , bt_ag_deferred_work );
284
283
k_work_init_delayable (& call -> ringing_work , bt_ag_ringing_work );
285
- hfp_ag_unlock (ag );
286
284
return call ;
287
285
}
288
286
}
@@ -940,9 +938,7 @@ static int bt_hfp_ag_brsf_handler(struct bt_hfp_ag *ag, struct net_buf *buf)
940
938
return - ENOTSUP ;
941
939
}
942
940
943
- hfp_ag_lock (ag );
944
941
ag -> hf_features = hf_features ;
945
- hfp_ag_unlock (ag );
946
942
947
943
return hfp_ag_send_data (ag , NULL , NULL , "\r\n+BRSF:%d\r\n" , ag -> ag_features );
948
944
}
@@ -957,13 +953,10 @@ static int bt_hfp_ag_bac_handler(struct bt_hfp_ag *ag, struct net_buf *buf)
957
953
return - ENOTSUP ;
958
954
}
959
955
960
- hfp_ag_lock (ag );
961
956
if (!(ag -> hf_features & BT_HFP_HF_FEATURE_CODEC_NEG ) ||
962
957
!(ag -> ag_features & BT_HFP_AG_FEATURE_CODEC_NEG )) {
963
- hfp_ag_unlock (ag );
964
958
return - ENOEXEC ;
965
959
}
966
- hfp_ag_unlock (ag );
967
960
968
961
while (buf -> len > 0 ) {
969
962
err = get_number (buf , & codec );
@@ -1064,9 +1057,7 @@ static void bt_hfp_ag_set_in_band_ring(struct bt_hfp_ag *ag, void *user_data)
1064
1057
{
1065
1058
bool is_inband_ringtone ;
1066
1059
1067
- hfp_ag_lock (ag );
1068
1060
is_inband_ringtone = (ag -> ag_features & BT_HFP_AG_FEATURE_INBAND_RINGTONE ) ? true : false;
1069
- hfp_ag_unlock (ag );
1070
1061
1071
1062
if (is_inband_ringtone && !atomic_test_bit (ag -> flags , BT_HFP_AG_INBAND_RING )) {
1072
1063
int err = hfp_ag_send_data (ag , NULL , NULL , "\r\n+BSIR:1\r\n" );
@@ -1522,13 +1513,10 @@ static int bt_hfp_ag_chld_handler(struct bt_hfp_ag *ag, struct net_buf *buf)
1522
1513
int err ;
1523
1514
char * response ;
1524
1515
1525
- hfp_ag_lock (ag );
1526
1516
if (!((ag -> ag_features & BT_HFP_AG_FEATURE_3WAY_CALL ) &&
1527
1517
(ag -> hf_features & BT_HFP_HF_FEATURE_3WAY_CALL ))) {
1528
- hfp_ag_unlock (ag );
1529
1518
return - ENOEXEC ;
1530
1519
}
1531
- hfp_ag_unlock (ag );
1532
1520
1533
1521
if (!is_char (buf , '=' )) {
1534
1522
return - ENOTSUP ;
@@ -1581,23 +1569,18 @@ static int bt_hfp_ag_bind_handler(struct bt_hfp_ag *ag, struct net_buf *buf)
1581
1569
char * data ;
1582
1570
uint32_t len ;
1583
1571
1584
- hfp_ag_lock (ag );
1585
1572
if (!((ag -> ag_features & BT_HFP_AG_FEATURE_HF_IND ) &&
1586
1573
(ag -> hf_features & BT_HFP_HF_FEATURE_HF_IND ))) {
1587
- hfp_ag_unlock (ag );
1588
1574
return - ENOEXEC ;
1589
1575
}
1590
- hfp_ag_unlock (ag );
1591
1576
1592
1577
if (is_char (buf , '?' )) {
1593
1578
if (!is_char (buf , '\r' )) {
1594
1579
return - ENOTSUP ;
1595
1580
}
1596
1581
1597
- hfp_ag_lock (ag );
1598
1582
hf_indicators = ag -> hf_indicators ;
1599
1583
supported_indicators = ag -> hf_indicators_of_ag & ag -> hf_indicators_of_hf ;
1600
- hfp_ag_unlock (ag );
1601
1584
len = MIN (NUM_BITS (sizeof (supported_indicators )), HFP_HF_IND_MAX );
1602
1585
for (int i = 1 ; i < len ; i ++ ) {
1603
1586
bool enabled ;
@@ -1634,9 +1617,7 @@ static int bt_hfp_ag_bind_handler(struct bt_hfp_ag *ag, struct net_buf *buf)
1634
1617
data = & ag -> buffer [0 ];
1635
1618
* data = '(' ;
1636
1619
data ++ ;
1637
- hfp_ag_lock (ag );
1638
1620
hf_indicators = ag -> hf_indicators_of_ag ;
1639
- hfp_ag_unlock (ag );
1640
1621
len = MIN (NUM_BITS (sizeof (hf_indicators )), HFP_HF_IND_MAX );
1641
1622
for (int i = 1 ; (i < len ) && (hf_indicators != 0 ); i ++ ) {
1642
1623
if (BIT (i ) & hf_indicators ) {
@@ -1677,9 +1658,7 @@ static int bt_hfp_ag_bind_handler(struct bt_hfp_ag *ag, struct net_buf *buf)
1677
1658
}
1678
1659
}
1679
1660
1680
- hfp_ag_lock (ag );
1681
1661
ag -> hf_indicators_of_hf = hf_indicators ;
1682
- hfp_ag_unlock (ag );
1683
1662
1684
1663
return 0 ;
1685
1664
}
@@ -2904,13 +2883,10 @@ static int bt_hfp_ag_ccwa_handler(struct bt_hfp_ag *ag, struct net_buf *buf)
2904
2883
int err ;
2905
2884
uint32_t value ;
2906
2885
2907
- hfp_ag_lock (ag );
2908
2886
if (!((ag -> ag_features & BT_HFP_AG_FEATURE_3WAY_CALL ) &&
2909
2887
(ag -> hf_features & BT_HFP_HF_FEATURE_3WAY_CALL ))) {
2910
- hfp_ag_unlock (ag );
2911
2888
return - ENOEXEC ;
2912
2889
}
2913
- hfp_ag_unlock (ag );
2914
2890
2915
2891
if (!is_char (buf , '=' )) {
2916
2892
return - ENOTSUP ;
@@ -2937,10 +2913,8 @@ static void bt_hfp_ag_vr_activate(struct bt_hfp_ag *ag, void *user_data)
2937
2913
{
2938
2914
bool feature ;
2939
2915
2940
- hfp_ag_lock (ag );
2941
2916
feature = (ag -> ag_features & BT_HFP_AG_FEATURE_ENH_VOICE_RECG ) &&
2942
2917
(ag -> hf_features & BT_HFP_HF_FEATURE_ENH_VOICE_RECG );
2943
- hfp_ag_unlock (ag );
2944
2918
2945
2919
#if defined(CONFIG_BT_HFP_AG_VOICE_RECG )
2946
2920
if (bt_ag && bt_ag -> voice_recognition ) {
@@ -2986,13 +2960,10 @@ static int bt_hfp_ag_bvra_handler(struct bt_hfp_ag *ag, struct net_buf *buf)
2986
2960
int err ;
2987
2961
uint32_t value ;
2988
2962
2989
- hfp_ag_lock (ag );
2990
2963
if (!((ag -> ag_features & BT_HFP_AG_FEATURE_VOICE_RECG ) &&
2991
2964
(ag -> hf_features & BT_HFP_HF_FEATURE_VOICE_RECG ))) {
2992
- hfp_ag_unlock (ag );
2993
2965
return - ENOEXEC ;
2994
2966
}
2995
- hfp_ag_unlock (ag );
2996
2967
2997
2968
if (!is_char (buf , '=' )) {
2998
2969
return - ENOTSUP ;
@@ -3024,14 +2995,11 @@ static int bt_hfp_ag_bvra_handler(struct bt_hfp_ag *ag, struct net_buf *buf)
3024
2995
err = hfp_ag_next_step (ag , bt_hfp_ag_vr_activate , NULL );
3025
2996
break ;
3026
2997
case BT_HFP_BVRA_READY_TO_ACCEPT :
3027
- hfp_ag_lock (ag );
3028
2998
if (!((ag -> ag_features & BT_HFP_AG_FEATURE_ENH_VOICE_RECG ) &&
3029
2999
(ag -> hf_features & BT_HFP_HF_FEATURE_ENH_VOICE_RECG ))) {
3030
- hfp_ag_unlock (ag );
3031
3000
LOG_WRN ("Enhance voice recognition is not supported" );
3032
3001
return - ENOEXEC ;
3033
3002
}
3034
- hfp_ag_unlock (ag );
3035
3003
if (!atomic_test_bit (ag -> flags , BT_HFP_AG_VRE_ACTIVATE )) {
3036
3004
LOG_WRN ("Voice recognition is not activated" );
3037
3005
return - ENOTSUP ;
@@ -3053,12 +3021,9 @@ static int bt_hfp_ag_binp_handler(struct bt_hfp_ag *ag, struct net_buf *buf)
3053
3021
char * number = NULL ;
3054
3022
#endif /* CONFIG_BT_HFP_AG_VOICE_TAG */
3055
3023
3056
- hfp_ag_lock (ag );
3057
3024
if (!(ag -> ag_features & BT_HFP_AG_FEATURE_VOICE_TAG )) {
3058
- hfp_ag_unlock (ag );
3059
3025
return - ENOEXEC ;
3060
3026
}
3061
- hfp_ag_unlock (ag );
3062
3027
3063
3028
if (!is_char (buf , '=' )) {
3064
3029
return - ENOTSUP ;
@@ -3966,7 +3931,6 @@ int bt_hfp_ag_reject(struct bt_hfp_ag_call *call)
3966
3931
int err = 0 ;
3967
3932
struct bt_hfp_ag * ag ;
3968
3933
bt_hfp_call_state_t call_state ;
3969
- uint32_t ag_features ;
3970
3934
3971
3935
LOG_DBG ("" );
3972
3936
@@ -3987,14 +3951,13 @@ int bt_hfp_ag_reject(struct bt_hfp_ag_call *call)
3987
3951
}
3988
3952
3989
3953
call_state = call -> call_state ;
3990
- ag_features = ag -> ag_features ;
3991
3954
hfp_ag_unlock (ag );
3992
3955
3993
3956
if (!atomic_test_bit (call -> flags , BT_HFP_AG_CALL_INCOMING )) {
3994
3957
return - EINVAL ;
3995
3958
}
3996
3959
3997
- if (!(ag_features & BT_HFP_AG_FEATURE_REJECT_CALL )) {
3960
+ if (!(ag -> ag_features & BT_HFP_AG_FEATURE_REJECT_CALL )) {
3998
3961
LOG_ERR ("AG has not ability to reject call" );
3999
3962
return - ENOTSUP ;
4000
3963
}
@@ -4599,13 +4562,12 @@ int bt_hfp_ag_vgm(struct bt_hfp_ag *ag, uint8_t vgm)
4599
4562
hfp_ag_unlock (ag );
4600
4563
return - ENOTCONN ;
4601
4564
}
4565
+ hfp_ag_unlock (ag );
4602
4566
4603
4567
if (!(ag -> hf_features & BT_HFP_HF_FEATURE_VOLUME )) {
4604
- hfp_ag_unlock (ag );
4605
4568
LOG_ERR ("Remote Audio Volume Control is unsupported" );
4606
4569
return - ENOTSUP ;
4607
4570
}
4608
- hfp_ag_unlock (ag );
4609
4571
4610
4572
err = hfp_ag_send_data (ag , NULL , NULL , "\r\n+VGM=%d\r\n" , vgm );
4611
4573
if (err ) {
@@ -4635,13 +4597,12 @@ int bt_hfp_ag_vgs(struct bt_hfp_ag *ag, uint8_t vgs)
4635
4597
hfp_ag_unlock (ag );
4636
4598
return - ENOTCONN ;
4637
4599
}
4600
+ hfp_ag_unlock (ag );
4638
4601
4639
4602
if (!(ag -> hf_features & BT_HFP_HF_FEATURE_VOLUME )) {
4640
- hfp_ag_unlock (ag );
4641
4603
LOG_ERR ("Remote Audio Volume Control is unsupported" );
4642
4604
return - ENOTSUP ;
4643
4605
}
4644
- hfp_ag_unlock (ag );
4645
4606
4646
4607
err = hfp_ag_send_data (ag , NULL , NULL , "\r\n+VGS=%d\r\n" , vgs );
4647
4608
if (err ) {
@@ -4706,11 +4667,8 @@ int bt_hfp_ag_voice_recognition(struct bt_hfp_ag *ag, bool activate)
4706
4667
return - ENOTSUP ;
4707
4668
}
4708
4669
4709
- hfp_ag_lock (ag );
4710
4670
feature = (ag -> ag_features & BT_HFP_AG_FEATURE_ENH_VOICE_RECG ) &&
4711
4671
(ag -> hf_features & BT_HFP_HF_FEATURE_ENH_VOICE_RECG );
4712
- hfp_ag_unlock (ag );
4713
-
4714
4672
if (!feature ) {
4715
4673
bvra = "" ;
4716
4674
} else {
@@ -4755,10 +4713,8 @@ int bt_hfp_ag_vre_state(struct bt_hfp_ag *ag, uint8_t state)
4755
4713
return - EINVAL ;
4756
4714
}
4757
4715
4758
- hfp_ag_lock (ag );
4759
4716
feature = (ag -> ag_features & BT_HFP_AG_FEATURE_ENH_VOICE_RECG ) &&
4760
4717
(ag -> hf_features & BT_HFP_HF_FEATURE_ENH_VOICE_RECG );
4761
- hfp_ag_unlock (ag );
4762
4718
if (!feature ) {
4763
4719
return - ENOTSUP ;
4764
4720
}
@@ -4806,18 +4762,14 @@ int bt_hfp_ag_vre_textual_representation(struct bt_hfp_ag *ag, uint8_t state, co
4806
4762
return - EINVAL ;
4807
4763
}
4808
4764
4809
- hfp_ag_lock (ag );
4810
4765
feature = (ag -> ag_features & BT_HFP_AG_FEATURE_ENH_VOICE_RECG ) &&
4811
4766
(ag -> hf_features & BT_HFP_HF_FEATURE_ENH_VOICE_RECG );
4812
- hfp_ag_unlock (ag );
4813
4767
if (!feature ) {
4814
4768
return - ENOTSUP ;
4815
4769
}
4816
4770
4817
- hfp_ag_lock (ag );
4818
4771
feature = (ag -> ag_features & BT_HFP_AG_FEATURE_VOICE_RECG_TEXT ) &&
4819
4772
(ag -> hf_features & BT_HFP_HF_FEATURE_VOICE_RECG_TEXT );
4820
- hfp_ag_unlock (ag );
4821
4773
if (!feature ) {
4822
4774
return - ENOTSUP ;
4823
4775
}
0 commit comments