mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Linus Walleij <linus.walleij@linaro.org>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Alexandre Courbot <gnurou@gmail.com>,
	Lan Tianyu <tianyu.lan@intel.com>, Lv Zheng <lv.zheng@intel.com>,
	Alan Cox <alan.cox@intel.com>,
	Mathias Nyman <mathias.nyman@linux.intel.com>,
	linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
	Mika Westerberg <mika.westerberg@linux.intel.com>
Subject: [PATCH 4/6] gpio / ACPI: Embed events list directly into struct acpi_gpio_chip
Date: Mon, 24 Feb 2014 18:00:09 +0200	[thread overview]
Message-ID: <1393257611-18031-5-git-send-email-mika.westerberg@linux.intel.com> (raw)
In-Reply-To: <1393257611-18031-1-git-send-email-mika.westerberg@linux.intel.com>

It is not necessary to have events as a pointer to list in struct
acpi_gpio_chip. Instead we can embed the list_head directly to struct
acpi_gpio_chip itself. This makes event handling a bit simpler because now
we don't need to check whether the pointer is NULL or not.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/gpio/gpiolib-acpi.c | 35 +++++++++++++----------------------
 1 file changed, 13 insertions(+), 22 deletions(-)

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index cb99dc2c552e..c60db4ddc166 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -28,7 +28,7 @@ struct acpi_gpio_event {
 
 struct acpi_gpio_chip {
 	struct gpio_chip *chip;
-	struct list_head *events;
+	struct list_head events;
 };
 
 static int acpi_gpiochip_find(struct gpio_chip *gc, void *data)
@@ -106,8 +106,7 @@ static void acpi_gpiochip_request_interrupts(struct acpi_gpio_chip *achip)
 	struct acpi_buffer buf = {ACPI_ALLOCATE_BUFFER, NULL};
 	struct gpio_chip *chip = achip->chip;
 	struct acpi_resource *res;
-	acpi_handle handle, evt_handle;
-	struct list_head *events = NULL;
+	acpi_handle handle;
 	acpi_status status;
 	unsigned int pin;
 	int irq, ret;
@@ -120,19 +119,12 @@ static void acpi_gpiochip_request_interrupts(struct acpi_gpio_chip *achip)
 	if (!handle)
 		return;
 
+	INIT_LIST_HEAD(&achip->events);
+
 	status = acpi_get_event_resources(handle, &buf);
 	if (ACPI_FAILURE(status))
 		return;
 
-	status = acpi_get_handle(handle, "_EVT", &evt_handle);
-	if (ACPI_SUCCESS(status)) {
-		events = kzalloc(sizeof(*events), GFP_KERNEL);
-		if (events) {
-			INIT_LIST_HEAD(events);
-			achip->events = events;
-		}
-	}
-
 	/*
 	 * If a GPIO interrupt has an ACPI event handler method, or _EVT is
 	 * present, set up an interrupt handler that calls the ACPI event
@@ -168,14 +160,19 @@ static void acpi_gpiochip_request_interrupts(struct acpi_gpio_chip *achip)
 				data = ev_handle;
 			}
 		}
-		if (!handler && events) {
+		if (!handler) {
 			struct acpi_gpio_event *event;
+			acpi_handle evt_handle;
+
+			status = acpi_get_handle(handle, "_EVT", &evt_handle);
+			if (ACPI_FAILURE(status))
+				continue;
 
 			event = kzalloc(sizeof(*event), GFP_KERNEL);
 			if (!event)
 				continue;
 
-			list_add_tail(&event->node, events);
+			list_add_tail(&event->node, &achip->events);
 			event->evt_handle = evt_handle;
 			event->pin = pin;
 			event->irq = irq;
@@ -207,23 +204,17 @@ static void acpi_gpiochip_request_interrupts(struct acpi_gpio_chip *achip)
  */
 static void acpi_gpiochip_free_interrupts(struct acpi_gpio_chip *achip)
 {
-	struct list_head *events;
 	struct acpi_gpio_event *event, *ep;
 	struct gpio_chip *chip = achip->chip;
 
-	if (!chip->dev || !chip->to_irq || !achip->events)
+	if (!chip->dev || !chip->to_irq)
 		return;
 
-	events = achip->events;
-	achip->events = NULL;
-
-	list_for_each_entry_safe_reverse(event, ep, events, node) {
+	list_for_each_entry_safe_reverse(event, ep, &achip->events, node) {
 		devm_free_irq(chip->dev, event->irq, event);
 		list_del(&event->node);
 		kfree(event);
 	}
-
-	kfree(events);
 }
 
 struct acpi_gpio_lookup {
-- 
1.9.0.rc3


  parent reply	other threads:[~2014-02-24 16:01 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-24 16:00 [PATCH 0/6] gpio / ACPI: Rework ACPI GPIO events and add support for operation regions Mika Westerberg
2014-02-24 16:00 ` [PATCH 1/6] gpiolib: Allow GPIO chips to request their own GPIOs Mika Westerberg
2014-02-25 14:10   ` Rafael J. Wysocki
2014-02-26  9:05     ` Mika Westerberg
2014-02-26 13:47       ` Rafael J. Wysocki
2014-02-27  9:48         ` Mika Westerberg
2014-03-05  2:49   ` Linus Walleij
2014-03-05 12:05     ` Mika Westerberg
2014-03-05 13:07       ` Rafael J. Wysocki
2014-03-06  2:16     ` Alexandre Courbot
2014-02-24 16:00 ` [PATCH 2/6] gpio / ACPI: Allocate ACPI specific data directly in acpi_gpiochip_add() Mika Westerberg
2014-02-25 14:21   ` Rafael J. Wysocki
2014-02-26  9:08     ` Mika Westerberg
2014-02-24 16:00 ` [PATCH 3/6] gpio / ACPI: Rename acpi_gpio_evt_pin to acpi_gpio_event Mika Westerberg
2014-02-25 14:23   ` Rafael J. Wysocki
2014-02-26  9:09     ` Mika Westerberg
2014-02-24 16:00 ` Mika Westerberg [this message]
2014-02-25 14:26   ` [PATCH 4/6] gpio / ACPI: Embed events list directly into struct acpi_gpio_chip Rafael J. Wysocki
2014-02-26  9:10     ` Mika Westerberg
2014-02-24 16:00 ` [PATCH 5/6] gpio / ACPI: Rework ACPI GPIO event handling Mika Westerberg
2014-02-25 14:44   ` Rafael J. Wysocki
2014-02-26  9:10     ` Mika Westerberg
2014-02-24 16:00 ` [PATCH 6/6] gpio / ACPI: Add support for ACPI GPIO operation regions Mika Westerberg
2014-02-25 14:55   ` Rafael J. Wysocki
2014-02-26  9:11     ` Mika Westerberg

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=1393257611-18031-5-git-send-email-mika.westerberg@linux.intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=alan.cox@intel.com \
    --cc=gnurou@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lv.zheng@intel.com \
    --cc=mathias.nyman@linux.intel.com \
    --cc=rjw@rjwysocki.net \
    --cc=tianyu.lan@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

Powered by JetHome