From: Kurt Van Dijck <kurt.van.dijck@eia.be>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: linux-kernel@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
Ryan Mallon <ryan@bluewatersys.com>,
Shawn Guo <shawn.guo@linaro.org>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 1/2] PWM: add pwm framework support
Date: Tue, 28 Jun 2011 13:14:10 +0200 [thread overview]
Message-ID: <20110628111410.GB19308@e-circ.dyndns.org> (raw)
In-Reply-To: <1309255368-9775-2-git-send-email-s.hauer@pengutronix.de>
On Tue, Jun 28, 2011 at 12:02:47PM +0200, Sascha Hauer wrote:
> This patch adds framework support for PWM (pulse width modulation) devices.
>
> The is a barebone PWM API already in the kernel under include/linux/pwm.h,
The ?? is ...
> +
[...]
> +Locking
> +-------
> +
> +The PWM core list manipulations are protected by a mutex, so pwm_request()
> +and pwm_free() may not be called from an atomic context. Currently the
> +PWM core does not enforce any locking to pwm_enable(), pwm_disable() and
> +pwm_config(), so the calling context is currently driver specific. This
> +is an issue derived from the former barebone API and should be fixed soon.
[...]
> +
> +struct pwm_device {
> + struct pwm_chip *chip;
> + const char *label;
> + int enabled;
.enabled is never used, in favor of FLAG_ENABLED
> + unsigned long flags;
> +#define FLAG_REQUESTED 0
> +#define FLAG_ENABLED 1
> + struct list_head node;
> +};
> +
[...]
> +
> +static struct pwm_device *find_pwm(int pwm_id)
s/find_pwm/_find_pwm/ to indicate it needs pwm_lock?
> +/**
> + * pwmchip_add() - register a new pwm
> + * @chip: the pwm
> + *
> + * register a new pwm. pwm->pwm_id must be initialized. if pwm_id < 0 then
> + * a dynamically assigned id will be used, otherwise the id specified,
> + */
> +int pwmchip_add(struct pwm_chip *chip)
> +{
> + struct pwm_device *pwm;
> + int ret = 0;
> +
> + pwm = kzalloc(sizeof(*pwm), GFP_KERNEL);
> + if (!pwm)
> + return -ENOMEM;
> +
> + pwm->chip = chip;
> +
> + mutex_lock(&pwm_lock);
> +
> + if (chip->pwm_id >= 0 && find_pwm(chip->pwm_id)) {
> + ret = -EBUSY;
> + goto out;
> + }
> +
> + if (chip->pwm_id < 0)
> + chip->pwm_id = next_pwm_id++;
> +
> + list_add_tail(&pwm->node, &pwm_list);
> +out:
> + mutex_unlock(&pwm_lock);
> +
+ if (ret) ??
> + kfree(pwm);
> +
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(pwmchip_add);
> +
Kind regards,
Kurt
next prev parent reply other threads:[~2011-06-28 11:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-28 10:02 [RFC] implement a generic PWM framework - once again Sascha Hauer
2011-06-28 10:02 ` [PATCH 1/2] PWM: add pwm framework support Sascha Hauer
2011-06-28 11:14 ` Kurt Van Dijck [this message]
2011-06-28 12:27 ` Arnd Bergmann
2011-06-28 16:18 ` Sascha Hauer
2011-06-28 17:03 ` Arnd Bergmann
2011-06-29 8:50 ` Sascha Hauer
2011-06-29 11:00 ` Arnd Bergmann
2011-06-28 19:40 ` Matthias Kaehlcke
2011-06-28 10:02 ` [PATCH 2/2] pwm: Add a i.MX23/28 pwm driver Sascha Hauer
2011-06-28 10:28 ` Lothar Waßmann
2011-06-28 15:22 ` Arnd Bergmann
2011-06-29 9:03 [PATCH v2] implement a generic PWM framework Sascha Hauer
2011-06-29 9:03 ` [PATCH 1/2] PWM: add pwm framework support Sascha Hauer
2011-06-29 11:38 ` Kurt Van Dijck
2011-06-29 11:41 ` Arnd Bergmann
2011-06-29 19:47 ` Matthias Kaehlcke
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=20110628111410.GB19308@e-circ.dyndns.org \
--to=kurt.van.dijck@eia.be \
--cc=arnd@arndb.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ryan@bluewatersys.com \
--cc=s.hauer@pengutronix.de \
--cc=shawn.guo@linaro.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
all inboxes | Powered by JetHome®