[U-Boot] [PATCH v2 10/22] spi: Add error checking for invalid bus widths

Simon Glass sjg at chromium.org
Sat Nov 19 21:04:50 CET 2016


Hi,

On 19 November 2016 at 07:53, Fabio Estevam <festevam at gmail.com> wrote:
> Hi Simon,
>
> On Sun, Nov 13, 2016 at 7:22 PM, Simon Glass <sjg at chromium.org> wrote:
>
>>  drivers/spi/spi-uclass.c | 8 ++++----
>>  1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c
>> index 26eada2..358e229 100644
>> --- a/drivers/spi/spi-uclass.c
>> +++ b/drivers/spi/spi-uclass.c
>> @@ -415,8 +415,8 @@ int spi_slave_ofdata_to_platdata(const void *blob, int node,
>>                 mode |= SPI_TX_QUAD;
>>                 break;
>>         default:
>> -               error("spi-tx-bus-width %d not supported\n", value);
>> -               break;
>> +               debug("spi-tx-bus-width %d not supported\n", value);
>> +               return -EPROTONOSUPPORT;
>
> EPROTONOSUPPORT means: /* Protocol not supported */, which does not
> seem to be very appropriate here.

This is a protocol as far as I can see - you can either use one pin or
four pins.

>
> Why not return -EINVAL instead?

The value is valid but is not supported. If we just return -EINVAL for
anything we don't like, it makes it harder to root-cause the error. In
particular we use -EINVAL when decoding the device tree. But
EPROTONOSUPPORT is not widely used.

Regards,
Simon


More information about the U-Boot mailing list