diff mbox series

[04/11] pinctrl: single: get register area size by device API

Message ID 20210123182711.7177-5-dariobin@libero.it
State Superseded
Delegated to: Lokesh Vutla
Headers show
Series Add support for pinmux status command on beaglebone | expand

Commit Message

Dario Binacchi Jan. 23, 2021, 6:27 p.m. UTC
Use dev_read_addr_size to get size of the controller's register area.

Signed-off-by: Dario Binacchi <dariobin@libero.it>
---

 drivers/pinctrl/pinctrl-single.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

Comments

Simon Glass Jan. 24, 2021, 2:03 a.m. UTC | #1
Hi Dario,

On Sat, 23 Jan 2021 at 11:27, Dario Binacchi <dariobin@libero.it> wrote:
>
> Use dev_read_addr_size to get size of the controller's register area.
>
> Signed-off-by: Dario Binacchi <dariobin@libero.it>
> ---
>
>  drivers/pinctrl/pinctrl-single.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
> index cec00e289c..c80a42a193 100644
> --- a/drivers/pinctrl/pinctrl-single.c
> +++ b/drivers/pinctrl/pinctrl-single.c
> @@ -182,17 +182,14 @@ static int single_set_state(struct udevice *dev,
>  static int single_of_to_plat(struct udevice *dev)
>  {
>         fdt_addr_t addr;
> -       u32 of_reg[2];
> -       int res;
> +       fdt_size_t size;
>         struct single_pdata *pdata = dev_get_plat(dev);
>
>         pdata->width =
>                 dev_read_u32_default(dev, "pinctrl-single,register-width", 0);
>
> -       res = dev_read_u32_array(dev, "reg", of_reg, 2);
> -       if (res)
> -               return res;
> -       pdata->offset = of_reg[1] - pdata->width / 8;
> +       dev_read_addr_size(dev, "reg", &size);

Please check return value.

> +       pdata->offset = size - pdata->width / BITS_PER_BYTE;
>
>         addr = dev_read_addr(dev);
>         if (addr == FDT_ADDR_T_NONE) {
> --
> 2.17.1
>

Regards,
Simon
diff mbox series

Patch

diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index cec00e289c..c80a42a193 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -182,17 +182,14 @@  static int single_set_state(struct udevice *dev,
 static int single_of_to_plat(struct udevice *dev)
 {
 	fdt_addr_t addr;
-	u32 of_reg[2];
-	int res;
+	fdt_size_t size;
 	struct single_pdata *pdata = dev_get_plat(dev);
 
 	pdata->width =
 		dev_read_u32_default(dev, "pinctrl-single,register-width", 0);
 
-	res = dev_read_u32_array(dev, "reg", of_reg, 2);
-	if (res)
-		return res;
-	pdata->offset = of_reg[1] - pdata->width / 8;
+	dev_read_addr_size(dev, "reg", &size);
+	pdata->offset = size - pdata->width / BITS_PER_BYTE;
 
 	addr = dev_read_addr(dev);
 	if (addr == FDT_ADDR_T_NONE) {