Re: [PATCH v2] staging: iio: trigger: iio-trig-periodic-rtc: Change frequency type to unsigned int

From: Jonathan Cameron
Date: Sat Feb 21 2015 - 13:11:26 EST


On 08/02/15 18:22, Rickard Strandqvist wrote:
> Change struct iio_prtc_trigger_info frequency
> type from int to unsigned int.
> Since it is always treated as such in the driver
> so they type should probably reflect this.
>
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@xxxxxxxxxxxxxxxxxx>
The only argument against this is that the rtc_irq_set_freq function takes
a signed int. Arguably that shouldn't perhaps, but whilst it does we should
probably track it's type to avoid confusion.

Jonathan
> ---
> drivers/staging/iio/trigger/iio-trig-periodic-rtc.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c b/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c
> index a24caf7..89df1d3 100644
> --- a/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c
> +++ b/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c
> @@ -24,7 +24,7 @@ static DEFINE_MUTEX(iio_prtc_trigger_list_lock);
>
> struct iio_prtc_trigger_info {
> struct rtc_device *rtc;
> - int frequency;
> + unsigned int frequency;
> struct rtc_task task;
> bool state;
> };
> @@ -36,7 +36,7 @@ static int iio_trig_periodic_rtc_set_state(struct iio_trigger *trig, bool state)
>
> if (trig_info->frequency == 0 && state)
> return -EINVAL;
> - dev_dbg(&trig_info->rtc->dev, "trigger frequency is %d\n",
> + dev_dbg(&trig_info->rtc->dev, "trigger frequency is %u\n",
> trig_info->frequency);
> ret = rtc_irq_set_state(trig_info->rtc, &trig_info->task, state);
> if (ret == 0)
> @@ -62,10 +62,10 @@ static ssize_t iio_trig_periodic_write_freq(struct device *dev,
> {
> struct iio_trigger *trig = to_iio_trigger(dev);
> struct iio_prtc_trigger_info *trig_info = iio_trigger_get_drvdata(trig);
> - int val;
> + unsigned int val;
> int ret;
>
> - ret = kstrtoint(buf, 10, &val);
> + ret = kstrtouint(buf, 10, &val);
> if (ret)
> goto error_ret;
>
> @@ -74,10 +74,8 @@ static ssize_t iio_trig_periodic_write_freq(struct device *dev,
> 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;
> + ret = rtc_irq_set_state(trig_info->rtc, &trig_info->task, 0);
> if (ret)
> goto error_ret;
>
>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/