[PATCH 3/4] pinctrl: mediatek: print bias info along with pinmux
David Lechner
dlechner at baylibre.com
Mon Mar 30 17:21:46 CEST 2026
On 3/30/26 9:51 AM, Julien Stephan wrote:
> Le ven. 13 mars 2026 à 22:56, David Lechner <dlechner at baylibre.com> a écrit :
>>
>> Add functionality to be able to print pin bias settings along with the
>> pinmux setting.
>>
>> This can be useful to debug why pins might not be working correctly.
>>
>> Signed-off-by: David Lechner <dlechner at baylibre.com>
>> ---
>> drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 96 ++++++++++++++++++++++++++-
>> drivers/pinctrl/mediatek/pinctrl-mtk-common.h | 4 ++
>> 2 files changed, 98 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
>> index 1028b8a93f5..ef4acc946a8 100644
>> --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
>> +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
>> @@ -237,9 +237,39 @@ static int mtk_get_pin_io_type(struct udevice *dev, int pin,
>> io_type->bias_set = priv->soc->io_type[io_n].bias_set;
>> io_type->drive_set = priv->soc->io_type[io_n].drive_set;
>> io_type->input_enable = priv->soc->io_type[io_n].input_enable;
>> + io_type->get_pinconf = priv->soc->io_type[io_n].get_pinconf;
>>
>> return 0;
>> }
>> +
>> +static int mtk_pinconf_get(struct udevice *dev, u32 pin, char *buf, size_t size)
>> +{
>> + struct mtk_io_type_desc io_type;
>> + int err, pos = 0;
>> +
>> + if (!mtk_get_pin_io_type(dev, pin, &io_type)) {
>> + pos += snprintf(buf + pos, size - pos, " (%s)", io_type.name);
>
> why += ? pos is initialized to 0. Same why buf +pos? and size - pos?
>
>> + if (pos >= size)
>> + return pos;
>> +
>> + if (io_type.get_pinconf) {
>> + err = io_type.get_pinconf(dev, pin, buf + pos, size - pos);
>> + if (err < 0)
>> + return err;
>> +
>> + pos += err;
>> + if (pos >= size)
>> + return pos;
>
> Can't this be removed?
The idea was to make it robust against future additions. Should be
fine to drop it.
>
>> + }
>> + }
>> +
>> + return pos;
>> +}
I will simplify it to:
static int mtk_pinconf_get(struct udevice *dev, u32 pin, char *buf, size_t size)
{
struct mtk_io_type_desc io_type;
int err, pos;
/* If we fail to get the type, then we just don't add any more info. */
if (mtk_get_pin_io_type(dev, pin, &io_type))
return 0;
pos = snprintf(buf, size, " (%s)", io_type.name);
if (pos >= size)
return pos;
if (io_type.get_pinconf) {
err = io_type.get_pinconf(dev, pin, buf + pos, size - pos);
if (err < 0)
return err;
pos += err;
}
return pos;
}
More information about the U-Boot
mailing list