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

Simon Glass sjg at chromium.org
Sat Nov 19 14:47:56 CET 2016


Hi Jagan,

On 17 November 2016 at 09:32, Jagan Teki <jagan at openedev.com> wrote:
> On Mon, Nov 14, 2016 at 2:52 AM, Simon Glass <sjg at chromium.org> wrote:
>> At present an invalid bus width prints a message but does not return an
>> error. This is the opposite of the correct behaviour. Adjust it to avoid
>> code bloat in the common case, and avoid hard-to-debug failure in the
>> uncommon case.
>>
>> Signed-off-by: Simon Glass <sjg at chromium.org>
>> ---
>>
>> Changes in v2: None
>>
>>  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;
>
> Why we need to return? we can simply warn saying that un-supported
> width so-that the plat->mode for prior mode assignment shouldn't fail.

My understanding (from the error()) call is that this is an error.
What should happen if an unsupported width is requested?

Regards,
Simon


More information about the U-Boot mailing list