Commit db74430a authored by Haotian Zhang's avatar Haotian Zhang Committed by Dmitry Torokhov
Browse files

Input: psxpad-spi - add a check for the return value of spi_setup()



The probe function in the psxpad-spi driver calls spi_setup()
but fails to check its return value. If the SPI bus setup fails,
the driver will still load successfully, resulting in potential
error in later I/O operations.

Add a check for the return value of spi_setup() and return
an error on failure.

Fixes: 8be193c7 ("Input: add support for PlayStation 1/2 joypads connected via SPI")
Signed-off-by: default avatarHaotian Zhang <vulab@iscas.ac.cn>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent d3366a04
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -344,7 +344,11 @@ static int psxpad_spi_probe(struct spi_device *spi)
	/* (PlayStation 1/2 joypad might be possible works 250kHz/500kHz) */
	spi->controller->min_speed_hz = 125000;
	spi->controller->max_speed_hz = 125000;
	spi_setup(spi);
	err = spi_setup(spi);
	if (err) {
		dev_err(&spi->dev, "failed to set up SPI: %d\n", err);
		return err;
	}

	/* pad settings */
	psxpad_set_motor_level(pad, 0, 0);