All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jagan Teki <jagan@openedev.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 10/22] spi: Add error checking for invalid bus widths
Date: Fri, 25 Nov 2016 22:27:40 +0530	[thread overview]
Message-ID: <CAD6G_RR7Eoism_Mn1sTKu-psJ06By-o=i0ksNbuJZ=9sQX-53Q@mail.gmail.com> (raw)
In-Reply-To: <CAPnjgZ0fFkPnLbXnRmBVLSRERpP1-T=MR4P3_ewobT5S2mn56A@mail.gmail.com>

Hi Simon,

On Thu, Nov 24, 2016 at 7:51 AM, Simon Glass <sjg@chromium.org> wrote:
> Hi Jagan,
>
> On 21 November 2016 at 10:57, Jagan Teki <jagan@openedev.com> wrote:
>> On Sun, Nov 20, 2016 at 2:19 AM, Fabio Estevam <festevam@gmail.com> wrote:
>>> On Sat, Nov 19, 2016 at 6:04 PM, Simon Glass <sjg@chromium.org> wrote:
>>>
>>>>> 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.
>>>
>>> Actually they are SPI modes: one, two 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.
>>>
>>> I think the current behaviour of not returning an error code on an
>>> invalid mode is correct and it matches what the kernel does in
>>> drivers/spi/spi.c.
>>>
>>> If an invalid mode is passed we just ignore it and operate in single
>>> mode instead.
>>>
>>> Maybe we can make this clearer by printing a message like this:
>>>
>>> --- a/drivers/spi/spi-uclass.c
>>> +++ b/drivers/spi/spi-uclass.c
>>> @@ -408,7 +408,7 @@ 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);
>>> +               printf("spi-tx-bus-width %d not supported, operating
>>> in single mode\n", value);
>>>                 break;
>>>         }
>>>
>>> @@ -423,7 +423,7 @@ int spi_slave_ofdata_to_platdata(const void *blob, int node,
>>>                 mode |= SPI_RX_QUAD;
>>>                 break;
>>>         default:
>>> -               error("spi-rx-bus-width %d not supported\n", value);
>>> +               printf("spi-rx-bus-width %d not supported, operating
>>> in single mode\n", value);
>>>                 break;
>>
>> Yes, this is what I am commenting about.
>>
>> -EINVAL not needed, we can print "%d is not supporting and operating
>> in normal/single mode and move on", So-that the dts will fix if
>> something went wrong.
>
> Well if you add printf() values you will bloat the code for little
> benefit. If the device tree is invalid it really should be fixed.

Yeah, ie what if dts has a wrong value and do print that and continue
with default width, so-that the user will update this for next run.
Since it's not key a attribute to break or decide functionality better
to go with it.

thanks!
-- 
Jagan Teki
Free Software Engineer | www.openedev.com
U-Boot, Linux | Upstream Maintainer
Hyderabad, India.

  reply	other threads:[~2016-11-25 16:57 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-13 21:21 [U-Boot] [PATCH v2 00/22] rockchip: Add support for Asus Chromebit Simon Glass
2016-11-13 21:21 ` [U-Boot] [PATCH v2 01/22] rockchip: video: Correct HDMI data source selection Simon Glass
2016-11-25 19:38   ` Simon Glass
2016-11-13 21:21 ` [U-Boot] [PATCH v2 02/22] rockchip: video: Correct VOP clock selection Simon Glass
2016-11-13 21:21 ` [U-Boot] [PATCH v2 03/22] rockchip: Allow jerry to use of-platdata Simon Glass
2016-11-25 19:38   ` Simon Glass
2016-11-13 21:21 ` [U-Boot] [PATCH v2 04/22] dm: core: Handle global_data moving in SPL Simon Glass
2016-11-13 21:21 ` [U-Boot] [PATCH v2 05/22] stdio: Correct code style nits Simon Glass
2016-11-25 19:38   ` Simon Glass
2016-11-13 21:22 ` [U-Boot] [PATCH v2 06/22] stdio: Correct numbering logic in stdio_probe_device() Simon Glass
2016-11-25 19:38   ` Simon Glass
2016-11-13 21:22 ` [U-Boot] [PATCH v2 07/22] spi: Add of-platdata support to SPI and SPI flash Simon Glass
2016-11-13 21:22 ` [U-Boot] [PATCH v2 08/22] rockchip: spi: Add support for of-platdata Simon Glass
2016-11-13 21:22 ` [U-Boot] [PATCH v2 09/22] rockchip: spi: Honour the deactivation delay Simon Glass
2016-11-13 21:22 ` [U-Boot] [PATCH v2 10/22] spi: Add error checking for invalid bus widths Simon Glass
2016-11-17 16:32   ` Jagan Teki
2016-11-19 13:47     ` Simon Glass
2016-11-19 14:53   ` Fabio Estevam
2016-11-19 20:04     ` Simon Glass
2016-11-19 20:49       ` Fabio Estevam
2016-11-19 23:56         ` Simon Glass
2016-11-21 17:57         ` Jagan Teki
2016-11-24  2:21           ` Simon Glass
2016-11-25 16:57             ` Jagan Teki [this message]
2016-11-25 16:59               ` Fabio Estevam
2016-11-25 19:38                 ` Simon Glass
2016-11-25 20:16                   ` Fabio Estevam
2016-11-26  3:28                   ` Jagan Teki
2016-11-30  3:11                     ` Simon Glass
2016-11-13 21:22 ` [U-Boot] [PATCH v2 11/22] spi: Add a debug() on bind failure Simon Glass
2016-11-13 21:22 ` [U-Boot] [PATCH v2 12/22] video: Use cache-alignment in video_sync() Simon Glass
2016-11-25 19:38   ` Simon Glass
2016-11-13 21:22 ` [U-Boot] [PATCH v2 13/22] video: Track whether a display is in use Simon Glass
2016-11-25 19:38   ` Simon Glass
2016-11-13 21:22 ` [U-Boot] [PATCH v2 14/22] rockchip: video: Check for device " Simon Glass
2016-11-13 21:22 ` [U-Boot] [PATCH v2 15/22] rockchip: Move jerry to use of-platdata Simon Glass
2016-11-13 21:22 ` [U-Boot] [PATCH v2 16/22] rockchip: Rename jerry files to veyron Simon Glass
2016-11-25 19:38   ` Simon Glass
2016-11-13 21:22 ` [U-Boot] [PATCH v2 17/22] rockchip: veyron: Add a note about the SDRAM voltage Simon Glass
2016-11-25 19:38   ` Simon Glass
2016-11-13 21:22 ` [U-Boot] [PATCH v2 18/22] rockchip: Move jerry SDRAM settings into its own .dts file Simon Glass
2016-11-13 21:22 ` [U-Boot] [PATCH v2 19/22] rockchip: clk: Support setting ACLK Simon Glass
2016-11-25 19:39   ` Simon Glass
2016-11-13 21:22 ` [U-Boot] [PATCH v2 20/22] rockchip: veyron: Adjust ARM clock after relocation Simon Glass
2016-11-13 21:22 ` [U-Boot] [PATCH v2 21/22] rockchip: video: Avoid using u8 in the HDMI driver Simon Glass
2016-11-13 21:22 ` [U-Boot] [PATCH v2 22/22] rockchip: Add support for veyron-mickey (Chromebit) Simon Glass
2016-11-25 19:39   ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAD6G_RR7Eoism_Mn1sTKu-psJ06By-o=i0ksNbuJZ=9sQX-53Q@mail.gmail.com' \
    --to=jagan@openedev.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.