]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
serial: max310x: use FIELD_PREP macro to set PLL bitfields
authorHugo Villeneuve <hvilleneuve@dimonoff.com>
Fri, 17 Apr 2026 14:53:34 +0000 (10:53 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 11 May 2026 15:20:18 +0000 (17:20 +0200)
Use FIELD_PREP macros to improve code readability.

Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
Link: https://patch.msgid.link/20260417-max310x-2-v1-7-b424e105ecac@dimonoff.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/max310x.c

index 7ab5e4bd87ee6c87dd211bc52a3a4eb169a2b202..b4449b68cfeee07d1d6d3206cf58f72fac00044e 100644 (file)
@@ -9,6 +9,7 @@
  *  Based on max3107.c, by Aavamobile
  */
 
+#include <linux/bitfield.h>
 #include <linux/bitops.h>
 #include <linux/clk.h>
 #include <linux/delay.h>
@@ -621,7 +622,9 @@ static int max310x_set_ref_clk(struct device *dev, struct max310x_port *s,
                u8 pll_id = max310x_pll_mult_to_id(cfg.pll_mult);
 
                clksrc |= MAX310X_CLKSRC_PLL_BIT;
-               regmap_write(s->regmap, MAX310X_PLLCFG_REG, (pll_id << 6) | cfg.prediv);
+               val = FIELD_PREP(MAX310X_PLLCFG_PLLFACTOR_MASK, pll_id) |
+                       FIELD_PREP(MAX310X_PLLCFG_PREDIV_MASK, cfg.prediv);
+               regmap_write(s->regmap, MAX310X_PLLCFG_REG, val);
        } else
                clksrc |= MAX310X_CLKSRC_PLLBYP_BIT;