提交 124dafde 编写于 作者: S Sebastian Andrzej Siewior 提交者: Felipe Balbi

usb: dwc3: remove custom unique id handling

The lockless implementation of the unique id is quite impressive (:P)
but dirver's core can handle it, we can remove it and make our code a
little smaller.

Cc: Anton Tikhomirov <av.tikhomirov@samsung.com>
Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: NFelipe Balbi <balbi@ti.com>
上级 6f115e45
...@@ -66,45 +66,6 @@ MODULE_PARM_DESC(maximum_speed, "Maximum supported speed."); ...@@ -66,45 +66,6 @@ MODULE_PARM_DESC(maximum_speed, "Maximum supported speed.");
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
#define DWC3_DEVS_POSSIBLE 32
static DECLARE_BITMAP(dwc3_devs, DWC3_DEVS_POSSIBLE);
int dwc3_get_device_id(void)
{
int id;
again:
id = find_first_zero_bit(dwc3_devs, DWC3_DEVS_POSSIBLE);
if (id < DWC3_DEVS_POSSIBLE) {
int old;
old = test_and_set_bit(id, dwc3_devs);
if (old)
goto again;
} else {
pr_err("dwc3: no space for new device\n");
id = -ENOMEM;
}
return id;
}
EXPORT_SYMBOL_GPL(dwc3_get_device_id);
void dwc3_put_device_id(int id)
{
int ret;
if (id < 0)
return;
ret = test_bit(id, dwc3_devs);
WARN(!ret, "dwc3: ID %d not in use\n", id);
smp_mb__before_clear_bit();
clear_bit(id, dwc3_devs);
}
EXPORT_SYMBOL_GPL(dwc3_put_device_id);
void dwc3_set_mode(struct dwc3 *dwc, u32 mode) void dwc3_set_mode(struct dwc3 *dwc, u32 mode)
{ {
u32 reg; u32 reg;
......
...@@ -868,7 +868,4 @@ void dwc3_host_exit(struct dwc3 *dwc); ...@@ -868,7 +868,4 @@ void dwc3_host_exit(struct dwc3 *dwc);
int dwc3_gadget_init(struct dwc3 *dwc); int dwc3_gadget_init(struct dwc3 *dwc);
void dwc3_gadget_exit(struct dwc3 *dwc); void dwc3_gadget_exit(struct dwc3 *dwc);
extern int dwc3_get_device_id(void);
extern void dwc3_put_device_id(int id);
#endif /* __DRIVERS_USB_DWC3_CORE_H */ #endif /* __DRIVERS_USB_DWC3_CORE_H */
...@@ -94,7 +94,6 @@ static int __devinit dwc3_exynos_probe(struct platform_device *pdev) ...@@ -94,7 +94,6 @@ static int __devinit dwc3_exynos_probe(struct platform_device *pdev)
struct dwc3_exynos *exynos; struct dwc3_exynos *exynos;
struct clk *clk; struct clk *clk;
int devid;
int ret = -ENOMEM; int ret = -ENOMEM;
exynos = kzalloc(sizeof(*exynos), GFP_KERNEL); exynos = kzalloc(sizeof(*exynos), GFP_KERNEL);
...@@ -105,20 +104,16 @@ static int __devinit dwc3_exynos_probe(struct platform_device *pdev) ...@@ -105,20 +104,16 @@ static int __devinit dwc3_exynos_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, exynos); platform_set_drvdata(pdev, exynos);
devid = dwc3_get_device_id();
if (devid < 0)
goto err1;
ret = dwc3_exynos_register_phys(exynos); ret = dwc3_exynos_register_phys(exynos);
if (ret) { if (ret) {
dev_err(&pdev->dev, "couldn't register PHYs\n"); dev_err(&pdev->dev, "couldn't register PHYs\n");
goto err1; goto err1;
} }
dwc3 = platform_device_alloc("dwc3", devid); dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO);
if (!dwc3) { if (!dwc3) {
dev_err(&pdev->dev, "couldn't allocate dwc3 device\n"); dev_err(&pdev->dev, "couldn't allocate dwc3 device\n");
goto err2; goto err1;
} }
clk = clk_get(&pdev->dev, "usbdrd30"); clk = clk_get(&pdev->dev, "usbdrd30");
...@@ -170,8 +165,6 @@ static int __devinit dwc3_exynos_probe(struct platform_device *pdev) ...@@ -170,8 +165,6 @@ static int __devinit dwc3_exynos_probe(struct platform_device *pdev)
clk_put(clk); clk_put(clk);
err3: err3:
platform_device_put(dwc3); platform_device_put(dwc3);
err2:
dwc3_put_device_id(devid);
err1: err1:
kfree(exynos); kfree(exynos);
err0: err0:
...@@ -187,8 +180,6 @@ static int __devexit dwc3_exynos_remove(struct platform_device *pdev) ...@@ -187,8 +180,6 @@ static int __devexit dwc3_exynos_remove(struct platform_device *pdev)
platform_device_unregister(exynos->usb2_phy); platform_device_unregister(exynos->usb2_phy);
platform_device_unregister(exynos->usb3_phy); platform_device_unregister(exynos->usb3_phy);
dwc3_put_device_id(exynos->dwc3->id);
if (pdata && pdata->phy_exit) if (pdata && pdata->phy_exit)
pdata->phy_exit(pdev, pdata->phy_type); pdata->phy_exit(pdev, pdata->phy_type);
......
...@@ -272,7 +272,6 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev) ...@@ -272,7 +272,6 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
struct resource *res; struct resource *res;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
int devid;
int size; int size;
int ret = -ENOMEM; int ret = -ENOMEM;
int irq; int irq;
...@@ -315,14 +314,10 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev) ...@@ -315,14 +314,10 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
return ret; return ret;
} }
devid = dwc3_get_device_id(); dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO);
if (devid < 0)
return -ENODEV;
dwc3 = platform_device_alloc("dwc3", devid);
if (!dwc3) { if (!dwc3) {
dev_err(dev, "couldn't allocate dwc3 device\n"); dev_err(dev, "couldn't allocate dwc3 device\n");
goto err1; return -ENOMEM;
} }
context = devm_kzalloc(dev, resource_size(res), GFP_KERNEL); context = devm_kzalloc(dev, resource_size(res), GFP_KERNEL);
...@@ -423,10 +418,6 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev) ...@@ -423,10 +418,6 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
err2: err2:
platform_device_put(dwc3); platform_device_put(dwc3);
err1:
dwc3_put_device_id(devid);
return ret; return ret;
} }
...@@ -437,9 +428,6 @@ static int __devexit dwc3_omap_remove(struct platform_device *pdev) ...@@ -437,9 +428,6 @@ static int __devexit dwc3_omap_remove(struct platform_device *pdev)
platform_device_unregister(omap->dwc3); platform_device_unregister(omap->dwc3);
platform_device_unregister(omap->usb2_phy); platform_device_unregister(omap->usb2_phy);
platform_device_unregister(omap->usb3_phy); platform_device_unregister(omap->usb3_phy);
dwc3_put_device_id(omap->dwc3->id);
return 0; return 0;
} }
......
...@@ -119,7 +119,6 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci, ...@@ -119,7 +119,6 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci,
struct platform_device *dwc3; struct platform_device *dwc3;
struct dwc3_pci *glue; struct dwc3_pci *glue;
int ret = -ENOMEM; int ret = -ENOMEM;
int devid;
struct device *dev = &pci->dev; struct device *dev = &pci->dev;
glue = devm_kzalloc(dev, sizeof(*glue), GFP_KERNEL); glue = devm_kzalloc(dev, sizeof(*glue), GFP_KERNEL);
...@@ -145,13 +144,7 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci, ...@@ -145,13 +144,7 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci,
return ret; return ret;
} }
devid = dwc3_get_device_id(); dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO);
if (devid < 0) {
ret = -ENOMEM;
goto err1;
}
dwc3 = platform_device_alloc("dwc3", devid);
if (!dwc3) { if (!dwc3) {
dev_err(dev, "couldn't allocate dwc3 device\n"); dev_err(dev, "couldn't allocate dwc3 device\n");
ret = -ENOMEM; ret = -ENOMEM;
...@@ -172,7 +165,7 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci, ...@@ -172,7 +165,7 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci,
ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res)); ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res));
if (ret) { if (ret) {
dev_err(dev, "couldn't add resources to dwc3 device\n"); dev_err(dev, "couldn't add resources to dwc3 device\n");
goto err2; goto err1;
} }
pci_set_drvdata(pci, glue); pci_set_drvdata(pci, glue);
...@@ -195,10 +188,6 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci, ...@@ -195,10 +188,6 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci,
err3: err3:
pci_set_drvdata(pci, NULL); pci_set_drvdata(pci, NULL);
platform_device_put(dwc3); platform_device_put(dwc3);
err2:
dwc3_put_device_id(devid);
err1: err1:
pci_disable_device(pci); pci_disable_device(pci);
...@@ -211,7 +200,6 @@ static void __devexit dwc3_pci_remove(struct pci_dev *pci) ...@@ -211,7 +200,6 @@ static void __devexit dwc3_pci_remove(struct pci_dev *pci)
platform_device_unregister(glue->usb2_phy); platform_device_unregister(glue->usb2_phy);
platform_device_unregister(glue->usb3_phy); platform_device_unregister(glue->usb3_phy);
dwc3_put_device_id(glue->dwc3->id);
platform_device_unregister(glue->dwc3); platform_device_unregister(glue->dwc3);
pci_set_drvdata(pci, NULL); pci_set_drvdata(pci, NULL);
pci_disable_device(pci); pci_disable_device(pci);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册