Message ID | 5b4dc259cb10e8e8c4a1dcb2aab37f2d4d89dbef.1698889581.git.hanshu-oc@zhaoxin.com |
---|---|
State | New |
Headers | show |
Series | i2c: add zhaoxin i2c controller driver | expand |
> - /* Disable interrupts, clock and delete adapter */ > - writew(0, i2c_dev->base + REG_IMR); > - clk_disable_unprepare(i2c_dev->clk); NACK to this patch. The above lines are very important and need to stay. It is, in fact, very dangerous to use devm_* and to not take care that interrupts are disabled before leaving remove(). I'd suggest to simply drop this patch. > - i2c_del_adapter(&i2c_dev->adapter); > + return devm_i2c_add_adapter(&pdev->dev, &i2c_dev->adapter); > } > > static const struct of_device_id wmt_i2c_dt_ids[] = { > @@ -402,7 +388,6 @@ static const struct of_device_id wmt_i2c_dt_ids[] = { > > static struct platform_driver wmt_i2c_driver = { > .probe = wmt_i2c_probe, > - .remove_new = wmt_i2c_remove, > .driver = { > .name = "wmt-i2c", > .of_match_table = wmt_i2c_dt_ids, > -- > 2.34.1 >
diff --git a/drivers/i2c/busses/i2c-wmt.c b/drivers/i2c/busses/i2c-wmt.c index ec2a8da134e5..406b6827c42d 100644 --- a/drivers/i2c/busses/i2c-wmt.c +++ b/drivers/i2c/busses/i2c-wmt.c @@ -376,23 +376,9 @@ static int wmt_i2c_probe(struct platform_device *pdev) return err; } - err = i2c_add_adapter(adap); - if (err) - return err; - platform_set_drvdata(pdev, i2c_dev); - return 0; -} - -static void wmt_i2c_remove(struct platform_device *pdev) -{ - struct wmt_i2c_dev *i2c_dev = platform_get_drvdata(pdev); - - /* Disable interrupts, clock and delete adapter */ - writew(0, i2c_dev->base + REG_IMR); - clk_disable_unprepare(i2c_dev->clk); - i2c_del_adapter(&i2c_dev->adapter); + return devm_i2c_add_adapter(&pdev->dev, &i2c_dev->adapter); } static const struct of_device_id wmt_i2c_dt_ids[] = { @@ -402,7 +388,6 @@ static const struct of_device_id wmt_i2c_dt_ids[] = { static struct platform_driver wmt_i2c_driver = { .probe = wmt_i2c_probe, - .remove_new = wmt_i2c_remove, .driver = { .name = "wmt-i2c", .of_match_table = wmt_i2c_dt_ids,
use API devm_i2c_add_adapter instead of i2c_add_adapter, remove callback remove_new. Signed-off-by: Hans Hu <hanshu-oc@zhaoxin.com> --- drivers/i2c/busses/i2c-wmt.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-)