linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: linux-acpi@vger.kernel.org, linux-i2c@vger.kernel.org,
	linux-gpio@vger.kernel.org, Lee Jones <lee.jones@linaro.org>,
	Wolfram Sang <wsa@the-dreams.de>,
	Linus Walleij <linus.walleij@linaro.org>,
	"Rafael J . Wysocki" <rjw@rjwysocki.net>,
	Mika Westerberg <mika.westerberg@intel.com>,
	"Puustinen, Ismo" <ismo.puustinen@intel.com>,
	"Pandruvada, Srinivas" <srinivas.pandruvada@intel.com>,
	linux-kernel@vger.kernel.org
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v2 5/8] gpio: pca953x: store driver_data for future use
Date: Thu,  1 Oct 2015 14:20:27 +0300	[thread overview]
Message-ID: <1443698430-74415-6-git-send-email-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <1443698430-74415-1-git-send-email-andriy.shevchenko@linux.intel.com>

Instead of using id->driver_data directly we copied it to the internal
structure. This will help to adapt driver for ACPI use.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpio-pca953x.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index 50caeb1..242e244 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -42,6 +42,9 @@
 #define PCA_INT			0x0100
 #define PCA953X_TYPE		0x1000
 #define PCA957X_TYPE		0x2000
+#define PCA_TYPE_MASK		0xF000
+
+#define PCA_CHIP_TYPE(x)	((x) & PCA_TYPE_MASK)
 
 static const struct i2c_device_id pca953x_id[] = {
 	{ "pca9505", 40 | PCA953X_TYPE | PCA_INT, },
@@ -95,6 +98,7 @@ struct pca953x_chip {
 	struct gpio_chip gpio_chip;
 	const char *const *names;
 	int	chip_type;
+	unsigned long driver_data;
 };
 
 static inline struct pca953x_chip *to_pca(struct gpio_chip *gc)
@@ -517,14 +521,13 @@ static irqreturn_t pca953x_irq_handler(int irq, void *devid)
 }
 
 static int pca953x_irq_setup(struct pca953x_chip *chip,
-			     const struct i2c_device_id *id,
 			     int irq_base)
 {
 	struct i2c_client *client = chip->client;
 	int ret, i, offset = 0;
 
 	if (client->irq && irq_base != -1
-			&& (id->driver_data & PCA_INT)) {
+			&& (chip->driver_data & PCA_INT)) {
 
 		switch (chip->chip_type) {
 		case PCA953X_TYPE:
@@ -581,12 +584,11 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
 
 #else /* CONFIG_GPIO_PCA953X_IRQ */
 static int pca953x_irq_setup(struct pca953x_chip *chip,
-			     const struct i2c_device_id *id,
 			     int irq_base)
 {
 	struct i2c_client *client = chip->client;
 
-	if (irq_base != -1 && (id->driver_data & PCA_INT))
+	if (irq_base != -1 && (chip->driver_data & PCA_INT))
 		dev_warn(&client->dev, "interrupt support not compiled in\n");
 
 	return 0;
@@ -673,14 +675,15 @@ static int pca953x_probe(struct i2c_client *client,
 
 	chip->client = client;
 
-	chip->chip_type = id->driver_data & (PCA953X_TYPE | PCA957X_TYPE);
+	chip->driver_data = id->driver_data;
+	chip->chip_type = PCA_CHIP_TYPE(chip->driver_data);
 
 	mutex_init(&chip->i2c_lock);
 
 	/* initialize cached registers from their original values.
 	 * we can't share this chip with another i2c master.
 	 */
-	pca953x_setup_gpio(chip, id->driver_data & PCA_GPIO_MASK);
+	pca953x_setup_gpio(chip, chip->driver_data & PCA_GPIO_MASK);
 
 	if (chip->chip_type == PCA953X_TYPE)
 		ret = device_pca953x_init(chip, invert);
@@ -693,7 +696,7 @@ static int pca953x_probe(struct i2c_client *client,
 	if (ret)
 		return ret;
 
-	ret = pca953x_irq_setup(chip, id, irq_base);
+	ret = pca953x_irq_setup(chip, irq_base);
 	if (ret)
 		return ret;
 
-- 
2.5.1

  parent reply	other threads:[~2015-10-01 11:20 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-01 11:20 [PATCH v2 0/8] enable I2C devices behind I2C bus on Gen2 Andy Shevchenko
2015-10-01 11:20 ` [PATCH v2 1/8] i2c / ACPI: Rework I2C device scanning Andy Shevchenko
2015-10-05 13:47   ` Rafael J. Wysocki
2015-10-01 11:20 ` [PATCH v2 2/8] mfd: core: redo ACPI matching of the children devices Andy Shevchenko
2015-10-01 14:54   ` Lee Jones
2015-10-01 21:59     ` Rafael J. Wysocki
2015-10-05 14:02   ` Rafael J. Wysocki
2015-10-13  9:21   ` Lee Jones
2015-10-01 11:20 ` [PATCH v2 3/8] mfd: intel_quark_i2c_gpio: load gpio driver first Andy Shevchenko
2015-10-01 14:54   ` Lee Jones
2015-10-02 12:11     ` Andy Shevchenko
2015-10-01 11:20 ` [PATCH v2 4/8] mfd: intel_quark_i2c_gpio: support devices behind i2c bus Andy Shevchenko
2015-10-01 11:20 ` Andy Shevchenko [this message]
2015-10-05  8:56   ` [PATCH v2 5/8] gpio: pca953x: store driver_data for future use Linus Walleij
2015-10-01 11:20 ` [PATCH v2 6/8] gpio: pca953x: support ACPI devices found on Galileo Gen2 Andy Shevchenko
2015-10-05  8:59   ` Linus Walleij
2015-10-01 11:20 ` [PATCH v2 7/8] at24: enable ACPI device " Andy Shevchenko
2015-10-01 11:20 ` [PATCH v2 8/8] pwm-pca9685: " Andy Shevchenko
2015-10-05  7:20 ` [PATCH v2 0/8] enable I2C devices behind I2C bus on Gen2 Linus Walleij
2015-10-05  7:28   ` Andy Shevchenko

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=1443698430-74415-6-git-send-email-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=ismo.puustinen@intel.com \
    --cc=lee.jones@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mika.westerberg@intel.com \
    --cc=rjw@rjwysocki.net \
    --cc=srinivas.pandruvada@intel.com \
    --cc=wsa@the-dreams.de \
    /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).