Skip to content

Commit 07aa339

Browse files
dmantipovStefan-Schmidt
authored andcommitted
mac802154: fix time calculation in ieee802154_configure_durations()
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 <[email protected]> Acked-by: Miquel Raynal <[email protected]> Message-ID: <[email protected]> Signed-off-by: Stefan Schmidt <[email protected]>
1 parent 4b377b4 commit 07aa339

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

net/mac802154/main.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,10 @@ void ieee802154_configure_durations(struct wpan_phy *phy,
161161
}
162162

163163
phy->symbol_duration = duration;
164-
phy->lifs_period = (IEEE802154_LIFS_PERIOD * phy->symbol_duration) / NSEC_PER_SEC;
165-
phy->sifs_period = (IEEE802154_SIFS_PERIOD * phy->symbol_duration) / NSEC_PER_SEC;
164+
phy->lifs_period =
165+
(IEEE802154_LIFS_PERIOD * phy->symbol_duration) / NSEC_PER_USEC;
166+
phy->sifs_period =
167+
(IEEE802154_SIFS_PERIOD * phy->symbol_duration) / NSEC_PER_USEC;
166168
}
167169
EXPORT_SYMBOL(ieee802154_configure_durations);
168170

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

187-
wpan_phy->lifs_period =
188-
(IEEE802154_LIFS_PERIOD * wpan_phy->symbol_duration) / 1000;
189-
wpan_phy->sifs_period =
190-
(IEEE802154_SIFS_PERIOD * wpan_phy->symbol_duration) / 1000;
189+
wpan_phy->lifs_period = (IEEE802154_LIFS_PERIOD *
190+
wpan_phy->symbol_duration) / NSEC_PER_USEC;
191+
wpan_phy->sifs_period = (IEEE802154_SIFS_PERIOD *
192+
wpan_phy->symbol_duration) / NSEC_PER_USEC;
191193
}
192194

193195
int ieee802154_register_hw(struct ieee802154_hw *hw)

0 commit comments

Comments
 (0)