Skip to content

Commit

Permalink
usb: gadget: udc: atmel: Check fifo configuration values against devi…
Browse files Browse the repository at this point in the history
…ce tree

Check fifo configuration values against device tree values for endpoint fifo
in auto configuration mode (fifo_mode=0).

Signed-off-by: Cristian Birsan <cristian.birsan@microchip.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
  • Loading branch information
Cristian Birsan authored and Felipe Balbi committed Apr 11, 2017
1 parent d7b2bff commit b378e3b
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions drivers/usb/gadget/udc/atmel_usba_udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2115,14 +2115,34 @@ static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev,
dev_err(&pdev->dev, "of_probe: fifo-size error(%d)\n", ret);
goto err;
}
ep->fifo_size = fifo_mode ? udc->fifo_cfg[i].fifo_size : val;
if (fifo_mode) {
if (val < udc->fifo_cfg[i].fifo_size) {
dev_warn(&pdev->dev,
"Using max fifo-size value from DT\n");
ep->fifo_size = val;
} else {
ep->fifo_size = udc->fifo_cfg[i].fifo_size;
}
} else {
ep->fifo_size = val;
}

ret = of_property_read_u32(pp, "atmel,nb-banks", &val);
if (ret) {
dev_err(&pdev->dev, "of_probe: nb-banks error(%d)\n", ret);
goto err;
}
ep->nr_banks = fifo_mode ? udc->fifo_cfg[i].nr_banks : val;
if (fifo_mode) {
if (val < udc->fifo_cfg[i].nr_banks) {
dev_warn(&pdev->dev,
"Using max nb-banks value from DT\n");
ep->nr_banks = val;
} else {
ep->nr_banks = udc->fifo_cfg[i].nr_banks;
}
} else {
ep->nr_banks = val;
}

ep->can_dma = of_property_read_bool(pp, "atmel,can-dma");
ep->can_isoc = of_property_read_bool(pp, "atmel,can-isoc");
Expand Down

0 comments on commit b378e3b

Please sign in to comment.