Skip to content

Commit

Permalink
DMA-API: usb: use dma_set_coherent_mask()
Browse files Browse the repository at this point in the history
The correct way for a driver to specify the coherent DMA mask is
not to directly access the field in the struct device, but to use
dma_set_coherent_mask().  Only arch and bus code should access this
member directly.

Convert all direct write accesses to using the correct API.

Acked-by: Felipe Balbi <balbi@ti.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
  • Loading branch information
Russell King committed Oct 31, 2013
1 parent 93b11b2 commit 22d9d8e
Show file tree
Hide file tree
Showing 19 changed files with 64 additions and 38 deletions.
5 changes: 3 additions & 2 deletions drivers/usb/chipidea/ci_hdrc_imx.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)

if (!pdev->dev.dma_mask)
pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
if (!pdev->dev.coherent_dma_mask)
pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
if (ret)
goto err_clk;

if (data->usbmisc_data) {
ret = imx_usbmisc_init(data->usbmisc_data);
Expand Down
5 changes: 3 additions & 2 deletions drivers/usb/dwc3/dwc3-exynos.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ static int dwc3_exynos_probe(struct platform_device *pdev)
*/
if (!dev->dma_mask)
dev->dma_mask = &dev->coherent_dma_mask;
if (!dev->coherent_dma_mask)
dev->coherent_dma_mask = DMA_BIT_MASK(32);
ret = dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
if (ret)
goto err1;

platform_set_drvdata(pdev, exynos);

Expand Down
4 changes: 3 additions & 1 deletion drivers/usb/gadget/lpc32xx_udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3078,7 +3078,9 @@ static int __init lpc32xx_udc_probe(struct platform_device *pdev)
udc->isp1301_i2c_client->addr);

pdev->dev.dma_mask = &lpc32xx_usbd_dmamask;
pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
retval = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
if (retval)
goto resource_fail;

udc->board = &lpc32xx_usbddata;

Expand Down
5 changes: 3 additions & 2 deletions drivers/usb/host/ehci-atmel.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ static int ehci_atmel_drv_probe(struct platform_device *pdev)
*/
if (!pdev->dev.dma_mask)
pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
if (!pdev->dev.coherent_dma_mask)
pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
retval = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
if (retval)
goto fail_create_hcd;

hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
if (!hcd) {
Expand Down
4 changes: 3 additions & 1 deletion drivers/usb/host/ehci-octeon.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ static int ehci_octeon_drv_probe(struct platform_device *pdev)
* We can DMA from anywhere. But the descriptors must be in
* the lower 4GB.
*/
pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
pdev->dev.dma_mask = &ehci_octeon_dma_mask;
ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
if (ret)
return ret;

hcd = usb_create_hcd(&ehci_octeon_hc_driver, &pdev->dev, "octeon");
if (!hcd)
Expand Down
8 changes: 5 additions & 3 deletions drivers/usb/host/ehci-omap.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
struct resource *res;
struct usb_hcd *hcd;
void __iomem *regs;
int ret = -ENODEV;
int ret;
int irq;
int i;
struct omap_hcd *omap;
Expand Down Expand Up @@ -146,9 +146,11 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
*/
if (!dev->dma_mask)
dev->dma_mask = &dev->coherent_dma_mask;
if (!dev->coherent_dma_mask)
dev->coherent_dma_mask = DMA_BIT_MASK(32);
ret = dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
if (ret)
return ret;

ret = -ENODEV;
hcd = usb_create_hcd(&ehci_omap_hc_driver, dev,
dev_name(dev));
if (!hcd) {
Expand Down
5 changes: 3 additions & 2 deletions drivers/usb/host/ehci-orion.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,9 @@ static int ehci_orion_drv_probe(struct platform_device *pdev)
*/
if (!pdev->dev.dma_mask)
pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
if (!pdev->dev.coherent_dma_mask)
pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
if (err)
goto err1;

if (!request_mem_region(res->start, resource_size(res),
ehci_orion_hc_driver.description)) {
Expand Down
7 changes: 4 additions & 3 deletions drivers/usb/host/ehci-platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static int ehci_platform_probe(struct platform_device *dev)
struct resource *res_mem;
struct usb_ehci_pdata *pdata;
int irq;
int err = -ENOMEM;
int err;

if (usb_disabled())
return -ENODEV;
Expand All @@ -91,8 +91,9 @@ static int ehci_platform_probe(struct platform_device *dev)
dev->dev.platform_data = &ehci_platform_defaults;
if (!dev->dev.dma_mask)
dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
if (!dev->dev.coherent_dma_mask)
dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
err = dma_set_coherent_mask(&dev->dev, DMA_BIT_MASK(32));
if (err)
return err;

pdata = dev_get_platdata(&dev->dev);

Expand Down
5 changes: 3 additions & 2 deletions drivers/usb/host/ehci-s5p.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ static int s5p_ehci_probe(struct platform_device *pdev)
*/
if (!pdev->dev.dma_mask)
pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
if (!pdev->dev.coherent_dma_mask)
pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
if (err)
return err;

s5p_setup_vbus_gpio(pdev);

Expand Down
5 changes: 3 additions & 2 deletions drivers/usb/host/ehci-spear.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev)
*/
if (!pdev->dev.dma_mask)
pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
if (!pdev->dev.coherent_dma_mask)
pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
retval = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
if (retval)
goto fail;

usbh_clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(usbh_clk)) {
Expand Down
5 changes: 3 additions & 2 deletions drivers/usb/host/ehci-tegra.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,9 @@ static int tegra_ehci_probe(struct platform_device *pdev)
*/
if (!pdev->dev.dma_mask)
pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
if (!pdev->dev.coherent_dma_mask)
pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
if (err)
return err;

hcd = usb_create_hcd(&tegra_ehci_hc_driver, &pdev->dev,
dev_name(&pdev->dev));
Expand Down
7 changes: 4 additions & 3 deletions drivers/usb/host/ohci-at91.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ MODULE_DEVICE_TABLE(of, at91_ohci_dt_ids);
static int ohci_at91_of_init(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
int i, gpio;
int i, gpio, ret;
enum of_gpio_flags flags;
struct at91_usbh_data *pdata;
u32 ports;
Expand All @@ -538,8 +538,9 @@ static int ohci_at91_of_init(struct platform_device *pdev)
*/
if (!pdev->dev.dma_mask)
pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
if (!pdev->dev.coherent_dma_mask)
pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
if (ret)
return ret;

pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
Expand Down
5 changes: 3 additions & 2 deletions drivers/usb/host/ohci-exynos.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ static int exynos_ohci_probe(struct platform_device *pdev)
*/
if (!pdev->dev.dma_mask)
pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
if (!pdev->dev.coherent_dma_mask)
pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
if (err)
return err;

exynos_ohci = devm_kzalloc(&pdev->dev, sizeof(struct exynos_ohci_hcd),
GFP_KERNEL);
Expand Down
4 changes: 3 additions & 1 deletion drivers/usb/host/ohci-nxp.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,10 @@ static int usb_hcd_nxp_probe(struct platform_device *pdev)
return -EPROBE_DEFER;
}

pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
if (ret)
goto fail_disable;

dev_dbg(&pdev->dev, "%s: " DRIVER_DESC " (nxp)\n", hcd_name);
if (usb_disabled()) {
Expand Down
4 changes: 3 additions & 1 deletion drivers/usb/host/ohci-octeon.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,10 @@ static int ohci_octeon_drv_probe(struct platform_device *pdev)
}

/* Ohci is a 32-bit device. */
pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
if (ret)
return ret;

hcd = usb_create_hcd(&ohci_octeon_hc_driver, &pdev->dev, "octeon");
if (!hcd)
Expand Down
8 changes: 5 additions & 3 deletions drivers/usb/host/ohci-omap3.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static int ohci_hcd_omap3_probe(struct platform_device *pdev)
struct usb_hcd *hcd = NULL;
void __iomem *regs = NULL;
struct resource *res;
int ret = -ENODEV;
int ret;
int irq;

if (usb_disabled())
Expand Down Expand Up @@ -168,9 +168,11 @@ static int ohci_hcd_omap3_probe(struct platform_device *pdev)
*/
if (!dev->dma_mask)
dev->dma_mask = &dev->coherent_dma_mask;
if (!dev->coherent_dma_mask)
dev->coherent_dma_mask = DMA_BIT_MASK(32);
ret = dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
if (ret)
goto err_io;

ret = -ENODEV;
hcd = usb_create_hcd(&ohci_omap3_hc_driver, dev,
dev_name(dev));
if (!hcd) {
Expand Down
6 changes: 4 additions & 2 deletions drivers/usb/host/ohci-pxa27x.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ static int ohci_pxa_of_init(struct platform_device *pdev)
struct device_node *np = pdev->dev.of_node;
struct pxaohci_platform_data *pdata;
u32 tmp;
int ret;

if (!np)
return 0;
Expand All @@ -297,8 +298,9 @@ static int ohci_pxa_of_init(struct platform_device *pdev)
*/
if (!pdev->dev.dma_mask)
pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
if (!pdev->dev.coherent_dma_mask)
pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
if (ret)
return ret;

pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
Expand Down
5 changes: 3 additions & 2 deletions drivers/usb/host/ohci-spear.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ static int spear_ohci_hcd_drv_probe(struct platform_device *pdev)
*/
if (!pdev->dev.dma_mask)
pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
if (!pdev->dev.coherent_dma_mask)
pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
retval = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
if (retval)
goto fail;

usbh_clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(usbh_clk)) {
Expand Down
5 changes: 3 additions & 2 deletions drivers/usb/host/uhci-platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ static int uhci_hcd_platform_probe(struct platform_device *pdev)
*/
if (!pdev->dev.dma_mask)
pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
if (!pdev->dev.coherent_dma_mask)
pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
if (ret)
return ret;

hcd = usb_create_hcd(&uhci_platform_hc_driver, &pdev->dev,
pdev->name);
Expand Down

0 comments on commit 22d9d8e

Please sign in to comment.