mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Clément Le Goffic" <clegoffic@baylibre.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Sudeep Holla <sudeep.holla@kernel.org>,
	Cristian Marussi <cristian.marussi@arm.com>,
	Linus Walleij <linusw@kernel.org>, Peng Fan <peng.fan@nxp.com>,
	Oleksii Moisieiev <oleksii_moisieiev@epam.com>,
	Andy Shevchenko <andy@kernel.org>, Dhruva Gole <d-gole@ti.com>,
	Bartosz Golaszewski <brgl@kernel.org>,
	arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 01/11] pinctrl: scmi: send the drive strength in microamperes
Date: Wed, 18 Nov 2026 15:56:45 +0100	[thread overview]
Message-ID: <f837a7b5-7fce-4571-96b2-f3d307d203c2@baylibre.com> (raw)
In-Reply-To: <CAMuHMdWwp4RtKnBpFNJPHdigzrQ-wf3yt-pBZGG9QKs9tcd_Ow@mail.gmail.com>

Hi Geert,

On 11/17/26 3:35 PM, Geert Uytterhoeven wrote:
> Hi Clément,
>
> On Fri, 13 Nov 2026 at 16:02, Clément Le Goffic <clegoffic@baylibre.com> wrote:
>> SCMI gives the drive strength in microamperes, but
>> PIN_CONFIG_DRIVE_STRENGTH is in milliamperes and was sent unchanged.
>> Convert it on set and on get. It is the only unit that differs: the
>> debounce is in microseconds and the pull resistances in ohms on both
>> sides, and every other value is a flag or implementation defined.
>>
>> Fixes: eb524cb651b7 ("pinctrl: Implementation of the generic scmi-pinctrl driver")
>> Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
>> Signed-off-by: Clément Le Goffic <clegoffic@baylibre.com>
>
> Thanks for your patch, which is now commit cc2f90768e971bcc ("pinctrl:
> scmi: send the drive strength in microamperes") in pinctrl/for-next.

Yes, Linus took it 1h before my v2 and I didn't see it.

[...]

>> +static u32 pinctrl_scmi_map_pinconf_arg_get(enum pin_config_param param, u32 value)
>> +{
>> +       if (param == PIN_CONFIG_DRIVE_STRENGTH)
>> +               return value / MILLI;
>
> Does this need rounding?

Rounding does not help I think: SCMI only talks µA, and 10800 µA has no exact mA form.
I will send a fix that returns -EINVAL on get when the value is not a whole mA.
PIN_CONFIG_DRIVE_STRENGTH_UA still gives the exact value.

> While MILLI = 1000UL is correct from a numerical point of view,
> it is not correct from a semantical point of view.
>
> <linux/units.h> has:
>
>     #define MICROWATT_PER_MILLIWATT 1000UL
>
> In the absence of a generic conversion value, "(MICRO / MILLI)" might
> be better.

Agreed, I will send a follow-up once Linus answers my question on v1 patch 7 about where to base v3 [1].

[...]

>> +               *arg *= MILLI;
>
> What happens if the result differs from the original value in µA,
> due to truncation or rounding?
>
> Likewise about the use of MILLI.

Multiplying a whole mA by 1000 gives an exact µA value, so it never differs, unless it overflows the u32.
The same fix will return -EINVAL for that case.
The platform refuses a value it does not support and the set fails with -EINVAL.

[1] https://lore.kernel.org/all/ce463c97-8fde-44b3-b3bd-c21a69ee61b9@baylibre.com/

Best regards,
Clément


  reply	other threads:[~2026-11-18 14:56 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 11:05 [PATCH v2 00/11] pinctrl: scmi: fixes and GPIO function support Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 01/11] pinctrl: scmi: send the drive strength in microamperes Clément Le Goffic
2026-11-17 14:35   ` Geert Uytterhoeven
2026-11-18 14:56     ` Clément Le Goffic [this message]
2026-11-13 11:05 ` [PATCH v2 02/11] pinctrl: scmi: map the schmitt trigger enable to its SCMI type Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 03/11] pinctrl: scmi: send the settings without argument as enabled Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 04/11] pinctrl: scmi: report an off setting as not set Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 05/11] firmware: arm_scmi: stop reading past PINCTRL_LIST_ASSOCIATIONS replies Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 06/11] firmware: arm_scmi: report the pin-only and GPIO flags of functions Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 07/11] pinctrl: scmi: give no groups to pin-only functions Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 08/11] pinctrl: scmi: mark the GPIO functions Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 09/11] pinctrl: scmi: report whether a function is GPIO Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 10/11] firmware: arm_scmi: add an operation to set the function of a single pin Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 11/11] pinctrl: scmi: select the GPIO function on GPIO requests Clément Le Goffic

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=f837a7b5-7fce-4571-96b2-f3d307d203c2@baylibre.com \
    --to=clegoffic@baylibre.com \
    --cc=andy@kernel.org \
    --cc=arm-scmi@vger.kernel.org \
    --cc=brgl@kernel.org \
    --cc=cristian.marussi@arm.com \
    --cc=d-gole@ti.com \
    --cc=geert@linux-m68k.org \
    --cc=linusw@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleksii_moisieiev@epam.com \
    --cc=peng.fan@nxp.com \
    --cc=sudeep.holla@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®