Commit fc9d0cd9 authored by Wolfram Sang's avatar Wolfram Sang

Merge branch 'i2c-mux/for-current' of https://github.com/peda-r/i2c-mux into i2c/for-current

Pull bugfixes from the i2c mux subsubsystem:

This fixes an old bug in resource cleanup on failure in i2c-mux-reg and
a new log spamming bug from this merge window in the i2c-mux core.
parents 2ea659a9 9fce894d
...@@ -395,18 +395,20 @@ int i2c_mux_add_adapter(struct i2c_mux_core *muxc, ...@@ -395,18 +395,20 @@ int i2c_mux_add_adapter(struct i2c_mux_core *muxc,
if (force_nr) { if (force_nr) {
priv->adap.nr = force_nr; priv->adap.nr = force_nr;
ret = i2c_add_numbered_adapter(&priv->adap); ret = i2c_add_numbered_adapter(&priv->adap);
if (ret < 0) {
dev_err(&parent->dev, dev_err(&parent->dev,
"failed to add mux-adapter %u as bus %u (error=%d)\n", "failed to add mux-adapter %u as bus %u (error=%d)\n",
chan_id, force_nr, ret); chan_id, force_nr, ret);
goto err_free_priv;
}
} else { } else {
ret = i2c_add_adapter(&priv->adap); ret = i2c_add_adapter(&priv->adap);
if (ret < 0) {
dev_err(&parent->dev, dev_err(&parent->dev,
"failed to add mux-adapter %u (error=%d)\n", "failed to add mux-adapter %u (error=%d)\n",
chan_id, ret); chan_id, ret);
goto err_free_priv;
} }
if (ret < 0) {
kfree(priv);
return ret;
} }
WARN(sysfs_create_link(&priv->adap.dev.kobj, &muxc->dev->kobj, WARN(sysfs_create_link(&priv->adap.dev.kobj, &muxc->dev->kobj,
...@@ -422,6 +424,10 @@ int i2c_mux_add_adapter(struct i2c_mux_core *muxc, ...@@ -422,6 +424,10 @@ int i2c_mux_add_adapter(struct i2c_mux_core *muxc,
muxc->adapter[muxc->num_adapters++] = &priv->adap; muxc->adapter[muxc->num_adapters++] = &priv->adap;
return 0; return 0;
err_free_priv:
kfree(priv);
return ret;
} }
EXPORT_SYMBOL_GPL(i2c_mux_add_adapter); EXPORT_SYMBOL_GPL(i2c_mux_add_adapter);
......
...@@ -196,20 +196,25 @@ static int i2c_mux_reg_probe(struct platform_device *pdev) ...@@ -196,20 +196,25 @@ static int i2c_mux_reg_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
mux->data.reg_size = resource_size(res); mux->data.reg_size = resource_size(res);
mux->data.reg = devm_ioremap_resource(&pdev->dev, res); mux->data.reg = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(mux->data.reg)) if (IS_ERR(mux->data.reg)) {
return PTR_ERR(mux->data.reg); ret = PTR_ERR(mux->data.reg);
goto err_put_parent;
}
} }
if (mux->data.reg_size != 4 && mux->data.reg_size != 2 && if (mux->data.reg_size != 4 && mux->data.reg_size != 2 &&
mux->data.reg_size != 1) { mux->data.reg_size != 1) {
dev_err(&pdev->dev, "Invalid register size\n"); dev_err(&pdev->dev, "Invalid register size\n");
return -EINVAL; ret = -EINVAL;
goto err_put_parent;
} }
muxc = i2c_mux_alloc(parent, &pdev->dev, mux->data.n_values, 0, 0, muxc = i2c_mux_alloc(parent, &pdev->dev, mux->data.n_values, 0, 0,
i2c_mux_reg_select, NULL); i2c_mux_reg_select, NULL);
if (!muxc) if (!muxc) {
return -ENOMEM; ret = -ENOMEM;
goto err_put_parent;
}
muxc->priv = mux; muxc->priv = mux;
platform_set_drvdata(pdev, muxc); platform_set_drvdata(pdev, muxc);
...@@ -223,7 +228,7 @@ static int i2c_mux_reg_probe(struct platform_device *pdev) ...@@ -223,7 +228,7 @@ static int i2c_mux_reg_probe(struct platform_device *pdev)
ret = i2c_mux_add_adapter(muxc, nr, mux->data.values[i], class); ret = i2c_mux_add_adapter(muxc, nr, mux->data.values[i], class);
if (ret) if (ret)
goto add_adapter_failed; goto err_del_mux_adapters;
} }
dev_dbg(&pdev->dev, "%d port mux on %s adapter\n", dev_dbg(&pdev->dev, "%d port mux on %s adapter\n",
...@@ -231,8 +236,10 @@ static int i2c_mux_reg_probe(struct platform_device *pdev) ...@@ -231,8 +236,10 @@ static int i2c_mux_reg_probe(struct platform_device *pdev)
return 0; return 0;
add_adapter_failed: err_del_mux_adapters:
i2c_mux_del_adapters(muxc); i2c_mux_del_adapters(muxc);
err_put_parent:
i2c_put_adapter(parent);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment