From: Thierry Reding <thierry.reding@gmail.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: linux-pwm@vger.kernel.org, kernel@pengutronix.de,
Steven Rostedt <rostedt@goodmis.org>,
Ingo Molnar <mingo@redhat.com>, Pavel Machek <pavel@ucw.cz>,
Douglas Anderson <dianders@chromium.org>,
Andrzej Hajda <andrzej.hajda@intel.com>,
Neil Armstrong <narmstrong@baylibre.com>,
Robert Foss <robert.foss@linaro.org>,
Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
Jonas Karlman <jonas@kwiboo.se>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <brgl@bgdev.pl>,
linux-leds@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-gpio@vger.kernel.org
Subject: Re: [PATCH 3/3] pwm: Handle .get_state() failures
Date: Wed, 28 Sep 2022 14:55:49 +0200 [thread overview]
Message-ID: <YzREVarafbsRUl4t@orome> (raw)
In-Reply-To: <20220916151506.298488-3-u.kleine-koenig@pengutronix.de>
[-- Attachment #1: Type: text/plain, Size: 1392 bytes --]
On Fri, Sep 16, 2022 at 05:15:06PM +0200, Uwe Kleine-König wrote:
> This suppresses diagnosis for PWM_DEBUG routines and makes sure that
> pwm->state isn't modified in pwm_device_request() if .get_state() fails.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
> drivers/pwm/core.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
> index 381db04cfa00..421573590613 100644
> --- a/drivers/pwm/core.c
> +++ b/drivers/pwm/core.c
> @@ -108,9 +108,14 @@ static int pwm_device_request(struct pwm_device *pwm, const char *label)
> }
>
> if (pwm->chip->ops->get_state) {
> - err = pwm->chip->ops->get_state(pwm->chip, pwm, &pwm->state);
> + struct pwm_state state;
> +
> + err = pwm->chip->ops->get_state(pwm->chip, pwm, &state);
> trace_pwm_get(pwm, &pwm->state, err);
>
> + if (!err)
> + pwm->state = state;
So basically this means that callers of pwm_get_state() will get the
zeroed out pwm->state. This can cause issues with the likes of
pwm_set_relative_duty_cycle() which many drivers would use. Do we
perhaps want to set an internal error in this case so that it can be
propagated to callers in pwm_get_state()? That would allow them to fall
back to some default configuration rather than potentially breaking
altogether.
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: Thierry Reding <thierry.reding@gmail.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: dri-devel@lists.freedesktop.org, linux-pwm@vger.kernel.org,
Jernej Skrabec <jernej.skrabec@gmail.com>,
kernel@pengutronix.de, Neil Armstrong <narmstrong@baylibre.com>,
Jonas Karlman <jonas@kwiboo.se>,
Douglas Anderson <dianders@chromium.org>,
Steven Rostedt <rostedt@goodmis.org>,
linux-gpio@vger.kernel.org,
Andrzej Hajda <andrzej.hajda@intel.com>,
Ingo Molnar <mingo@redhat.com>,
Robert Foss <robert.foss@linaro.org>, Pavel Machek <pavel@ucw.cz>,
Bartosz Golaszewski <brgl@bgdev.pl>,
linux-leds@vger.kernel.org,
Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
Subject: Re: [PATCH 3/3] pwm: Handle .get_state() failures
Date: Wed, 28 Sep 2022 14:55:49 +0200 [thread overview]
Message-ID: <YzREVarafbsRUl4t@orome> (raw)
In-Reply-To: <20220916151506.298488-3-u.kleine-koenig@pengutronix.de>
[-- Attachment #1: Type: text/plain, Size: 1392 bytes --]
On Fri, Sep 16, 2022 at 05:15:06PM +0200, Uwe Kleine-König wrote:
> This suppresses diagnosis for PWM_DEBUG routines and makes sure that
> pwm->state isn't modified in pwm_device_request() if .get_state() fails.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
> drivers/pwm/core.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
> index 381db04cfa00..421573590613 100644
> --- a/drivers/pwm/core.c
> +++ b/drivers/pwm/core.c
> @@ -108,9 +108,14 @@ static int pwm_device_request(struct pwm_device *pwm, const char *label)
> }
>
> if (pwm->chip->ops->get_state) {
> - err = pwm->chip->ops->get_state(pwm->chip, pwm, &pwm->state);
> + struct pwm_state state;
> +
> + err = pwm->chip->ops->get_state(pwm->chip, pwm, &state);
> trace_pwm_get(pwm, &pwm->state, err);
>
> + if (!err)
> + pwm->state = state;
So basically this means that callers of pwm_get_state() will get the
zeroed out pwm->state. This can cause issues with the likes of
pwm_set_relative_duty_cycle() which many drivers would use. Do we
perhaps want to set an internal error in this case so that it can be
propagated to callers in pwm_get_state()? That would allow them to fall
back to some default configuration rather than potentially breaking
altogether.
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2022-09-28 12:56 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-16 15:15 [PATCH 1/3] pwm: Change prototype of .get_state() callback to return an error Uwe Kleine-König
2022-09-16 15:15 ` Uwe Kleine-König
2022-09-16 15:15 ` [PATCH 2/3] pwm/tracing: Also record trace events for failed apply calls Uwe Kleine-König
2022-09-16 15:15 ` Uwe Kleine-König
2022-09-28 12:50 ` Thierry Reding
2022-09-28 12:50 ` Thierry Reding
2022-09-16 15:15 ` [PATCH 3/3] pwm: Handle .get_state() failures Uwe Kleine-König
2022-09-16 15:15 ` Uwe Kleine-König
2022-09-28 12:55 ` Thierry Reding [this message]
2022-09-28 12:55 ` Thierry Reding
2022-09-28 12:49 ` [PATCH 1/3] pwm: Change prototype of .get_state() callback to return an error Thierry Reding
2022-09-28 12:49 ` Thierry Reding
2022-09-29 6:55 ` Uwe Kleine-König
2022-09-29 6:55 ` Uwe Kleine-König
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=YzREVarafbsRUl4t@orome \
--to=thierry.reding@gmail.com \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=andrzej.hajda@intel.com \
--cc=brgl@bgdev.pl \
--cc=dianders@chromium.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=kernel@pengutronix.de \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=narmstrong@baylibre.com \
--cc=pavel@ucw.cz \
--cc=robert.foss@linaro.org \
--cc=rostedt@goodmis.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.