Skip to content

Commit 373c36b

Browse files
SyberiaEmperorbroonie
authored andcommitted
spi: tegra114: Remove unnecessary NULL-pointer checks
cs_setup, cs_hold and cs_inactive points to fields of spi_device struct, so there is no sense in checking them for NULL. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 04e6bb0 ("spi: modify set_cs_timing parameter") Signed-off-by: Alexander Danilenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent f5b1942 commit 373c36b

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

drivers/spi/spi-tegra114.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -722,27 +722,23 @@ static int tegra_spi_set_hw_cs_timing(struct spi_device *spi)
722722
struct spi_delay *setup = &spi->cs_setup;
723723
struct spi_delay *hold = &spi->cs_hold;
724724
struct spi_delay *inactive = &spi->cs_inactive;
725-
u8 setup_dly, hold_dly, inactive_dly;
725+
u8 setup_dly, hold_dly;
726726
u32 setup_hold;
727727
u32 spi_cs_timing;
728728
u32 inactive_cycles;
729729
u8 cs_state;
730730

731-
if ((setup && setup->unit != SPI_DELAY_UNIT_SCK) ||
732-
(hold && hold->unit != SPI_DELAY_UNIT_SCK) ||
733-
(inactive && inactive->unit != SPI_DELAY_UNIT_SCK)) {
731+
if (setup->unit != SPI_DELAY_UNIT_SCK ||
732+
hold->unit != SPI_DELAY_UNIT_SCK ||
733+
inactive->unit != SPI_DELAY_UNIT_SCK) {
734734
dev_err(&spi->dev,
735735
"Invalid delay unit %d, should be SPI_DELAY_UNIT_SCK\n",
736736
SPI_DELAY_UNIT_SCK);
737737
return -EINVAL;
738738
}
739739

740-
setup_dly = setup ? setup->value : 0;
741-
hold_dly = hold ? hold->value : 0;
742-
inactive_dly = inactive ? inactive->value : 0;
743-
744-
setup_dly = min_t(u8, setup_dly, MAX_SETUP_HOLD_CYCLES);
745-
hold_dly = min_t(u8, hold_dly, MAX_SETUP_HOLD_CYCLES);
740+
setup_dly = min_t(u8, setup->value, MAX_SETUP_HOLD_CYCLES);
741+
hold_dly = min_t(u8, hold->value, MAX_SETUP_HOLD_CYCLES);
746742
if (setup_dly && hold_dly) {
747743
setup_hold = SPI_SETUP_HOLD(setup_dly - 1, hold_dly - 1);
748744
spi_cs_timing = SPI_CS_SETUP_HOLD(tspi->spi_cs_timing1,
@@ -754,7 +750,7 @@ static int tegra_spi_set_hw_cs_timing(struct spi_device *spi)
754750
}
755751
}
756752

757-
inactive_cycles = min_t(u8, inactive_dly, MAX_INACTIVE_CYCLES);
753+
inactive_cycles = min_t(u8, inactive->value, MAX_INACTIVE_CYCLES);
758754
if (inactive_cycles)
759755
inactive_cycles--;
760756
cs_state = inactive_cycles ? 0 : 1;

0 commit comments

Comments
 (0)