From: Christopher Heiny <cheiny@synaptics.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Linux Input <linux-input@vger.kernel.org>,
Andrew Duggan <aduggan@synaptics.com>,
Vincent Huang <vincent.huang@tw.synaptics.com>,
Vivian Ly <vly@synaptics.com>,
Daniel Rosenberg <daniel.rosenberg@synaptics.com>,
Jean Delvare <khali@linux-fr.org>,
Joerie de Gram <j.de.gram@gmail.com>,
Linus Walleij <linus.walleij@stericsson.com>,
Benjamin Tissoires <benjamin.tissoires@redhat.com>
Subject: Re: [PATCH V2] input synaptics-rmi4: Bug fixes to ATTN GPIO handling.
Date: Fri, 27 Dec 2013 15:43:27 -0800 [thread overview]
Message-ID: <52BE109F.1070904@synaptics.com> (raw)
In-Reply-To: <20131226223718.GC18562@core.coreip.homeip.net>
On 12/26/2013 02:37 PM, Dmitry Torokhov wrote:
> Hi Chris,
>
> On Mon, Dec 23, 2013 at 06:44:19PM -0800, Christopher Heiny wrote:
>> This patch fixes some bugs in handling of the RMI4 attention line GPIO.
>>
>> 1) in enable_sensor(), eliminate the complicated check on ATTN and just
>> call process_interrupt_requests(). This will have minimal overhead if ATTN
>> is not asserted, and clears the state of the RMI4 device in any case.
>>
>> 2) Correctly free the GPIO in rmi_driver_remove().
>>
>> 3) in rmi_driver_probe()
>> - declare the name of the attention gpio (GPIO_LABEL)
>> - use gpio_request_one() to get the gpio and export it.
>> - simplify conditional gpio acquisition logic and combine with interrupt
>> setup
>>
>> 4) use gpio_is_valid() instead of comparing to 0.
>>
>> Signed-off-by: Christopher Heiny <cheiny@synaptics.com>
>> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>> Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
>>
>> ---
>>
>> drivers/input/rmi4/rmi_driver.c | 43 ++++++++++++++++++++++-------------------
>> 1 file changed, 23 insertions(+), 20 deletions(-)
>>
>> diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
>> index a30c7d3..9b02358 100644
>> --- a/drivers/input/rmi4/rmi_driver.c
>> +++ b/drivers/input/rmi4/rmi_driver.c
>> @@ -140,7 +140,6 @@ static int enable_sensor(struct rmi_device *rmi_dev)
>> struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
>> struct rmi_phys_device *rmi_phys;
>> int retval = 0;
>> - struct rmi_device_platform_data *pdata = to_rmi_platform_data(rmi_dev);
>>
>> if (data->enabled)
>> return 0;
>> @@ -169,11 +168,7 @@ static int enable_sensor(struct rmi_device *rmi_dev)
>>
>> data->enabled = true;
>>
>> - if (!pdata->level_triggered &&
>> - gpio_get_value(pdata->attn_gpio) == pdata->attn_polarity)
>> - retval = process_interrupt_requests(rmi_dev);
>> -
>> - return retval;
>> + return process_interrupt_requests(rmi_dev);
>> }
>>
>> static void rmi_free_function_list(struct rmi_device *rmi_dev)
>> @@ -800,13 +795,20 @@ static SIMPLE_DEV_PM_OPS(rmi_driver_pm, rmi_driver_suspend, rmi_driver_resume);
>> static int rmi_driver_remove(struct device *dev)
>> {
>> struct rmi_device *rmi_dev = to_rmi_device(dev);
>> + const struct rmi_device_platform_data *pdata =
>> + to_rmi_platform_data(rmi_dev);
>>
>> disable_sensor(rmi_dev);
>> rmi_free_function_list(rmi_dev);
>>
>> + if (gpio_is_valid(pdata->attn_gpio))
>> + gpio_free(pdata->attn_gpio);
>
> It looks like you let driver registration to continue even if GPIO
> request fails. You probably need to introduce a flag indicating whether
> you successfully requested gpio or not. Or you can treat failure to
> acquire gpio as fatal.
In testing, the driver continues to work even if the GPIO is not
acquired, but some diagnostic features may not be available, so we treat
the failure to acquire as a warning. I'll add a flag to indicate
whether it was acquired or not.
>
>> +
>> return 0;
>> }
>>
>> +static const char GPIO_LABEL[] = "attn";
>> +
>> static int rmi_driver_probe(struct device *dev)
>> {
>> struct rmi_driver *rmi_driver;
>> @@ -937,7 +939,7 @@ static int rmi_driver_probe(struct device *dev)
>> mutex_init(&data->suspend_mutex);
>> }
>>
>> - if (pdata->attn_gpio) {
>> + if (gpio_is_valid(pdata->attn_gpio)) {
>> data->irq = gpio_to_irq(pdata->attn_gpio);
>> if (pdata->level_triggered) {
>> data->irq_flags = IRQF_ONESHOT |
>> @@ -948,24 +950,17 @@ static int rmi_driver_probe(struct device *dev)
>> (pdata->attn_polarity == RMI_ATTN_ACTIVE_HIGH)
>> ? IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING;
>> }
>> - } else
>> - data->poll_interval = ktime_set(0,
>> - (pdata->poll_interval_ms ? pdata->poll_interval_ms :
>> - DEFAULT_POLL_INTERVAL_MS) * 1000 * 1000);
>> -
>> - if (data->f01_container->dev.driver) {
>> - /* Driver already bound, so enable ATTN now. */
>> - enable_sensor(rmi_dev);
>> - }
>>
>> - if (IS_ENABLED(CONFIG_RMI4_DEV) && pdata->attn_gpio) {
>
> Do you really need to export gpio if you do not have RMI4_DEV option?
Not really, but it doesn't hurt to do so. I was trying to simplify the
driver logic, but I guess that went too far. I'll re-add the check.
[snip]
next prev parent reply other threads:[~2013-12-27 23:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-24 2:44 [PATCH V2] input synaptics-rmi4: Bug fixes to ATTN GPIO handling Christopher Heiny
2013-12-26 22:37 ` Dmitry Torokhov
2013-12-27 23:43 ` Christopher Heiny [this message]
-- strict thread matches above, loose matches on Subject: below --
2013-12-17 20:16 Christopher Heiny
2013-12-18 14:39 ` Dmitry Torokhov
2013-12-19 1:23 ` Christopher Heiny
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=52BE109F.1070904@synaptics.com \
--to=cheiny@synaptics.com \
--cc=aduggan@synaptics.com \
--cc=benjamin.tissoires@redhat.com \
--cc=daniel.rosenberg@synaptics.com \
--cc=dmitry.torokhov@gmail.com \
--cc=j.de.gram@gmail.com \
--cc=khali@linux-fr.org \
--cc=linus.walleij@stericsson.com \
--cc=linux-input@vger.kernel.org \
--cc=vincent.huang@tw.synaptics.com \
--cc=vly@synaptics.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).