linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shubhrajyoti <shubhrajyoti@ti.com>
To: oskar.andero@sonyericsson.com
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	"linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"jic23@cam.ac.uk" <jic23@cam.ac.uk>,
	"aghayal@codeaurora.org" <aghayal@codeaurora.org>,
	"Cavin, Courtney" <Courtney.Cavin@sonyericsson.com>
Subject: Re: [PATCH v3] input: add driver support for Sharp gp2ap002a00f proximity sensor
Date: Fri, 18 Nov 2011 21:00:13 +0530	[thread overview]
Message-ID: <4EC67A05.6000107@ti.com> (raw)
In-Reply-To: <20111118094429.GA29713@caracas.corpusers.net>

On Friday 18 November 2011 03:14 PM, oskar.andero@sonyericsson.com wrote:
> On 22:43 Thu 17 Nov     , Dmitry Torokhov wrote:
>> On Thu, Nov 17, 2011 at 12:22:19PM +0100, oskar.andero@sonyericsson.com wrote:
>>> Hi Dmitry,
>>>
>>> On 13:18 Wed 16 Nov     , Oskar Andero wrote:
>>>> On 12:28 Wed 16 Nov     , Shubhrajyoti wrote:
>>>>> On Wednesday 16 November 2011 04:07 PM, oskar.andero@sonyericsson.com
>>>>> wrote:
>>>>>> On 19:29 Tue 15 Nov     , Dmitry Torokhov wrote:
>>>>>>> On Tue, Nov 15, 2011 at 01:53:52PM +0100, oskar.andero@sonyericsson.com wrote:
>>>>>>>> On 10:43 Tue 15 Nov     , Dmitry Torokhov wrote:
>>>>>>>>> On Tue, Nov 15, 2011 at 10:26:00AM +0100, oskar.andero@sonyericsson.com wrote:
>>>>>>>>>> From: Courtney Cavin <courtney.cavin@sonyericsson.com>
>>>>>>>>>> +
>>>>>>>>>> +#ifdef CONFIG_PM_SLEEP
>>>>>>>>>> +static int gp2a_suspend(struct device *dev)
>>>>>>>>>> +{
>>>>>>>>>> +	struct i2c_client *client = to_i2c_client(dev);
>>>>>>>>>> +	struct gp2a_data *dt = i2c_get_clientdata(client);
>>>>>>>>>> +	int error;
>>>>>>>>>> +
>>>>>>>>>> +	mutex_lock(&dt->device->mutex);
>>>>>>>>>> +
>>>>>>>>>> +	if (dt->device->users) {
>>>>>>>>>> +		if (device_may_wakeup(&client->dev)) {
>>>>>>>>>> +			enable_irq_wake(client->irq);
>>>>>>>>> I think this part should happen regardless of whether device has users,
>>>>>>>>> only non wakeup source case needs it.
>>>>>>>> Hmm.. why would one want to enable irq_wake when there are no users?
>>>>>>>> Wouldn't this cause the device to wakeup at every irq and report an
>>>>>>>> switch event that no one listens to?
>>>>>>> You are suspending the system and want to have this device as a wakeup
>>>>>>> source. Note: not wake up _device_ at every IRQ but wake up the whole
>>>>>>> _system_ when device generates an IRQ while system is asleep.
>>>>>>> It does not matter whether there are users for the events; you
>>>>>>> want the system to wake up.
>>>>>>>
>>>>>>> At least this is the usual semantics.
>>>>>> I see you point. However, the way we use the proximity sensor we can only wake up
>>>>>> the system when we have an application that is actually interested in the change.
>>>>>> This is for power save reasons.
>>>>>> If we use the "usual semantic", we would wake up the system at every proximity
>>>>>> detection regardlessly. For instance, I wouldn't want to wake up a cell phone laying
>>>>>> on the desk when I put my hand over it. That would hurt the battery time.
>>>>> Even in that case it shouldn't harm the power if no user is there the
>>>>> close would have been called
>>>>> and you should  be in the shut down mode? Am I missing something?
>>>> You are right - the chip will only generate interrupts when it's opened, so the case
>>>> I described shouldn't actually be a problem. However, does it make sense to enable irq_wake
>>>> for a device that will never generate interrupts?
>>> Do you have any input on my question above? My suggestion is to keep the code as it is,
>>> unless you see a reason for enabling wake_irq on an irq that will never happen.
>> So let me get it straight - with your particular device (as in phone)
>> you do not expect the sensor to be used as a wakeup source for the
>> system. If this is correct then it does not really matter what suspend
>> and resume callbacks are doing. Other devices using the same sensor
>> might have different requirements, including being a wakeup source for
>> the system.
> We use the sensor for wakeup source only if some application is listening
> for proximity events, i.e. has the sensor open at suspend.
>
> You are right - for me it doesn't really matter if we call enable_irq_wake()
> regardless of dt->device->users with the current implementation, but I don't
> see the reason for doing that when an irq will never occur in suspend.
I dont think it is true for drivers that need wakeup and are listening
and a
user initiated suspend happens.
> To have the chip wakeup the system without any users means we need to enable
> the chip in gp2a_suspend() I guess, which seems a bit strange, right?
> E.g. (in pseudo code):
>
> static int gp2a_suspend(struct device *dev)
> {
> 	if (device_may_wakeup(&client->dev)) {
> 		gp2a_enable(dt);
> 		enable_irq_wake(client->irq);
> 	} else if (dt->device->users) {
> 		gp2a_disable(dt);
> 	}
> }
>
> -Oskar


      reply	other threads:[~2011-11-18 15:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-15  9:26 [PATCH v3] input: add driver support for Sharp gp2ap002a00f proximity sensor oskar.andero
2011-11-15  9:43 ` Dmitry Torokhov
2011-11-15 12:53   ` oskar.andero
2011-11-15 18:29     ` Dmitry Torokhov
2011-11-16 10:37       ` oskar.andero
2011-11-16 11:28         ` Shubhrajyoti
2011-11-16 12:18           ` oskar.andero
2011-11-17 11:22             ` oskar.andero
2011-11-17 21:43               ` Dmitry Torokhov
2011-11-18  9:44                 ` oskar.andero
2011-11-18 15:30                   ` Shubhrajyoti [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=4EC67A05.6000107@ti.com \
    --to=shubhrajyoti@ti.com \
    --cc=Courtney.Cavin@sonyericsson.com \
    --cc=aghayal@codeaurora.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jic23@cam.ac.uk \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oskar.andero@sonyericsson.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 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).