[PATCH 07/10] serial: max310x: use FIELD_PREP macro to set PLL bitfields

From: Hugo Villeneuve

Date: Fri Apr 17 2026 - 10:54:18 EST


From: Hugo Villeneuve <hvilleneuve@xxxxxxxxxxxx>

Use FIELD_PREP macros to improve code readability.

Signed-off-by: Hugo Villeneuve <hvilleneuve@xxxxxxxxxxxx>
---
drivers/tty/serial/max310x.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
index 7ab5e4bd87ee6c87dd211bc52a3a4eb169a2b202..b4449b68cfeee07d1d6d3206cf58f72fac00044e 100644
--- a/drivers/tty/serial/max310x.c
+++ b/drivers/tty/serial/max310x.c
@@ -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;


--
2.47.3