]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
usb: dwc2: handle return code of dev_read_size() in of to, plat function
authorWolfgang Grandegger <wg@aries-embedded.de>
Mon, 14 Mar 2022 08:32:53 +0000 (09:32 +0100)
committerMarek Vasut <marex@denx.de>
Mon, 14 Mar 2022 11:31:12 +0000 (12:31 +0100)
dev_read_size() returns -EINVAL (-22) if the property "g-tx-fifo-size"
does not exist. If that's the case, we now keep the default value of 0.

Signed-off-by: Wolfgang Grandegger <wg@aries-embedded.de>
drivers/usb/gadget/dwc2_udc_otg.c

index 2748270ad6a8266f732d4f2d849d0944d1cbee0c..77988f78ab3095270a28dfd9b7600ddfcbad71b5 100644 (file)
@@ -996,8 +996,9 @@ static int dwc2_udc_otg_of_to_plat(struct udevice *dev)
        plat->rx_fifo_sz = dev_read_u32_default(dev, "g-rx-fifo-size", 0);
        plat->np_tx_fifo_sz = dev_read_u32_default(dev, "g-np-tx-fifo-size", 0);
 
-       plat->tx_fifo_sz_nb =
-               dev_read_size(dev, "g-tx-fifo-size") / sizeof(u32);
+       ret = dev_read_size(dev, "g-tx-fifo-size");
+       if (ret > 0)
+               plat->tx_fifo_sz_nb = ret / sizeof(u32);
        if (plat->tx_fifo_sz_nb > DWC2_MAX_HW_ENDPOINTS)
                plat->tx_fifo_sz_nb = DWC2_MAX_HW_ENDPOINTS;
        if (plat->tx_fifo_sz_nb) {