diff mbox series

[3/4] PHY: rockchip: USB2: Allow 64 bits reg property

Message ID 20210614154359.805555-4-benjamin.gaignard@collabora.com
State Changes Requested
Headers show
Series Add USB2 support for rk3568 | expand

Commit Message

Benjamin Gaignard June 14, 2021, 3:43 p.m. UTC
In rk356x device-tree "reg" property could be coded on 64 bits.
Change reg type and of_property_read_ to make it works.

Signed-off-by: Peter Geis <pgwipeout@gmail.com>
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
---
 drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Robin Murphy June 14, 2021, 5:09 p.m. UTC | #1
On 2021-06-14 16:43, Benjamin Gaignard wrote:
> In rk356x device-tree "reg" property could be coded on 64 bits.
> Change reg type and of_property_read_ to make it works.

On platforms with #address-cells=1, this isn't going to do what you 
think. Worse, it's not even going to fail, because you *can* read a 
64-bit value from an address cell with a size cell after it...

Robin.

> Signed-off-by: Peter Geis <pgwipeout@gmail.com>
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
> ---
>   drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> index 46ebdb1460a3d..45518f96d7217 100644
> --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> @@ -1068,7 +1068,7 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev)
>   	struct rockchip_usb2phy *rphy;
>   	const struct rockchip_usb2phy_cfg *phy_cfgs;
>   	const struct of_device_id *match;
> -	unsigned int reg;
> +	u64 reg;
>   	int index, ret;
>   
>   	rphy = devm_kzalloc(dev, sizeof(*rphy), GFP_KERNEL);
> @@ -1098,7 +1098,7 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev)
>   		rphy->usbgrf = NULL;
>   	}
>   
> -	if (of_property_read_u32(np, "reg", &reg)) {
> +	if (of_property_read_u64(np, "reg", &reg)) {
>   		dev_err(dev, "the reg property is not assigned in %pOFn node\n",
>   			np);
>   		return -EINVAL;
>
Peter Geis June 14, 2021, 9:58 p.m. UTC | #2
On Mon, Jun 14, 2021 at 1:09 PM Robin Murphy <robin.murphy@arm.com> wrote:
>
> On 2021-06-14 16:43, Benjamin Gaignard wrote:
> > In rk356x device-tree "reg" property could be coded on 64 bits.
> > Change reg type and of_property_read_ to make it works.
>
> On platforms with #address-cells=1, this isn't going to do what you
> think. Worse, it's not even going to fail, because you *can* read a
> 64-bit value from an address cell with a size cell after it...

Apologies, this was a hack and in no way ready for submission.

While I've got you here, what would be the best way to handle this?
Since previous generations #address-cells=1 and #size-cells=1, where
the rk356x #address-cells=2 and #size-cells=2 and we need to account
for both of them.

Thanks,
Peter

>
> Robin.
>
> > Signed-off-by: Peter Geis <pgwipeout@gmail.com>
> > Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
> > ---
> >   drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> > index 46ebdb1460a3d..45518f96d7217 100644
> > --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> > +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
> > @@ -1068,7 +1068,7 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev)
> >       struct rockchip_usb2phy *rphy;
> >       const struct rockchip_usb2phy_cfg *phy_cfgs;
> >       const struct of_device_id *match;
> > -     unsigned int reg;
> > +     u64 reg;
> >       int index, ret;
> >
> >       rphy = devm_kzalloc(dev, sizeof(*rphy), GFP_KERNEL);
> > @@ -1098,7 +1098,7 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev)
> >               rphy->usbgrf = NULL;
> >       }
> >
> > -     if (of_property_read_u32(np, "reg", &reg)) {
> > +     if (of_property_read_u64(np, "reg", &reg)) {
> >               dev_err(dev, "the reg property is not assigned in %pOFn node\n",
> >                       np);
> >               return -EINVAL;
> >
diff mbox series

Patch

diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
index 46ebdb1460a3d..45518f96d7217 100644
--- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
+++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
@@ -1068,7 +1068,7 @@  static int rockchip_usb2phy_probe(struct platform_device *pdev)
 	struct rockchip_usb2phy *rphy;
 	const struct rockchip_usb2phy_cfg *phy_cfgs;
 	const struct of_device_id *match;
-	unsigned int reg;
+	u64 reg;
 	int index, ret;
 
 	rphy = devm_kzalloc(dev, sizeof(*rphy), GFP_KERNEL);
@@ -1098,7 +1098,7 @@  static int rockchip_usb2phy_probe(struct platform_device *pdev)
 		rphy->usbgrf = NULL;
 	}
 
-	if (of_property_read_u32(np, "reg", &reg)) {
+	if (of_property_read_u64(np, "reg", &reg)) {
 		dev_err(dev, "the reg property is not assigned in %pOFn node\n",
 			np);
 		return -EINVAL;