Skip to content

Commit

Permalink
mac802154: fix time calculation in ieee802154_configure_durations()
Browse files Browse the repository at this point in the history
Since 'symbol_duration' of 'struct wpan_phy' is in nanoseconds but
'lifs_period' and 'sifs_period' are both in microseconds, fix time
calculation in 'ieee802154_configure_durations()' and use convenient
'NSEC_PER_USEC' in 'ieee802154_setup_wpan_phy_pib()' as well.
Compile tested only.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 781830c ("net: mac802154: Set durations automatically")
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>
Message-ID: <20240508114010.219527-1-dmantipov@yandex.ru>
Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
  • Loading branch information
dmantipov authored and Stefan-Schmidt committed May 18, 2024
1 parent 4b377b4 commit 07aa339
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions net/mac802154/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,10 @@ void ieee802154_configure_durations(struct wpan_phy *phy,
}

phy->symbol_duration = duration;
phy->lifs_period = (IEEE802154_LIFS_PERIOD * phy->symbol_duration) / NSEC_PER_SEC;
phy->sifs_period = (IEEE802154_SIFS_PERIOD * phy->symbol_duration) / NSEC_PER_SEC;
phy->lifs_period =
(IEEE802154_LIFS_PERIOD * phy->symbol_duration) / NSEC_PER_USEC;
phy->sifs_period =
(IEEE802154_SIFS_PERIOD * phy->symbol_duration) / NSEC_PER_USEC;
}
EXPORT_SYMBOL(ieee802154_configure_durations);

Expand All @@ -184,10 +186,10 @@ static void ieee802154_setup_wpan_phy_pib(struct wpan_phy *wpan_phy)
* Should be done when all drivers sets this value.
*/

wpan_phy->lifs_period =
(IEEE802154_LIFS_PERIOD * wpan_phy->symbol_duration) / 1000;
wpan_phy->sifs_period =
(IEEE802154_SIFS_PERIOD * wpan_phy->symbol_duration) / 1000;
wpan_phy->lifs_period = (IEEE802154_LIFS_PERIOD *
wpan_phy->symbol_duration) / NSEC_PER_USEC;
wpan_phy->sifs_period = (IEEE802154_SIFS_PERIOD *
wpan_phy->symbol_duration) / NSEC_PER_USEC;
}

int ieee802154_register_hw(struct ieee802154_hw *hw)
Expand Down

0 comments on commit 07aa339

Please sign in to comment.