summaryrefslogtreecommitdiffstats
path: root/drivers/usb/host
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2017-03-08 14:09:01 -0800
committerSascha Hauer <s.hauer@pengutronix.de>2017-03-09 11:51:27 +0100
commitfb1ff1794a29a282927bd859e3c6ff2a304a8ea6 (patch)
tree0ccb73047f85bfbd65d7ddaefe2b3ee41140a922 /drivers/usb/host
parent56f3bd1cd31fe1caefb13189b351640c40d5d2b0 (diff)
downloadbarebox-fb1ff1794a29a282927bd859e3c6ff2a304a8ea6.tar.gz
barebox-fb1ff1794a29a282927bd859e3c6ff2a304a8ea6.tar.xz
usb: ohci-at91: Convert global variables to private data
Store driver data in per-device private variable as opposed to storing it in global vairables. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/usb/host')
-rw-r--r--drivers/usb/host/ohci-at91.c59
1 files changed, 37 insertions, 22 deletions
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index ca583ff4d0..cd7b321fda 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -27,66 +27,81 @@
#include "ohci.h"
-/* interface and function clocks; sometimes also an AHB clock */
-static struct clk *iclk, *fclk;
+struct ohci_at91_priv {
+ struct device_d *dev;
+ struct clk *iclk;
+ struct clk *fclk;
+ struct ohci_regs __iomem *regs;
+};
-static void at91_start_clock(void)
+static void at91_start_clock(struct ohci_at91_priv *ohci_at91)
{
- clk_enable(iclk);
- clk_enable(fclk);
+ clk_enable(ohci_at91->iclk);
+ clk_enable(ohci_at91->fclk);
}
-static void at91_stop_clock(void)
+static void at91_stop_clock(struct ohci_at91_priv *ohci_at91)
{
- clk_disable(fclk);
- clk_disable(iclk);
+ clk_disable(ohci_at91->fclk);
+ clk_disable(ohci_at91->iclk);
}
static int at91_ohci_probe(struct device_d *dev)
{
- struct ohci_regs __iomem *regs = (struct ohci_regs __iomem *)dev->resource[0].start;
+ struct resource *io;
+ struct ohci_at91_priv *ohci_at91 = xzalloc(sizeof(*ohci_at91));
+
+ dev->priv = ohci_at91;
+ ohci_at91->dev = dev;
+
+ io = dev_get_resource(dev, IORESOURCE_MEM, 0);
+ if (IS_ERR(io)) {
+ dev_err(dev, "Failed to get IORESOURCE_MEM\n");
+ return PTR_ERR(io);
+ }
+ ohci_at91->regs = IOMEM(io->start);
- iclk = clk_get(NULL, "ohci_clk");
- if (IS_ERR(iclk)) {
+ ohci_at91->iclk = clk_get(NULL, "ohci_clk");
+ if (IS_ERR(ohci_at91->iclk)) {
dev_err(dev, "Failed to get 'ohci_clk'\n");
- return PTR_ERR(iclk);
+ return PTR_ERR(ohci_at91->iclk);
}
- fclk = clk_get(NULL, "uhpck");
- if (IS_ERR(fclk)) {
+ ohci_at91->fclk = clk_get(NULL, "uhpck");
+ if (IS_ERR(ohci_at91->fclk)) {
dev_err(dev, "Failed to get 'uhpck'\n");
- return PTR_ERR(fclk);
+ return PTR_ERR(ohci_at91->fclk);
}
/*
* Start the USB clocks.
*/
- at91_start_clock();
+ at91_start_clock(ohci_at91);
/*
* The USB host controller must remain in reset.
*/
- writel(0, &regs->control);
+ writel(0, &ohci_at91->regs->control);
- add_generic_device("ohci", DEVICE_ID_DYNAMIC, NULL, dev->resource[0].start,
- resource_size(&dev->resource[0]), IORESOURCE_MEM, NULL);
+ add_generic_device("ohci", DEVICE_ID_DYNAMIC, NULL, io->start,
+ resource_size(io), IORESOURCE_MEM, NULL);
return 0;
}
static void at91_ohci_remove(struct device_d *dev)
{
- struct ohci_regs __iomem *regs = (struct ohci_regs __iomem *)dev->resource[0].start;
+ struct ohci_at91_priv *ohci_at91 = dev->priv;
/*
* Put the USB host controller into reset.
*/
- writel(0, &regs->control);
+ writel(0, &ohci_at91->regs->control);
/*
* Stop the USB clocks.
*/
- at91_stop_clock();
+ at91_stop_clock(ohci_at91);
}
static struct driver_d at91_ohci_driver = {