Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

spi: sh-msiof: Simplify BRG's Division Ratio

As FIELD_PREP() masks the value to be stored in the field, the Baud Rate
Generator's Division Ratio handling can be simplified from a look-up
table to a single subtraction.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://patch.msgid.link/e736221942b0381fb53dc64109a1389f7ec5f44a.1747401908.git.geert+renesas@glider.be
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Geert Uytterhoeven and committed by
Mark Brown
39d0856f 5b91dc7e

+2 -12
+2 -12
drivers/spi/spi-sh-msiof.c
··· 112 112 /* SITSCR and SIRSCR */ 113 113 #define SISCR_BRPS GENMASK(12, 8) /* Prescaler Setting (1-32) */ 114 114 #define SISCR_BRDV GENMASK(2, 0) /* Baud Rate Generator's Division Ratio */ 115 - #define SISCR_BRDV_DIV_2 0U 116 - #define SISCR_BRDV_DIV_4 1U 117 - #define SISCR_BRDV_DIV_8 2U 118 - #define SISCR_BRDV_DIV_16 3U 119 - #define SISCR_BRDV_DIV_32 4U 120 - #define SISCR_BRDV_DIV_1 7U 121 115 122 116 /* SICTR */ 123 117 #define SICTR_TSCKIZ GENMASK(31, 30) /* Transmit Clock I/O Polarity Select */ ··· 250 256 100); 251 257 } 252 258 253 - static const u32 sh_msiof_spi_div_array[] = { 254 - SISCR_BRDV_DIV_1, SISCR_BRDV_DIV_2, SISCR_BRDV_DIV_4, 255 - SISCR_BRDV_DIV_8, SISCR_BRDV_DIV_16, SISCR_BRDV_DIV_32, 256 - }; 257 - 258 259 static void sh_msiof_spi_set_clk_regs(struct sh_msiof_spi_priv *p, 259 260 struct spi_transfer *t) 260 261 { ··· 288 299 289 300 t->effective_speed_hz = parent_rate / (brps << div_pow); 290 301 291 - scr = FIELD_PREP(SISCR_BRDV, sh_msiof_spi_div_array[div_pow]) | 302 + /* div_pow == 0 maps to SISCR_BRDV_DIV_1 == all ones */ 303 + scr = FIELD_PREP(SISCR_BRDV, div_pow - 1) | 292 304 FIELD_PREP(SISCR_BRPS, brps - 1); 293 305 sh_msiof_write(p, SITSCR, scr); 294 306 if (!(p->ctlr->flags & SPI_CONTROLLER_MUST_TX))