[U-Boot] [PATCH v3 1/9] dm: pinctrl: Add get_pin_muxing() ops

Simon Glass sjg at chromium.org
Wed Oct 24 14:14:53 UTC 2018


Hi Patrice,

On 23 October 2018 at 00:41, Patrice CHOTARD <patrice.chotard at st.com> wrote:
> Hi Simon
>
> On 10/19/18 5:28 AM, Simon Glass wrote:
>> Hi Patrice,
>>
>> On 9 October 2018 at 07:31, Patrice Chotard <patrice.chotard at st.com> wrote:
>>> Add get_pin_muxing() which allows to display the muxing
>>> of a given pin belonging to a pin-controller.
>>>
>>> Signed-off-by: Patrice Chotard <patrice.chotard at st.com>
>>> ---
>>>
>>> Changes in v3:
>>>  - Replace const char **buf parameter by char *buf, int size parameters
>>>    for pinctrl_get_pin_muxing()
>>>
>>> Changes in v2:
>>>  - Replace pinmux_show ops which displayed the complete pin-controller
>>>    muxing by get_pin_muxing ops which displays the muxing of one pin
>>>
>>>  drivers/pinctrl/pinctrl-uclass.c | 13 +++++++++++++
>>>  include/dm/pinctrl.h             | 32 ++++++++++++++++++++++++++++++++
>>>  2 files changed, 45 insertions(+)
>>
>> Reviewed-by: Simon Glass <sjg at chromium.org>
>>
>> But please see below.
>>
>>>
>>> diff --git a/drivers/pinctrl/pinctrl-uclass.c b/drivers/pinctrl/pinctrl-uclass.c
>>> index c38bb212ed74..cd2ca4e4950e 100644
>>> --- a/drivers/pinctrl/pinctrl-uclass.c
>>> +++ b/drivers/pinctrl/pinctrl-uclass.c
>>> @@ -249,6 +249,19 @@ int pinctrl_get_gpio_mux(struct udevice *dev, int banknum, int index)
>>>         return ops->get_gpio_mux(dev, banknum, index);
>>>  }
>>>
>>> +int pinctrl_get_pin_muxing(struct udevice *dev, int selector, char *buf,
>>> +                          int size)
>>> +{
>>> +       struct pinctrl_ops *ops = pinctrl_get_ops(dev);
>>> +
>>> +       if (!ops->get_pin_muxing)
>>> +               return -ENOSYS;
>>> +
>>> +       snprintf(buf, size, ops->get_pin_muxing(dev, selector));
>>
>> I wonder if it would be easy to return -ENOSPC if the string is too long?
>
> Not so easy, for example in pinctrl_stm32.c, depending of the pin's
> muxing mode, i not only copy but also, in some case, concatenate
> additional information. It would complexify the pinctrl code.

OK. Well snprintf() should return a useful value, but I'm not sure if
it tells you when the buffer is exhausted.

Regards,
Simon


More information about the U-Boot mailing list