Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1614930

[PATCH linux-next v3 1/4] usb: gadget: udc: atmel: Check fifo configuration values against device tree

From <cristian.birsan@microchip.com>
Newsgroups linux.kernel
Subject [PATCH linux-next v3 1/4] usb: gadget: udc: atmel: Check fifo configuration values against device tree
Date 2017-04-03 09:30 +0200
Message-ID <ts4B4-3Mv-21@gated-at.bofh.it> (permalink)
References <ts4B4-3Mv-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Cristian Birsan <cristian.birsan@microchip.com>

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>
---
 drivers/usb/gadget/udc/atmel_usba_udc.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
index 2035906b..a98734a 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -2118,14 +2118,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");
-- 
2.7.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH linux-next v3 0/4] usb: gadget: udc: atmel: Endpoint allocation scheme fixes <cristian.birsan@microchip.com> - 2017-04-03 09:30 +0200
  [PATCH linux-next v3 1/4] usb: gadget: udc: atmel: Check fifo configuration values against device tree <cristian.birsan@microchip.com> - 2017-04-03 09:30 +0200
  [PATCH linux-next v3 2/4] usb: gadget: udc: atmel: Minor code cleanup <cristian.birsan@microchip.com> - 2017-04-03 09:30 +0200
    Re: [PATCH linux-next v3 2/4] usb: gadget: udc: atmel: Minor code cleanup Felipe Balbi <balbi@kernel.org> - 2017-04-05 14:40 +0200
      Re: [PATCH linux-next v3 2/4] usb: gadget: udc: atmel: Minor code  cleanup m91496 <Cristian.Birsan@microchip.com> - 2017-04-07 18:10 +0200

csiph-web