spi: bitbang: Use NSEC_PER_*SEC rather than hard coding
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 2 May 2024 15:48:25 +0000 (18:48 +0300)
committerMark Brown <broonie@kernel.org>
Fri, 3 May 2024 02:09:29 +0000 (11:09 +0900)
Use NSEC_PER_*SEC rather than the hard coded value of 1000s.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20240502154825.2752464-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-bitbang.c

index a0e2204fc0397ed58ffb83a131fa28804ab0bb3b..c11af39c9842d3b640390f2b24e06336a3feaccd 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/errno.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
+#include <linux/time64.h>
 
 #include <linux/spi/spi.h>
 #include <linux/spi/spi_bitbang.h>
@@ -168,8 +169,8 @@ int spi_bitbang_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
        if (!hz)
                hz = spi->max_speed_hz;
        if (hz) {
-               cs->nsecs = (1000000000/2) / hz;
-               if (cs->nsecs > (MAX_UDELAY_MS * 1000 * 1000))
+               cs->nsecs = (NSEC_PER_SEC / 2) / hz;
+               if (cs->nsecs > (MAX_UDELAY_MS * NSEC_PER_MSEC))
                        return -EINVAL;
        }