linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "qipeng.zha" <qipeng.zha@intel.com>
To: linux-gpio@vger.kernel.org
Cc: linus.walleij@linaro.org, mika.westerberg@intel.com,
	qi.zheng@intel.com, "qipeng.zha" <qipeng.zha@intel.com>
Subject: [PATCH] gpiolib: fix issue of gpio acpi handler
Date: Fri,  6 Mar 2015 23:08:38 +0800	[thread overview]
Message-ID: <1425654518-48935-1-git-send-email-qipeng.zha@intel.com> (raw)

From: "qipeng.zha" <qipeng.zha@intel.com>

If GPIO driver use pin mapping, need to tranlate pin number
between ACPI table and GPIO driver.

This issue is found on one platform with Cherryview gpio
controller, kernel is hang when executed _PS0 method of
one ACPI device, since without this translation, it access
invalid gpiodesc array.

Verified it works again with this patch.

Signed-off-by: qipeng.zha <qipeng.zha@intel.com>
---
 drivers/gpio/gpiolib-acpi.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index c0929d9..661e272 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -551,6 +551,13 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
 		struct gpio_desc *desc;
 		bool found;
 
+		/*Translate ACPI gpio pin to offset in gpio driver*/
+		pin = acpi_gpiochip_pin_to_gpio_offset(chip, pin);
+		if (pin < 0) {
+			status = AE_BAD_PARAMETER;
+			goto out;
+		}
+
 		mutex_lock(&achip->conn_lock);
 
 		found = false;
-- 
1.8.3.2


             reply	other threads:[~2015-03-06  7:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-06 15:08 qipeng.zha [this message]
2015-03-09 11:12 ` [PATCH] gpiolib: fix issue of gpio acpi handler Mika Westerberg
2015-03-09 11:14   ` 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=1425654518-48935-1-git-send-email-qipeng.zha@intel.com \
    --to=qipeng.zha@intel.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=mika.westerberg@intel.com \
    --cc=qi.zheng@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).