aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRajkumar Manoharan <rmanohar@qca.qualcomm.com>2012-06-11 02:49:36 -0400
committerJohn W. Linville <linville@tuxdriver.com>2012-06-13 14:35:55 -0400
commit9e2e0c84699ce7adeddb5cd5763956493ca7d331 (patch)
treee66228b87b3f8cd704cdd577007444f1a47c5f05
parent92a33298e9a329d4bed9f723811c5bedc7d92b9c (diff)
ath9k: simplify btcoex profile management
This patch simplifies profile management utility functions. * Separate find_profile from add/del functions * Return correct values when the profile list is empty or profile is ot found * flush the profiles when there are entries in the list Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/ath/ath9k/mci.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/drivers/net/wireless/ath/ath9k/mci.c b/drivers/net/wireless/ath/ath9k/mci.c
index 49137f477b05..2ea5e933b3ba 100644
--- a/drivers/net/wireless/ath/ath9k/mci.c
+++ b/drivers/net/wireless/ath/ath9k/mci.c
@@ -28,11 +28,14 @@ ath_mci_find_profile(struct ath_mci_profile *mci,
28{ 28{
29 struct ath_mci_profile_info *entry; 29 struct ath_mci_profile_info *entry;
30 30
31 if (list_empty(&mci->info))
32 return NULL;
33
31 list_for_each_entry(entry, &mci->info, list) { 34 list_for_each_entry(entry, &mci->info, list) {
32 if (entry->conn_handle == info->conn_handle) 35 if (entry->conn_handle == info->conn_handle)
33 break; 36 return entry;
34 } 37 }
35 return entry; 38 return NULL;
36} 39}
37 40
38static bool ath_mci_add_profile(struct ath_common *common, 41static bool ath_mci_add_profile(struct ath_common *common,
@@ -49,31 +52,21 @@ static bool ath_mci_add_profile(struct ath_common *common,
49 (info->type != MCI_GPM_COEX_PROFILE_VOICE)) 52 (info->type != MCI_GPM_COEX_PROFILE_VOICE))
50 return false; 53 return false;
51 54
52 entry = ath_mci_find_profile(mci, info); 55 entry = kzalloc(sizeof(*entry), GFP_KERNEL);
53 56 if (!entry)
54 if (entry) { 57 return false;
55 memcpy(entry, info, 10);
56 } else {
57 entry = kzalloc(sizeof(*entry), GFP_KERNEL);
58 if (!entry)
59 return false;
60 58
61 memcpy(entry, info, 10); 59 memcpy(entry, info, 10);
62 INC_PROF(mci, info); 60 INC_PROF(mci, info);
63 list_add_tail(&info->list, &mci->info); 61 list_add_tail(&entry->list, &mci->info);
64 }
65 62
66 return true; 63 return true;
67} 64}
68 65
69static void ath_mci_del_profile(struct ath_common *common, 66static void ath_mci_del_profile(struct ath_common *common,
70 struct ath_mci_profile *mci, 67 struct ath_mci_profile *mci,
71 struct ath_mci_profile_info *info) 68 struct ath_mci_profile_info *entry)
72{ 69{
73 struct ath_mci_profile_info *entry;
74
75 entry = ath_mci_find_profile(mci, info);
76
77 if (!entry) 70 if (!entry)
78 return; 71 return;
79 72
@@ -86,12 +79,16 @@ void ath_mci_flush_profile(struct ath_mci_profile *mci)
86{ 79{
87 struct ath_mci_profile_info *info, *tinfo; 80 struct ath_mci_profile_info *info, *tinfo;
88 81
82 mci->aggr_limit = 0;
83
84 if (list_empty(&mci->info))
85 return;
86
89 list_for_each_entry_safe(info, tinfo, &mci->info, list) { 87 list_for_each_entry_safe(info, tinfo, &mci->info, list) {
90 list_del(&info->list); 88 list_del(&info->list);
91 DEC_PROF(mci, info); 89 DEC_PROF(mci, info);
92 kfree(info); 90 kfree(info);
93 } 91 }
94 mci->aggr_limit = 0;
95} 92}
96 93
97static void ath_mci_adjust_aggr_limit(struct ath_btcoex *btcoex) 94static void ath_mci_adjust_aggr_limit(struct ath_btcoex *btcoex)
@@ -229,12 +226,17 @@ static void ath_mci_process_profile(struct ath_softc *sc,
229 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 226 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
230 struct ath_btcoex *btcoex = &sc->btcoex; 227 struct ath_btcoex *btcoex = &sc->btcoex;
231 struct ath_mci_profile *mci = &btcoex->mci; 228 struct ath_mci_profile *mci = &btcoex->mci;
229 struct ath_mci_profile_info *entry = NULL;
230
231 entry = ath_mci_find_profile(mci, info);
232 if (entry)
233 memcpy(entry, info, 10);
232 234
233 if (info->start) { 235 if (info->start) {
234 if (!ath_mci_add_profile(common, mci, info)) 236 if (!entry && !ath_mci_add_profile(common, mci, info))
235 return; 237 return;
236 } else 238 } else
237 ath_mci_del_profile(common, mci, info); 239 ath_mci_del_profile(common, mci, entry);
238 240
239 btcoex->btcoex_period = ATH_MCI_DEF_BT_PERIOD; 241 btcoex->btcoex_period = ATH_MCI_DEF_BT_PERIOD;
240 mci->aggr_limit = mci->num_sco ? 6 : 0; 242 mci->aggr_limit = mci->num_sco ? 6 : 0;
@@ -263,8 +265,6 @@ static void ath_mci_process_status(struct ath_softc *sc,
263 if (status->is_link) 265 if (status->is_link)
264 return; 266 return;
265 267
266 memset(&info, 0, sizeof(struct ath_mci_profile_info));
267
268 info.conn_handle = status->conn_handle; 268 info.conn_handle = status->conn_handle;
269 if (ath_mci_find_profile(mci, &info)) 269 if (ath_mci_find_profile(mci, &info))
270 return; 270 return;