diff options
author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2020-07-17 14:36:46 +0900 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2020-07-20 11:37:47 -0600 |
commit | 3c12c62ba5fa12c988336a9de5784c6b5fbaac54 (patch) | |
tree | 70381d65e1e42fe7aafb4dd525596ecd3c621179 /drivers/usb | |
parent | 6ec7545b99d62a5d931473e853aea30f8b9b2aa3 (diff) |
treewide: convert (void *)devfdt_get_addr() to dev_read_addr_ptr()
Use the _ptr suffixed variant instead of casting. Also, convert it to
dev_read_addr_ptr(), which is safe to CONFIG_OF_LIVE.
One curious part is an error check like follows in
drivers/watchdog/omap_wdt.c:
priv->regs = (struct wd_timer *)devfdt_get_addr(dev);
if (!priv->regs)
return -EINVAL;
devfdt_get_addr() returns FDT_ADDR_T_NONE (i.e. -1) on error.
So, this code does not catch any error in DT parsing.
dev_read_addr_ptr() returns NULL on error, so this error check
will work.
I generated this commit by the following command:
$ find . -name .git -prune -o -name '*.[ch]' -type f -print | \
xargs sed -i -e 's/([^*)]*\*)devfdt_get_addr(/dev_read_addr_ptr(/'
I manually fixed drivers/usb/host/ehci-mx6.c
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/host/ehci-mx5.c | 2 | ||||
-rw-r--r-- | drivers/usb/host/ehci-mx6.c | 4 | ||||
-rw-r--r-- | drivers/usb/host/ehci-omap.c | 2 | ||||
-rw-r--r-- | drivers/usb/host/ehci-vf.c | 2 | ||||
-rw-r--r-- | drivers/usb/host/ohci-da8xx.c | 2 | ||||
-rw-r--r-- | drivers/usb/host/ohci-generic.c | 2 |
6 files changed, 7 insertions, 7 deletions
diff --git a/drivers/usb/host/ehci-mx5.c b/drivers/usb/host/ehci-mx5.c index 212b362332..caafa68899 100644 --- a/drivers/usb/host/ehci-mx5.c +++ b/drivers/usb/host/ehci-mx5.c @@ -306,7 +306,7 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev) static int ehci_usb_probe(struct udevice *dev) { struct usb_platdata *plat = dev_get_platdata(dev); - struct usb_ehci *ehci = (struct usb_ehci *)devfdt_get_addr(dev); + struct usb_ehci *ehci = dev_read_addr_ptr(dev); struct ehci_mx5_priv_data *priv = dev_get_priv(dev); enum usb_init_type type = plat->init_type; struct ehci_hccr *hccr; diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c index 5f84c7b91d..37b59758bb 100644 --- a/drivers/usb/host/ehci-mx6.c +++ b/drivers/usb/host/ehci-mx6.c @@ -473,7 +473,7 @@ static const struct ehci_ops mx6_ehci_ops = { static int ehci_usb_phy_mode(struct udevice *dev) { struct usb_platdata *plat = dev_get_platdata(dev); - void *__iomem addr = (void *__iomem)devfdt_get_addr(dev); + void *__iomem addr = dev_read_addr_ptr(dev); void *__iomem phy_ctrl, *__iomem phy_status; const void *blob = gd->fdt_blob; int offset = dev_of_offset(dev), phy_off; @@ -580,7 +580,7 @@ static int ehci_usb_bind(struct udevice *dev) static int ehci_usb_probe(struct udevice *dev) { struct usb_platdata *plat = dev_get_platdata(dev); - struct usb_ehci *ehci = (struct usb_ehci *)devfdt_get_addr(dev); + struct usb_ehci *ehci = dev_read_addr_ptr(dev); struct ehci_mx6_priv_data *priv = dev_get_priv(dev); enum usb_init_type type = plat->init_type; struct ehci_hccr *hccr; diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c index 93ab83941d..82b99eeef1 100644 --- a/drivers/usb/host/ehci-omap.c +++ b/drivers/usb/host/ehci-omap.c @@ -382,7 +382,7 @@ static int omap_ehci_probe(struct udevice *dev) struct ehci_hccr *hccr; struct ehci_hcor *hcor; - priv->ehci = (struct omap_ehci *)devfdt_get_addr(dev); + priv->ehci = dev_read_addr_ptr(dev); priv->portnr = dev->seq; priv->init_type = plat->init_type; diff --git a/drivers/usb/host/ehci-vf.c b/drivers/usb/host/ehci-vf.c index 562207d3d2..2768d40974 100644 --- a/drivers/usb/host/ehci-vf.c +++ b/drivers/usb/host/ehci-vf.c @@ -224,7 +224,7 @@ static int vf_usb_ofdata_to_platdata(struct udevice *dev) priv->portnr = dev->seq; - priv->ehci = (struct usb_ehci *)devfdt_get_addr(dev); + priv->ehci = dev_read_addr_ptr(dev); mode = fdt_getprop(dt_blob, node, "dr_mode", NULL); if (mode) { if (0 == strcmp(mode, "host")) { diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c index 692018243c..22e7b565b5 100644 --- a/drivers/usb/host/ohci-da8xx.c +++ b/drivers/usb/host/ohci-da8xx.c @@ -89,7 +89,7 @@ int usb_cpu_init_fail(void) #if CONFIG_IS_ENABLED(DM_USB) static int ohci_da8xx_probe(struct udevice *dev) { - struct ohci_regs *regs = (struct ohci_regs *)devfdt_get_addr(dev); + struct ohci_regs *regs = dev_read_addr_ptr(dev); struct da8xx_ohci *priv = dev_get_priv(dev); int i, err, ret, clock_nb; diff --git a/drivers/usb/host/ohci-generic.c b/drivers/usb/host/ohci-generic.c index 631711a9e8..b84bf8ac0f 100644 --- a/drivers/usb/host/ohci-generic.c +++ b/drivers/usb/host/ohci-generic.c @@ -79,7 +79,7 @@ static int ohci_shutdown_phy(struct udevice *dev) static int ohci_usb_probe(struct udevice *dev) { - struct ohci_regs *regs = (struct ohci_regs *)devfdt_get_addr(dev); + struct ohci_regs *regs = dev_read_addr_ptr(dev); struct generic_ohci *priv = dev_get_priv(dev); int i, err, ret, clock_nb, reset_nb; |