All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Brownell <david-b@pacbell.net>
To: Trilok Soni <soni.trilok@gmail.com>
Cc: linux-input@vger.kernel.org, OMAP <linux-omap@vger.kernel.org>
Subject: Re: [patch/rfc 2.6.28-rc2] input: twl4030_keypad driver
Date: Thu, 22 Jan 2009 09:42:49 -0800	[thread overview]
Message-ID: <200901220942.50252.david-b@pacbell.net> (raw)
In-Reply-To: <5d5443650901212309u10bdbf46pb76950f49fc7cebb@mail.gmail.com>

Hi,

On Wednesday 21 January 2009, Trilok Soni wrote:
> > +
> > +static void twl4030_kp_scan(struct twl4030_keypad *kp, int release_all)
> > +{
> > +       u16 new_state[MAX_ROWS];
> > +       int col, row;
> > +
> > +       ...
> > +
> > +                       key = twl4030_find_key(kp, col, row);
> > +                       if (key < 0)
> > +                               dev_warn(kp->dbg_dev,
> > +                                       "Spurious key event %d-%d\n",
> > +                                        col, row);
> > +                       else if (key & KEY_PERSISTENT)
> > +                               continue;
> > +                       else
> > +                               input_report_key(kp->input, key,
> > +                                                new_state[row] & (1 << col));
> > +               }
> > +               kp->kp_state[row] = new_state[row];
> > +       }
> 
> where do I find input_sync(...) being called?

Yeah, I was wondering about that too.  The code
obviously works without it ... I'll add that call
anyway.


> > +
> > +       dev_set_drvdata(&pdev->dev, kp);
> 
> How about platform_set_drvdata ??

Those calls are exactly equivalent, although you're
right that platform_* versions are preferred.  Either
is correct.


> > +       /* setup input device */
> > +       set_bit(EV_KEY, kp->input->evbit);
> 
> __set_bit please.
> 
> > +
> > +       /* Enable auto repeat feature of Linux input subsystem */
> > +       if (pdata->rep)
> > +               set_bit(EV_REP, kp->input->evbit);
> > +
> > +       for (i = 0; i < kp->keymapsize; i++)
> > +               set_bit(kp->keymap[i] & KEYNUM_MASK,
> > +                               kp->input->keybit);
> 
> Ditto.

The practical difference there being that __set_bit() is
a bit less costly (space and time), being non-atomic; there
is no semantic difference.  Either is correct.


> > +       /*
> > +        * This ISR will always execute in kernel thread context because of
> > +        * the need to access the TWL4030 over the I2C bus.
> > +        *
> > +        * NOTE:  we assume this host is wired to TWL4040 INT1, not INT2 ...
> > +        */
> > +       ret = request_irq(kp->irq, do_kp_irq, 0, pdev->name, kp);
> 
> How about adding IRQF_SAMPLE_RANDOME here ??

Input system does that automagically; it should not be
sampled twice.


> > +err5:
> > +       /* mask all events - we don't care about the result */
> > +       (void) twl4030_kpwrite_u8(kp, 0xff, KEYP_IMR1);
> > +       free_irq(kp->irq, NULL);
> > +err3:
> > +       input_unregister_device(kp->input);
> 
> No free_device after input_unregister_device. Add kp->input = NULL above.
> 
> > +err2:
> > +       input_free_device(kp->input);

and kfree(kp) was missing too ...

I'll merge the following with any other feedback.

- Dave

---
 drivers/input/keyboard/twl4030_keypad.c |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

--- a/drivers/input/keyboard/twl4030_keypad.c
+++ b/drivers/input/keyboard/twl4030_keypad.c
@@ -260,6 +260,7 @@ static void twl4030_kp_scan(struct twl40
 		}
 		kp->kp_state[row] = new_state[row];
 	}
+	input_sync(kp->input);
 }
 
 /*
@@ -316,7 +317,7 @@ static int __devinit twl4030_kp_probe(st
 
 	/* ASSERT:  cols <= 8, rows <= 8 */
 
-	dev_set_drvdata(&pdev->dev, kp);
+	platform_set_drvdata(pdev, kp);
 
 	/* Get the debug Device */
 	kp->dbg_dev = &pdev->dev;
@@ -334,14 +335,14 @@ static int __devinit twl4030_kp_probe(st
 	kp->irq = platform_get_irq(pdev, 0);
 
 	/* setup input device */
-	set_bit(EV_KEY, kp->input->evbit);
+	__set_bit(EV_KEY, kp->input->evbit);
 
 	/* Enable auto repeat feature of Linux input subsystem */
 	if (pdata->rep)
-		set_bit(EV_REP, kp->input->evbit);
+		__set_bit(EV_REP, kp->input->evbit);
 
 	for (i = 0; i < kp->keymapsize; i++)
-		set_bit(kp->keymap[i] & KEYNUM_MASK,
+		__set_bit(kp->keymap[i] & KEYNUM_MASK,
 				kp->input->keybit);
 
 	kp->input->name	= "TWL4030 Keypad";
@@ -441,15 +442,16 @@ err5:
 	free_irq(kp->irq, NULL);
 err3:
 	input_unregister_device(kp->input);
+	kp->input = NULL;
 err2:
 	input_free_device(kp->input);
-
+	kfree(kp);
 	return -ENODEV;
 }
 
 static int __devexit twl4030_kp_remove(struct platform_device *pdev)
 {
-	struct twl4030_keypad *kp = dev_get_drvdata(&pdev->dev);
+	struct twl4030_keypad *kp = platform_get_drvdata(pdev);
 
 	free_irq(kp->irq, kp);
 	input_unregister_device(kp->input);


  reply	other threads:[~2009-01-22 17:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-22  0:13 [patch/rfc 2.6.28-rc2] input: twl4030_keypad driver David Brownell
2009-01-22  7:09 ` Trilok Soni
2009-01-22 17:42   ` David Brownell [this message]
2009-01-22 17:57     ` Trilok Soni
2009-01-30  0:17 ` hartleys
2009-01-30  0:57   ` David Brownell
2009-01-30 17:13     ` hartleys
2009-02-06  1:11       ` David Brownell

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=200901220942.50252.david-b@pacbell.net \
    --to=david-b@pacbell.net \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=soni.trilok@gmail.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 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.