All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Wang <jason77.wang@gmail.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Jason Wang <jason77.wang@gmail.com>,
	notasas@gmail.com, vapier@gentoo.org,
	linux-input@vger.kernel.org
Subject: Re: [PATCH 4/4] Input: ads7846 - modificatons of _stop()/_disable() conditions
Date: Mon, 20 Sep 2010 16:18:49 +0800	[thread overview]
Message-ID: <4C9718E9.5040104@gmail.com> (raw)
In-Reply-To: <20100917160709.GC14186@core.coreip.homeip.net>

Dmitry Torokhov wrote:
> On Fri, Sep 17, 2010 at 05:20:14PM +0800, Jason Wang wrote:
>   
>> Dmitry Torokhov wrote:
>>     
>>> Hi Jason,
>>>
>>> On Thursday, September 16, 2010 03:51:26 am Jason Wang wrote:
>>>       
>>>> The design like that, we can stop or disable ADC, one difference is
>>>> the disable not only stop the ADC but also close the power regulator.
>>>> So we change the condition flag to stopped in the _stop() function.
>>>>
>>>> Because we call __ads7846_disable() in the suspend/resume process, so
>>>> move disabled flag modification from ads7846_disable() to the
>>>> __ads7846_disable(), otherwise when we call _disable() in the suspend,
>>>> and the ADC is really suspended but the flag shows that it isn't.
>>>>         
>>> I disagree with the patch. "Disable" knob is separate from PM
>>> knobs (suspend/resume); and thus that attribute should only read
>>> "1" when
>>> user forcibly disabled the device via sysfs. Same goes for open/close.
>>>
>>> Thanks.
>>>
>>>       
>> OK, i will fix this patch.
>>
>>     
>
> Hmm, I am not sure what there is to fix... Maybe I misunderstood your
> description. Could you please try again to explain what you are trying
> to achieve?
>
> Thanks!
>
>   
It seems that i mis-understand your original design. I am wrong for this
patch because i mingled disabled and suspended flags.

Your original design is like that, these two flags are separate ones, 
either one
is true, we should stop ADC, Both of them is false we can restart ADC.

But current design(don't apply my 0004-xxx.patch) has some little bugs:
the condition in the ads7846_restart is,
static void ads7846_restart(struct ads7846 *ts)
{
if (!ts->disabled && !ts->suspended) {

But, when we call ads7846_enable()/ads7846_resume(), the 
disabled/suspended flag's
update are all at the place after the ads7846_restart() is called, so 
this will cause the
ads7846_restart() can't be executed. User will see after they 
enable/wakeup this driver
through sysfs, the driver still doesn't work.

There are two smallest fixes, i don't know which one is better?

1) replace the stop()/restart() condition flag to ->stopped:
static void ads7846_stop(struct ads7846 *ts)
{
- if (!ts->disabled && !ts->suspended) {
+ if (!ts->stopped) {
/* Signal IRQ thread to stop polling and disable the handler. */
ts->stopped = true;
mb();
@@ -210,7 +210,7 @@ static void ads7846_stop(struct ads7846 *ts)
/* Must be called with ts->lock held */
static void ads7846_restart(struct ads7846 *ts)
{
- if (!ts->disabled && !ts->suspended) {
+ if (ts->stopped) {
/* Tell IRQ thread that it may poll the device. */
ts->stopped = false;
mb();

2) move the flags update in the enable()/resume() a little bit forward:

--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -253,10 +253,11 @@ static void ads7846_enable(struct ads7846 *ts)
{
mutex_lock(&ts->lock);

- if (ts->disabled && !ts->suspended)
+ if (ts->disabled && !ts->suspended) {
+ ts->disabled = false;
__ads7846_enable(ts);
-
- ts->disabled = false;
+ } else
+ ts->disabled = false;

mutex_unlock(&ts->lock);
}
@@ -919,10 +920,10 @@ static int ads7846_resume(struct spi_device *spi)
if (device_may_wakeup(&ts->spi->dev))
disable_irq_wake(ts->spi->irq);

+ ts->suspended = false;
+
if (!ts->disabled)
__ads7846_enable(ts);
-
- ts->suspended = false;
}

mutex_unlock(&ts->lock);


Thanks,
Jason.

  reply	other threads:[~2010-09-20  8:15 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-16 10:51 [PATCH 0/4] Switch ads7846 driver to use soft irq Jason Wang
2010-09-16 10:51 ` [PATCH 1/4] Input: ads7846 - switch to using threaded IRQ Jason Wang
2010-09-16 10:51   ` [PATCH 2/4] Input: ads7846 - add a include header to prevent building fails Jason Wang
2010-09-16 10:51     ` [PATCH 3/4] Input: ads7846 - restore ADC to powerdown mode if no messgaes needed Jason Wang
2010-09-16 10:51       ` [PATCH 4/4] Input: ads7846 - modificatons of _stop()/_disable() conditions Jason Wang
2010-09-17  6:39         ` Dmitry Torokhov
2010-09-17  9:20           ` Jason Wang
2010-09-17 16:07             ` Dmitry Torokhov
2010-09-20  8:18               ` Jason Wang [this message]
2010-10-12  9:58                 ` Jason Wang
2010-10-12 16:00                   ` Dmitry Torokhov
2010-10-13  3:12                     ` Jason Wang
2010-10-13 22:17                       ` Grazvydas Ignotas
2010-10-14  2:14                         ` Jason Wang
2010-10-14 21:40                           ` Grazvydas Ignotas
2010-10-15  2:29                             ` Jason Wang
2010-10-18 23:19                               ` Tony Lindgren
2010-10-19  1:25                                 ` Jason Wang
2010-09-17  1:48 ` [PATCH 0/4] Switch ads7846 driver to use soft irq Jason Wang

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=4C9718E9.5040104@gmail.com \
    --to=jason77.wang@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=notasas@gmail.com \
    --cc=vapier@gentoo.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.