From: Alexander Aring <alex.aring@gmail.com>
To: linux-wpan@vger.kernel.org
Cc: kernel@pengutronix.de, Alexander Aring <alex.aring@gmail.com>
Subject: [PATCHv2 wpan-next 06/16] mac802154: check for really changes
Date: Wed, 6 May 2015 13:40:18 +0200 [thread overview]
Message-ID: <1430912428-17284-7-git-send-email-alex.aring@gmail.com> (raw)
In-Reply-To: <1430912428-17284-1-git-send-email-alex.aring@gmail.com>
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>
---
include/net/cfg802154.h | 12 ++++++++++++
net/mac802154/cfg.c | 26 ++++++++++++++++++++++++++
2 files changed, 38 insertions(+)
diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h
index e53242a..de00e5c 100644
--- a/include/net/cfg802154.h
+++ b/include/net/cfg802154.h
@@ -92,6 +92,18 @@ struct wpan_phy_cca {
enum nl802154_cca_opts opt;
};
+static inline bool
+wpan_phy_cca_cmp(const struct wpan_phy_cca *a, const struct wpan_phy_cca *b)
+{
+ if (a->mode != b->mode)
+ return false;
+
+ if (a->mode == NL802154_CCA_ENERGY_CARRIER)
+ return a->opt == b->opt;
+
+ return true;
+}
+
struct wpan_phy {
struct mutex pib_lock;
diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c
index c636015..45c4dc3 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)
ASSERT_RTNL();
+ if (wpan_phy->current_page == page &&
+ wpan_phy->current_channel == channel)
+ return 0;
+
ret = drv_set_channel(local, page, channel);
if (!ret) {
wpan_phy->current_page = page;
@@ -91,6 +95,9 @@ ieee802154_set_cca_mode(struct wpan_phy *wpan_phy,
ASSERT_RTNL();
+ if (wpan_phy_cca_cmp(&wpan_phy->cca, cca))
+ return 0;
+
/* check if phy support this setting */
if (!(local->hw.flags & IEEE802154_HW_CCA_MODE))
return -EOPNOTSUPP;
@@ -108,6 +115,9 @@ ieee802154_set_pan_id(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
{
ASSERT_RTNL();
+ if (wpan_dev->pan_id == pan_id)
+ return 0;
+
wpan_dev->pan_id = pan_id;
return 0;
}
@@ -121,6 +131,10 @@ ieee802154_set_backoff_exponent(struct wpan_phy *wpan_phy,
ASSERT_RTNL();
+ if (wpan_dev->min_be == min_be &&
+ wpan_dev->max_be == max_be)
+ return 0;
+
if (!(local->hw.flags & IEEE802154_HW_CSMA_PARAMS))
return -EOPNOTSUPP;
@@ -135,6 +149,9 @@ ieee802154_set_short_addr(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
{
ASSERT_RTNL();
+ if (wpan_dev->short_addr == short_addr)
+ return 0;
+
wpan_dev->short_addr = short_addr;
return 0;
}
@@ -148,6 +165,9 @@ ieee802154_set_max_csma_backoffs(struct wpan_phy *wpan_phy,
ASSERT_RTNL();
+ if (wpan_dev->csma_retries == max_csma_backoffs)
+ return 0;
+
if (!(local->hw.flags & IEEE802154_HW_CSMA_PARAMS))
return -EOPNOTSUPP;
@@ -164,6 +184,9 @@ ieee802154_set_max_frame_retries(struct wpan_phy *wpan_phy,
ASSERT_RTNL();
+ if (wpan_dev->frame_retries == max_frame_retries)
+ return 0;
+
if (!(local->hw.flags & IEEE802154_HW_FRAME_RETRIES))
return -EOPNOTSUPP;
@@ -179,6 +202,9 @@ ieee802154_set_lbt_mode(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
ASSERT_RTNL();
+ if (wpan_dev->lbt == mode)
+ return 0;
+
if (!(local->hw.flags & IEEE802154_HW_LBT))
return -EOPNOTSUPP;
--
2.3.7
next prev parent reply other threads:[~2015-05-06 11:41 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-06 11:40 [PATCHv2 wpan-next 00/16] ieee802154: add support for phy capabilities Alexander Aring
2015-05-06 11:40 ` [PATCHv2 wpan-next 01/16] ieee802154: change transmit power to s32 Alexander Aring
2015-05-06 11:40 ` [PATCHv2 wpan-next 02/16] ieee802154: change transmit power to mbm Alexander Aring
2015-05-06 11:40 ` [PATCHv2 wpan-next 03/16] ieee802154: change cca ed level " Alexander Aring
2015-05-06 11:40 ` [PATCHv2 wpan-next 04/16] ieee802154: introduce wpan_phy_supported Alexander Aring
2015-05-06 11:40 ` [PATCHv2 wpan-next 05/16] ieee802154: add several phy supported handling Alexander Aring
2015-05-06 11:40 ` Alexander Aring [this message]
2015-05-06 11:40 ` [PATCHv2 wpan-next 07/16] mac802154: remove check if operation is supported Alexander Aring
2015-05-06 11:40 ` [PATCHv2 wpan-next 08/16] ieee802154: add iftypes capability Alexander Aring
2015-05-06 11:40 ` [PATCHv2 wpan-next 09/16] ieee802154: add support for get tx powers Alexander Aring
2015-05-06 12:02 ` Phoebe Buckheister
2015-05-06 13:19 ` Alexander Aring
2015-05-06 11:40 ` [PATCHv2 wpan-next 10/16] ieee802154: add support for get cca ed levels Alexander Aring
2015-05-06 11:40 ` [PATCHv2 wpan-next 11/16] at86rf230: set cca_modes supported flags Alexander Aring
2015-05-06 11:40 ` [PATCHv2 wpan-next 12/16] at86rf230: add reset states of tx power level Alexander Aring
2015-05-06 11:40 ` [PATCHv2 wpan-next 13/16] at86rf230: rework tx power support Alexander Aring
2015-05-06 11:40 ` [PATCHv2 wpan-next 14/16] at86rf230: rework tx cca energy detection level Alexander Aring
2015-05-06 11:40 ` [PATCHv2 wpan-next 15/16] ieee802154: check transmit power before driver layer Alexander Aring
2015-05-06 11:40 ` [PATCHv2 wpan-next 16/16] nl802154: add support for dump phy capabilities Alexander Aring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1430912428-17284-7-git-send-email-alex.aring@gmail.com \
--to=alex.aring@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linux-wpan@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox