From: Jonathan Cameron <jic23@kernel.org>
To: Peter Meerwald <pmeerw@pmeerw.net>, linux-iio@vger.kernel.org
Subject: Re: [PATCH v2 12/12] staging:iio-trig-periodic-rtc: Allow to reset frequency to 0
Date: Sat, 14 Jun 2014 16:12:14 +0100 [thread overview]
Message-ID: <539C664E.3070104@kernel.org> (raw)
In-Reply-To: <1402549229-4449-13-git-send-email-pmeerw@pmeerw.net>
On 12/06/14 06:00, Peter Meerwald wrote:
> periodic rtc trigger initially has frequency 0
>
> it is possible to change trigger frequency on-the-fly, but it is not
> possible to set frequency back to 0
>
> this patch allows to set trigger frequency to 0, thereby disabling
> the rtc interrupt
>
> Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Applied to the togreg branch of iio.git
thanks,
> ---
> drivers/staging/iio/trigger/iio-trig-periodic-rtc.c | 19 ++++++++++++++++---
> 1 file changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c b/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c
> index 362a54a..b5108a1 100644
> --- a/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c
> +++ b/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c
> @@ -26,16 +26,22 @@ struct iio_prtc_trigger_info {
> struct rtc_device *rtc;
> int frequency;
> struct rtc_task task;
> + bool state;
> };
>
> static int iio_trig_periodic_rtc_set_state(struct iio_trigger *trig, bool state)
> {
> struct iio_prtc_trigger_info *trig_info = iio_trigger_get_drvdata(trig);
> - if (trig_info->frequency == 0)
> + int ret;
> + if (trig_info->frequency == 0 && state)
> return -EINVAL;
> dev_dbg(&trig_info->rtc->dev, "trigger frequency is %d\n",
> trig_info->frequency);
> - return rtc_irq_set_state(trig_info->rtc, &trig_info->task, state);
> + ret = rtc_irq_set_state(trig_info->rtc, &trig_info->task, state);
> + if (ret == 0)
> + trig_info->state = state;
> +
> + return ret;
> }
>
> static ssize_t iio_trig_periodic_read_freq(struct device *dev,
> @@ -61,7 +67,14 @@ static ssize_t iio_trig_periodic_write_freq(struct device *dev,
> if (ret)
> goto error_ret;
>
> - ret = rtc_irq_set_freq(trig_info->rtc, &trig_info->task, val);
> + if (val > 0) {
> + ret = rtc_irq_set_freq(trig_info->rtc, &trig_info->task, val);
> + if (ret == 0 && trig_info->state && trig_info->frequency == 0)
> + ret = rtc_irq_set_state(trig_info->rtc, &trig_info->task, 1);
> + } else if (val == 0) {
> + ret = rtc_irq_set_state(trig_info->rtc, &trig_info->task, 0);
> + } else
> + ret = -EINVAL;
> if (ret)
> goto error_ret;
>
>
prev parent reply other threads:[~2014-06-14 15:10 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-12 5:00 [PATCH v2 00/12] misc IIO cleanup Peter Meerwald
2014-06-12 5:00 ` [PATCH v2 01/12] iio:adc:ad5791: Use BIT() and GENMASK() macros Peter Meerwald
2014-06-14 14:46 ` Jonathan Cameron
2014-06-12 5:00 ` [PATCH v2 02/12] iio:adc:ad5504: " Peter Meerwald
2014-06-14 14:49 ` Jonathan Cameron
2014-06-12 5:00 ` [PATCH v2 03/12] iio:adc:ad7887: " Peter Meerwald
2014-06-14 15:03 ` Jonathan Cameron
2014-06-12 5:00 ` [PATCH v2 04/12] iio:adc:ad7476: Use GENMASK() macro Peter Meerwald
2014-06-14 15:04 ` Jonathan Cameron
2014-06-12 5:00 ` [PATCH v2 05/12] iio:adc:ad7298: Use BIT() and GENMASK() macros Peter Meerwald
2014-06-14 15:04 ` Jonathan Cameron
2014-06-12 5:00 ` [PATCH v2 06/12] iio: Move documentation of iio-trig-sysfs to ABI/testing Peter Meerwald
2014-06-14 15:05 ` Jonathan Cameron
2014-06-12 5:00 ` [PATCH v2 07/12] staging:iio: Update iio_event_monitor program Peter Meerwald
2014-06-14 15:08 ` Jonathan Cameron
2014-06-12 5:00 ` [PATCH v2 08/12] staging:iio: Fix iio_utils.h function prototypes Peter Meerwald
2014-06-14 15:08 ` Jonathan Cameron
2014-06-12 5:00 ` [PATCH v2 09/12] staging:iio: Fix mention of INDIO_RING_TRIGGERED to INDIO_BUFFER_TRIGGERED Peter Meerwald
2014-06-14 15:08 ` Jonathan Cameron
2014-06-12 5:00 ` [PATCH v2 10/12] staging:iio: Fix error handling in generic_buffer example Peter Meerwald
2014-06-14 15:09 ` Jonathan Cameron
2014-06-12 5:00 ` [PATCH v2 11/12] staging:iio-trig-periodic-rtc: Cleanup Peter Meerwald
2014-06-14 15:11 ` Jonathan Cameron
2014-06-12 5:00 ` [PATCH v2 12/12] staging:iio-trig-periodic-rtc: Allow to reset frequency to 0 Peter Meerwald
2014-06-14 15:12 ` Jonathan Cameron [this message]
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=539C664E.3070104@kernel.org \
--to=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
/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).