devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Mathieu Dubois-Briand" <mathieu.dubois-briand@bootlin.com>
To: "Uwe Kleine-König" <ukleinek@kernel.org>
Cc: "Lee Jones" <lee@kernel.org>, "Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Kamel Bouhara" <kamel.bouhara@bootlin.com>,
	"Linus Walleij" <linus.walleij@linaro.org>,
	"Bartosz Golaszewski" <brgl@bgdev.pl>,
	"Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-gpio@vger.kernel.org, linux-input@vger.kernel.org,
	linux-pwm@vger.kernel.org,
	"Grégory Clement" <gregory.clement@bootlin.com>,
	"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>
Subject: Re: [PATCH v3 3/7] pwm: max7360: Add MAX7360 PWM support
Date: Fri, 17 Jan 2025 16:47:45 +0100	[thread overview]
Message-ID: <D74GSFVY17UV.GMN119MAVAK0@bootlin.com> (raw)
In-Reply-To: <v4bf6bharih6zgz52ya5twfyf47wh3fu56ovic5gjxak2jhufy@q3eudujjwrhm>

On Fri Jan 17, 2025 at 3:40 PM CET, Uwe Kleine-König wrote:
> On Fri, Jan 17, 2025 at 03:11:29PM +0100, Mathieu Dubois-Briand wrote:
> > On Fri Jan 17, 2025 at 10:33 AM CET, Uwe Kleine-König wrote:
> > > Hello Mathieu,
> > >
> > > On Mon, Jan 13, 2025 at 01:42:27PM +0100, mathieu.dubois-briand@bootlin.com wrote:
> > > > From: Kamel Bouhara <kamel.bouhara@bootlin.com>
> > ...
> > > > +static int max7360_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
> > > > +			     const struct pwm_state *state)
> > > > +{
> > > > +	struct max7360_pwm *max7360_pwm;
> > > > +	u64 duty_steps;
> > > > +	int ret;
> > > > +
> > > > +	if (state->polarity != PWM_POLARITY_NORMAL)
> > > > +		return -EINVAL;
> > > > +
> > > > +	if (state->period != MAX7360_PWM_PERIOD_NS) {
> > > > +		dev_warn(&chip->dev,
> > > > +			 "unsupported pwm period: %llu, should be %u\n",
> > > > +			 state->period, MAX7360_PWM_PERIOD_NS);
> > > > +		return -EINVAL;
> > >
> > > Please don't emit error messages in .apply(). Also a driver is supposed
> > > to round down .period, so any value >= MAX7360_PWM_PERIOD_NS should be
> > > accepted.
> > >
> > > Also note that you might want to implement the waveform callbacks
> > > instead of .apply() and .get_state() for the more modern abstraction
> > > (with slightly different rounding rules).
> > >
> > 
> > Sure, I just switched to the waveform callbacks, it was quite
> > straightforward.
>
> sounds great. Note that the detail in rounding that is different for
> waveforms is that a value that cannot be round down to a valid value
> (because it's too small) is round up. This is a bit ugly in the drivers
> but simplifies usage considerably. So you never return -EINVAL because
> the values don't fit.
>

Sorry, I'm not sure I got it right. Does this affect the three members
of pwm_waveform (period_length_ns, duty_offset_ns, duty_length_ns) ? So
on this device where the period is fixed and I cannot define an offset,
does that mean I will silently accept any value for period_length_ns and
duty_offset_ns ?

Best regards,
Mathieu

-- 
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


  reply	other threads:[~2025-01-17 15:47 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-13 12:42 [PATCH v3 0/7] Add support for MAX7360 Mathieu Dubois-Briand
2025-01-13 12:42 ` [PATCH v3 1/7] dt-bindings: mfd: gpio: Add MAX7360 Mathieu Dubois-Briand
2025-01-14  8:11   ` Krzysztof Kozlowski
2025-01-14 13:02     ` Mathieu Dubois-Briand
2025-01-13 12:42 ` [PATCH v3 2/7] mfd: Add max7360 support mathieu.dubois-briand
2025-01-15 15:42   ` Lee Jones
2025-01-17 10:38     ` Mathieu Dubois-Briand
2025-01-13 12:42 ` [PATCH v3 3/7] pwm: max7360: Add MAX7360 PWM support mathieu.dubois-briand
2025-01-17  9:33   ` Uwe Kleine-König
2025-01-17 14:11     ` Mathieu Dubois-Briand
2025-01-17 14:40       ` Uwe Kleine-König
2025-01-17 15:47         ` Mathieu Dubois-Briand [this message]
2025-01-20 14:13           ` Uwe Kleine-König
2025-01-22 12:37             ` Mathieu Dubois-Briand
2025-01-13 12:42 ` [PATCH v3 4/7] gpio: max7360: Add MAX7360 gpio support Mathieu Dubois-Briand
2025-01-14 14:33   ` Linus Walleij
2025-01-14 17:57     ` Mathieu Dubois-Briand
2025-01-17 15:22     ` Mathieu Dubois-Briand
2025-01-22 13:18       ` Linus Walleij
2025-01-27 12:52       ` Andy Shevchenko
2025-01-27 13:07   ` Andy Shevchenko
2025-02-12 12:57     ` Mathieu Dubois-Briand
2025-02-12 15:14       ` Andy Shevchenko
2025-02-12 16:08         ` Mathieu Dubois-Briand
2025-02-12 16:17           ` Andy Shevchenko
2025-02-13 10:59             ` Mathieu Dubois-Briand
2025-02-13 13:45               ` Mathieu Dubois-Briand
2025-02-13 19:47                 ` Andy Shevchenko
2025-02-14  8:42                   ` Mathieu Dubois-Briand
2025-01-13 12:42 ` [PATCH v3 5/7] input: keyboard: Add support for MAX7360 keypad Mathieu Dubois-Briand
2025-01-13 12:42 ` [PATCH v3 6/7] input: misc: Add support for MAX7360 rotary Mathieu Dubois-Briand
2025-01-14 13:16   ` Mathieu Dubois-Briand
2025-01-13 12:42 ` [PATCH v3 7/7] MAINTAINERS: Add entry on MAX7360 driver Mathieu Dubois-Briand

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=D74GSFVY17UV.GMN119MAVAK0@bootlin.com \
    --to=mathieu.dubois-briand@bootlin.com \
    --cc=brgl@bgdev.pl \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=gregory.clement@bootlin.com \
    --cc=kamel.bouhara@bootlin.com \
    --cc=krzk+dt@kernel.org \
    --cc=lee@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=ukleinek@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;
as well as URLs for NNTP newsgroup(s).