From: peter.ujfalusi@ti.com (Peter Ujfalusi)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 1/3] pwm: Add pwm_cansleep() as exported API to users
Date: Fri, 25 Jan 2013 14:51:54 +0100 [thread overview]
Message-ID: <51028DFA.1060305@ti.com> (raw)
In-Reply-To: <1359121471-21457-2-git-send-email-florian.vaussard@epfl.ch>
On 01/25/2013 02:44 PM, Florian Vaussard wrote:
> Calls to some external PWM chips can sleep. To help users,
> add pwm_cansleep() API.
>
> Signed-off-by: Florian Vaussard <florian.vaussard@epfl.ch>
Reviewed-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
> ---
> drivers/pwm/core.c | 12 ++++++++++++
> include/linux/pwm.h | 10 ++++++++++
> 2 files changed, 22 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
> index 4a13da4..e737f5f 100644
> --- a/drivers/pwm/core.c
> +++ b/drivers/pwm/core.c
> @@ -763,6 +763,18 @@ void devm_pwm_put(struct device *dev, struct pwm_device *pwm)
> }
> EXPORT_SYMBOL_GPL(devm_pwm_put);
>
> +/**
> + * pwm_cansleep() - report whether pwm access will sleep
> + * @pwm: PWM device
> + *
> + * It returns nonzero if accessing the PWM can sleep.
> + */
> +int pwm_cansleep(struct pwm_device *pwm)
> +{
> + return pwm->chip->can_sleep;
> +}
> +EXPORT_SYMBOL_GPL(pwm_cansleep);
> +
> #ifdef CONFIG_DEBUG_FS
> static void pwm_dbg_show(struct pwm_chip *chip, struct seq_file *s)
> {
> diff --git a/include/linux/pwm.h b/include/linux/pwm.h
> index 70655a2..e2cb5c7 100644
> --- a/include/linux/pwm.h
> +++ b/include/linux/pwm.h
> @@ -146,6 +146,8 @@ struct pwm_ops {
> * @base: number of first PWM controlled by this chip
> * @npwm: number of PWMs controlled by this chip
> * @pwms: array of PWM devices allocated by the framework
> + * @can_sleep: flag must be set iff config()/enable()/disable() methods sleep,
> + * as they must while accessing PWM chips over I2C or SPI
> */
> struct pwm_chip {
> struct device *dev;
> @@ -159,6 +161,7 @@ struct pwm_chip {
> struct pwm_device * (*of_xlate)(struct pwm_chip *pc,
> const struct of_phandle_args *args);
> unsigned int of_pwm_n_cells;
> + unsigned int can_sleep:1;
> };
>
> #if IS_ENABLED(CONFIG_PWM)
> @@ -182,6 +185,8 @@ struct pwm_device *devm_pwm_get(struct device *dev, const char *con_id);
> struct pwm_device *devm_of_pwm_get(struct device *dev, struct device_node *np,
> const char *con_id);
> void devm_pwm_put(struct device *dev, struct pwm_device *pwm);
> +
> +int pwm_cansleep(struct pwm_device *pwm);
> #else
> static inline int pwm_set_chip_data(struct pwm_device *pwm, void *data)
> {
> @@ -242,6 +247,11 @@ static inline struct pwm_device *devm_of_pwm_get(struct device *dev,
> static inline void devm_pwm_put(struct device *dev, struct pwm_device *pwm)
> {
> }
> +
> +static inline int pwm_cansleep(struct pwm_device *pwm)
> +{
> + return 0;
> +}
> #endif
>
> struct pwm_lookup {
>
--
P?ter
WARNING: multiple messages have this Message-ID (diff)
From: Peter Ujfalusi <peter.ujfalusi@ti.com>
To: Florian Vaussard <florian.vaussard@epfl.ch>
Cc: Bryan Wu <cooloney@gmail.com>, Richard Purdie <rpurdie@rpsys.net>,
Thierry Reding <thierry.reding@avionic-design.de>,
<linux-leds@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 1/3] pwm: Add pwm_cansleep() as exported API to users
Date: Fri, 25 Jan 2013 14:51:54 +0100 [thread overview]
Message-ID: <51028DFA.1060305@ti.com> (raw)
In-Reply-To: <1359121471-21457-2-git-send-email-florian.vaussard@epfl.ch>
On 01/25/2013 02:44 PM, Florian Vaussard wrote:
> Calls to some external PWM chips can sleep. To help users,
> add pwm_cansleep() API.
>
> Signed-off-by: Florian Vaussard <florian.vaussard@epfl.ch>
Reviewed-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
> ---
> drivers/pwm/core.c | 12 ++++++++++++
> include/linux/pwm.h | 10 ++++++++++
> 2 files changed, 22 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
> index 4a13da4..e737f5f 100644
> --- a/drivers/pwm/core.c
> +++ b/drivers/pwm/core.c
> @@ -763,6 +763,18 @@ void devm_pwm_put(struct device *dev, struct pwm_device *pwm)
> }
> EXPORT_SYMBOL_GPL(devm_pwm_put);
>
> +/**
> + * pwm_cansleep() - report whether pwm access will sleep
> + * @pwm: PWM device
> + *
> + * It returns nonzero if accessing the PWM can sleep.
> + */
> +int pwm_cansleep(struct pwm_device *pwm)
> +{
> + return pwm->chip->can_sleep;
> +}
> +EXPORT_SYMBOL_GPL(pwm_cansleep);
> +
> #ifdef CONFIG_DEBUG_FS
> static void pwm_dbg_show(struct pwm_chip *chip, struct seq_file *s)
> {
> diff --git a/include/linux/pwm.h b/include/linux/pwm.h
> index 70655a2..e2cb5c7 100644
> --- a/include/linux/pwm.h
> +++ b/include/linux/pwm.h
> @@ -146,6 +146,8 @@ struct pwm_ops {
> * @base: number of first PWM controlled by this chip
> * @npwm: number of PWMs controlled by this chip
> * @pwms: array of PWM devices allocated by the framework
> + * @can_sleep: flag must be set iff config()/enable()/disable() methods sleep,
> + * as they must while accessing PWM chips over I2C or SPI
> */
> struct pwm_chip {
> struct device *dev;
> @@ -159,6 +161,7 @@ struct pwm_chip {
> struct pwm_device * (*of_xlate)(struct pwm_chip *pc,
> const struct of_phandle_args *args);
> unsigned int of_pwm_n_cells;
> + unsigned int can_sleep:1;
> };
>
> #if IS_ENABLED(CONFIG_PWM)
> @@ -182,6 +185,8 @@ struct pwm_device *devm_pwm_get(struct device *dev, const char *con_id);
> struct pwm_device *devm_of_pwm_get(struct device *dev, struct device_node *np,
> const char *con_id);
> void devm_pwm_put(struct device *dev, struct pwm_device *pwm);
> +
> +int pwm_cansleep(struct pwm_device *pwm);
> #else
> static inline int pwm_set_chip_data(struct pwm_device *pwm, void *data)
> {
> @@ -242,6 +247,11 @@ static inline struct pwm_device *devm_of_pwm_get(struct device *dev,
> static inline void devm_pwm_put(struct device *dev, struct pwm_device *pwm)
> {
> }
> +
> +static inline int pwm_cansleep(struct pwm_device *pwm)
> +{
> + return 0;
> +}
> #endif
>
> struct pwm_lookup {
>
--
Péter
next prev parent reply other threads:[~2013-01-25 13:51 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-25 13:44 [PATCH v2 0/3] leds-pwm: Defer PWM calls if PWM can sleep Florian Vaussard
2013-01-25 13:44 ` Florian Vaussard
2013-01-25 13:44 ` [PATCH v2 1/3] pwm: Add pwm_cansleep() as exported API to users Florian Vaussard
2013-01-25 13:44 ` Florian Vaussard
2013-01-25 13:51 ` Peter Ujfalusi [this message]
2013-01-25 13:51 ` Peter Ujfalusi
2013-01-26 5:40 ` Thierry Reding
2013-01-26 5:40 ` Thierry Reding
2013-01-28 8:45 ` Peter Ujfalusi
2013-01-28 8:45 ` Peter Ujfalusi
2013-01-28 9:36 ` Florian Vaussard
2013-01-28 9:36 ` Florian Vaussard
2013-01-28 9:57 ` Thierry Reding
2013-01-28 9:57 ` Thierry Reding
2013-01-28 10:57 ` Florian Vaussard
2013-01-28 10:57 ` Florian Vaussard
2013-01-28 13:16 ` Thierry Reding
2013-01-28 13:16 ` Thierry Reding
2013-01-28 15:01 ` Russell King - ARM Linux
2013-01-28 15:01 ` Russell King - ARM Linux
2013-01-28 15:46 ` Florian Vaussard
2013-01-28 15:46 ` Florian Vaussard
2013-01-25 13:44 ` [PATCH v2 2/3] pwm: Add can_sleep property to drivers Florian Vaussard
2013-01-25 13:44 ` Florian Vaussard
2013-01-25 13:51 ` Peter Ujfalusi
2013-01-25 13:51 ` Peter Ujfalusi
2013-01-25 13:44 ` [PATCH v2 3/3] leds: leds-pwm: Defer led_pwm_set() if PWM can sleep Florian Vaussard
2013-01-25 13:44 ` Florian Vaussard
2013-01-25 13:52 ` Peter Ujfalusi
2013-01-25 13:52 ` Peter Ujfalusi
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=51028DFA.1060305@ti.com \
--to=peter.ujfalusi@ti.com \
--cc=linux-arm-kernel@lists.infradead.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 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.