<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 3/10/25 13:35, Patrice CHOTARD
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:329df3e4-1493-4966-a7e2-ebd628503e8c@foss.st.com">
      <pre class="moz-quote-pre" wrap="">

On 3/10/25 11:00, Patrice CHOTARD wrote:
</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">

On 3/6/25 15:13, Patrice CHOTARD wrote:
</pre>
        <blockquote type="cite">
          <pre class="moz-quote-pre" wrap="">

On 3/6/25 11:56, Cheick Traore wrote:
</pre>
          <blockquote type="cite">
            <pre class="moz-quote-pre" wrap="">It was possible to provide a duty_ns greater than period_ns to
"pwm config" command. The framework must check the values before
providing them to drivers.

Signed-off-by: Cheick Traore <a class="moz-txt-link-rfc2396E" href="mailto:cheick.traore@foss.st.com"><cheick.traore@foss.st.com></a>
---

 drivers/pwm/pwm-uclass.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/pwm/pwm-uclass.c b/drivers/pwm/pwm-uclass.c
index 6543db1d623..b4491f7dcd4 100644
--- a/drivers/pwm/pwm-uclass.c
+++ b/drivers/pwm/pwm-uclass.c
@@ -27,6 +27,9 @@ int pwm_set_config(struct udevice *dev, uint channel, uint period_ns,
        if (!ops->set_config)
                return -ENOSYS;
 
+       if (duty_ns > period_ns)
+               return -EINVAL;
+
        return ops->set_config(dev, channel, period_ns, duty_ns);
 }
 
</pre>
          </blockquote>
          <pre class="moz-quote-pre" wrap="">Reviewed-by: Patrice Chotard <a class="moz-txt-link-rfc2396E" href="mailto:patrice.chotard@foss.st.com"><patrice.chotard@foss.st.com></a>

Thanks
Patrice
</pre>
        </blockquote>
        <pre class="moz-quote-pre" wrap="">Applied to u-boot-stm32/next

Thanks
Patrice
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">

Hi Cheick

Unfortunately, this patch is causing U-Boot CI test failed:
see <a class="moz-txt-link-freetext" href="https://source.denx.de/u-boot/custodians/u-boot-stm/-/jobs/1054426">https://source.denx.de/u-boot/custodians/u-boot-stm/-/jobs/1054426</a>

More precisely ut_dm_dm_test_cros_ec_pwm, see test/dm/cros_ec_pwm.c

Either update test/dm/cros_ec_pwm.c or another solution is simply to 
clamp duty_ns to period_ns as following ?

 +      if (duty_ns > period_ns)
 +              duty_ns = period_ns;
 +

Patrice


</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">_______________________________________________
Uboot-stm32 mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Uboot-stm32@st-md-mailman.stormreply.com">Uboot-stm32@st-md-mailman.stormreply.com</a>
<a class="moz-txt-link-freetext" href="https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32">https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32</a>
</pre>
      </blockquote>
    </blockquote>
    <p
style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin: 0px 0px 16px; color: rgb(0, 0, 0); font-family: Open_Sans, system-ui, Helvetica, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgba(255, 255, 255, 0.9); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Hi
      Patrice,</p>
    <p
style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin: 0px 0px 16px; color: rgb(0, 0, 0); font-family: Open_Sans, system-ui, Helvetica, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgba(255, 255, 255, 0.9); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">It
      seems like this patch should finally be reverted.</p>
    <p
style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin: 0px 0px 16px; color: rgb(0, 0, 0); font-family: Open_Sans, system-ui, Helvetica, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgba(255, 255, 255, 0.9); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">When
      the duty cycle exceeds the period, some drivers already clamp the
      value of the duty cycle to the maximum value or do not apply the
      duty cycle.</p>
    <p
style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin: 0px 0px 16px; color: rgb(0, 0, 0); font-family: Open_Sans, system-ui, Helvetica, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgba(255, 255, 255, 0.9); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">So,
      I will check the duty cycle in<span> </span><code
style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: monospace, monospace; font-size: 1em;">drivers/pwm/pwm-stm32.c</code><span> </span>and
      return<span> </span><code
style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: monospace, monospace; font-size: 1em;">-EINVAL</code><span> </span>when
      it exceeds the period.</p>
    <p
style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin: 0px 0px 16px; color: rgb(0, 0, 0); font-family: Open_Sans, system-ui, Helvetica, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgba(255, 255, 255, 0.9); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Thanks,</p>
    <p
style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin: 0px 0px 16px; color: rgb(0, 0, 0); font-family: Open_Sans, system-ui, Helvetica, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgba(255, 255, 255, 0.9); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Cheick<br>
    </p>
    <p></p>
  </body>
</html>