diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c index fa9ca7d5b..7a9d942a1 100644 --- a/drivers/usb/host/ehci-atmel.c +++ b/drivers/usb/host/ehci-atmel.c @@ -29,29 +29,34 @@ #include "ehci.h" -/* interface and function clocks; sometimes also an AHB clock */ -static struct clk *iclk, *fclk; +struct atmel_ehci_priv { + struct device_d *dev; + struct clk *iclk; + struct clk *uclk; +}; -static int atmel_start_clock(void) +static int atmel_start_clock(struct atmel_ehci_priv *atehci) { int ret; - ret = clk_enable(iclk); + ret = clk_enable(atehci->iclk); if (ret < 0) { - pr_err("Error enabling interface clock\n"); + dev_err(atehci->dev, + "Error enabling interface clock\n"); return ret; } - ret = clk_enable(fclk); + ret = clk_enable(atehci->uclk); if (ret < 0) - pr_err("Error enabling function clock\n"); + dev_err(atehci->dev, + "Error enabling function clock\n"); return ret; } -static void atmel_stop_clock(void) +static void atmel_stop_clock(struct atmel_ehci_priv *atehci) { - clk_disable(fclk); - clk_disable(iclk); + clk_disable(atehci->iclk); + clk_disable(atehci->uclk); } static int atmel_ehci_probe(struct device_d *dev) @@ -59,15 +64,20 @@ static int atmel_ehci_probe(struct device_d *dev) int ret; struct resource *iores; struct ehci_data data; + struct atmel_ehci_priv *atehci; - iclk = clk_get(dev, "ehci_clk"); - if (IS_ERR(iclk)) { + atehci = xzalloc(sizeof(*atehci)); + atehci->dev = dev; + dev->priv = atehci; + + atehci->iclk = clk_get(dev, "ehci_clk"); + if (IS_ERR(atehci->iclk)) { dev_err(dev, "Error getting interface clock\n"); return -ENOENT; } - fclk = clk_get(dev, "uhpck"); - if (IS_ERR(fclk)) { + atehci->uclk = clk_get(dev, "uhpck"); + if (IS_ERR(atehci->iclk)) { dev_err(dev, "Error getting function clock\n"); return -ENOENT; } @@ -75,7 +85,7 @@ static int atmel_ehci_probe(struct device_d *dev) /* * Start the USB clocks. */ - ret = atmel_start_clock(); + ret = atmel_start_clock(atehci); if (ret < 0) return ret; @@ -96,7 +106,7 @@ static void atmel_ehci_remove(struct device_d *dev) /* * Stop the USB clocks. */ - atmel_stop_clock(); + atmel_stop_clock(dev->priv); } static struct driver_d atmel_ehci_driver = {