Skip to content

Commit c958bb6

Browse files
prabhakarladbroonie
authored andcommitted
spi: rzv2h-rspi: Simplify clock rate search function signatures
The spr_min and spr_max parameters passed to rzv2h_rspi_find_rate_variable() and rzv2h_rspi_find_rate_fixed() were always called with RSPI_SPBR_SPR_MIN and RSPI_SPBR_SPR_MAX respectively. There is no need to pass these as parameters since the valid SPR range is fixed by the hardware. Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Link: https://patch.msgid.link/20260410080517.2405700-4-prabhakar.mahadev-lad.rj@bp.renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 0335767 commit c958bb6

1 file changed

Lines changed: 11 additions & 15 deletions

File tree

drivers/spi/spi-rzv2h-rspi.c

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ struct rzv2h_rspi_best_clock {
8888
};
8989

9090
struct rzv2h_rspi_info {
91-
void (*find_tclk_rate)(struct clk *clk, u32 hz, u8 spr_min, u8 spr_max,
91+
void (*find_tclk_rate)(struct clk *clk, u32 hz,
9292
struct rzv2h_rspi_best_clock *best_clk);
93-
void (*find_pclk_rate)(struct clk *clk, u32 hz, u8 spr_low, u8 spr_high,
93+
void (*find_pclk_rate)(struct clk *clk, u32 hz,
9494
struct rzv2h_rspi_best_clock *best_clk);
9595
const char *tclk_name;
9696
unsigned int fifo_size;
@@ -413,7 +413,6 @@ static inline u32 rzv2h_rspi_calc_bitrate(unsigned long tclk_rate, u8 spr,
413413
}
414414

415415
static void rzv2h_rspi_find_rate_variable(struct clk *clk, u32 hz,
416-
u8 spr_min, u8 spr_max,
417416
struct rzv2h_rspi_best_clock *best)
418417
{
419418
long clk_rate, clk_min_rate, clk_max_rate;
@@ -464,7 +463,7 @@ static void rzv2h_rspi_find_rate_variable(struct clk *clk, u32 hz,
464463
* minimum SPR that is in the valid range.
465464
*/
466465
min_rate_spr = DIV_ROUND_CLOSEST(clk_min_rate, rate_div) - 1;
467-
if (min_rate_spr > spr_max)
466+
if (min_rate_spr > RSPI_SPBR_SPR_MAX)
468467
continue;
469468

470469
/*
@@ -474,14 +473,14 @@ static void rzv2h_rspi_find_rate_variable(struct clk *clk, u32 hz,
474473
* maximum SPR that is in the valid range.
475474
*/
476475
max_rate_spr = DIV_ROUND_CLOSEST(clk_max_rate, rate_div) - 1;
477-
if (max_rate_spr < spr_min)
476+
if (max_rate_spr < RSPI_SPBR_SPR_MIN)
478477
break;
479478

480-
if (min_rate_spr < spr_min)
481-
min_rate_spr = spr_min;
479+
if (min_rate_spr < RSPI_SPBR_SPR_MIN)
480+
min_rate_spr = RSPI_SPBR_SPR_MIN;
482481

483-
if (max_rate_spr > spr_max)
484-
max_rate_spr = spr_max;
482+
if (max_rate_spr > RSPI_SPBR_SPR_MAX)
483+
max_rate_spr = RSPI_SPBR_SPR_MAX;
485484

486485
for (spr = min_rate_spr; spr <= max_rate_spr; spr++) {
487486
clk_rate = (spr + 1) * rate_div;
@@ -512,7 +511,6 @@ static void rzv2h_rspi_find_rate_variable(struct clk *clk, u32 hz,
512511
}
513512

514513
static void rzv2h_rspi_find_rate_fixed(struct clk *clk, u32 hz,
515-
u8 spr_min, u8 spr_max,
516514
struct rzv2h_rspi_best_clock *best)
517515
{
518516
unsigned long clk_rate;
@@ -545,7 +543,7 @@ static void rzv2h_rspi_find_rate_fixed(struct clk *clk, u32 hz,
545543
*/
546544
if (!spr && !brdv)
547545
continue;
548-
if (spr >= spr_min && spr <= spr_max)
546+
if (spr >= RSPI_SPBR_SPR_MIN && spr <= RSPI_SPBR_SPR_MAX)
549547
goto clock_found;
550548
}
551549

@@ -575,12 +573,10 @@ static u32 rzv2h_rspi_setup_clock(struct rzv2h_rspi_priv *rspi, u32 hz)
575573
};
576574
int ret;
577575

578-
rspi->info->find_tclk_rate(rspi->tclk, hz, RSPI_SPBR_SPR_MIN,
579-
RSPI_SPBR_SPR_MAX, &best_clock);
576+
rspi->info->find_tclk_rate(rspi->tclk, hz, &best_clock);
580577

581578
if (best_clock.error && rspi->info->find_pclk_rate)
582-
rspi->info->find_pclk_rate(rspi->pclk, hz, RSPI_SPBR_SPR_MIN,
583-
RSPI_SPBR_SPR_MAX, &best_clock);
579+
rspi->info->find_pclk_rate(rspi->pclk, hz, &best_clock);
584580

585581
if (!best_clock.clk_rate)
586582
return -EINVAL;

0 commit comments

Comments
 (0)