Skip to content

Commit 645094b

Browse files
andy-shevbroonie
authored andcommitted
spi: bitbang: Use NSEC_PER_*SEC rather than hard coding
Use NSEC_PER_*SEC rather than the hard coded value of 1000s. Signed-off-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 6be871d commit 645094b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/spi/spi-bitbang.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/errno.h>
1212
#include <linux/platform_device.h>
1313
#include <linux/slab.h>
14+
#include <linux/time64.h>
1415

1516
#include <linux/spi/spi.h>
1617
#include <linux/spi/spi_bitbang.h>
@@ -168,8 +169,8 @@ int spi_bitbang_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
168169
if (!hz)
169170
hz = spi->max_speed_hz;
170171
if (hz) {
171-
cs->nsecs = (1000000000/2) / hz;
172-
if (cs->nsecs > (MAX_UDELAY_MS * 1000 * 1000))
172+
cs->nsecs = (NSEC_PER_SEC / 2) / hz;
173+
if (cs->nsecs > (MAX_UDELAY_MS * NSEC_PER_MSEC))
173174
return -EINVAL;
174175
}
175176

0 commit comments

Comments
 (0)