linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Input: rotary_encoder cleanup
@ 2009-06-20 22:15 H Hartley Sweeten
  2009-06-23 16:21 ` Daniel Mack
  0 siblings, 1 reply; 12+ messages in thread
From: H Hartley Sweeten @ 2009-06-20 22:15 UTC (permalink / raw)
  To: linux-input; +Cc: Daniel Mack

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>
Cc: Daniel Mack <daniel@caiaq.de>

---

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); 

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2009-07-09 16:31 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-20 22:15 [PATCH] Input: rotary_encoder cleanup H Hartley Sweeten
2009-06-23 16:21 ` Daniel Mack
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

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).