From: Daniel Mack <daniel@caiaq.de>
To: H Hartley Sweeten <hartleys@visionengravers.com>
Cc: linux-input@vger.kernel.org
Subject: Re: [PATCH] Input: rotary_encoder cleanup
Date: Tue, 23 Jun 2009 18:21:26 +0200 [thread overview]
Message-ID: <20090623162126.GL29236@buzzloop.caiaq.de> (raw)
In-Reply-To: <BD79186B4FD85F4B8E60E381CAEE1909019683A5@mi8nycmail19.Mi8.com>
On Sat, Jun 20, 2009 at 06:15:51PM -0400, H Hartley Sweeten wrote:
> There is no need to carry the two irq numbers in the allocated memory.
> They are only needed for the free_irq() calls during the remove. Since
> the driver is already carrying the platform_data we can just call
> gpio_to_irq() to get the irq number.
>
> Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Acked-by: Daniel Mack <daniel@caiaq.de>
Thanks!
> diff --git a/drivers/input/misc/rotary_encoder.c b/drivers/input/misc/rotary_encoder.c
> index c806fbf..910d2db 100644
> --- a/drivers/input/misc/rotary_encoder.c
> +++ b/drivers/input/misc/rotary_encoder.c
> @@ -32,9 +32,6 @@ struct rotary_encoder {
> unsigned int axis;
> unsigned int pos;
>
> - unsigned int irq_a;
> - unsigned int irq_b;
> -
> bool armed;
> unsigned char dir; /* 0 - clockwise, 1 - CCW */
> };
> @@ -121,8 +118,6 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev)
>
> encoder->input = input;
> encoder->pdata = pdata;
> - encoder->irq_a = gpio_to_irq(pdata->gpio_a);
> - encoder->irq_b = gpio_to_irq(pdata->gpio_b);
>
> /* create and register the input driver */
> input->name = pdev->name;
> @@ -160,21 +155,21 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev)
> }
>
> /* request the IRQs */
> - err = request_irq(encoder->irq_a, &rotary_encoder_irq,
> + err = request_irq(gpio_to_irq(pdata->gpio_a), &rotary_encoder_irq,
> IORESOURCE_IRQ_HIGHEDGE | IORESOURCE_IRQ_LOWEDGE,
> DRV_NAME, encoder);
> if (err) {
> dev_err(&pdev->dev, "unable to request IRQ %d\n",
> - encoder->irq_a);
> + gpio_to_irq(pdata->gpio_a));
> goto exit_free_gpio_b;
> }
>
> - err = request_irq(encoder->irq_b, &rotary_encoder_irq,
> + err = request_irq(gpio_to_irq(pdata->gpio_b), &rotary_encoder_irq,
> IORESOURCE_IRQ_HIGHEDGE | IORESOURCE_IRQ_LOWEDGE,
> DRV_NAME, encoder);
> if (err) {
> dev_err(&pdev->dev, "unable to request IRQ %d\n",
> - encoder->irq_b);
> + gpio_to_irq(pdata->gpio_b));
> goto exit_free_irq_a;
> }
>
> @@ -183,7 +178,7 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev)
> return 0;
>
> exit_free_irq_a:
> - free_irq(encoder->irq_a, encoder);
> + free_irq(gpio_to_irq(pdata->gpio_a), encoder);
> exit_free_gpio_b:
> gpio_free(pdata->gpio_b);
> exit_free_gpio_a:
> @@ -202,8 +197,8 @@ static int __devexit rotary_encoder_remove(struct platform_device *pdev)
> struct rotary_encoder *encoder = platform_get_drvdata(pdev);
> struct rotary_encoder_platform_data *pdata = pdev->dev.platform_data;
>
> - free_irq(encoder->irq_a, encoder);
> - free_irq(encoder->irq_b, encoder);
> + free_irq(gpio_to_irq(pdata->gpio_a), encoder);
> + free_irq(gpio_to_irq(pdata->gpio_b), encoder);
> gpio_free(pdata->gpio_a);
> gpio_free(pdata->gpio_b);
> input_unregister_device(encoder->input);
> --
> To unsubscribe from this list: send the line "unsubscribe linux-input" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2009-06-23 16:21 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-20 22:15 [PATCH] Input: rotary_encoder cleanup H Hartley Sweeten
2009-06-23 16:21 ` Daniel Mack [this message]
2009-06-30 2:32 ` Dmitry Torokhov
2009-06-30 15:56 ` H Hartley Sweeten
2009-07-01 18:33 ` Daniel Mack
2009-07-01 18:45 ` H Hartley Sweeten
2009-07-01 18:49 ` Daniel Mack
2009-07-07 18:32 ` H Hartley Sweeten
2009-07-08 6:56 ` Dmitry Torokhov
2009-07-08 21:47 ` H Hartley Sweeten
2009-07-09 4:17 ` Dmitry Torokhov
2009-07-09 16:31 ` H Hartley Sweeten
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=20090623162126.GL29236@buzzloop.caiaq.de \
--to=daniel@caiaq.de \
--cc=hartleys@visionengravers.com \
--cc=linux-input@vger.kernel.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).