All of lore.kernel.org
 help / color / mirror / Atom feed
From: Naveen Krishna Ch <naveenkrishna.ch@gmail.com>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: Naveen Krishna Chatradhi <ch.naveen@samsung.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	"linux-samsung-soc@vger.kernel.org" 
	<linux-samsung-soc@vger.kernel.org>,
	dianders@chromium.org, gregkh@linuxfoundation.org,
	tomasz.figa@gmail.com
Subject: Re: [PATCH v3] iio: exynos_adc: use wait_for_completion_timeout instead of interruptible
Date: Sat, 12 Oct 2013 12:10:40 +0530	[thread overview]
Message-ID: <CAHfPSqCfU8OPx2BmJsUu+FGuau7wu2vEDJEad8ff7U031mMO4g@mail.gmail.com> (raw)
In-Reply-To: <52580B95.5010603@metafoo.de>

On 11 October 2013 20:00, Lars-Peter Clausen <lars@metafoo.de> wrote:
> On 10/11/2013 10:23 AM, Naveen Krishna Chatradhi wrote:
>> This patch does the following
>> 1. use wait_for_completion_timeout instead of
>>    wait_for_completion_interruptible_timeout
>> 2. Reset software if a timeout happens.
>> 3. Also reduce the timeout to 100milli secs
>
> It is always good to have a description of why a chance should be done in
> the commit message. It is obvious what the patch does by just looking at the
> changed lines, it is not that obvious though why those lines had to be changed.
>
>>
>> Note: submitted for review at https://patchwork.kernel.org/patch/2279591/
>>
>> Signed-off-by: Naveen Krishna Chatradhi <ch.naveen@samsung.com>
>> Cc: Doug Anderson <dianders@chromium.org>
>> Cc: Lars-Peter Clausen <lars@metafoo.de>
>> ---
>> Changes since v1:
>> As per discussion at
>> http://marc.info/?l=linux-kernel&m=136517637228869&w=3
>>
>> This patch does the following
>> 1. use wait_for_completion_timeout instead of
>>    wait_for_completion_interruptible_timeout
>> 2. Reset software if a timeout happens.
>> 3. Also reduce the timeout to 100milli secs
>>
>> Changes since v2:
>> None.
>> Rebased and reposting.
>>
>> ---
>>  drivers/iio/adc/exynos_adc.c |   66 +++++++++++++++++++++++-------------------
>>  1 file changed, 36 insertions(+), 30 deletions(-)
>>
>> diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c
>> index d25b262..f18ed7e 100644
>> --- a/drivers/iio/adc/exynos_adc.c
>> +++ b/drivers/iio/adc/exynos_adc.c
>> @@ -82,7 +82,7 @@ enum adc_version {
>>  #define ADC_CON_EN_START     (1u << 0)
>>  #define ADC_DATX_MASK                0xFFF
>>
>> -#define EXYNOS_ADC_TIMEOUT   (msecs_to_jiffies(1000))
>> +#define EXYNOS_ADC_TIMEOUT   (msecs_to_jiffies(100))
>>
>>  struct exynos_adc {
>>       void __iomem            *regs;
>> @@ -112,6 +112,30 @@ static inline unsigned int exynos_adc_get_version(struct platform_device *pdev)
>>       return (unsigned int)match->data;
>>  }
>>
>> +static void exynos_adc_hw_init(struct exynos_adc *info)
>> +{
>> +     u32 con1, con2;
>> +
>> +     if (info->version == ADC_V2) {
>> +             con1 = ADC_V2_CON1_SOFT_RESET;
>> +             writel(con1, ADC_V2_CON1(info->regs));
>> +
>> +             con2 = ADC_V2_CON2_OSEL | ADC_V2_CON2_ESEL |
>> +                     ADC_V2_CON2_HIGHF | ADC_V2_CON2_C_TIME(0);
>> +             writel(con2, ADC_V2_CON2(info->regs));
>> +
>> +             /* Enable interrupts */
>> +             writel(1, ADC_V2_INT_EN(info->regs));
>> +     } else {
>> +             /* set default prescaler values and Enable prescaler */
>> +             con1 =  ADC_V1_CON_PRSCLV(49) | ADC_V1_CON_PRSCEN;
>> +
>> +             /* Enable 12-bit ADC resolution */
>> +             con1 |= ADC_V1_CON_RES;
>> +             writel(con1, ADC_V1_CON(info->regs));
>> +     }
>> +}
>> +
>>  static int exynos_read_raw(struct iio_dev *indio_dev,
>>                               struct iio_chan_spec const *chan,
>>                               int *val,
>> @@ -121,6 +145,7 @@ static int exynos_read_raw(struct iio_dev *indio_dev,
>>       struct exynos_adc *info = iio_priv(indio_dev);
>>       unsigned long timeout;
>>       u32 con1, con2;
>> +     int ret;
>>
>>       if (mask != IIO_CHAN_INFO_RAW)
>>               return -EINVAL;
>> @@ -145,16 +170,21 @@ static int exynos_read_raw(struct iio_dev *indio_dev,
>>                               ADC_V1_CON(info->regs));
>>       }
>>
>> -     timeout = wait_for_completion_interruptible_timeout
>> +     timeout = wait_for_completion_timeout
>>                       (&info->completion, EXYNOS_ADC_TIMEOUT);
>
> Nitpick: It would be nice to put the &info->completion on the same line as
> the wait_for_completion...
I received a comment from Grant regarding the same.
I'm away from work this weekend. Will submit the code once i get back,
>
>> +     if (timeout == 0) {
>> +             dev_warn(&indio_dev->dev, "Conversion timed out reseting\n");
>> +             exynos_adc_hw_init(info);
>> +             ret = -ETIMEDOUT;
>> +     } else {
>> +             *val = info->value;
>> +             ret = IIO_VAL_INT;
>> +     }
>>       *val = info->value;
>
> This line above should probably be removed.
Yes this is unnecessary. Will remove this.
>
>>
>>       mutex_unlock(&indio_dev->mlock);
>>
>> -     if (timeout == 0)
>> -             return -ETIMEDOUT;
>> -
>> -     return IIO_VAL_INT;
>> +     return ret;
>>  }
>>
>>  static irqreturn_t exynos_adc_isr(int irq, void *dev_id)
>> @@ -226,30 +256,6 @@ static int exynos_adc_remove_devices(struct device *dev, void *c)
>>       return 0;
>>  }
>>
>> -static void exynos_adc_hw_init(struct exynos_adc *info)
>> -{
>> -     u32 con1, con2;
>> -
>> -     if (info->version == ADC_V2) {
>> -             con1 = ADC_V2_CON1_SOFT_RESET;
>> -             writel(con1, ADC_V2_CON1(info->regs));
>> -
>> -             con2 = ADC_V2_CON2_OSEL | ADC_V2_CON2_ESEL |
>> -                     ADC_V2_CON2_HIGHF | ADC_V2_CON2_C_TIME(0);
>> -             writel(con2, ADC_V2_CON2(info->regs));
>> -
>> -             /* Enable interrupts */
>> -             writel(1, ADC_V2_INT_EN(info->regs));
>> -     } else {
>> -             /* set default prescaler values and Enable prescaler */
>> -             con1 =  ADC_V1_CON_PRSCLV(49) | ADC_V1_CON_PRSCEN;
>> -
>> -             /* Enable 12-bit ADC resolution */
>> -             con1 |= ADC_V1_CON_RES;
>> -             writel(con1, ADC_V1_CON(info->regs));
>> -     }
>> -}
>> -
>>  static int exynos_adc_probe(struct platform_device *pdev)
>>  {
>>       struct exynos_adc *info = NULL;
>>
>
Thanks for the review.



-- 
Shine bright,
(: Nav :)

WARNING: multiple messages have this Message-ID (diff)
From: Naveen Krishna Ch <naveenkrishna.ch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
Cc: Naveen Krishna Chatradhi
	<ch.naveen-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
	linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	"linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org,
	tomasz.figa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Subject: Re: [PATCH v3] iio: exynos_adc: use wait_for_completion_timeout instead of interruptible
Date: Sat, 12 Oct 2013 12:10:40 +0530	[thread overview]
Message-ID: <CAHfPSqCfU8OPx2BmJsUu+FGuau7wu2vEDJEad8ff7U031mMO4g@mail.gmail.com> (raw)
In-Reply-To: <52580B95.5010603-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>

On 11 October 2013 20:00, Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org> wrote:
> On 10/11/2013 10:23 AM, Naveen Krishna Chatradhi wrote:
>> This patch does the following
>> 1. use wait_for_completion_timeout instead of
>>    wait_for_completion_interruptible_timeout
>> 2. Reset software if a timeout happens.
>> 3. Also reduce the timeout to 100milli secs
>
> It is always good to have a description of why a chance should be done in
> the commit message. It is obvious what the patch does by just looking at the
> changed lines, it is not that obvious though why those lines had to be changed.
>
>>
>> Note: submitted for review at https://patchwork.kernel.org/patch/2279591/
>>
>> Signed-off-by: Naveen Krishna Chatradhi <ch.naveen-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
>> Cc: Doug Anderson <dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
>> Cc: Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
>> ---
>> Changes since v1:
>> As per discussion at
>> http://marc.info/?l=linux-kernel&m=136517637228869&w=3
>>
>> This patch does the following
>> 1. use wait_for_completion_timeout instead of
>>    wait_for_completion_interruptible_timeout
>> 2. Reset software if a timeout happens.
>> 3. Also reduce the timeout to 100milli secs
>>
>> Changes since v2:
>> None.
>> Rebased and reposting.
>>
>> ---
>>  drivers/iio/adc/exynos_adc.c |   66 +++++++++++++++++++++++-------------------
>>  1 file changed, 36 insertions(+), 30 deletions(-)
>>
>> diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c
>> index d25b262..f18ed7e 100644
>> --- a/drivers/iio/adc/exynos_adc.c
>> +++ b/drivers/iio/adc/exynos_adc.c
>> @@ -82,7 +82,7 @@ enum adc_version {
>>  #define ADC_CON_EN_START     (1u << 0)
>>  #define ADC_DATX_MASK                0xFFF
>>
>> -#define EXYNOS_ADC_TIMEOUT   (msecs_to_jiffies(1000))
>> +#define EXYNOS_ADC_TIMEOUT   (msecs_to_jiffies(100))
>>
>>  struct exynos_adc {
>>       void __iomem            *regs;
>> @@ -112,6 +112,30 @@ static inline unsigned int exynos_adc_get_version(struct platform_device *pdev)
>>       return (unsigned int)match->data;
>>  }
>>
>> +static void exynos_adc_hw_init(struct exynos_adc *info)
>> +{
>> +     u32 con1, con2;
>> +
>> +     if (info->version == ADC_V2) {
>> +             con1 = ADC_V2_CON1_SOFT_RESET;
>> +             writel(con1, ADC_V2_CON1(info->regs));
>> +
>> +             con2 = ADC_V2_CON2_OSEL | ADC_V2_CON2_ESEL |
>> +                     ADC_V2_CON2_HIGHF | ADC_V2_CON2_C_TIME(0);
>> +             writel(con2, ADC_V2_CON2(info->regs));
>> +
>> +             /* Enable interrupts */
>> +             writel(1, ADC_V2_INT_EN(info->regs));
>> +     } else {
>> +             /* set default prescaler values and Enable prescaler */
>> +             con1 =  ADC_V1_CON_PRSCLV(49) | ADC_V1_CON_PRSCEN;
>> +
>> +             /* Enable 12-bit ADC resolution */
>> +             con1 |= ADC_V1_CON_RES;
>> +             writel(con1, ADC_V1_CON(info->regs));
>> +     }
>> +}
>> +
>>  static int exynos_read_raw(struct iio_dev *indio_dev,
>>                               struct iio_chan_spec const *chan,
>>                               int *val,
>> @@ -121,6 +145,7 @@ static int exynos_read_raw(struct iio_dev *indio_dev,
>>       struct exynos_adc *info = iio_priv(indio_dev);
>>       unsigned long timeout;
>>       u32 con1, con2;
>> +     int ret;
>>
>>       if (mask != IIO_CHAN_INFO_RAW)
>>               return -EINVAL;
>> @@ -145,16 +170,21 @@ static int exynos_read_raw(struct iio_dev *indio_dev,
>>                               ADC_V1_CON(info->regs));
>>       }
>>
>> -     timeout = wait_for_completion_interruptible_timeout
>> +     timeout = wait_for_completion_timeout
>>                       (&info->completion, EXYNOS_ADC_TIMEOUT);
>
> Nitpick: It would be nice to put the &info->completion on the same line as
> the wait_for_completion...
I received a comment from Grant regarding the same.
I'm away from work this weekend. Will submit the code once i get back,
>
>> +     if (timeout == 0) {
>> +             dev_warn(&indio_dev->dev, "Conversion timed out reseting\n");
>> +             exynos_adc_hw_init(info);
>> +             ret = -ETIMEDOUT;
>> +     } else {
>> +             *val = info->value;
>> +             ret = IIO_VAL_INT;
>> +     }
>>       *val = info->value;
>
> This line above should probably be removed.
Yes this is unnecessary. Will remove this.
>
>>
>>       mutex_unlock(&indio_dev->mlock);
>>
>> -     if (timeout == 0)
>> -             return -ETIMEDOUT;
>> -
>> -     return IIO_VAL_INT;
>> +     return ret;
>>  }
>>
>>  static irqreturn_t exynos_adc_isr(int irq, void *dev_id)
>> @@ -226,30 +256,6 @@ static int exynos_adc_remove_devices(struct device *dev, void *c)
>>       return 0;
>>  }
>>
>> -static void exynos_adc_hw_init(struct exynos_adc *info)
>> -{
>> -     u32 con1, con2;
>> -
>> -     if (info->version == ADC_V2) {
>> -             con1 = ADC_V2_CON1_SOFT_RESET;
>> -             writel(con1, ADC_V2_CON1(info->regs));
>> -
>> -             con2 = ADC_V2_CON2_OSEL | ADC_V2_CON2_ESEL |
>> -                     ADC_V2_CON2_HIGHF | ADC_V2_CON2_C_TIME(0);
>> -             writel(con2, ADC_V2_CON2(info->regs));
>> -
>> -             /* Enable interrupts */
>> -             writel(1, ADC_V2_INT_EN(info->regs));
>> -     } else {
>> -             /* set default prescaler values and Enable prescaler */
>> -             con1 =  ADC_V1_CON_PRSCLV(49) | ADC_V1_CON_PRSCEN;
>> -
>> -             /* Enable 12-bit ADC resolution */
>> -             con1 |= ADC_V1_CON_RES;
>> -             writel(con1, ADC_V1_CON(info->regs));
>> -     }
>> -}
>> -
>>  static int exynos_adc_probe(struct platform_device *pdev)
>>  {
>>       struct exynos_adc *info = NULL;
>>
>
Thanks for the review.



-- 
Shine bright,
(: Nav :)

  reply	other threads:[~2013-10-12  6:41 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-15 16:26 [RFC: PATCH 2/2] iio: adc: exynos_adc: Handle timeout and race conditions Naveen Krishna Chatradhi
2013-03-15 21:53 ` Lars-Peter Clausen
2013-03-15 21:53   ` Lars-Peter Clausen
2013-03-16  0:37   ` Doug Anderson
2013-03-16 14:41     ` Lars-Peter Clausen
2013-03-16 14:41       ` Lars-Peter Clausen
2013-04-03 17:06       ` Doug Anderson
2013-04-03 17:06         ` Doug Anderson
2013-04-05  8:53         ` Lars-Peter Clausen
2013-04-05 14:56           ` Doug Anderson
2013-04-05 14:56             ` Doug Anderson
2013-04-05 16:38             ` Lars-Peter Clausen
2013-04-04  3:59 ` [PATCH 14/14] temp: iio: adc: exynos_adc: Handle timeout issues Naveen Krishna Chatradhi
2013-04-04  4:09   ` Naveen Krishna Ch
     [not found] ` <1363364801-23684-1-git-send-email-ch.naveen-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2013-04-04  4:06   ` [PATCH] " Naveen Krishna Chatradhi
2013-04-04  4:06     ` Naveen Krishna Chatradhi
     [not found]     ` <1365048389-6364-1-git-send-email-naveenkrishna.ch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-04-13  4:36       ` Naveen Krishna Ch
2013-04-13  4:36         ` Naveen Krishna Ch
     [not found]         ` <CAHfPSqAVUVdFwtMxJYCGaPv_+iO_GEc9_UGNXwuSj9uu_fB81g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-04-15 16:01           ` Doug Anderson
2013-04-15 16:01             ` Doug Anderson
2013-05-02 18:01     ` [PATCH v2] " Naveen Krishna Chatradhi
     [not found]       ` <1367517663-12225-1-git-send-email-naveenkrishna.ch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-05-02 18:10         ` Tomasz Figa
2013-05-02 18:10           ` Tomasz Figa
2013-05-02 18:22           ` Naveen Krishna Ch
2013-05-02 18:22             ` Naveen Krishna Ch
     [not found]             ` <CAHfPSqCc81765zQVur=AtW2Cf+taYef=LYJK008i03cmYPu0WQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-05-02 18:36               ` Tomasz Figa
2013-05-02 18:36                 ` Tomasz Figa
2013-10-11  8:23     ` [PATCH v3] iio: exynos_adc: use wait_for_completion_timeout instead of interruptible Naveen Krishna Chatradhi
2013-10-11 14:30       ` Lars-Peter Clausen
2013-10-11 14:30         ` Lars-Peter Clausen
2013-10-12  6:40         ` Naveen Krishna Ch [this message]
2013-10-12  6:40           ` Naveen Krishna Ch
2013-10-12  6:40           ` Naveen Krishna Ch
2013-10-15  5:15       ` [PATCH v4] " Naveen Krishna Chatradhi
2013-10-25 15:42         ` Doug Anderson
2013-10-28  5:41       ` [PATCH v5] " Naveen Krishna Chatradhi
2013-11-05  9:45       ` [PATCH v6] " Naveen Krishna Chatradhi
2013-11-10 12:48         ` Tomasz Figa
2013-11-10 12:48           ` Tomasz Figa

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=CAHfPSqCfU8OPx2BmJsUu+FGuau7wu2vEDJEad8ff7U031mMO4g@mail.gmail.com \
    --to=naveenkrishna.ch@gmail.com \
    --cc=ch.naveen@samsung.com \
    --cc=dianders@chromium.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=tomasz.figa@gmail.com \
    /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.