From: Dario Binacchi Date: Sun, 11 Apr 2021 07:39:43 +0000 (+0200) Subject: pinctrl: single: get register area size by device API X-Git-Tag: v2025.01-rc5-pxa1908~1916^2~8 X-Git-Url: http://git.dujemihanovic.xyz/login.html?a=commitdiff_plain;h=9fd8a430f33f1a412a43c12a8b83e19ed91a16fd;p=u-boot.git pinctrl: single: get register area size by device API Use dev_read_addr_size to get size of the controller's register area. Signed-off-by: Dario Binacchi Reviewed-by: Pratyush Yadav --- diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c index cec00e289c..d5656de8e8 100644 --- a/drivers/pinctrl/pinctrl-single.c +++ b/drivers/pinctrl/pinctrl-single.c @@ -182,17 +182,19 @@ 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; + addr = dev_read_addr_size(dev, "reg", &size); + if (addr == FDT_ADDR_T_NONE) { + dev_err(dev, "failed to get base register size\n"); + return -EINVAL; + } + + pdata->offset = size - pdata->width / BITS_PER_BYTE; addr = dev_read_addr(dev); if (addr == FDT_ADDR_T_NONE) {