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: drop check for validity of device chip selects

Now that we know the number of chip selects of a device, we can assume
these are valid, and do not need to check them first.

Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
Link: https://patch.msgid.link/20250915183725.219473-5-jonas.gorski@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Jonas Gorski and committed by
Mark Brown
f3982dac 1c923f62

+3 -9
+3 -9
drivers/spi/spi.c
··· 623 623 */ 624 624 #define SPI_INVALID_CS ((s8)-1) 625 625 626 - static inline bool is_valid_cs(s8 chip_select) 627 - { 628 - return chip_select != SPI_INVALID_CS; 629 - } 630 - 631 626 static inline int spi_dev_check_cs(struct device *dev, 632 627 struct spi_device *spi, u8 idx, 633 628 struct spi_device *new_spi, u8 new_idx) ··· 633 638 cs = spi_get_chipselect(spi, idx); 634 639 for (idx_new = new_idx; idx_new < new_spi->num_chipselect; idx_new++) { 635 640 cs_new = spi_get_chipselect(new_spi, idx_new); 636 - if (is_valid_cs(cs) && is_valid_cs(cs_new) && cs == cs_new) { 641 + if (cs == cs_new) { 637 642 dev_err(dev, "chipselect %u already in use\n", cs_new); 638 643 return -EBUSY; 639 644 } ··· 679 684 for (idx = 0; idx < spi->num_chipselect; idx++) { 680 685 /* Chipselects are numbered 0..max; validate. */ 681 686 cs = spi_get_chipselect(spi, idx); 682 - if (is_valid_cs(cs) && cs >= ctlr->num_chipselect) { 687 + if (cs >= ctlr->num_chipselect) { 683 688 dev_err(dev, "cs%d >= max %d\n", spi_get_chipselect(spi, idx), 684 689 ctlr->num_chipselect); 685 690 return -EINVAL; ··· 725 730 726 731 for (idx = 0; idx < spi->num_chipselect; idx++) { 727 732 cs = spi_get_chipselect(spi, idx); 728 - if (is_valid_cs(cs)) 729 - spi_set_csgpiod(spi, idx, ctlr->cs_gpiods[cs]); 733 + spi_set_csgpiod(spi, idx, ctlr->cs_gpiods[cs]); 730 734 } 731 735 } 732 736