linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
To: linux-kernel@vger.kernel.org
Cc: Paul Mundt <lethal@linux-sh.org>,
	Magnus Damm <magnus.damm@gmail.com>,
	Simon Horman <horms@verge.net.au>,
	Linus Walleij <linus.walleij@linaro.org>,
	Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>,
	Phil Edworthy <phil.edworthy@renesas.com>,
	Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
Subject: [PATCH 10/42] sh-pfc: Support passing resources through platform device
Date: Wed, 21 Nov 2012 03:27:11 +0100	[thread overview]
Message-ID: <1353464863-10281-11-git-send-email-laurent.pinchart+renesas@ideasonboard.com> (raw)
In-Reply-To: <1353464863-10281-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com>

Resources should be passed through the platform device, not through
platform data. Default to platform device resources and fall back to
platform data resources if not available.

Support for platform data resources will be removed when arch code will
be converted.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/sh/pfc/core.c |   29 +++++++++++++++++++++--------
 drivers/sh/pfc/core.h |    2 ++
 2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/drivers/sh/pfc/core.c b/drivers/sh/pfc/core.c
index 9736e3d..4e4adc7 100644
--- a/drivers/sh/pfc/core.c
+++ b/drivers/sh/pfc/core.c
@@ -30,29 +30,42 @@ static void pfc_iounmap(struct sh_pfc *pfc)
 {
 	int k;
 
-	for (k = 0; k < pfc->pdata->num_resources; k++)
+	for (k = 0; k < pfc->num_windows; k++)
 		if (pfc->window[k].virt)
 			iounmap(pfc->window[k].virt);
 
 	kfree(pfc->window);
+	pfc->num_windows = 0;
 	pfc->window = NULL;
 }
 
-static int pfc_ioremap(struct sh_pfc *pfc)
+static int pfc_ioremap(struct sh_pfc *pfc, struct platform_device *pdev)
 {
+	unsigned int num_resources;
 	struct resource *res;
 	int k;
 
-	if (!pfc->pdata->num_resources)
+	if (pdev->num_resources) {
+		num_resources = pdev->num_resources;
+		res = pdev->resource;
+	} else {
+		num_resources = pfc->pdata->num_resources;
+		res = pfc->pdata->resource;
+	}
+
+	if (num_resources == 0) {
+		pfc->num_windows = 0;
 		return 0;
+	}
 
-	pfc->window = kzalloc(pfc->pdata->num_resources * sizeof(*pfc->window),
+	pfc->window = kzalloc(num_resources * sizeof(*pfc->window),
 			      GFP_NOWAIT);
 	if (!pfc->window)
 		goto err1;
 
-	for (k = 0; k < pfc->pdata->num_resources; k++) {
-		res = pfc->pdata->resource + k;
+	pfc->num_windows = num_resources;
+
+	for (k = 0; k < num_resources; k++, res++) {
 		WARN_ON(resource_type(res) != IORESOURCE_MEM);
 		pfc->window[k].phys = res->start;
 		pfc->window[k].size = resource_size(res);
@@ -77,7 +90,7 @@ static void __iomem *pfc_phys_to_virt(struct sh_pfc *pfc,
 	int k;
 
 	/* scan through physical windows and convert address */
-	for (k = 0; k < pfc->pdata->num_resources; k++) {
+	for (k = 0; k < pfc->num_windows; k++) {
 		window = pfc->window + k;
 
 		if (address < window->phys)
@@ -516,7 +529,7 @@ static int sh_pfc_probe(struct platform_device *pdev)
 	pfc->pdata = pdata;
 	pfc->dev = &pdev->dev;
 
-	ret = pfc_ioremap(pfc);
+	ret = pfc_ioremap(pfc, pdev);
 	if (unlikely(ret < 0))
 		return ret;
 
diff --git a/drivers/sh/pfc/core.h b/drivers/sh/pfc/core.h
index 1287b3e..b71f559 100644
--- a/drivers/sh/pfc/core.h
+++ b/drivers/sh/pfc/core.h
@@ -28,7 +28,9 @@ struct sh_pfc {
 	struct sh_pfc_platform_data *pdata;
 	spinlock_t lock;
 
+	unsigned int num_windows;
 	struct pfc_window *window;
+
 	struct sh_pfc_chip *gpio;
 	struct sh_pfc_pinctrl *pinctrl;
 };
-- 
1.7.8.6


  parent reply	other threads:[~2012-11-21  2:36 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-21  2:27 [PATCH 00/42] SH pin control and GPIO rework Laurent Pinchart
2012-11-21  2:27 ` [PATCH 01/42] sh-pfc: Split platform data from the sh_pfc structure Laurent Pinchart
2012-11-21  2:27 ` [PATCH 02/42] sh-pfc: Move private definitions and declarations to private header Laurent Pinchart
2012-11-21  2:27 ` [PATCH 03/42] sh-pfc: Merge PFC core and pinctrl Laurent Pinchart
2012-11-21  2:27 ` [PATCH 04/42] sh-pfc: Merge PFC core and gpio Laurent Pinchart
2012-11-21  2:27 ` [PATCH 05/42] sh-pfc: Move platform device and driver to the core Laurent Pinchart
2012-11-21  2:27 ` [PATCH 06/42] sh-pfc: Let the compiler decide whether to inline functions Laurent Pinchart
2012-11-21  2:27 ` [PATCH 07/42] sh-pfc: Remove check for impossible error condition Laurent Pinchart
2012-11-21  2:27 ` [PATCH 08/42] sh-pfc: Sort headers alphabetically Laurent Pinchart
2012-11-21  2:27 ` [PATCH 09/42] sh-pfc: Split platform device and platform driver registration Laurent Pinchart
2012-11-21  2:27 ` Laurent Pinchart [this message]
2012-11-21  2:27 ` [PATCH 11/42] ARM: shmobile: Register PFC platform device Laurent Pinchart
2012-11-21  5:16   ` Simon Horman
2012-11-21 12:43     ` Laurent Pinchart
2012-11-26  1:02       ` Simon Horman
2012-11-26 10:34         ` Laurent Pinchart
2012-11-27  2:26           ` Simon Horman
2012-11-27 11:19             ` Laurent Pinchart
2012-11-28  0:58               ` Simon Horman
2012-11-21  2:27 ` [PATCH 12/42] SH: " Laurent Pinchart
2012-11-21  2:27 ` [PATCH 13/42] sh-pfc: Remove platform device registration Laurent Pinchart
2012-11-21  2:27 ` [PATCH 14/42] sh-pfc: Remove unused resource and num_resources platform data fields Laurent Pinchart
2012-11-21  2:27 ` [PATCH 15/42] ARM: shmobile: Select PINCTRL Laurent Pinchart
2012-11-21  2:27 ` [PATCH 16/42] sh: Select PINCTRL for CPU subtypes that require it Laurent Pinchart
2012-11-21  2:27 ` [PATCH 17/42] sh-pfc: Move driver from drivers/sh/ to drivers/pinctrl/ Laurent Pinchart
2012-11-21  3:28   ` viresh kumar
2012-11-21 13:17     ` Laurent Pinchart
2012-11-21  2:27 ` [PATCH 18/42] sh-pfc: Support pinmux info in driver data instead of platform data Laurent Pinchart
2012-11-21  2:27 ` [PATCH 19/42] sh-pfc: Add r8a7740 pinmux support Laurent Pinchart
2012-11-21  2:27 ` [PATCH 20/42] sh-pfc: Add r8a7779 " Laurent Pinchart
2012-11-21  2:27 ` [PATCH 21/42] sh-pfc: Add sh7367 " Laurent Pinchart
2012-11-22  4:56   ` Nobuhiro Iwamatsu
2012-11-21  2:27 ` [PATCH 22/42] sh-pfc: Add sh7372 " Laurent Pinchart
2012-11-21  2:27 ` [PATCH 23/42] sh-pfc: Add sh7377 " Laurent Pinchart
2012-11-22  4:55   ` Nobuhiro Iwamatsu
2012-11-22 11:12     ` Laurent Pinchart
2012-11-21  2:27 ` [PATCH 24/42] sh-pfc: Add sh73a0 " Laurent Pinchart
2012-11-21  2:27 ` [PATCH 25/42] ARM: shmobile: pfc: Use driver-provided pinmux info Laurent Pinchart
2012-11-21  2:27 ` [PATCH 26/42] sh-pfc: Add sh7203 pinmux support Laurent Pinchart
2012-11-21  2:27 ` [PATCH 27/42] sh-pfc: Add sh7264 " Laurent Pinchart
2012-11-21  2:27 ` [PATCH 28/42] sh-pfc: Add sh7269 " Laurent Pinchart
2012-11-21  2:27 ` [PATCH 29/42] sh-pfc: Add sh7720 " Laurent Pinchart
2012-11-21  2:27 ` [PATCH 30/42] sh-pfc: Add sh7722 " Laurent Pinchart
2012-11-21  2:27 ` [PATCH 31/42] sh-pfc: Add sh7723 " Laurent Pinchart
2012-11-21  2:27 ` [PATCH 32/42] sh-pfc: Add sh7724 " Laurent Pinchart
2012-11-21  2:27 ` [PATCH 33/42] sh-pfc: Add sh7734 " Laurent Pinchart
2012-11-21  2:27 ` [PATCH 34/42] sh-pfc: Add sh7757 " Laurent Pinchart
2012-11-21  2:27 ` [PATCH 35/42] sh-pfc: Add sh7785 " Laurent Pinchart
2012-11-21  2:27 ` [PATCH 36/42] sh-pfc: Add sh7786 " Laurent Pinchart
2012-11-21  2:27 ` [PATCH 37/42] sh-pfc: Add shx3 " Laurent Pinchart
2012-11-21  2:27 ` [PATCH 39/42] sh-pfc: Remove pinmux_info definition Laurent Pinchart
2012-11-21  2:27 ` [PATCH 40/42] sh-pfc: Move sh_pfc.h from include/linux/ to driver directory Laurent Pinchart
2012-11-21  2:27 ` [PATCH 41/42] ARM: shmobile: r8a7740: Add pin control resources Laurent Pinchart
2012-11-21  2:27 ` [PATCH 42/42] ARM: shmobile: sh7372: " Laurent Pinchart
2012-11-21  4:23 ` [PATCH 00/42] SH pin control and GPIO rework Paul Mundt
2012-11-21 14:51 ` 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=1353464863-10281-11-git-send-email-laurent.pinchart+renesas@ideasonboard.com \
    --to=laurent.pinchart+renesas@ideasonboard.com \
    --cc=horms@verge.net.au \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=lethal@linux-sh.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=nobuhiro.iwamatsu.yj@renesas.com \
    --cc=phil.edworthy@renesas.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).