lkml.org 
[lkml]   [2023]   [Jul]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v2 10/15] spi: Use predefined constants from bits.h and units.h
    Date
    Instead of hard coded numbers, use predefined constancts,
    such as BITS_PER_BYTE.

    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    ---
    include/linux/spi/spi.h | 5 +++--
    1 file changed, 3 insertions(+), 2 deletions(-)

    diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
    index 9fb8efb068c6..10265184ea02 100644
    --- a/include/linux/spi/spi.h
    +++ b/include/linux/spi/spi.h
    @@ -25,6 +25,7 @@
    #include <linux/string.h>
    #include <linux/types.h>
    #include <linux/u64_stats_sync.h>
    +#include <linux/units.h>

    #include <asm/byteorder.h>

    @@ -1294,9 +1295,9 @@ static inline bool spi_is_bpw_supported(struct spi_device *spi, u32 bpw)
    static inline unsigned int spi_controller_xfer_timeout(struct spi_controller *ctlr,
    struct spi_transfer *xfer)
    {
    - u32 speed_hz = xfer->speed_hz ?: 100000;
    + u32 speed_hz = xfer->speed_hz ?: 100 * HZ_PER_KHZ;

    - return max(xfer->len * 8 * 2 / (speed_hz / 1000), 500U);
    + return max(xfer->len * BITS_PER_BYTE * 2 / (speed_hz / MILLI), 500UL);
    }

    /*---------------------------------------------------------------------------*/
    --
    2.40.0.1.gaa8946217a0b
    \
     
     \ /
      Last update: 2023-07-10 17:51    [W:3.759 / U:0.012 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site