Commit e4925198 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux

Pull i2c fixes from Wolfram Sang:
 "Mostly slight adjusments for new drivers, but also one core fix for
  which finally the dependencies are now available as well"

* 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
  i2c: Mark instantiated device nodes with OF_POPULATE
  i2c: jz4780: Fix return value if probe fails
  i2c: xgene-slimpro: Fix missing mbox_free_channel call in probe error path
  i2c: I2C_MT65XX should depend on HAS_DMA
parents 8a7b8ff4 4f001fd3
...@@ -633,6 +633,7 @@ config I2C_MPC ...@@ -633,6 +633,7 @@ config I2C_MPC
config I2C_MT65XX config I2C_MT65XX
tristate "MediaTek I2C adapter" tristate "MediaTek I2C adapter"
depends on ARCH_MEDIATEK || COMPILE_TEST depends on ARCH_MEDIATEK || COMPILE_TEST
depends on HAS_DMA
help help
This selects the MediaTek(R) Integrated Inter Circuit bus driver This selects the MediaTek(R) Integrated Inter Circuit bus driver
for MT65xx and MT81xx. for MT65xx and MT81xx.
......
...@@ -764,12 +764,15 @@ static int jz4780_i2c_probe(struct platform_device *pdev) ...@@ -764,12 +764,15 @@ static int jz4780_i2c_probe(struct platform_device *pdev)
if (IS_ERR(i2c->clk)) if (IS_ERR(i2c->clk))
return PTR_ERR(i2c->clk); return PTR_ERR(i2c->clk);
clk_prepare_enable(i2c->clk); ret = clk_prepare_enable(i2c->clk);
if (ret)
return ret;
if (of_property_read_u32(pdev->dev.of_node, "clock-frequency", ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency",
&clk_freq)) { &clk_freq);
if (ret) {
dev_err(&pdev->dev, "clock-frequency not specified in DT"); dev_err(&pdev->dev, "clock-frequency not specified in DT");
return clk_freq; goto err;
} }
i2c->speed = clk_freq / 1000; i2c->speed = clk_freq / 1000;
...@@ -790,10 +793,8 @@ static int jz4780_i2c_probe(struct platform_device *pdev) ...@@ -790,10 +793,8 @@ static int jz4780_i2c_probe(struct platform_device *pdev)
i2c->irq = platform_get_irq(pdev, 0); i2c->irq = platform_get_irq(pdev, 0);
ret = devm_request_irq(&pdev->dev, i2c->irq, jz4780_i2c_irq, 0, ret = devm_request_irq(&pdev->dev, i2c->irq, jz4780_i2c_irq, 0,
dev_name(&pdev->dev), i2c); dev_name(&pdev->dev), i2c);
if (ret) { if (ret)
ret = -ENODEV;
goto err; goto err;
}
ret = i2c_add_adapter(&i2c->adap); ret = i2c_add_adapter(&i2c->adap);
if (ret < 0) { if (ret < 0) {
......
...@@ -419,6 +419,7 @@ static int xgene_slimpro_i2c_probe(struct platform_device *pdev) ...@@ -419,6 +419,7 @@ static int xgene_slimpro_i2c_probe(struct platform_device *pdev)
rc = i2c_add_adapter(adapter); rc = i2c_add_adapter(adapter);
if (rc) { if (rc) {
dev_err(&pdev->dev, "Adapter registeration failed\n"); dev_err(&pdev->dev, "Adapter registeration failed\n");
mbox_free_channel(ctx->mbox_chan);
return rc; return rc;
} }
......
...@@ -1012,6 +1012,8 @@ EXPORT_SYMBOL_GPL(i2c_new_device); ...@@ -1012,6 +1012,8 @@ EXPORT_SYMBOL_GPL(i2c_new_device);
*/ */
void i2c_unregister_device(struct i2c_client *client) void i2c_unregister_device(struct i2c_client *client)
{ {
if (client->dev.of_node)
of_node_clear_flag(client->dev.of_node, OF_POPULATED);
device_unregister(&client->dev); device_unregister(&client->dev);
} }
EXPORT_SYMBOL_GPL(i2c_unregister_device); EXPORT_SYMBOL_GPL(i2c_unregister_device);
...@@ -1320,8 +1322,11 @@ static void of_i2c_register_devices(struct i2c_adapter *adap) ...@@ -1320,8 +1322,11 @@ static void of_i2c_register_devices(struct i2c_adapter *adap)
dev_dbg(&adap->dev, "of_i2c: walking child nodes\n"); dev_dbg(&adap->dev, "of_i2c: walking child nodes\n");
for_each_available_child_of_node(adap->dev.of_node, node) for_each_available_child_of_node(adap->dev.of_node, node) {
if (of_node_test_and_set_flag(node, OF_POPULATED))
continue;
of_i2c_register_device(adap, node); of_i2c_register_device(adap, node);
}
} }
static int of_dev_node_match(struct device *dev, void *data) static int of_dev_node_match(struct device *dev, void *data)
...@@ -1853,6 +1858,11 @@ static int of_i2c_notify(struct notifier_block *nb, unsigned long action, ...@@ -1853,6 +1858,11 @@ static int of_i2c_notify(struct notifier_block *nb, unsigned long action,
if (adap == NULL) if (adap == NULL)
return NOTIFY_OK; /* not for us */ return NOTIFY_OK; /* not for us */
if (of_node_test_and_set_flag(rd->dn, OF_POPULATED)) {
put_device(&adap->dev);
return NOTIFY_OK;
}
client = of_i2c_register_device(adap, rd->dn); client = of_i2c_register_device(adap, rd->dn);
put_device(&adap->dev); put_device(&adap->dev);
...@@ -1863,6 +1873,10 @@ static int of_i2c_notify(struct notifier_block *nb, unsigned long action, ...@@ -1863,6 +1873,10 @@ static int of_i2c_notify(struct notifier_block *nb, unsigned long action,
} }
break; break;
case OF_RECONFIG_CHANGE_REMOVE: case OF_RECONFIG_CHANGE_REMOVE:
/* already depopulated? */
if (!of_node_check_flag(rd->dn, OF_POPULATED))
return NOTIFY_OK;
/* find our device by node */ /* find our device by node */
client = of_find_i2c_device_by_node(rd->dn); client = of_find_i2c_device_by_node(rd->dn);
if (client == NULL) if (client == NULL)
......
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