linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miguel Aguilar <miguel.aguilar@ridgerun.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: nsnehaprabha@ti.com,
	davinci-linux-open-source@linux.davincidsp.com,
	linux-input@vger.kernel.org, todd.fischer@ridgerun.com,
	diego.dompe@ridgerun.com, clark.becker@ridgerun.com,
	santiago.nunez@ridgerun.com
Subject: Re: [PATCH 1/3] Input: DaVinci Key Scan Driver
Date: Fri, 25 Sep 2009 08:19:37 -0600	[thread overview]
Message-ID: <4ABCD179.9010007@ridgerun.com> (raw)
In-Reply-To: <20090925040127.GA416@core.coreip.homeip.net>

Dmitry Torokhov wrote:
> On Thu, Sep 24, 2009 at 10:53:22AM -0600, miguel.aguilar@ridgerun.com wrote:
>>  
>> +config KEYBOARD_DAVINCI
>> +	tristate "TI DaVinci Key Scan"
>> +	depends on ARCH_DAVINCI_DM365
>> +	help
>> +	  Say Y to enable keypad module support for the TI DaVinci
>> +	  platforms (DM365).
> 
> Missing period.
[MA] Ok
> 
>> +	  
>> +	  To compile this driver as a module, choose M here: the
>> +	  module will be called davinci_keyscan.
>> +
>> +
>> +static int __init davinci_ks_probe(struct platform_device *pdev)
>> +{
>> +	struct davinci_ks *davinci_ks;
>> +	struct input_dev *key_dev;
>> +	struct resource *res, *mem;
>> +	struct device * dev = &pdev->dev;
>> +	struct davinci_ks_platform_data *pdata = pdev->dev.platform_data;
>> +	int ret, i;
>> +
>> +	dev_info(dev, "DaVinci Key Scan Driver\n");
> 
> The boot is already quite noisy and input core will emit message when
> device is registered so this one is not needed.
[MA] OK.
> 
>> +
>> +	davinci_ks = kzalloc(sizeof(struct davinci_ks) +
>> +		sizeof(unsigned short) * pdata->keymapsize, GFP_KERNEL);
>> +	if(!davinci_ks) {
>> +		dev_dbg(dev, "could not allocate memory for private data\n");
>> +		return -ENOMEM;
>> +	}
>> +
>> +	if (!pdata->keymap) {
>> +		dev_dbg(dev, "no keymap from pdata\n");
> 
> You are leaking davinci_ks here. Maybe you should check pdata->keymap
> first.
[MA] Do you mean check pdata->keymap before davinci_ks allocation?
> 
>> +		return -EINVAL;
>> +	}
>> +
>> +	memcpy(davinci_ks->keymap, pdata->keymap,
>> +		    sizeof(unsigned short) * pdata->keymapsize);
>> +
>> +	key_dev = input_allocate_device();
>> +	if (!key_dev) {
>> +		dev_dbg(dev, "could not allocate input device\n");
>> +		ret = -ENOMEM;
>> +		goto fail1;
>> +	}
>> +
>> +	platform_set_drvdata(pdev, davinci_ks);
>> +
>> +	davinci_ks->input = key_dev;
>> +
>> +	davinci_ks->irq = platform_get_irq(pdev, 0);
>> +	if (davinci_ks->irq < 0) {
>> +		dev_err(dev, "no key scan irq\n");
>> +		ret = davinci_ks->irq;
>> +		goto fail2;
>> +	}
>> +
>> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> +	if (!res) {
>> +		dev_err(dev, "no mem resource\n");
>> +		ret = -EINVAL;
>> +		goto fail2;
>> +	}
>> +
>> +	davinci_ks->pbase = res->start;
>> +	davinci_ks->base_size = resource_size(res);
>> +
>> +	mem = request_mem_region(davinci_ks->pbase, davinci_ks->base_size, pdev->name);
>> +	if (!mem) {
>> +		dev_err(dev, "key scan registers at %08x are not free\n",
>> +			davinci_ks->pbase);
>> +		ret = -EBUSY;
>> +		goto fail2;
>> +	}
>> +
>> +	davinci_ks->base = ioremap(davinci_ks->pbase, davinci_ks->base_size);
>> +	if (!davinci_ks->base) {
>> +		dev_err(dev, "can't ioremap MEM resource.\n");
>> +		ret = -ENOMEM;
>> +		goto fail3;
>> +	}
>> +
>> +	/* Enable auto repeat feature of Linux input subsystem */
>> +	if (pdata->rep)
>> +		__set_bit(EV_REP, key_dev->evbit);
>> +
>> +	/* Setup input device */
>> +	__set_bit(EV_KEY, key_dev->evbit);
>> +
>> +	/* Setup the platform data */
>> +	davinci_ks->pdata = pdata;
>> +
>> +	for (i = 0; i < davinci_ks->pdata->keymapsize; i++)
>> +		__set_bit(davinci_ks->pdata->keymap[i], key_dev->keybit);
>> +
>> +	key_dev->name = "davinci_keyscan";
>> +	key_dev->phys = "davinci_keyscan/input0";
>> +	key_dev->dev.parent = &pdev->dev;
>> +	key_dev->id.bustype = BUS_HOST;
>> +	key_dev->id.vendor = 0x0001;
>> +	key_dev->id.product = 0x0001;
>> +	key_dev->id.version = 0x0001;
>> +	key_dev->keycode = davinci_ks->keymap;
>> +	key_dev->keycodesize = sizeof(davinci_ks->keymap[0]);
>> +	key_dev->keycodemax = davinci_ks->pdata->keymapsize;
>> +
>> +	ret = input_register_device(davinci_ks->input);
>> +	if (ret < 0) {
>> +		dev_err(dev, "unable to register DaVinci keyscan device\n");
>> +		goto fail4;
>> +	}
>> +
>> +	ret = request_irq(davinci_ks->irq, davinci_ks_interrupt, IRQF_DISABLED,
>> +                         "davinci_keyscan", davinci_ks);
>> +	if (ret < 0) {
>> +		dev_err(dev, "unable to register DaVinci keyscan Interrupt\n");
>> +		goto fail5;
>> +	}
> 
> FWIW you may request IRQ before registering the device - as soon as it
> is alloctaed it can survive events going through it.
[MA] Ok. request_irq before input_register_device.
> 

Thanks,

Miguel Aguilar


  reply	other threads:[~2009-09-25 14:19 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-24 16:53 [PATCH 1/3] Input: DaVinci Key Scan Driver miguel.aguilar
2009-09-24 17:13 ` Miguel Aguilar
2009-09-25  4:01 ` Dmitry Torokhov
2009-09-25 14:19   ` Miguel Aguilar [this message]
2009-09-28 17:02     ` Dmitry Torokhov
2009-09-25  6:13 ` Nori, Sekhar
2009-09-25 14:21   ` Miguel Aguilar
2009-09-25 14:31     ` Nori, Sekhar
     [not found]       ` <B85A65D85D7EB246BE421B3FB0FBB59301DDAB36C3-/tLxBxkBPtCIQmiDNMet8wC/G2K4zDHf@public.gmane.org>
2009-09-25 14:39         ` Paulraj, Sandeep
     [not found]           ` <0554BEF07D437848AF01B9C9B5F0BC5D92C8EBC0-bGftbgMkZa+IQmiDNMet8wC/G2K4zDHf@public.gmane.org>
2009-09-25 14:45             ` Miguel Aguilar
2009-09-28 17:02               ` Dmitry Torokhov
2009-09-28 17:06                 ` Paulraj, Sandeep
2009-09-29 21:24                   ` Kevin Hilman
2009-09-30 13:40                     ` Miguel Aguilar
2009-10-05 17:54                       ` Dmitry Torokhov
     [not found]                         ` <20091005175428.GB18588-WlK9ik9hQGAhIp7JRqBPierSzoNAToWh@public.gmane.org>
2009-10-05 19:29                           ` Miguel Aguilar
2009-09-28 17:14               ` Paulraj, Sandeep

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=4ABCD179.9010007@ridgerun.com \
    --to=miguel.aguilar@ridgerun.com \
    --cc=clark.becker@ridgerun.com \
    --cc=davinci-linux-open-source@linux.davincidsp.com \
    --cc=diego.dompe@ridgerun.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=nsnehaprabha@ti.com \
    --cc=santiago.nunez@ridgerun.com \
    --cc=todd.fischer@ridgerun.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).