aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWolfram Sang <wsa+renesas@sang-engineering.com>2016-08-23 11:28:03 -0400
committerWolfram Sang <wsa@the-dreams.de>2016-09-08 10:56:21 -0400
commite35478eac030990e23a56bf11dc074c5a069124a (patch)
tree374c5730ed236839f66165713b35498992acc958
parentb31cc4b37e8e33e84e9f990d0d84387f37ef01a1 (diff)
i2c: mux: demux-pinctrl: run properly with multiple instances
We can't use a static property for all the changesets, so we now create dynamic ones for each changeset. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Fixes: 50a5ba87690814 ("i2c: mux: demux-pinctrl: add driver") Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
-rw-r--r--drivers/i2c/muxes/i2c-demux-pinctrl.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/i2c/muxes/i2c-demux-pinctrl.c b/drivers/i2c/muxes/i2c-demux-pinctrl.c
index b6b9d2582fac..b3893f6282ba 100644
--- a/drivers/i2c/muxes/i2c-demux-pinctrl.c
+++ b/drivers/i2c/muxes/i2c-demux-pinctrl.c
@@ -37,8 +37,6 @@ struct i2c_demux_pinctrl_priv {
37 struct i2c_demux_pinctrl_chan chan[]; 37 struct i2c_demux_pinctrl_chan chan[];
38}; 38};
39 39
40static struct property status_okay = { .name = "status", .length = 3, .value = "ok" };
41
42static int i2c_demux_master_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) 40static int i2c_demux_master_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
43{ 41{
44 struct i2c_demux_pinctrl_priv *priv = adap->algo_data; 42 struct i2c_demux_pinctrl_priv *priv = adap->algo_data;
@@ -193,6 +191,7 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev)
193{ 191{
194 struct device_node *np = pdev->dev.of_node; 192 struct device_node *np = pdev->dev.of_node;
195 struct i2c_demux_pinctrl_priv *priv; 193 struct i2c_demux_pinctrl_priv *priv;
194 struct property *props;
196 int num_chan, i, j, err; 195 int num_chan, i, j, err;
197 196
198 num_chan = of_count_phandle_with_args(np, "i2c-parent", NULL); 197 num_chan = of_count_phandle_with_args(np, "i2c-parent", NULL);
@@ -203,7 +202,10 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev)
203 202
204 priv = devm_kzalloc(&pdev->dev, sizeof(*priv) 203 priv = devm_kzalloc(&pdev->dev, sizeof(*priv)
205 + num_chan * sizeof(struct i2c_demux_pinctrl_chan), GFP_KERNEL); 204 + num_chan * sizeof(struct i2c_demux_pinctrl_chan), GFP_KERNEL);
206 if (!priv) 205
206 props = devm_kcalloc(&pdev->dev, num_chan, sizeof(*props), GFP_KERNEL);
207
208 if (!priv || !props)
207 return -ENOMEM; 209 return -ENOMEM;
208 210
209 err = of_property_read_string(np, "i2c-bus-name", &priv->bus_name); 211 err = of_property_read_string(np, "i2c-bus-name", &priv->bus_name);
@@ -221,8 +223,12 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev)
221 } 223 }
222 priv->chan[i].parent_np = adap_np; 224 priv->chan[i].parent_np = adap_np;
223 225
226 props[i].name = devm_kstrdup(&pdev->dev, "status", GFP_KERNEL);
227 props[i].value = devm_kstrdup(&pdev->dev, "ok", GFP_KERNEL);
228 props[i].length = 3;
229
224 of_changeset_init(&priv->chan[i].chgset); 230 of_changeset_init(&priv->chan[i].chgset);
225 of_changeset_update_property(&priv->chan[i].chgset, adap_np, &status_okay); 231 of_changeset_update_property(&priv->chan[i].chgset, adap_np, &props[i]);
226 } 232 }
227 233
228 priv->num_chan = num_chan; 234 priv->num_chan = num_chan;