diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2012-10-29 13:09:53 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2012-10-31 09:18:52 -0400 |
commit | 124dafde8f8174caf5cef1c3eaba001657d66f4f (patch) | |
tree | 6fc02aec00e90e333db788691b48910ddb38e34c /drivers | |
parent | 6f115e45a09846ae84154735e6215622e2e8e535 (diff) |
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: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/dwc3/core.c | 39 | ||||
-rw-r--r-- | drivers/usb/dwc3/core.h | 3 | ||||
-rw-r--r-- | drivers/usb/dwc3/dwc3-exynos.c | 13 | ||||
-rw-r--r-- | drivers/usb/dwc3/dwc3-omap.c | 16 | ||||
-rw-r--r-- | drivers/usb/dwc3/dwc3-pci.c | 16 |
5 files changed, 6 insertions, 81 deletions
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index b923183c43cb..d8d327a5e53b 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c | |||
@@ -66,45 +66,6 @@ MODULE_PARM_DESC(maximum_speed, "Maximum supported speed."); | |||
66 | 66 | ||
67 | /* -------------------------------------------------------------------------- */ | 67 | /* -------------------------------------------------------------------------- */ |
68 | 68 | ||
69 | #define DWC3_DEVS_POSSIBLE 32 | ||
70 | |||
71 | static DECLARE_BITMAP(dwc3_devs, DWC3_DEVS_POSSIBLE); | ||
72 | |||
73 | int dwc3_get_device_id(void) | ||
74 | { | ||
75 | int id; | ||
76 | |||
77 | again: | ||
78 | id = find_first_zero_bit(dwc3_devs, DWC3_DEVS_POSSIBLE); | ||
79 | if (id < DWC3_DEVS_POSSIBLE) { | ||
80 | int old; | ||
81 | |||
82 | old = test_and_set_bit(id, dwc3_devs); | ||
83 | if (old) | ||
84 | goto again; | ||
85 | } else { | ||
86 | pr_err("dwc3: no space for new device\n"); | ||
87 | id = -ENOMEM; | ||
88 | } | ||
89 | |||
90 | return id; | ||
91 | } | ||
92 | EXPORT_SYMBOL_GPL(dwc3_get_device_id); | ||
93 | |||
94 | void dwc3_put_device_id(int id) | ||
95 | { | ||
96 | int ret; | ||
97 | |||
98 | if (id < 0) | ||
99 | return; | ||
100 | |||
101 | ret = test_bit(id, dwc3_devs); | ||
102 | WARN(!ret, "dwc3: ID %d not in use\n", id); | ||
103 | smp_mb__before_clear_bit(); | ||
104 | clear_bit(id, dwc3_devs); | ||
105 | } | ||
106 | EXPORT_SYMBOL_GPL(dwc3_put_device_id); | ||
107 | |||
108 | void dwc3_set_mode(struct dwc3 *dwc, u32 mode) | 69 | void dwc3_set_mode(struct dwc3 *dwc, u32 mode) |
109 | { | 70 | { |
110 | u32 reg; | 71 | u32 reg; |
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 243affc93431..499956344262 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h | |||
@@ -868,7 +868,4 @@ void dwc3_host_exit(struct dwc3 *dwc); | |||
868 | int dwc3_gadget_init(struct dwc3 *dwc); | 868 | int dwc3_gadget_init(struct dwc3 *dwc); |
869 | void dwc3_gadget_exit(struct dwc3 *dwc); | 869 | void dwc3_gadget_exit(struct dwc3 *dwc); |
870 | 870 | ||
871 | extern int dwc3_get_device_id(void); | ||
872 | extern void dwc3_put_device_id(int id); | ||
873 | |||
874 | #endif /* __DRIVERS_USB_DWC3_CORE_H */ | 871 | #endif /* __DRIVERS_USB_DWC3_CORE_H */ |
diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c index ca6597853f90..586f1051b059 100644 --- a/drivers/usb/dwc3/dwc3-exynos.c +++ b/drivers/usb/dwc3/dwc3-exynos.c | |||
@@ -94,7 +94,6 @@ static int __devinit dwc3_exynos_probe(struct platform_device *pdev) | |||
94 | struct dwc3_exynos *exynos; | 94 | struct dwc3_exynos *exynos; |
95 | struct clk *clk; | 95 | struct clk *clk; |
96 | 96 | ||
97 | int devid; | ||
98 | int ret = -ENOMEM; | 97 | int ret = -ENOMEM; |
99 | 98 | ||
100 | exynos = kzalloc(sizeof(*exynos), GFP_KERNEL); | 99 | exynos = kzalloc(sizeof(*exynos), GFP_KERNEL); |
@@ -105,20 +104,16 @@ static int __devinit dwc3_exynos_probe(struct platform_device *pdev) | |||
105 | 104 | ||
106 | platform_set_drvdata(pdev, exynos); | 105 | platform_set_drvdata(pdev, exynos); |
107 | 106 | ||
108 | devid = dwc3_get_device_id(); | ||
109 | if (devid < 0) | ||
110 | goto err1; | ||
111 | |||
112 | ret = dwc3_exynos_register_phys(exynos); | 107 | ret = dwc3_exynos_register_phys(exynos); |
113 | if (ret) { | 108 | if (ret) { |
114 | dev_err(&pdev->dev, "couldn't register PHYs\n"); | 109 | dev_err(&pdev->dev, "couldn't register PHYs\n"); |
115 | goto err1; | 110 | goto err1; |
116 | } | 111 | } |
117 | 112 | ||
118 | dwc3 = platform_device_alloc("dwc3", devid); | 113 | dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO); |
119 | if (!dwc3) { | 114 | if (!dwc3) { |
120 | dev_err(&pdev->dev, "couldn't allocate dwc3 device\n"); | 115 | dev_err(&pdev->dev, "couldn't allocate dwc3 device\n"); |
121 | goto err2; | 116 | goto err1; |
122 | } | 117 | } |
123 | 118 | ||
124 | clk = clk_get(&pdev->dev, "usbdrd30"); | 119 | clk = clk_get(&pdev->dev, "usbdrd30"); |
@@ -170,8 +165,6 @@ err4: | |||
170 | clk_put(clk); | 165 | clk_put(clk); |
171 | err3: | 166 | err3: |
172 | platform_device_put(dwc3); | 167 | platform_device_put(dwc3); |
173 | err2: | ||
174 | dwc3_put_device_id(devid); | ||
175 | err1: | 168 | err1: |
176 | kfree(exynos); | 169 | kfree(exynos); |
177 | err0: | 170 | err0: |
@@ -187,8 +180,6 @@ static int __devexit dwc3_exynos_remove(struct platform_device *pdev) | |||
187 | platform_device_unregister(exynos->usb2_phy); | 180 | platform_device_unregister(exynos->usb2_phy); |
188 | platform_device_unregister(exynos->usb3_phy); | 181 | platform_device_unregister(exynos->usb3_phy); |
189 | 182 | ||
190 | dwc3_put_device_id(exynos->dwc3->id); | ||
191 | |||
192 | if (pdata && pdata->phy_exit) | 183 | if (pdata && pdata->phy_exit) |
193 | pdata->phy_exit(pdev, pdata->phy_type); | 184 | pdata->phy_exit(pdev, pdata->phy_type); |
194 | 185 | ||
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c index ee57a10d90d0..900d435f41d1 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c | |||
@@ -272,7 +272,6 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev) | |||
272 | struct resource *res; | 272 | struct resource *res; |
273 | struct device *dev = &pdev->dev; | 273 | struct device *dev = &pdev->dev; |
274 | 274 | ||
275 | int devid; | ||
276 | int size; | 275 | int size; |
277 | int ret = -ENOMEM; | 276 | int ret = -ENOMEM; |
278 | int irq; | 277 | int irq; |
@@ -315,14 +314,10 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev) | |||
315 | return ret; | 314 | return ret; |
316 | } | 315 | } |
317 | 316 | ||
318 | devid = dwc3_get_device_id(); | 317 | dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO); |
319 | if (devid < 0) | ||
320 | return -ENODEV; | ||
321 | |||
322 | dwc3 = platform_device_alloc("dwc3", devid); | ||
323 | if (!dwc3) { | 318 | if (!dwc3) { |
324 | dev_err(dev, "couldn't allocate dwc3 device\n"); | 319 | dev_err(dev, "couldn't allocate dwc3 device\n"); |
325 | goto err1; | 320 | return -ENOMEM; |
326 | } | 321 | } |
327 | 322 | ||
328 | context = devm_kzalloc(dev, resource_size(res), GFP_KERNEL); | 323 | context = devm_kzalloc(dev, resource_size(res), GFP_KERNEL); |
@@ -423,10 +418,6 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev) | |||
423 | 418 | ||
424 | err2: | 419 | err2: |
425 | platform_device_put(dwc3); | 420 | platform_device_put(dwc3); |
426 | |||
427 | err1: | ||
428 | dwc3_put_device_id(devid); | ||
429 | |||
430 | return ret; | 421 | return ret; |
431 | } | 422 | } |
432 | 423 | ||
@@ -437,9 +428,6 @@ static int __devexit dwc3_omap_remove(struct platform_device *pdev) | |||
437 | platform_device_unregister(omap->dwc3); | 428 | platform_device_unregister(omap->dwc3); |
438 | platform_device_unregister(omap->usb2_phy); | 429 | platform_device_unregister(omap->usb2_phy); |
439 | platform_device_unregister(omap->usb3_phy); | 430 | platform_device_unregister(omap->usb3_phy); |
440 | |||
441 | dwc3_put_device_id(omap->dwc3->id); | ||
442 | |||
443 | return 0; | 431 | return 0; |
444 | } | 432 | } |
445 | 433 | ||
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c index 94f550e37f98..13962597f3fe 100644 --- a/drivers/usb/dwc3/dwc3-pci.c +++ b/drivers/usb/dwc3/dwc3-pci.c | |||
@@ -119,7 +119,6 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci, | |||
119 | struct platform_device *dwc3; | 119 | struct platform_device *dwc3; |
120 | struct dwc3_pci *glue; | 120 | struct dwc3_pci *glue; |
121 | int ret = -ENOMEM; | 121 | int ret = -ENOMEM; |
122 | int devid; | ||
123 | struct device *dev = &pci->dev; | 122 | struct device *dev = &pci->dev; |
124 | 123 | ||
125 | glue = devm_kzalloc(dev, sizeof(*glue), GFP_KERNEL); | 124 | glue = devm_kzalloc(dev, sizeof(*glue), GFP_KERNEL); |
@@ -145,13 +144,7 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci, | |||
145 | return ret; | 144 | return ret; |
146 | } | 145 | } |
147 | 146 | ||
148 | devid = dwc3_get_device_id(); | 147 | dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO); |
149 | if (devid < 0) { | ||
150 | ret = -ENOMEM; | ||
151 | goto err1; | ||
152 | } | ||
153 | |||
154 | dwc3 = platform_device_alloc("dwc3", devid); | ||
155 | if (!dwc3) { | 148 | if (!dwc3) { |
156 | dev_err(dev, "couldn't allocate dwc3 device\n"); | 149 | dev_err(dev, "couldn't allocate dwc3 device\n"); |
157 | ret = -ENOMEM; | 150 | ret = -ENOMEM; |
@@ -172,7 +165,7 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci, | |||
172 | ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res)); | 165 | ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res)); |
173 | if (ret) { | 166 | if (ret) { |
174 | dev_err(dev, "couldn't add resources to dwc3 device\n"); | 167 | dev_err(dev, "couldn't add resources to dwc3 device\n"); |
175 | goto err2; | 168 | goto err1; |
176 | } | 169 | } |
177 | 170 | ||
178 | pci_set_drvdata(pci, glue); | 171 | pci_set_drvdata(pci, glue); |
@@ -195,10 +188,6 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci, | |||
195 | err3: | 188 | err3: |
196 | pci_set_drvdata(pci, NULL); | 189 | pci_set_drvdata(pci, NULL); |
197 | platform_device_put(dwc3); | 190 | platform_device_put(dwc3); |
198 | |||
199 | err2: | ||
200 | dwc3_put_device_id(devid); | ||
201 | |||
202 | err1: | 191 | err1: |
203 | pci_disable_device(pci); | 192 | pci_disable_device(pci); |
204 | 193 | ||
@@ -211,7 +200,6 @@ static void __devexit dwc3_pci_remove(struct pci_dev *pci) | |||
211 | 200 | ||
212 | platform_device_unregister(glue->usb2_phy); | 201 | platform_device_unregister(glue->usb2_phy); |
213 | platform_device_unregister(glue->usb3_phy); | 202 | platform_device_unregister(glue->usb3_phy); |
214 | dwc3_put_device_id(glue->dwc3->id); | ||
215 | platform_device_unregister(glue->dwc3); | 203 | platform_device_unregister(glue->dwc3); |
216 | pci_set_drvdata(pci, NULL); | 204 | pci_set_drvdata(pci, NULL); |
217 | pci_disable_device(pci); | 205 | pci_disable_device(pci); |