mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jean-Francois Dagenais <jeff.dagenais@gmail.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: grant.likely@secretlab.ca, linus.walleij@stericsson.com,
	linux-kernel@vger.kernel.org, linux-input@vger.kernel.org,
	michael.hennerich@analog.com
Subject: Re: [PATCH 1/2] input: adp5588-keys - get value from data out when dir out
Date: Tue, 24 Apr 2012 09:33:11 -0400	[thread overview]
Message-ID: <6E61B4B4-D654-41E0-ACF3-FA9F2D4B8C0F@gmail.com> (raw)
In-Reply-To: <20120421064710.GC2360@core.coreip.homeip.net>


On Apr 21, 2012, at 2:47, Dmitry Torokhov wrote:

> Hi Jean-François,
> 
> On Fri, Apr 20, 2012 at 11:32:00AM -0400, Jean-François Dagenais wrote:
>> As discussed here: http://ez.analog.com/message/35852,
>> the 5587 revC and 5588 revB spec sheets contain a mistake
>> in the GPIO_DAT_STATx register description.
>> 
>> According to R.Shnell at ADI, as well as my own
>> observations, it should read:
>> "GPIO data status (shows GPIO state when read for inputs)".
>> 
>> This commit changes the get value function accordingly.
>> 
>> A similar patch for gpio-adp5588 follows.
>> 
>> Signed-off-by: Jean-François Dagenais <jeff.dagenais@gmail.com>
>> Acked-by: Michael Hennerich <michael.hennerich@analog.com>
>> ---
>> drivers/input/keyboard/adp5588-keys.c |    7 +++++++
>> 1 files changed, 7 insertions(+), 0 deletions(-)
>> 
>> diff --git a/drivers/input/keyboard/adp5588-keys.c b/drivers/input/keyboard/adp5588-keys.c
>> index 6412ced..b7a0f1a 100644
>> --- a/drivers/input/keyboard/adp5588-keys.c
>> +++ b/drivers/input/keyboard/adp5588-keys.c
>> @@ -78,6 +78,13 @@ static int adp5588_gpio_get_value(struct gpio_chip *chip, unsigned off)
>> 	unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]);
>> 	unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
>> 
>> +	mutex_lock(&kpad->gpio_lock);
>> +	if (kpad->dir[bank] & bit) {
>> +		int result = !!(kpad->dat_out[bank] & bit);
>> +		mutex_unlock(&kpad->gpio_lock);
>> +		return result;
>> +	}
>> +	mutex_unlock(&kpad->gpio_lock);
>> 	return !!(adp5588_read(kpad->client, GPIO_DAT_STAT1 + bank) & bit);
> 
> This locking looks wrong as it is possible for adp5588_gpio_get_value()
> to get scheduled out after checking kpad->dir[bank] and releasing
> kpad->gpio_lock while another thread executes
> adp5588_gpio_direction_output() and modifies kpad->dir[bank].
> 
> You should keep mutex for the entire duration; something like this:
> 
> 	mutex_lock(&kpad->gpio_lock);
> 	if (kpad->dir[bank] & bit)
> 		val = kpad->dat_out[bank];
> 	else
> 		val = adp5588_read(kpad->client, GPIO_DAT_STAT1 + bank);
> 	mutex_unlock(&kpad->gpio_lock);
> 
> 	return !!(val & bit);
> 
Agreed, I think I wanted to minimize refactoring a bit too much and got distracted. I will send V2 shortly for both drivers.
> Thanks.
Thank you!
> 
> -- 
> Dmitry


  reply	other threads:[~2012-04-24 13:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-20 15:32 Jean-François Dagenais
2012-04-20 15:32 ` [PATCH 2/2] gpio: adp5588 " Jean-François Dagenais
2012-04-21  6:47 ` [PATCH 1/2] input: adp5588-keys " Dmitry Torokhov
2012-04-24 13:33   ` Jean-Francois Dagenais [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-01-09 15:05 Jean-François Dagenais

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=6E61B4B4-D654-41E0-ACF3-FA9F2D4B8C0F@gmail.com \
    --to=jeff.dagenais@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=grant.likely@secretlab.ca \
    --cc=linus.walleij@stericsson.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.hennerich@analog.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

all inboxes | Powered by JetHome®