From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org,
linux-input@vger.kernel.org, linux-leds@vger.kernel.org,
linux-spi@vger.kernel.org, linux-fbdev@vger.kernel.org,
alsa-devel@alsa-project.org,
Andrea Adami <andrea.adami@gmail.com>,
Russell King <linux@arm.linux.org.uk>,
Daniel Mack <daniel@zonque.org>,
Haojian Zhuang <haojian.zhuang@gmail.com>,
Robert Jarzmik <robert.jarzmik@free.fr>,
Linus Walleij <linus.walleij@linaro.org>,
Alexandre Courbot <gnurou@gmail.com>,
Bryan Wu <cooloney@gmail.com>, Richard Purdie <rpurdie@rpsys.net>,
Samuel Ortiz <sameo@linux.intel.com>,
Lee Jones <lee.jones@linaro.org>, Mark Brown <broonie@kernel.org>,
Jingoo Han <jg1.han@samsung.com>,
Liam Girdwood <lgirdwood@gmail.com>
Subject: Re: [PATCH 04/15] input: convert LoCoMo keyboard driver to use new locomo core
Date: Mon, 27 Oct 2014 17:09:38 -0700 [thread overview]
Message-ID: <20141028000938.GE7594@dtor-ws> (raw)
In-Reply-To: <1414454528-24240-5-git-send-email-dbaryshkov@gmail.com>
On Tue, Oct 28, 2014 at 03:01:57AM +0300, Dmitry Eremin-Solenikov wrote:
> As LoCoMo is switching to new device model, adapt keyboard driver to
> support new locomo core driver.
>
> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
> ---
> drivers/input/keyboard/Kconfig | 1 -
> drivers/input/keyboard/locomokbd.c | 165 ++++++++++++++++++++-----------------
> 2 files changed, 91 insertions(+), 75 deletions(-)
>
> diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
> index a3958c6..b660516 100644
> --- a/drivers/input/keyboard/Kconfig
> +++ b/drivers/input/keyboard/Kconfig
> @@ -337,7 +337,6 @@ config KEYBOARD_LM8333
>
> config KEYBOARD_LOCOMO
> tristate "LoCoMo Keyboard Support"
> - depends on SHARP_LOCOMO
> help
> Say Y here if you are running Linux on a Sharp Zaurus Collie or Poodle based PDA
>
> diff --git a/drivers/input/keyboard/locomokbd.c b/drivers/input/keyboard/locomokbd.c
> index c94d610..c2fabf3 100644
> --- a/drivers/input/keyboard/locomokbd.c
> +++ b/drivers/input/keyboard/locomokbd.c
> @@ -28,16 +28,10 @@
> #include <linux/init.h>
> #include <linux/input.h>
> #include <linux/delay.h>
> -#include <linux/device.h>
> +#include <linux/platform_device.h>
> #include <linux/interrupt.h>
> -#include <linux/ioport.h>
> -
> -#include <asm/hardware/locomo.h>
> -#include <asm/irq.h>
> -
> -MODULE_AUTHOR("John Lenz <lenz@cs.wisc.edu>");
> -MODULE_DESCRIPTION("LoCoMo keyboard driver");
> -MODULE_LICENSE("GPL");
> +#include <linux/io.h>
> +#include <linux/mfd/locomo.h>
>
> #define LOCOMOKBD_NUMKEYS 128
>
> @@ -75,7 +69,8 @@ struct locomokbd {
> struct input_dev *input;
> char phys[32];
>
> - unsigned long base;
> + void __iomem *base;
> + int irq;
> spinlock_t lock;
>
> struct timer_list timer;
> @@ -84,37 +79,37 @@ struct locomokbd {
> };
>
> /* helper functions for reading the keyboard matrix */
> -static inline void locomokbd_charge_all(unsigned long membase)
> +static inline void locomokbd_charge_all(void __iomem *membase)
> {
> - locomo_writel(0x00FF, membase + LOCOMO_KSC);
> + writew(0x00FF, membase + LOCOMO_KSC);
> }
>
> -static inline void locomokbd_activate_all(unsigned long membase)
> +static inline void locomokbd_activate_all(void __iomem *membase)
> {
> unsigned long r;
>
> - locomo_writel(0, membase + LOCOMO_KSC);
> - r = locomo_readl(membase + LOCOMO_KIC);
> + writew(0, membase + LOCOMO_KSC);
> + r = readw(membase + LOCOMO_KIC);
> r &= 0xFEFF;
> - locomo_writel(r, membase + LOCOMO_KIC);
> + writew(r, membase + LOCOMO_KIC);
> }
>
> -static inline void locomokbd_activate_col(unsigned long membase, int col)
> +static inline void locomokbd_activate_col(void __iomem *membase, int col)
> {
> unsigned short nset;
> unsigned short nbset;
>
> nset = 0xFF & ~(1 << col);
> nbset = (nset << 8) + nset;
> - locomo_writel(nbset, membase + LOCOMO_KSC);
> + writew(nbset, membase + LOCOMO_KSC);
> }
>
> -static inline void locomokbd_reset_col(unsigned long membase, int col)
> +static inline void locomokbd_reset_col(void __iomem *membase, int col)
> {
> unsigned short nbset;
>
> nbset = ((0xFF & ~(1 << col)) << 8) + 0xFF;
> - locomo_writel(nbset, membase + LOCOMO_KSC);
> + writew(nbset, membase + LOCOMO_KSC);
> }
>
> /*
> @@ -129,7 +124,7 @@ static void locomokbd_scankeyboard(struct locomokbd *locomokbd)
> unsigned int row, col, rowd;
> unsigned long flags;
> unsigned int num_pressed;
> - unsigned long membase = locomokbd->base;
> + void __iomem *membase = locomokbd->base;
>
> spin_lock_irqsave(&locomokbd->lock, flags);
>
> @@ -141,7 +136,7 @@ static void locomokbd_scankeyboard(struct locomokbd *locomokbd)
> locomokbd_activate_col(membase, col);
> udelay(KB_DELAY);
>
> - rowd = ~locomo_readl(membase + LOCOMO_KIB);
> + rowd = ~readw(membase + LOCOMO_KIB);
> for (row = 0; row < KB_ROWS; row++) {
> unsigned int scancode, pressed, key;
>
> @@ -194,11 +189,11 @@ static irqreturn_t locomokbd_interrupt(int irq, void *dev_id)
> struct locomokbd *locomokbd = dev_id;
> u16 r;
>
> - r = locomo_readl(locomokbd->base + LOCOMO_KIC);
> + r = readw(locomokbd->base + LOCOMO_KIC);
> if ((r & 0x0001) == 0)
> return IRQ_HANDLED;
>
> - locomo_writel(r & ~0x0100, locomokbd->base + LOCOMO_KIC); /* Ack */
> + writew(r & ~0x0100, locomokbd->base + LOCOMO_KIC); /* Ack */
>
> /** wait chattering delay **/
> udelay(100);
> @@ -222,8 +217,8 @@ static int locomokbd_open(struct input_dev *dev)
> struct locomokbd *locomokbd = input_get_drvdata(dev);
> u16 r;
>
> - r = locomo_readl(locomokbd->base + LOCOMO_KIC) | 0x0010;
> - locomo_writel(r, locomokbd->base + LOCOMO_KIC);
> + r = readw(locomokbd->base + LOCOMO_KIC) | 0x0010;
> + writew(r, locomokbd->base + LOCOMO_KIC);
> return 0;
> }
>
> @@ -232,35 +227,39 @@ static void locomokbd_close(struct input_dev *dev)
> struct locomokbd *locomokbd = input_get_drvdata(dev);
> u16 r;
>
> - r = locomo_readl(locomokbd->base + LOCOMO_KIC) & ~0x0010;
> - locomo_writel(r, locomokbd->base + LOCOMO_KIC);
> + r = readw(locomokbd->base + LOCOMO_KIC) & ~0x0010;
> + writew(r, locomokbd->base + LOCOMO_KIC);
> }
>
> -static int locomokbd_probe(struct locomo_dev *dev)
> +static int locomokbd_probe(struct platform_device *dev)
> {
> struct locomokbd *locomokbd;
> struct input_dev *input_dev;
> int i, err;
> + struct resource *res;
> +
> + locomokbd = devm_kzalloc(&dev->dev, sizeof(struct locomokbd),
> + GFP_KERNEL);
> + if (!locomokbd)
> + return -ENOMEM;
>
> - locomokbd = kzalloc(sizeof(struct locomokbd), GFP_KERNEL);
> input_dev = input_allocate_device();
> - if (!locomokbd || !input_dev) {
> - err = -ENOMEM;
> - goto err_free_mem;
> - }
> + if (!input_dev)
> + return -ENOMEM;
>
> - /* try and claim memory region */
> - if (!request_mem_region((unsigned long) dev->mapbase,
> - dev->length,
> - LOCOMO_DRIVER_NAME(dev))) {
> - err = -EBUSY;
> - printk(KERN_ERR "locomokbd: Can't acquire access to io memory for keyboard\n");
> - goto err_free_mem;
> - }
> + res = platform_get_resource(dev, IORESOURCE_MEM, 0);
> + if (!res)
> + return -ENODEV;
>
> - locomo_set_drvdata(dev, locomokbd);
> + locomokbd->irq = platform_get_irq(dev, 0);
> + if (locomokbd->irq < 0)
> + return -ENXIO;
>
> - locomokbd->base = (unsigned long) dev->mapbase;
> + platform_set_drvdata(dev, locomokbd);
> +
> + locomokbd->base = devm_ioremap_resource(&dev->dev, res);
> + if (IS_ERR(locomokbd->base))
> + return PTR_ERR(locomokbd->base);
You are leaking memory (input device) here. Since you can't convert all
resources to devm* I'd rather you leave them all explicitly managed
instead of having a mix.
Thanks.
--
Dmitry
next prev parent reply other threads:[~2014-10-28 0:09 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-28 0:01 [PATCH 00/15] new locomo driver Dmitry Eremin-Solenikov
2014-10-28 0:01 ` [PATCH 01/15] mfd: add new driver for Sharp LoCoMo Dmitry Eremin-Solenikov
[not found] ` <1414454528-24240-2-git-send-email-dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-10-31 7:42 ` Linus Walleij
2014-10-31 9:54 ` Dmitry Eremin-Solenikov
[not found] ` <CALT56yNX8v4mZn=o1ZoVLHPmg6wq0dgFNowpqNuFtU=eCc+d8w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-03 13:41 ` Linus Walleij
2014-11-05 20:02 ` Dmitry Eremin-Solenikov
2014-11-05 20:24 ` Mark Brown
2014-11-14 12:47 ` Dmitry Eremin-Solenikov
2014-11-14 15:10 ` Mark Brown
2014-11-14 15:30 ` Dmitry Eremin-Solenikov
2014-11-05 20:32 ` Lars-Peter Clausen
2014-11-05 20:42 ` Lars-Peter Clausen
2014-10-28 0:01 ` [PATCH 02/15] GPIO: port LoCoMo gpio support from old driver Dmitry Eremin-Solenikov
2014-10-31 7:48 ` Linus Walleij
[not found] ` <CACRpkdY7tRadod2vQfEytmw-ubaMAvr_=XTczD5bUMkqie0xkg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-10-31 9:39 ` Dmitry Eremin-Solenikov
[not found] ` <CALT56yOgMUA7o2dzfHph=S2zkDV4zERzMh4ishpPwpAx7Cqj6Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-03 13:43 ` Linus Walleij
[not found] ` <CACRpkdb7v3LmOhbhQ9TPk1_bnLnpwizawW6RQvhQRLSjRewAaQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-05 21:33 ` Dmitry Eremin-Solenikov
2014-11-06 6:03 ` Mark Brown
2014-11-11 13:16 ` Dmitry Eremin-Solenikov
[not found] ` <CALT56yPr42FV66USngocw=eWPt81d5R2MJxmzBnv02HOMmXAkA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-11 13:23 ` Mark Brown
2014-11-14 10:11 ` Linus Walleij
2014-11-14 12:48 ` Dmitry Eremin-Solenikov
2014-10-28 0:01 ` [PATCH 03/15] leds: port locomo leds driver to new locomo core Dmitry Eremin-Solenikov
[not found] ` <1414454528-24240-1-git-send-email-dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-10-28 0:01 ` [PATCH 04/15] input: convert LoCoMo keyboard driver to use " Dmitry Eremin-Solenikov
2014-10-28 0:09 ` Dmitry Torokhov [this message]
2014-10-28 0:02 ` [PATCH 08/15] ARM: sa1100: make collie use new locomo drivers Dmitry Eremin-Solenikov
2014-10-28 0:02 ` [PATCH 12/15] ARM: pxa: poodle: don't preallocate IRQ space for locomo Dmitry Eremin-Solenikov
2014-10-28 19:13 ` Robert Jarzmik
2014-10-28 0:02 ` [PATCH 13/15] ARM: drop old LoCoMo driver Dmitry Eremin-Solenikov
2014-10-28 0:02 ` [PATCH 14/15] gpio: locomo: implement per-pin irq handling Dmitry Eremin-Solenikov
2014-10-31 8:00 ` Linus Walleij
2014-10-31 9:35 ` Dmitry Eremin-Solenikov
2014-10-28 0:02 ` [PATCH 15/15] spi: add locomo SPI driver Dmitry Eremin-Solenikov
[not found] ` <1414454528-24240-16-git-send-email-dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-10-28 11:03 ` Mark Brown
2014-10-28 0:01 ` [PATCH 05/15] video: backlight: add new locomo backlight driver Dmitry Eremin-Solenikov
2014-10-28 0:24 ` Jingoo Han
2014-10-28 0:01 ` [PATCH 06/15] video: lcd: add LoCoMo LCD driver Dmitry Eremin-Solenikov
2014-10-28 0:30 ` Jingoo Han
2014-10-28 16:47 ` Dmitry Eremin-Solenikov
2014-10-28 0:02 ` [PATCH 07/15] video: backlight: drop old locomo bl/lcd driver Dmitry Eremin-Solenikov
2014-10-28 0:02 ` [PATCH 09/15] ARM: sa1100: don't preallocate IRQ space for locomo Dmitry Eremin-Solenikov
2014-10-31 7:50 ` Linus Walleij
2014-10-31 9:33 ` Dmitry Eremin-Solenikov
2014-10-28 0:02 ` [PATCH 10/15] ARM: pxa: poodle: use new LoCoMo driver Dmitry Eremin-Solenikov
2014-10-28 0:02 ` [PATCH 11/15] sound: soc: poodle: make use of new locomo GPIO interface Dmitry Eremin-Solenikov
[not found] ` <1414454528-24240-12-git-send-email-dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-10-28 14:58 ` Mark Brown
[not found] ` <20141028145850.GU18557-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-10-28 16:45 ` Dmitry Eremin-Solenikov
2014-10-29 3:03 ` Alexandre Courbot
[not found] ` <CAAVeFuKgARoMFzf+663iP6cULs93d4WSQS8ESjUb9VcxguWurA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-10-31 9:52 ` Linus Walleij
2014-10-31 9:58 ` Dmitry Eremin-Solenikov
2014-11-01 5:42 ` Alexandre Courbot
2014-10-28 0:13 ` [PATCH 00/15] new locomo driver Russell King - ARM Linux
[not found] ` <20141028001338.GZ27405-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2014-10-28 0:28 ` Dmitry Eremin-Solenikov
2014-10-28 0:29 ` Mark Brown
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=20141028000938.GE7594@dtor-ws \
--to=dmitry.torokhov@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=andrea.adami@gmail.com \
--cc=broonie@kernel.org \
--cc=cooloney@gmail.com \
--cc=daniel@zonque.org \
--cc=dbaryshkov@gmail.com \
--cc=gnurou@gmail.com \
--cc=haojian.zhuang@gmail.com \
--cc=jg1.han@samsung.com \
--cc=lee.jones@linaro.org \
--cc=lgirdwood@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=robert.jarzmik@free.fr \
--cc=rpurdie@rpsys.net \
--cc=sameo@linux.intel.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).