Re: [PATCH] Input: pxspad - add check for spi_setup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

[Cc += linux-spi]

On Fri, Jul 05, 2024 at 04:20:57PM +0800, Chen Ni wrote:
> Add check for the return value of spi_setup() and return the error
> if it fails in order to catch the error.

Does this fix a real-world problem, or did you notice this using a
linter or by just reading through the driver?

> Signed-off-by: Chen Ni <nichen@xxxxxxxxxxx>
> ---
>  drivers/input/joystick/psxpad-spi.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/input/joystick/psxpad-spi.c b/drivers/input/joystick/psxpad-spi.c
> index c47fc5f34bd0..5b53d43c797a 100644
> --- a/drivers/input/joystick/psxpad-spi.c
> +++ b/drivers/input/joystick/psxpad-spi.c
> @@ -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 < 0) {
> +		dev_err(&spi->dev, "failed to set up spi: %d\n", err);
> +		return err;

Please consider using dev_err_probe() in such cases. It allows for a
more compact error path and emits the error code in a human readable
way.

Apart from that: spi_setup() is inconsistent as it emits error messages
for some error paths but not for all. Probably the better change is to
make spi_setup() consistent here. I suggest to add error messages to the
error paths that currently don't have a message and drop this patch.

Best regards
Uwe

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux