diff options
author | Alexander Aring <alex.aring@gmail.com> | 2015-05-17 15:44:44 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2015-05-19 05:44:42 -0400 |
commit | 791021bf13ec9d0fc14bfd8c9c4b368ace568239 (patch) | |
tree | 5e5bb4fe5815f959379b94e89194c7d5fecf5e12 | |
parent | fea3318d20776a94afeea0460c6ee9904e60569e (diff) |
mac802154: check for really changes
This patch adds check if the value is really changed inside pib/mib.
If a transceiver do support only one value for e.g. max_be then this
will also handle that the driver layer doesn't need to care about
handling to set one value only.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r-- | include/net/cfg802154.h | 12 | ||||
-rw-r--r-- | net/mac802154/cfg.c | 26 |
2 files changed, 38 insertions, 0 deletions
diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h index 23abd08a310a..37abc1603285 100644 --- a/include/net/cfg802154.h +++ b/include/net/cfg802154.h | |||
@@ -94,6 +94,18 @@ struct wpan_phy_cca { | |||
94 | enum nl802154_cca_opts opt; | 94 | enum nl802154_cca_opts opt; |
95 | }; | 95 | }; |
96 | 96 | ||
97 | static inline bool | ||
98 | wpan_phy_cca_cmp(const struct wpan_phy_cca *a, const struct wpan_phy_cca *b) | ||
99 | { | ||
100 | if (a->mode != b->mode) | ||
101 | return false; | ||
102 | |||
103 | if (a->mode == NL802154_CCA_ENERGY_CARRIER) | ||
104 | return a->opt == b->opt; | ||
105 | |||
106 | return true; | ||
107 | } | ||
108 | |||
97 | struct wpan_phy { | 109 | struct wpan_phy { |
98 | struct mutex pib_lock; | 110 | struct mutex pib_lock; |
99 | 111 | ||
diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c index c63601582c71..45c4dc39766e 100644 --- a/net/mac802154/cfg.c +++ b/net/mac802154/cfg.c | |||
@@ -73,6 +73,10 @@ ieee802154_set_channel(struct wpan_phy *wpan_phy, u8 page, u8 channel) | |||
73 | 73 | ||
74 | ASSERT_RTNL(); | 74 | ASSERT_RTNL(); |
75 | 75 | ||
76 | if (wpan_phy->current_page == page && | ||
77 | wpan_phy->current_channel == channel) | ||
78 | return 0; | ||
79 | |||
76 | ret = drv_set_channel(local, page, channel); | 80 | ret = drv_set_channel(local, page, channel); |
77 | if (!ret) { | 81 | if (!ret) { |
78 | wpan_phy->current_page = page; | 82 | wpan_phy->current_page = page; |
@@ -91,6 +95,9 @@ ieee802154_set_cca_mode(struct wpan_phy *wpan_phy, | |||
91 | 95 | ||
92 | ASSERT_RTNL(); | 96 | ASSERT_RTNL(); |
93 | 97 | ||
98 | if (wpan_phy_cca_cmp(&wpan_phy->cca, cca)) | ||
99 | return 0; | ||
100 | |||
94 | /* check if phy support this setting */ | 101 | /* check if phy support this setting */ |
95 | if (!(local->hw.flags & IEEE802154_HW_CCA_MODE)) | 102 | if (!(local->hw.flags & IEEE802154_HW_CCA_MODE)) |
96 | return -EOPNOTSUPP; | 103 | return -EOPNOTSUPP; |
@@ -108,6 +115,9 @@ ieee802154_set_pan_id(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev, | |||
108 | { | 115 | { |
109 | ASSERT_RTNL(); | 116 | ASSERT_RTNL(); |
110 | 117 | ||
118 | if (wpan_dev->pan_id == pan_id) | ||
119 | return 0; | ||
120 | |||
111 | wpan_dev->pan_id = pan_id; | 121 | wpan_dev->pan_id = pan_id; |
112 | return 0; | 122 | return 0; |
113 | } | 123 | } |
@@ -121,6 +131,10 @@ ieee802154_set_backoff_exponent(struct wpan_phy *wpan_phy, | |||
121 | 131 | ||
122 | ASSERT_RTNL(); | 132 | ASSERT_RTNL(); |
123 | 133 | ||
134 | if (wpan_dev->min_be == min_be && | ||
135 | wpan_dev->max_be == max_be) | ||
136 | return 0; | ||
137 | |||
124 | if (!(local->hw.flags & IEEE802154_HW_CSMA_PARAMS)) | 138 | if (!(local->hw.flags & IEEE802154_HW_CSMA_PARAMS)) |
125 | return -EOPNOTSUPP; | 139 | return -EOPNOTSUPP; |
126 | 140 | ||
@@ -135,6 +149,9 @@ ieee802154_set_short_addr(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev, | |||
135 | { | 149 | { |
136 | ASSERT_RTNL(); | 150 | ASSERT_RTNL(); |
137 | 151 | ||
152 | if (wpan_dev->short_addr == short_addr) | ||
153 | return 0; | ||
154 | |||
138 | wpan_dev->short_addr = short_addr; | 155 | wpan_dev->short_addr = short_addr; |
139 | return 0; | 156 | return 0; |
140 | } | 157 | } |
@@ -148,6 +165,9 @@ ieee802154_set_max_csma_backoffs(struct wpan_phy *wpan_phy, | |||
148 | 165 | ||
149 | ASSERT_RTNL(); | 166 | ASSERT_RTNL(); |
150 | 167 | ||
168 | if (wpan_dev->csma_retries == max_csma_backoffs) | ||
169 | return 0; | ||
170 | |||
151 | if (!(local->hw.flags & IEEE802154_HW_CSMA_PARAMS)) | 171 | if (!(local->hw.flags & IEEE802154_HW_CSMA_PARAMS)) |
152 | return -EOPNOTSUPP; | 172 | return -EOPNOTSUPP; |
153 | 173 | ||
@@ -164,6 +184,9 @@ ieee802154_set_max_frame_retries(struct wpan_phy *wpan_phy, | |||
164 | 184 | ||
165 | ASSERT_RTNL(); | 185 | ASSERT_RTNL(); |
166 | 186 | ||
187 | if (wpan_dev->frame_retries == max_frame_retries) | ||
188 | return 0; | ||
189 | |||
167 | if (!(local->hw.flags & IEEE802154_HW_FRAME_RETRIES)) | 190 | if (!(local->hw.flags & IEEE802154_HW_FRAME_RETRIES)) |
168 | return -EOPNOTSUPP; | 191 | return -EOPNOTSUPP; |
169 | 192 | ||
@@ -179,6 +202,9 @@ ieee802154_set_lbt_mode(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev, | |||
179 | 202 | ||
180 | ASSERT_RTNL(); | 203 | ASSERT_RTNL(); |
181 | 204 | ||
205 | if (wpan_dev->lbt == mode) | ||
206 | return 0; | ||
207 | |||
182 | if (!(local->hw.flags & IEEE802154_HW_LBT)) | 208 | if (!(local->hw.flags & IEEE802154_HW_LBT)) |
183 | return -EOPNOTSUPP; | 209 | return -EOPNOTSUPP; |
184 | 210 | ||