UPSTREAM: usb: ohci: ohci-da8xx: Cleanup Error handling and fix flags

Per feedback from Marek, he suggested better handling and
to enable DM_FLAG_OS_PREPARE, this patch re-orders some of
the error checking, and errors returns the error code right
away and also sets DM_FLAG_OS_PREPARE.

Change-Id: I639a5e4f6d5c89a18e722db2601cf18acb96cbb3
Signed-off-by: Adam Ford <aford173@gmail.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit 3a90b50a32b6b8a2d66dc10c19e3c15d5bd1a092)
This commit is contained in:
Adam Ford 2019-05-07 06:57:39 -05:00 committed by Frank Wang
parent 518b4f5b8d
commit 0620c8ad4c
1 changed files with 5 additions and 4 deletions

View File

@ -94,6 +94,10 @@ static int ohci_da8xx_probe(struct udevice *dev)
err = 0; err = 0;
priv->clock_count = 0; priv->clock_count = 0;
clock_nb = dev_count_phandle_with_args(dev, "clocks", "#clock-cells"); clock_nb = dev_count_phandle_with_args(dev, "clocks", "#clock-cells");
if (clock_nb < 0)
return clock_nb;
if (clock_nb > 0) { if (clock_nb > 0) {
priv->clocks = devm_kcalloc(dev, clock_nb, sizeof(struct clk), priv->clocks = devm_kcalloc(dev, clock_nb, sizeof(struct clk),
GFP_KERNEL); GFP_KERNEL);
@ -113,9 +117,6 @@ static int ohci_da8xx_probe(struct udevice *dev)
} }
priv->clock_count++; priv->clock_count++;
} }
} else if (clock_nb != -ENOENT) {
dev_err(dev, "failed to get clock phandle(%d)\n", clock_nb);
return clock_nb;
} }
err = usb_cpu_init(); err = usb_cpu_init();
@ -171,6 +172,6 @@ U_BOOT_DRIVER(ohci_generic) = {
.remove = ohci_da8xx_remove, .remove = ohci_da8xx_remove,
.ops = &ohci_usb_ops, .ops = &ohci_usb_ops,
.priv_auto_alloc_size = sizeof(struct da8xx_ohci), .priv_auto_alloc_size = sizeof(struct da8xx_ohci),
.flags = DM_FLAG_ALLOC_PRIV_DMA, .flags = DM_FLAG_ALLOC_PRIV_DMA | DM_FLAG_OS_PREPARE,
}; };
#endif #endif