From: Magnus Damm <magnus.damm@gmail.com>
To: linux-pci@vger.kernel.org
Cc: horms@verge.net.au, linux-sh@vger.kernel.org,
linux-kernel@vger.kernel.org,
valentine.barshak@cogentembedded.com, ben.dooks@codethink.co.uk,
geert@linux-m68k.org, bhelgaas@google.com,
Magnus Damm <magnus.damm@gmail.com>
Subject: [PATCH v2 04/08] PCI: rcar: Register each instance independently
Date: Thu, 13 Feb 2014 12:03:42 +0900 [thread overview]
Message-ID: <20140213030342.10398.10051.sendpatchset@w520> (raw)
In-Reply-To: <20140213030302.10398.37322.sendpatchset@w520>
From: Magnus Damm <damm@opensource.se>
Convert the code to allow per-device probe() like other device
drivers. This also delays driver registration due to change from
subsys_initcall() to regular module_platform_driver().
Signed-off-by: Magnus Damm <damm@opensource.se>
---
Changes since V1:
- Updated to fit on top of patches from Ben Dooks
- Use hw_private[1] for hw.private_data, thanks Geert!
- Use ARRAY_SIZE with hw_private for hw.nr_controllers
drivers/pci/host/pci-rcar-gen2.c | 76 +++++++++-----------------------------
1 file changed, 18 insertions(+), 58 deletions(-)
--- 0006/drivers/pci/host/pci-rcar-gen2.c
+++ work/drivers/pci/host/pci-rcar-gen2.c 2014-02-13 10:10:25.000000000 +0900
@@ -91,9 +91,6 @@
#define RCAR_PCI_UNIT_REV_REG (RCAR_AHBPCI_PCICOM_OFFSET + 0x48)
-/* Number of internal PCI controllers */
-#define RCAR_PCI_NR_CONTROLLERS 3
-
struct rcar_pci_priv {
struct device *dev;
void __iomem *reg;
@@ -292,6 +289,8 @@ static int __init rcar_pci_setup(int nr,
pci_add_resource(&sys->resources, &priv->io_res);
pci_add_resource(&sys->resources, &priv->mem_res);
+ /* Setup bus number based on platform device id */
+ sys->busnr = to_platform_device(priv->dev)->id;
return 1;
}
@@ -300,48 +299,13 @@ static struct pci_ops rcar_pci_ops = {
.write = rcar_pci_write_config,
};
-static struct hw_pci rcar_hw_pci __initdata = {
- .map_irq = rcar_pci_map_irq,
- .ops = &rcar_pci_ops,
- .setup = rcar_pci_setup,
-};
-
-static int rcar_pci_count __initdata;
-
-static int __init rcar_pci_add_controller(struct rcar_pci_priv *priv)
-{
- void **private_data;
- int count;
-
- if (rcar_hw_pci.nr_controllers < rcar_pci_count)
- goto add_priv;
-
- /* (Re)allocate private data pointer array if needed */
- count = rcar_pci_count + RCAR_PCI_NR_CONTROLLERS;
- private_data = kzalloc(count * sizeof(void *), GFP_KERNEL);
- if (!private_data)
- return -ENOMEM;
-
- rcar_pci_count = count;
- if (rcar_hw_pci.private_data) {
- memcpy(private_data, rcar_hw_pci.private_data,
- rcar_hw_pci.nr_controllers * sizeof(void *));
- kfree(rcar_hw_pci.private_data);
- }
-
- rcar_hw_pci.private_data = private_data;
-
-add_priv:
- /* Add private data pointer to the array */
- rcar_hw_pci.private_data[rcar_hw_pci.nr_controllers++] = priv;
- return 0;
-}
-
-static int __init rcar_pci_probe(struct platform_device *pdev)
+static int rcar_pci_probe(struct platform_device *pdev)
{
struct resource *cfg_res, *mem_res;
struct rcar_pci_priv *priv;
void __iomem *reg;
+ struct hw_pci hw;
+ void *hw_private[1];
cfg_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
reg = devm_ioremap_resource(&pdev->dev, cfg_res);
@@ -377,31 +341,27 @@ static int __init rcar_pci_probe(struct
return priv->irq;
}
- return rcar_pci_add_controller(priv);
+ hw_private[0] = priv;
+ memset(&hw, 0, sizeof(hw));
+ hw.nr_controllers = ARRAY_SIZE(hw_private);
+ hw.private_data = hw_private;
+ hw.map_irq = rcar_pci_map_irq;
+ hw.ops = &rcar_pci_ops;
+ hw.setup = rcar_pci_setup;
+ pci_common_init_dev(&pdev->dev, &hw);
+ return 0;
}
static struct platform_driver rcar_pci_driver = {
.driver = {
.name = "pci-rcar-gen2",
+ .owner = THIS_MODULE,
+ .suppress_bind_attrs = true,
},
+ .probe = rcar_pci_probe,
};
-static int __init rcar_pci_init(void)
-{
- int retval;
-
- retval = platform_driver_probe(&rcar_pci_driver, rcar_pci_probe);
- if (!retval)
- pci_common_init(&rcar_hw_pci);
-
- /* Private data pointer array is not needed any more */
- kfree(rcar_hw_pci.private_data);
- rcar_hw_pci.private_data = NULL;
-
- return retval;
-}
-
-subsys_initcall(rcar_pci_init);
+module_platform_driver(rcar_pci_driver);
MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("Renesas R-Car Gen2 internal PCI");
WARNING: multiple messages have this Message-ID (diff)
From: Magnus Damm <magnus.damm@gmail.com>
To: linux-pci@vger.kernel.org
Cc: horms@verge.net.au, linux-sh@vger.kernel.org,
linux-kernel@vger.kernel.org,
valentine.barshak@cogentembedded.com, ben.dooks@codethink.co.uk,
geert@linux-m68k.org, bhelgaas@google.com,
Magnus Damm <magnus.damm@gmail.com>
Subject: [PATCH v2 04/08] PCI: rcar: Register each instance independently
Date: Thu, 13 Feb 2014 03:03:42 +0000 [thread overview]
Message-ID: <20140213030342.10398.10051.sendpatchset@w520> (raw)
In-Reply-To: <20140213030302.10398.37322.sendpatchset@w520>
From: Magnus Damm <damm@opensource.se>
Convert the code to allow per-device probe() like other device
drivers. This also delays driver registration due to change from
subsys_initcall() to regular module_platform_driver().
Signed-off-by: Magnus Damm <damm@opensource.se>
---
Changes since V1:
- Updated to fit on top of patches from Ben Dooks
- Use hw_private[1] for hw.private_data, thanks Geert!
- Use ARRAY_SIZE with hw_private for hw.nr_controllers
drivers/pci/host/pci-rcar-gen2.c | 76 +++++++++-----------------------------
1 file changed, 18 insertions(+), 58 deletions(-)
--- 0006/drivers/pci/host/pci-rcar-gen2.c
+++ work/drivers/pci/host/pci-rcar-gen2.c 2014-02-13 10:10:25.000000000 +0900
@@ -91,9 +91,6 @@
#define RCAR_PCI_UNIT_REV_REG (RCAR_AHBPCI_PCICOM_OFFSET + 0x48)
-/* Number of internal PCI controllers */
-#define RCAR_PCI_NR_CONTROLLERS 3
-
struct rcar_pci_priv {
struct device *dev;
void __iomem *reg;
@@ -292,6 +289,8 @@ static int __init rcar_pci_setup(int nr,
pci_add_resource(&sys->resources, &priv->io_res);
pci_add_resource(&sys->resources, &priv->mem_res);
+ /* Setup bus number based on platform device id */
+ sys->busnr = to_platform_device(priv->dev)->id;
return 1;
}
@@ -300,48 +299,13 @@ static struct pci_ops rcar_pci_ops = {
.write = rcar_pci_write_config,
};
-static struct hw_pci rcar_hw_pci __initdata = {
- .map_irq = rcar_pci_map_irq,
- .ops = &rcar_pci_ops,
- .setup = rcar_pci_setup,
-};
-
-static int rcar_pci_count __initdata;
-
-static int __init rcar_pci_add_controller(struct rcar_pci_priv *priv)
-{
- void **private_data;
- int count;
-
- if (rcar_hw_pci.nr_controllers < rcar_pci_count)
- goto add_priv;
-
- /* (Re)allocate private data pointer array if needed */
- count = rcar_pci_count + RCAR_PCI_NR_CONTROLLERS;
- private_data = kzalloc(count * sizeof(void *), GFP_KERNEL);
- if (!private_data)
- return -ENOMEM;
-
- rcar_pci_count = count;
- if (rcar_hw_pci.private_data) {
- memcpy(private_data, rcar_hw_pci.private_data,
- rcar_hw_pci.nr_controllers * sizeof(void *));
- kfree(rcar_hw_pci.private_data);
- }
-
- rcar_hw_pci.private_data = private_data;
-
-add_priv:
- /* Add private data pointer to the array */
- rcar_hw_pci.private_data[rcar_hw_pci.nr_controllers++] = priv;
- return 0;
-}
-
-static int __init rcar_pci_probe(struct platform_device *pdev)
+static int rcar_pci_probe(struct platform_device *pdev)
{
struct resource *cfg_res, *mem_res;
struct rcar_pci_priv *priv;
void __iomem *reg;
+ struct hw_pci hw;
+ void *hw_private[1];
cfg_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
reg = devm_ioremap_resource(&pdev->dev, cfg_res);
@@ -377,31 +341,27 @@ static int __init rcar_pci_probe(struct
return priv->irq;
}
- return rcar_pci_add_controller(priv);
+ hw_private[0] = priv;
+ memset(&hw, 0, sizeof(hw));
+ hw.nr_controllers = ARRAY_SIZE(hw_private);
+ hw.private_data = hw_private;
+ hw.map_irq = rcar_pci_map_irq;
+ hw.ops = &rcar_pci_ops;
+ hw.setup = rcar_pci_setup;
+ pci_common_init_dev(&pdev->dev, &hw);
+ return 0;
}
static struct platform_driver rcar_pci_driver = {
.driver = {
.name = "pci-rcar-gen2",
+ .owner = THIS_MODULE,
+ .suppress_bind_attrs = true,
},
+ .probe = rcar_pci_probe,
};
-static int __init rcar_pci_init(void)
-{
- int retval;
-
- retval = platform_driver_probe(&rcar_pci_driver, rcar_pci_probe);
- if (!retval)
- pci_common_init(&rcar_hw_pci);
-
- /* Private data pointer array is not needed any more */
- kfree(rcar_hw_pci.private_data);
- rcar_hw_pci.private_data = NULL;
-
- return retval;
-}
-
-subsys_initcall(rcar_pci_init);
+module_platform_driver(rcar_pci_driver);
MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("Renesas R-Car Gen2 internal PCI");
next prev parent reply other threads:[~2014-02-13 3:02 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-13 3:03 [PATCH 00/08] PCI: rcar: Recent driver patches from Ben Dooks and me Magnus Damm
2014-02-13 3:03 ` Magnus Damm
2014-02-13 3:03 ` [PATCH 01/08] PCI: rcar: check platform_get_irq() return code Magnus Damm
2014-02-13 3:03 ` Magnus Damm
2014-02-13 3:03 ` [PATCH v2 02/08] PCI: rcar: add error interrupt handling Magnus Damm
2014-02-13 3:03 ` Magnus Damm
2014-02-13 3:03 ` [PATCH 03/08] PCI: rcar: fix bridge logic configuration accesses Magnus Damm
2014-02-13 3:03 ` Magnus Damm
2014-02-13 3:03 ` Magnus Damm [this message]
2014-02-13 3:03 ` [PATCH v2 04/08] PCI: rcar: Register each instance independently Magnus Damm
2014-02-13 3:03 ` [PATCH v2 05/08] PCI: rcar: Break out window size handling Magnus Damm
2014-02-13 3:03 ` Magnus Damm
2014-02-13 3:04 ` [PATCH v2 06/08] PCI: rcar: Add DMABOUNCE support Magnus Damm
2014-02-13 3:04 ` Magnus Damm
2014-02-13 3:04 ` [PATCH 07/08] PCI: rcar: Enable BOUNCE in case of HIGHMEM Magnus Damm
2014-02-13 3:04 ` Magnus Damm
2014-02-13 3:04 ` [PATCH 08/08] PCI: rcar: Make the Kconfig dependencies more generic Magnus Damm
2014-02-13 3:04 ` Magnus Damm
2014-02-13 4:39 ` [PATCH 00/08] PCI: rcar: Recent driver patches from Ben Dooks and me Simon Horman
2014-02-13 4:39 ` Simon Horman
2014-02-14 18:34 ` Bjorn Helgaas
2014-02-14 18:34 ` Bjorn Helgaas
2014-02-17 1:12 ` Simon Horman
2014-02-17 1:12 ` Simon Horman
2014-02-13 12:34 ` Ben Dooks
2014-02-14 5:40 ` Magnus Damm
2014-02-14 5:40 ` Magnus Damm
2014-02-14 10:52 ` Ben Dooks
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=20140213030342.10398.10051.sendpatchset@w520 \
--to=magnus.damm@gmail.com \
--cc=ben.dooks@codethink.co.uk \
--cc=bhelgaas@google.com \
--cc=geert@linux-m68k.org \
--cc=horms@verge.net.au \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=valentine.barshak@cogentembedded.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.