diff mbox series

[05/11] pinctrl: single: check "register-width" DT property

Message ID 20210123182711.7177-6-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
In more recent versions of the Linux kernel the driver's probe function
returns an error if the "pinctrl-single,register-width" DT property is
missing. The lack of this information, in fact, does not allow to know
whether to access the registers of the controller at 8, 16 or 32 bits.

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

 drivers/pinctrl/pinctrl-single.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 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:
>
> In more recent versions of the Linux kernel the driver's probe function
> returns an error if the "pinctrl-single,register-width" DT property is
> missing. The lack of this information, in fact, does not allow to know
> whether to access the registers of the controller at 8, 16 or 32 bits.

"Update it to ..."

>
> Signed-off-by: Dario Binacchi <dariobin@libero.it>
> ---
>
>  drivers/pinctrl/pinctrl-single.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
>

Reviewed-by: Simon Glass <sjg@chromium.org>

Consider updating the pinctrl tests for this.
diff mbox series

Patch

diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index c80a42a193..8fd3bf66de 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -22,7 +22,7 @@  struct single_pdata {
 	fdt_addr_t base;
 	int offset;
 	u32 mask;
-	int width;
+	u32 width;
 	bool bits_per_mux;
 };
 
@@ -184,9 +184,13 @@  static int single_of_to_plat(struct udevice *dev)
 	fdt_addr_t addr;
 	fdt_size_t size;
 	struct single_pdata *pdata = dev_get_plat(dev);
+	int ret;
 
-	pdata->width =
-		dev_read_u32_default(dev, "pinctrl-single,register-width", 0);
+	ret = dev_read_u32(dev, "pinctrl-single,register-width", &pdata->width);
+	if (ret) {
+		dev_err(dev, "missing register width\n");
+		return ret;
+	}
 
 	dev_read_addr_size(dev, "reg", &size);
 	pdata->offset = size - pdata->width / BITS_PER_BYTE;