Skip to content

Commit 57b935e

Browse files
committed
Merge tag 'spi-fix-v6.11-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
Pull spi fixes from Mark Brown: "A few SPI fixes: clock rate calculation fixes for the Kunpeng and lpsi drivers and a missing registration of a device ID for spidev (which had only been updated for DT cases, causing warnings)" * tag 'spi-fix-v6.11-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: spi: spi-fsl-lpspi: Fix scldiv calculation spi: spidev: Add missing spi_device_id for bh2228fv spi: hisi-kunpeng: Add verification for the max_frequency provided by the firmware spi: hisi-kunpeng: Add validation for the minimum value of speed_hz
2 parents 15833fe + 730bbfa commit 57b935e

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

drivers/spi/spi-fsl-lpspi.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ static void fsl_lpspi_set_watermark(struct fsl_lpspi_data *fsl_lpspi)
296296
static int fsl_lpspi_set_bitrate(struct fsl_lpspi_data *fsl_lpspi)
297297
{
298298
struct lpspi_config config = fsl_lpspi->config;
299-
unsigned int perclk_rate, scldiv;
299+
unsigned int perclk_rate, scldiv, div;
300300
u8 prescale;
301301

302302
perclk_rate = clk_get_rate(fsl_lpspi->clk_per);
@@ -313,8 +313,10 @@ static int fsl_lpspi_set_bitrate(struct fsl_lpspi_data *fsl_lpspi)
313313
return -EINVAL;
314314
}
315315

316+
div = DIV_ROUND_UP(perclk_rate, config.speed_hz);
317+
316318
for (prescale = 0; prescale < 8; prescale++) {
317-
scldiv = perclk_rate / config.speed_hz / (1 << prescale) - 2;
319+
scldiv = div / (1 << prescale) - 2;
318320
if (scldiv < 256) {
319321
fsl_lpspi->config.prescale = prescale;
320322
break;

drivers/spi/spi-hisi-kunpeng.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,9 @@ static int hisi_spi_probe(struct platform_device *pdev)
481481
return -EINVAL;
482482
}
483483

484+
if (host->max_speed_hz == 0)
485+
return dev_err_probe(dev, -EINVAL, "spi-max-frequency can't be 0\n");
486+
484487
ret = device_property_read_u16(dev, "num-cs",
485488
&host->num_chipselect);
486489
if (ret)
@@ -495,6 +498,7 @@ static int hisi_spi_probe(struct platform_device *pdev)
495498
host->transfer_one = hisi_spi_transfer_one;
496499
host->handle_err = hisi_spi_handle_err;
497500
host->dev.fwnode = dev->fwnode;
501+
host->min_speed_hz = DIV_ROUND_UP(host->max_speed_hz, CLK_DIV_MAX);
498502

499503
hisi_spi_hw_init(hs);
500504

drivers/spi/spidev.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,7 @@ static const struct class spidev_class = {
700700
};
701701

702702
static const struct spi_device_id spidev_spi_ids[] = {
703+
{ .name = "bh2228fv" },
703704
{ .name = "dh2228fv" },
704705
{ .name = "ltc2488" },
705706
{ .name = "sx1301" },

0 commit comments

Comments
 (0)