From: Jonathan Cameron <jic23@kernel.org>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: Jonathan Cameron <jic23@cam.ac.uk>,
linux-iio@vger.kernel.org, drivers@analog.com
Subject: Re: [PATCH 2/4] staging:iio:trigger:bfintmr: Only enable timer when necessary
Date: Mon, 17 Sep 2012 22:11:51 +0100 [thread overview]
Message-ID: <50579217.9060307@kernel.org> (raw)
In-Reply-To: <1347884808-26833-2-git-send-email-lars@metafoo.de>
On 09/17/2012 01:26 PM, Lars-Peter Clausen wrote:
> This patch hooks up the set_trigger_state callback for the blackfin timer
> trigger driver and only enables the timer when a trigger consumer requests it to
> be enabled. There really is no reason to keep the timer running and generate
> interrupts if nobody is listening to them.
I'll take your word for this one ;)
merged to togreg branch of iio.git
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> ---
> drivers/staging/iio/trigger/iio-trig-bfin-timer.c | 27 ++++++++++++++++++---
> 1 file changed, 24 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c
> index 2772ea2..d9d3dc9 100644
> --- a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c
> +++ b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c
> @@ -57,12 +57,28 @@ struct bfin_tmr_state {
> int irq;
> };
>
> +static int iio_bfin_tmr_set_state(struct iio_trigger *trig, bool state)
> +{
> + struct bfin_tmr_state *st = trig->private_data;
> +
> + if (get_gptimer_period(st->t->id) == 0)
> + return -EINVAL;
> +
> + if (state)
> + enable_gptimers(st->t->bit);
> + else
> + disable_gptimers(st->t->bit);
> +
> + return 0;
> +}
> +
> static ssize_t iio_bfin_tmr_frequency_store(struct device *dev,
> struct device_attribute *attr, const char *buf, size_t count)
> {
> struct iio_trigger *trig = to_iio_trigger(dev);
> struct bfin_tmr_state *st = trig->private_data;
> long val;
> + bool enabled;
> int ret;
>
> ret = strict_strtoul(buf, 10, &val);
> @@ -74,7 +90,10 @@ static ssize_t iio_bfin_tmr_frequency_store(struct device *dev,
> goto error_ret;
> }
>
> - disable_gptimers(st->t->bit);
> + enabled = get_enabled_gptimers() & st->t->bit;
> +
> + if (enabled)
> + disable_gptimers(st->t->bit);
>
> if (!val)
> goto error_ret;
> @@ -87,7 +106,9 @@ static ssize_t iio_bfin_tmr_frequency_store(struct device *dev,
>
> set_gptimer_period(st->t->id, val);
> set_gptimer_pwidth(st->t->id, 1);
> - enable_gptimers(st->t->bit);
> +
> + if (enabled)
> + enable_gptimers(st->t->bit);
>
> error_ret:
> return ret ? ret : count;
> @@ -127,7 +148,6 @@ static const struct attribute_group *iio_bfin_tmr_trigger_attr_groups[] = {
> NULL
> };
>
> -
> static irqreturn_t iio_bfin_tmr_trigger_isr(int irq, void *devid)
> {
> struct bfin_tmr_state *st = devid;
> @@ -151,6 +171,7 @@ static int iio_bfin_tmr_get_number(int irq)
>
> static const struct iio_trigger_ops iio_bfin_tmr_trigger_ops = {
> .owner = THIS_MODULE,
> + .set_trigger_state = iio_bfin_tmr_set_state,
> };
>
> static int __devinit iio_bfin_tmr_trigger_probe(struct platform_device *pdev)
>
next prev parent reply other threads:[~2012-09-17 21:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-17 12:26 [PATCH 1/4] staging:iio:trigger:bfintmr: Avoid divide by zero Lars-Peter Clausen
2012-09-17 12:26 ` [PATCH 2/4] staging:iio:trigger:bfintmr: Only enable timer when necessary Lars-Peter Clausen
2012-09-17 21:11 ` Jonathan Cameron [this message]
2012-09-17 12:26 ` [PATCH 3/4] staging:iio:trigger:bfintmr Add output support Lars-Peter Clausen
2012-09-17 21:09 ` Jonathan Cameron
2012-09-17 12:26 ` [PATCH 4/4] iio: ad7476: Add support for the ad7091r Lars-Peter Clausen
2012-09-17 21:14 ` Jonathan Cameron
2012-09-18 7:58 ` Lars-Peter Clausen
2012-09-17 21:11 ` [PATCH 1/4] staging:iio:trigger:bfintmr: Avoid divide by zero Jonathan Cameron
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=50579217.9060307@kernel.org \
--to=jic23@kernel.org \
--cc=drivers@analog.com \
--cc=jic23@cam.ac.uk \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.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 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.