Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: t.figa@samsung.com (Tomasz Figa)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 08/15] pinctrl: samsung: Hold pointer to driver data in bank struct
Date: Thu, 11 Oct 2012 10:11:14 +0200	[thread overview]
Message-ID: <1349943081-27939-9-git-send-email-t.figa@samsung.com> (raw)
In-Reply-To: <1349943081-27939-1-git-send-email-t.figa@samsung.com>

This patch is a preparation for converting the pinctrl-samsung driver to
one GPIO chip and IRQ domain per bank. It allows one having only
a pointer to particular bank struct to access driver data struct.

Signed-off-by: Tomasz Figa <t.figa@samsung.com>
---
 drivers/pinctrl/pinctrl-samsung.c | 18 ++++++++++--------
 drivers/pinctrl/pinctrl-samsung.h |  2 ++
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-samsung.c b/drivers/pinctrl/pinctrl-samsung.c
index f266710..53493c3 100644
--- a/drivers/pinctrl/pinctrl-samsung.c
+++ b/drivers/pinctrl/pinctrl-samsung.c
@@ -789,17 +789,18 @@ static const struct of_device_id samsung_pinctrl_dt_match[];
 
 /* retrieve the soc specific data */
 static struct samsung_pin_ctrl *samsung_pinctrl_get_soc_data(
+				struct samsung_pinctrl_drv_data *d,
 				struct platform_device *pdev)
 {
 	int id;
 	const struct of_device_id *match;
-	const struct device_node *node = pdev->dev.of_node;
+	struct device_node *node = pdev->dev.of_node;
 	struct device_node *np;
 	struct samsung_pin_ctrl *ctrl;
 	struct samsung_pin_bank *bank;
 	int i;
 
-	id = of_alias_get_id(pdev->dev.of_node, "pinctrl");
+	id = of_alias_get_id(node, "pinctrl");
 	if (id < 0) {
 		dev_err(&pdev->dev, "failed to get alias id\n");
 		return NULL;
@@ -809,6 +810,7 @@ static struct samsung_pin_ctrl *samsung_pinctrl_get_soc_data(
 
 	bank = ctrl->pin_banks;
 	for (i = 0; i < ctrl->nr_banks; ++i, ++bank) {
+		bank->drvdata = d;
 		bank->pin_base = ctrl->nr_pins;
 		ctrl->nr_pins += bank->nr_pins;
 		if (bank->eint_type == EINT_TYPE_GPIO) {
@@ -848,18 +850,18 @@ static int __devinit samsung_pinctrl_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	ctrl = samsung_pinctrl_get_soc_data(pdev);
-	if (!ctrl) {
-		dev_err(&pdev->dev, "driver data not available\n");
-		return -EINVAL;
-	}
-
 	drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
 	if (!drvdata) {
 		dev_err(dev, "failed to allocate memory for driver's "
 				"private data\n");
 		return -ENOMEM;
 	}
+
+	ctrl = samsung_pinctrl_get_soc_data(drvdata, pdev);
+	if (!ctrl) {
+		dev_err(&pdev->dev, "driver data not available\n");
+		return -EINVAL;
+	}
 	drvdata->ctrl = ctrl;
 	drvdata->dev = dev;
 
diff --git a/drivers/pinctrl/pinctrl-samsung.h b/drivers/pinctrl/pinctrl-samsung.h
index 5c53f32..ea5dadd 100644
--- a/drivers/pinctrl/pinctrl-samsung.h
+++ b/drivers/pinctrl/pinctrl-samsung.h
@@ -112,6 +112,7 @@ struct samsung_pinctrl_drv_data;
  * @irq_base: starting controller local irq number of the bank.
  * @name: name to be prefixed for each pin in this pin bank.
  * @of_node: OF node of the bank.
+ * @drvdata: link to controller driver data
  */
 struct samsung_pin_bank {
 	u32		pctl_offset;
@@ -126,6 +127,7 @@ struct samsung_pin_bank {
 	u32		irq_base;
 	char		*name;
 	struct device_node *of_node;
+	struct samsung_pinctrl_drv_data *drvdata;
 };
 
 /**
-- 
1.7.12

  parent reply	other threads:[~2012-10-11  8:11 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-11  8:11 [PATCH v2 00/15] pinctrl: samsung: Usability and extensibiltiy improvements Tomasz Figa
2012-10-11  8:11 ` [PATCH 01/15] pinctrl: samsung: Detect and handle unsupported configuration types Tomasz Figa
2012-10-11 13:57   ` Linus Walleij
2012-10-11 14:00     ` Kyungmin Park
2012-10-11 14:06       ` Linus Walleij
2012-10-11  8:11 ` [PATCH 02/15] pinctrl: samsung: Do not pass gpio_chip to pin_to_reg_bank Tomasz Figa
2012-10-11  8:11 ` [PATCH 03/15] pinctrl: samsung: Assing pin numbers dynamically Tomasz Figa
2012-10-11  8:11 ` [PATCH 04/15] pinctrl: samsung: Remove static pin enumerations Tomasz Figa
2012-10-11  8:11 ` [PATCH 05/15] pinctrl: samsung: Distinguish between pin group and bank nodes Tomasz Figa
2012-10-11  8:11 ` [PATCH 06/15] ARM: dts: exynos4210-pinctrl: Add nodes for pin banks Tomasz Figa
2012-10-11  8:11 ` [PATCH 07/15] pinctrl: samsung: Match pin banks with their device nodes Tomasz Figa
2012-10-11  8:11 ` Tomasz Figa [this message]
2012-10-11  8:11 ` [PATCH 09/15] pinctrl: samsung: Include bank-specific eint offset in bank struct Tomasz Figa
2012-10-11  8:11 ` [PATCH 10/15] pinctrl: exynos: Use one IRQ domain per pin bank Tomasz Figa
2012-10-11  8:11 ` [PATCH 11/15] pinctrl: samsung: Use one GPIO chip " Tomasz Figa
2012-10-11  8:11 ` [PATCH 12/15] pinctrl: samsung: Use per-bank IRQ domain for wake-up interrupts Tomasz Figa
2012-10-11  8:11 ` [PATCH 13/15] pinctrl: exynos: Set pin function to EINT in irq_set_type of wake-up EINT Tomasz Figa
2012-10-11  8:11 ` [PATCH 14/15] pinctrl: samsung: Add GPIO to IRQ translation Tomasz Figa
2012-10-11  8:11 ` [PATCH 15/15] Documentation: Update samsung-pinctrl device tree bindings documentation Tomasz Figa
2012-10-11  9:01 ` [PATCH v2 00/15] pinctrl: samsung: Usability and extensibiltiy improvements Kyungmin Park
2012-10-11 12:50 ` Thomas Abraham
2012-10-11 14:05 ` Linus Walleij
2012-10-11 14:20 ` Linus Walleij

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=1349943081-27939-9-git-send-email-t.figa@samsung.com \
    --to=t.figa@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.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