]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
hpet: Optimize local variable data type in hpet_alloc()
authorThorsten Blum <thorsten.blum@toblux.com>
Wed, 10 Jul 2024 21:52:39 +0000 (23:52 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 31 Jul 2024 11:12:02 +0000 (13:12 +0200)
The local variable period uses at most 32 bits and can be a u32 instead
of unsigned long. The upper 32 bits are all 0 after masking and right
shifting cap by HPET_COUNTER_CLK_PERIOD_SHIFT and can be discarded.

Since do_div() casts the divisor to u32 anyway, changing the data type
of period to u32 also removes the following Coccinelle/coccicheck
warning reported by do_div.cocci:

  WARNING: do_div() does a 64-by-32 division, please consider using div64_ul instead

Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20240710215238.799239-2-thorsten.blum@toblux.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/char/hpet.c

index da32e8ed0830967fcf9b08a2832dd28ae8584f35..f6c92106eb98526c0a730bae590bedd44a346981 100644 (file)
@@ -808,7 +808,7 @@ int hpet_alloc(struct hpet_data *hdp)
        struct hpets *hpetp;
        struct hpet __iomem *hpet;
        static struct hpets *last;
-       unsigned long period;
+       u32 period;
        unsigned long long temp;
        u32 remainder;