diff options
author | Patrice Chotard <patrice.chotard@st.com> | 2019-02-25 13:39:55 +0100 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2019-04-11 20:10:05 -0600 |
commit | dce406e0a2d776424efd03aa6a83b817557d2373 (patch) | |
tree | 4d7554e015ef3f329134c23f15db3bb7c76276bd /drivers | |
parent | f00d89fd506755d68a224c19fd77c70e9199fcb4 (diff) |
dm: pinctrl: Avoid race condition on probe for UCLASS_PINCTRL
In case of system with several pin-controller device, probe the first
UCLASS_PINCTRL by seq number (defined by alias) to avoid race condition
with I2C PINCONTROL driver for GPIO expander (GPIO expander need I2C bus,
I2C driver need PINCONFIG).
Signed-off-by: Patrick DELAUNAY <patrick.delaunay@st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/pinctrl/pinctrl-uclass.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/pinctrl/pinctrl-uclass.c b/drivers/pinctrl/pinctrl-uclass.c index 6db0445067..4e6cef8ae7 100644 --- a/drivers/pinctrl/pinctrl-uclass.c +++ b/drivers/pinctrl/pinctrl-uclass.c @@ -179,11 +179,14 @@ static int pinctrl_select_state_simple(struct udevice *dev) int ret; /* - * For simplicity, assume the first device of PINCTRL uclass - * is the correct one. This is most likely OK as there is - * usually only one pinctrl device on the system. + * For most system, there is only one pincontroller device. But in + * case of multiple pincontroller devices, probe the one with sequence + * number 0 (defined by alias) to avoid race condition. */ - ret = uclass_get_device(UCLASS_PINCTRL, 0, &pctldev); + ret = uclass_get_device_by_seq(UCLASS_PINCTRL, 0, &pctldev); + if (ret) + /* if not found, get the first one */ + ret = uclass_get_device(UCLASS_PINCTRL, 0, &pctldev); if (ret) return ret; |