linux-pwm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Young <sean@mess.org>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: linux-media@vger.kernel.org, linux-pwm@vger.kernel.org,
	"Ivaylo Dimitrov" <ivo.g.dimitrov.75@gmail.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Jonathan Corbet" <corbet@lwn.net>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 2/4] pwm: make it possible to apply pwm changes in atomic context
Date: Sat, 9 Dec 2023 09:49:51 +0000	[thread overview]
Message-ID: <ZXQ4P39_sq10XD9u@gofer.mess.org> (raw)
In-Reply-To: <ZXNCKFZcjFznko89@orome.fritz.box>

Hi Thierry,


On Fri, Dec 08, 2023 at 05:19:52PM +0100, Thierry Reding wrote:
> On Wed, Nov 29, 2023 at 09:13:35AM +0000, Sean Young wrote:
> > Some pwm devices require sleeping, for example if the pwm device is
> > connected over i2c. However, many pwm devices could be used from atomic
> > context, e.g. memmory mapped pwm. This is useful for, for example, the
> > pwm-ir-tx driver which requires precise timing. Sleeping causes havoc
> > with the generated IR signal.
> > 
> > Since not all pmw devices can support atomic context, we also add a
> > pwm_is_atomic() function to check if it is supported.
> 
> s/i2c/I2C/ and s/pwm/PWM/ in the above. Also, s/memmory/memory/

Thanks for your detailed review. I agree with all your points, they are
all nice improvements. Just a question at the bottom:

> 
> > 
> > Signed-off-by: Sean Young <sean@mess.org>
> > ---
> >  Documentation/driver-api/pwm.rst |  9 +++++
> >  drivers/pwm/core.c               | 63 ++++++++++++++++++++++++++------
> >  drivers/pwm/pwm-renesas-tpu.c    |  1 -
> >  include/linux/pwm.h              | 29 ++++++++++++++-
> >  4 files changed, 87 insertions(+), 15 deletions(-)
> > 
> > diff --git a/Documentation/driver-api/pwm.rst b/Documentation/driver-api/pwm.rst
> > index f1d8197c8c43..1d4536fdf47c 100644
> > --- a/Documentation/driver-api/pwm.rst
> > +++ b/Documentation/driver-api/pwm.rst
> > @@ -43,6 +43,15 @@ After being requested, a PWM has to be configured using::
> >  
> >  	int pwm_apply_might_sleep(struct pwm_device *pwm, struct pwm_state *state);
> >  
> > +Some PWM devices can be used from atomic context. You can check if this is
> > +supported with::
> > +
> > +        bool pwm_is_atomic(struct pwm_device *pwm);
> 
> This is now going to look a bit odd. I think it'd be best to change this
> to pwm_might_sleep() for consistency with the pwm_apply_might_sleep()
> function. Fine to keep the actual member variable as atomic, though, so
> we don't have to change the default for all drivers.

Agreed, I was struggling with finding good name and yours is much better,
thanks.

 > +{
> > +	return pwm->chip->atomic;
> > +}
> > +
> >  /* PWM provider APIs */
> >  int pwm_capture(struct pwm_device *pwm, struct pwm_capture *result,
> >  		unsigned long timeout);
> > @@ -406,16 +420,27 @@ struct pwm_device *devm_fwnode_pwm_get(struct device *dev,
> >  				       struct fwnode_handle *fwnode,
> >  				       const char *con_id);
> >  #else
> > +static inline bool pwm_is_atomic(struct pwm_device *pwm)
> > +{
> > +	return false;
> > +}
> > +
> >  static inline int pwm_apply_might_sleep(struct pwm_device *pwm,
> >  					const struct pwm_state *state)
> >  {
> >  	might_sleep();
> > -	return -ENOTSUPP;
> > +	return -EOPNOTSUPP;
> > +}
> > +
> > +static inline int pwm_apply_atomic(struct pwm_device *pwm,
> > +				   const struct pwm_state *state)
> > +{
> > +	return -EOPNOTSUPP;
> >  }
> >  
> >  static inline int pwm_adjust_config(struct pwm_device *pwm)
> >  {
> > -	return -ENOTSUPP;
> > +	return -EOPNOTSUPP;
> >  }
> 
> What's wrong with ENOTSUPP?

This was found by checkpatch, see

https://github.com/torvalds/linux/blob/master/scripts/checkpatch.pl#L4891-L4892

# ENOTSUPP is not a standard error code and should be avoided in new patches.
# Folks usually mean EOPNOTSUPP (also called ENOTSUP), when they type ENOTSUPP.

ENOTSUPP is not really widely used in the tree.

So it was really done to keep checkpatch happy, please let me know what you
would like me to do here.

Thanks,

Sean

  reply	other threads:[~2023-12-09  9:49 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-29  9:13 [PATCH v6 0/4] Improve pwm-ir-tx precision Sean Young
2023-11-29  9:13 ` [PATCH v6 1/4] pwm: rename pwm_apply_state() to pwm_apply_might_sleep() Sean Young
2023-12-09 13:57   ` Uwe Kleine-König
2023-12-11  8:30     ` Sean Young
2023-12-10  3:59   ` Dmitry Torokhov
2023-11-29  9:13 ` [PATCH v6 2/4] pwm: make it possible to apply pwm changes in atomic context Sean Young
2023-12-08 16:19   ` Thierry Reding
2023-12-09  9:49     ` Sean Young [this message]
2023-11-29  9:13 ` [PATCH v6 3/4] pwm: bcm2835: allow pwm driver to be used " Sean Young
2023-11-29 17:47   ` Florian Fainelli
2023-12-08 16:22   ` Thierry Reding
2023-12-08 17:01     ` Sean Young
2023-12-08 17:20       ` Uwe Kleine-König
2023-12-09  9:11         ` Sean Young
2023-12-11 14:17         ` Thierry Reding
2023-11-29  9:13 ` [PATCH v6 4/4] media: pwm-ir-tx: trigger edges from hrtimer interrupt context Sean Young
2023-12-08 16:29   ` Thierry Reding
2023-12-09  9:52     ` Sean Young

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=ZXQ4P39_sq10XD9u@gofer.mess.org \
    --to=sean@mess.org \
    --cc=corbet@lwn.net \
    --cc=ivo.g.dimitrov.75@gmail.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /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).