aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Aring <alex.aring@gmail.com>2014-10-28 13:21:23 -0400
committerMarcel Holtmann <marcel@holtmann.org>2014-10-28 18:19:07 -0400
commita543c5989d7711d984608f4e12a73218642ca865 (patch)
tree2a0613d1873fbd5d37de7c330430309ddfc72e1c
parente1d299f61a1660cbbabccfa0d07421861b9b9711 (diff)
mac802154: remove driver ops in wpan-phy
This patch removes the driver ops callbacks inside of wpan_phy struct. It was used to check if a phy supports this driver ops call. We do this now via hardware flags. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r--include/net/cfg802154.h8
-rw-r--r--net/ieee802154/nl-mac.c19
-rw-r--r--net/mac802154/iface.c12
-rw-r--r--net/mac802154/main.c85
4 files changed, 8 insertions, 116 deletions
diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h
index 5c674673ef20..440b9bece9c6 100644
--- a/include/net/cfg802154.h
+++ b/include/net/cfg802154.h
@@ -57,14 +57,6 @@ struct wpan_phy {
57 const char *name, int type); 57 const char *name, int type);
58 void (*del_iface)(struct wpan_phy *phy, struct net_device *dev); 58 void (*del_iface)(struct wpan_phy *phy, struct net_device *dev);
59 59
60 int (*set_txpower)(struct wpan_phy *phy, int db);
61 int (*set_lbt)(struct wpan_phy *phy, bool on);
62 int (*set_cca_mode)(struct wpan_phy *phy, u8 cca_mode);
63 int (*set_cca_ed_level)(struct wpan_phy *phy, int level);
64 int (*set_csma_params)(struct wpan_phy *phy, u8 min_be, u8 max_be,
65 u8 retries);
66 int (*set_frame_retries)(struct wpan_phy *phy, s8 retries);
67
68 char priv[0] __aligned(NETDEV_ALIGN); 60 char priv[0] __aligned(NETDEV_ALIGN);
69}; 61};
70 62
diff --git a/net/ieee802154/nl-mac.c b/net/ieee802154/nl-mac.c
index fb6866d1dd39..abd0f31bdc66 100644
--- a/net/ieee802154/nl-mac.c
+++ b/net/ieee802154/nl-mac.c
@@ -664,20 +664,6 @@ int ieee802154_set_macparams(struct sk_buff *skb, struct genl_info *info)
664 664
665 phy = ops->get_phy(dev); 665 phy = ops->get_phy(dev);
666 666
667 if ((!phy->set_lbt && info->attrs[IEEE802154_ATTR_LBT_ENABLED]) ||
668 (!phy->set_cca_mode && info->attrs[IEEE802154_ATTR_CCA_MODE]) ||
669 (!phy->set_cca_ed_level &&
670 info->attrs[IEEE802154_ATTR_CCA_ED_LEVEL]) ||
671 (!phy->set_csma_params &&
672 (info->attrs[IEEE802154_ATTR_CSMA_RETRIES] ||
673 info->attrs[IEEE802154_ATTR_CSMA_MIN_BE] ||
674 info->attrs[IEEE802154_ATTR_CSMA_MAX_BE])) ||
675 (!phy->set_frame_retries &&
676 info->attrs[IEEE802154_ATTR_FRAME_RETRIES])) {
677 rc = -EOPNOTSUPP;
678 goto out_phy;
679 }
680
681 ops->get_mac_params(dev, &params); 667 ops->get_mac_params(dev, &params);
682 668
683 if (info->attrs[IEEE802154_ATTR_TXPOWER]) 669 if (info->attrs[IEEE802154_ATTR_TXPOWER])
@@ -708,10 +694,9 @@ int ieee802154_set_macparams(struct sk_buff *skb, struct genl_info *info)
708 694
709 wpan_phy_put(phy); 695 wpan_phy_put(phy);
710 dev_put(dev); 696 dev_put(dev);
711 return rc;
712 697
713out_phy: 698 return 0;
714 wpan_phy_put(phy); 699
715out: 700out:
716 dev_put(dev); 701 dev_put(dev);
717 return rc; 702 return rc;
diff --git a/net/mac802154/iface.c b/net/mac802154/iface.c
index 025cd5aba13f..300877a1a0c9 100644
--- a/net/mac802154/iface.c
+++ b/net/mac802154/iface.c
@@ -196,32 +196,32 @@ static int mac802154_wpan_open(struct net_device *dev)
196 196
197 mutex_lock(&phy->pib_lock); 197 mutex_lock(&phy->pib_lock);
198 198
199 if (phy->set_txpower) { 199 if (local->hw.flags & IEEE802154_HW_TXPOWER) {
200 rc = drv_set_tx_power(local, sdata->mac_params.transmit_power); 200 rc = drv_set_tx_power(local, sdata->mac_params.transmit_power);
201 if (rc < 0) 201 if (rc < 0)
202 goto out; 202 goto out;
203 } 203 }
204 204
205 if (phy->set_lbt) { 205 if (local->hw.flags & IEEE802154_HW_LBT) {
206 rc = drv_set_lbt_mode(local, sdata->mac_params.lbt); 206 rc = drv_set_lbt_mode(local, sdata->mac_params.lbt);
207 if (rc < 0) 207 if (rc < 0)
208 goto out; 208 goto out;
209 } 209 }
210 210
211 if (phy->set_cca_mode) { 211 if (local->hw.flags & IEEE802154_HW_CCA_MODE) {
212 rc = drv_set_cca_mode(local, sdata->mac_params.cca_mode); 212 rc = drv_set_cca_mode(local, sdata->mac_params.cca_mode);
213 if (rc < 0) 213 if (rc < 0)
214 goto out; 214 goto out;
215 } 215 }
216 216
217 if (phy->set_cca_ed_level) { 217 if (local->hw.flags & IEEE802154_HW_CCA_ED_LEVEL) {
218 rc = drv_set_cca_ed_level(local, 218 rc = drv_set_cca_ed_level(local,
219 sdata->mac_params.cca_ed_level); 219 sdata->mac_params.cca_ed_level);
220 if (rc < 0) 220 if (rc < 0)
221 goto out; 221 goto out;
222 } 222 }
223 223
224 if (phy->set_csma_params) { 224 if (local->hw.flags & IEEE802154_HW_CSMA_PARAMS) {
225 rc = drv_set_csma_params(local, sdata->mac_params.min_be, 225 rc = drv_set_csma_params(local, sdata->mac_params.min_be,
226 sdata->mac_params.max_be, 226 sdata->mac_params.max_be,
227 sdata->mac_params.csma_retries); 227 sdata->mac_params.csma_retries);
@@ -229,7 +229,7 @@ static int mac802154_wpan_open(struct net_device *dev)
229 goto out; 229 goto out;
230 } 230 }
231 231
232 if (phy->set_frame_retries) { 232 if (local->hw.flags & IEEE802154_HW_FRAME_RETRIES) {
233 rc = drv_set_max_frame_retries(local, 233 rc = drv_set_max_frame_retries(local,
234 sdata->mac_params.frame_retries); 234 sdata->mac_params.frame_retries);
235 if (rc < 0) 235 if (rc < 0)
diff --git a/net/mac802154/main.c b/net/mac802154/main.c
index 24ecc09de2a4..9fa9514b3a36 100644
--- a/net/mac802154/main.c
+++ b/net/mac802154/main.c
@@ -121,49 +121,6 @@ err:
121 return ERR_PTR(err); 121 return ERR_PTR(err);
122} 122}
123 123
124static int mac802154_set_txpower(struct wpan_phy *phy, int db)
125{
126 struct ieee802154_local *local = wpan_phy_priv(phy);
127
128 return drv_set_tx_power(local, db);
129}
130
131static int mac802154_set_lbt(struct wpan_phy *phy, bool on)
132{
133 struct ieee802154_local *local = wpan_phy_priv(phy);
134
135 return drv_set_lbt_mode(local, on);
136}
137
138static int mac802154_set_cca_mode(struct wpan_phy *phy, u8 mode)
139{
140 struct ieee802154_local *local = wpan_phy_priv(phy);
141
142 return drv_set_cca_mode(local, mode);
143}
144
145static int mac802154_set_cca_ed_level(struct wpan_phy *phy, s32 level)
146{
147 struct ieee802154_local *local = wpan_phy_priv(phy);
148
149 return drv_set_cca_ed_level(local, level);
150}
151
152static int mac802154_set_csma_params(struct wpan_phy *phy, u8 min_be,
153 u8 max_be, u8 retries)
154{
155 struct ieee802154_local *local = wpan_phy_priv(phy);
156
157 return drv_set_csma_params(local, min_be, max_be, retries);
158}
159
160static int mac802154_set_frame_retries(struct wpan_phy *phy, s8 retries)
161{
162 struct ieee802154_local *local = wpan_phy_priv(phy);
163
164 return drv_set_max_frame_retries(local, retries);
165}
166
167static void ieee802154_tasklet_handler(unsigned long data) 124static void ieee802154_tasklet_handler(unsigned long data)
168{ 125{
169 struct ieee802154_local *local = (struct ieee802154_local *)data; 126 struct ieee802154_local *local = (struct ieee802154_local *)data;
@@ -262,48 +219,6 @@ int ieee802154_register_hw(struct ieee802154_hw *hw)
262 struct ieee802154_local *local = hw_to_local(hw); 219 struct ieee802154_local *local = hw_to_local(hw);
263 int rc = -ENOSYS; 220 int rc = -ENOSYS;
264 221
265 if (hw->flags & IEEE802154_HW_TXPOWER) {
266 if (!local->ops->set_txpower)
267 goto out;
268
269 local->phy->set_txpower = mac802154_set_txpower;
270 }
271
272 if (hw->flags & IEEE802154_HW_LBT) {
273 if (!local->ops->set_lbt)
274 goto out;
275
276 local->phy->set_lbt = mac802154_set_lbt;
277 }
278
279 if (hw->flags & IEEE802154_HW_CCA_MODE) {
280 if (!local->ops->set_cca_mode)
281 goto out;
282
283 local->phy->set_cca_mode = mac802154_set_cca_mode;
284 }
285
286 if (hw->flags & IEEE802154_HW_CCA_ED_LEVEL) {
287 if (!local->ops->set_cca_ed_level)
288 goto out;
289
290 local->phy->set_cca_ed_level = mac802154_set_cca_ed_level;
291 }
292
293 if (hw->flags & IEEE802154_HW_CSMA_PARAMS) {
294 if (!local->ops->set_csma_params)
295 goto out;
296
297 local->phy->set_csma_params = mac802154_set_csma_params;
298 }
299
300 if (hw->flags & IEEE802154_HW_FRAME_RETRIES) {
301 if (!local->ops->set_frame_retries)
302 goto out;
303
304 local->phy->set_frame_retries = mac802154_set_frame_retries;
305 }
306
307 local->workqueue = 222 local->workqueue =
308 create_singlethread_workqueue(wpan_phy_name(local->phy)); 223 create_singlethread_workqueue(wpan_phy_name(local->phy));
309 if (!local->workqueue) { 224 if (!local->workqueue) {