Skip to content

Commit d052db1

Browse files
Wolfram SangWolfram Sang
authored andcommitted
i2c: mux: demux-pinctrl: make drivers with no pinctrl work again
Some drivers like i2c-gpio do not have dedicated pinctrl states. They broke when error checking for pinctrl was added. Detect them now, and in their case, simply skip over pinctrl configuration. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
1 parent bc33b0c commit d052db1

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

drivers/i2c/muxes/i2c-demux-pinctrl.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,28 @@ static int i2c_demux_activate_master(struct i2c_demux_pinctrl_priv *priv, u32 ne
6969
goto err_with_revert;
7070
}
7171

72-
p = devm_pinctrl_get_select(adap->dev.parent, priv->bus_name);
72+
/*
73+
* Check if there are pinctrl states at all. Note: we cant' use
74+
* devm_pinctrl_get_select() because we need to distinguish between
75+
* the -ENODEV from devm_pinctrl_get() and pinctrl_lookup_state().
76+
*/
77+
p = devm_pinctrl_get(adap->dev.parent);
7378
if (IS_ERR(p)) {
7479
ret = PTR_ERR(p);
75-
goto err_with_put;
80+
/* continue if just no pinctrl states (e.g. i2c-gpio), otherwise exit */
81+
if (ret != -ENODEV)
82+
goto err_with_put;
83+
} else {
84+
/* there are states. check and use them */
85+
struct pinctrl_state *s = pinctrl_lookup_state(p, priv->bus_name);
86+
87+
if (IS_ERR(s)) {
88+
ret = PTR_ERR(s);
89+
goto err_with_put;
90+
}
91+
ret = pinctrl_select_state(p, s);
92+
if (ret < 0)
93+
goto err_with_put;
7694
}
7795

7896
priv->chan[new_chan].parent_adap = adap;

0 commit comments

Comments
 (0)