From: Anirudh Ghayal <aghayal@codeaurora.org>
To: "linux-input@vger.kernel.org" <linux-input@vger.kernel.org>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Trilok Soni <tsoni@codeaurora.org>,
linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org
Subject: Re: [rtc-linux] Re: [RFC v1 PATCH 2/6] input: pm8058_keypad: Qualcomm PMIC8058 keypad controller driver
Date: Thu, 06 Jan 2011 17:26:39 +0530 [thread overview]
Message-ID: <4D25ADF7.7010901@codeaurora.org> (raw)
In-Reply-To: <20101206181427.GA18567@core.coreip.homeip.net>
Hi Dimitry,
On 12/6/2010 11:44 PM, Dmitry Torokhov wrote:
> Hi Trilok,
>
> On Wed, Nov 10, 2010 at 06:17:57PM +0530, Trilok Soni wrote:
>> Add Qualcomm PMIC8058 based keypad controller driver
>> supporting upto 18x8 matrix configuration.
>>
>
> Looks very good, just a couple of small things:
>
>> +
>> +#include<linux/input/pmic8058-keypad.h>
>
> Move to MFD directory with the rest of pmic8058 definitions?
>
>> + */
>> +struct pmic8058_kp {
>> + const struct pmic8058_keypad_data *pdata;
>> + struct input_dev *input;
>> + int key_sense_irq;
>> + int key_stuck_irq;
>> +
>> + unsigned short *keycodes;
>
> I'd pull the keycodes into this structure (at the end) so it can be
> allocated in one shot. Hmm it even appears to be constant-sized. So just
> declare it right here and be done with it.
>
>> +
>> +static int pmic8058_detect_ghost_keys(struct pmic8058_kp *kp, u16 *new_state)
>
> bool
>
>> +{
>> + int row, found_first = -1;
>> + u16 check, row_state;
>> +
>> + check = 0;
>> + for (row = 0; row< kp->pdata->num_rows; row++) {
>> + row_state = (~new_state[row])&
>> + ((1<< kp->pdata->num_cols) - 1);
>> +
>> + if (hweight16(row_state)> 1) {
>> + if (found_first == -1)
>> + found_first = row;
>> + if (check& row_state) {
>> + dev_dbg(kp->dev, "detected ghost key on row[%d]"
>> + " and row[%d]\n", found_first, row);
>> + return 1;
>
> true
>
>> + }
>> + }
>> + check |= row_state;
>> + }
>> + return 0;
>
> false
>
>> +
>> +static int pmic8058_kpd_init(struct pmic8058_kp *kp)
>> +{
>> + int bits, rc, cycles;
>> + u8 scan_val = 0, ctrl_val = 0;
>> + static u8 row_bits[] = {
>
> const?
>
>> + 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 7,
>> + };
>> +
>> +}
>> +
>> +static int pmic8058_kp_enable(struct pmic8058_kp *kp)
>> +{
>> + int rc;
>> +
>> + kp->ctrl_reg |= KEYP_CTRL_KEYP_EN;
>> +
>> + rc = pmic8058_kp_write_u8(kp, kp->ctrl_reg, KEYP_CTRL);
>> + if (rc< 0)
>> + return rc;
>> +
>> + enable_irq(kp->key_sense_irq);
>> + enable_irq(kp->key_stuck_irq);
>> +
>> + return rc;
>> +}
>> +
>> +static int pmic8058_kp_disable(struct pmic8058_kp *kp)
>> +{
>> + int rc;
>> +
>> + kp->ctrl_reg&= ~KEYP_CTRL_KEYP_EN;
>> +
>> + rc = pmic8058_kp_write_u8(kp, kp->ctrl_reg, KEYP_CTRL);
>> + if (rc< 0)
>> + return rc;
>> +
>> + disable_irq(kp->key_sense_irq);
>> + disable_irq(kp->key_stuck_irq);
>> +
>> + return rc;
>> +}
>> +
>> +static int pmic8058_kp_open(struct input_dev *dev)
>> +{
>> + struct pmic8058_kp *kp = input_get_drvdata(dev);
>> +
>> + return pmic8058_kp_enable(kp);
>> +}
>> +
>> +static void pmic8058_kp_close(struct input_dev *dev)
>> +{
>> + struct pmic8058_kp *kp = input_get_drvdata(dev);
>> +
>> + pmic8058_kp_disable(kp);
>> +}
>> +
>
> You need to protect suspend/resume from racing with open_close. Take
> dev->mutex and act depending on whether there are users of the device.
In our case, we can only disable/enable the keypad in suspend/resume if
the device is not configured as wakeup. The call pmic8058_kp_disable(kp)
disables the keypad totally rather than placing it in the low power mode
(the hardware does support this capability). So, we plan to add the race
check only if the device is not configured as wakeup capable.
>
>> + if (pdata->rows_gpio_start< 0 || pdata->cols_gpio_start< 0) {
>> + dev_err(&pdev->dev, "invalid gpio_start platform data\n");
>> + return -EINVAL;
>
> These are declared as unsigned. Hmm, doesn't sparse catch it?
>
> Thanks.
>
Thanks,
Anirudh
--
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
next prev parent reply other threads:[~2011-01-06 11:56 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-10 12:47 [RFC v1 PATCH 0/6] Qualcomm PMIC8058 sub-device drivers Trilok Soni
2010-11-10 12:47 ` [RFC v1 PATCH 1/6] matrix_keypad: Increase the max limit of rows and columns Trilok Soni
2010-11-10 18:33 ` Eric Miao
2010-11-10 23:30 ` Dmitry Torokhov
2010-11-17 17:54 ` Dmitry Torokhov
2010-11-10 12:47 ` [RFC v1 PATCH 2/6] input: pm8058_keypad: Qualcomm PMIC8058 keypad controller driver Trilok Soni
2010-11-16 3:49 ` Trilok Soni
2010-11-17 18:02 ` Dmitry Torokhov
2010-12-06 18:14 ` Dmitry Torokhov
2010-12-07 9:22 ` Trilok Soni
2010-12-07 9:30 ` Dmitry Torokhov
2010-12-07 9:32 ` Trilok Soni
2011-01-06 11:56 ` Anirudh Ghayal [this message]
2010-11-10 12:47 ` [RFC v1 PATCH 3/6] led: pmic8058: Add PMIC8058 leds driver Trilok Soni
2010-11-10 20:45 ` Lars-Peter Clausen
2010-11-10 23:28 ` Dmitry Torokhov
2010-11-10 23:50 ` Lars-Peter Clausen
2010-11-11 12:15 ` Trilok Soni
2010-12-06 13:44 ` Trilok Soni
2010-12-07 15:11 ` Lars-Peter Clausen
2010-12-07 15:47 ` Trilok Soni
2010-11-10 12:47 ` [RFC v1 PATCH 4/6] input: pmic8058_pwrkey: Add support for power key Trilok Soni
2010-11-11 7:21 ` Dmitry Torokhov
2010-11-11 12:00 ` Trilok Soni
2010-11-12 0:57 ` Dmitry Torokhov
2010-11-12 8:56 ` Trilok Soni
2010-11-12 19:58 ` Dmitry Torokhov
2010-11-10 12:48 ` [RFC v1 PATCH 5/6] input: pmic8058-othc: Add support for PM8058 based OTHC Trilok Soni
2010-11-16 3:08 ` Trilok Soni
2010-11-16 5:36 ` Datta, Shubhrajyoti
2010-11-16 6:36 ` Trilok Soni
2010-12-01 5:34 ` Anirudh Ghayal
2010-12-07 10:04 ` Dmitry Torokhov
2010-12-07 12:10 ` Anirudh Ghayal
2010-11-10 12:48 ` [RFC v1 PATCH 6/6] drivers: rtc: Add support for Qualcomm PMIC8058 RTC Trilok Soni
2010-11-12 8:53 ` Trilok Soni
2010-11-12 12:53 ` Lars-Peter Clausen
2010-11-12 15:17 ` [rtc-linux] " Anirudh Ghayal
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=4D25ADF7.7010901@codeaurora.org \
--to=aghayal@codeaurora.org \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tsoni@codeaurora.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 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).