Pull i2c fixes from Wolfram Sang: "We had various reports of problems with deferred probing in the I2C subsystem, so this pull requst is a little bigger than usual. Most issues should be addressed now so devices will be found correctly. A few ususal driver bugfixes are in here, too" * 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: i2c: i2c-mux-pinctrl: use deferred probe when adapter not found i2c: i2c-arb-gpio-challenge: use deferred probe when adapter not found i2c: i2c-mux-gpio: use deferred probing i2c: i2c-mux-gpio: don't ignore of_get_named_gpio errors i2c: omap: Clear ARDY bit twice i2c: Not all adapters have a parent i2c: i2c-stu300: replace platform_driver_probe to support deferred probing i2c: i2c-mxs: replace platform_driver_probe to support deferred probing i2c: i2c-imx: replace platform_driver_probe to support deferred probing i2c: i2c-designware-platdrv: replace platform_driver_probe to support deferred probing
Unified · Split
| @@ -270,7 +270,8 @@ static SIMPLE_DEV_PM_OPS(dw_i2c_dev_pm_ops, dw_i2c_suspend, dw_i2c_resume); · 269 unmodified lines | ||
| 270 | 270 | MODULE_ALIAS("platform:i2c_designware"); |
| 271 | 271 | |
| 272 | 272 | static struct platform_driver dw_i2c_driver = { |
| 273 | − .remove = dw_i2c_remove, | |
| 273 | + .probe = dw_i2c_probe, | |
| 274 | + .remove = dw_i2c_remove, | |
| 274 | 275 | .driver = { |
| 275 | 276 | .name = "i2c_designware", |
| 276 | 277 | .owner = THIS_MODULE, |
| @@ -282,7 +283,7 @@ static struct platform_driver dw_i2c_driver = { · 5 unmodified lines | ||
| 282 | 283 | |
| 283 | 284 | static int __init dw_i2c_init_driver(void) |
| 284 | 285 | { |
| 285 | − return platform_driver_probe(&dw_i2c_driver, dw_i2c_probe); | |
| 286 | + return platform_driver_register(&dw_i2c_driver); | |
| 286 | 287 | } |
| 287 | 288 | subsys_initcall(dw_i2c_init_driver); |
| 288 | 289 | |
| @@ -365,7 +365,7 @@ static void i2c_imx_stop(struct imx_i2c_struct *i2c_imx) · 364 unmodified lines | ||
| 365 | 365 | clk_disable_unprepare(i2c_imx->clk); |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | −static void __init i2c_imx_set_clk(struct imx_i2c_struct *i2c_imx, | |
| 368 | +static void i2c_imx_set_clk(struct imx_i2c_struct *i2c_imx, | |
| 369 | 369 | unsigned int rate) |
| 370 | 370 | { |
| 371 | 371 | struct imx_i2c_clk_pair *i2c_clk_div = i2c_imx->hwdata->clk_div; |
| @@ -589,7 +589,7 @@ static struct i2c_algorithm i2c_imx_algo = { · 217 unmodified lines | ||
| 589 | 589 | .functionality = i2c_imx_func, |
| 590 | 590 | }; |
| 591 | 591 | |
| 592 | −static int __init i2c_imx_probe(struct platform_device *pdev) | |
| 592 | +static int i2c_imx_probe(struct platform_device *pdev) | |
| 593 | 593 | { |
| 594 | 594 | const struct of_device_id *of_id = of_match_device(i2c_imx_dt_ids, |
| 595 | 595 | &pdev->dev); |
| @@ -697,7 +697,7 @@ static int __init i2c_imx_probe(struct platform_device *pdev) · 101 unmodified lines | ||
| 697 | 697 | return 0; /* Return OK */ |
| 698 | 698 | } |
| 699 | 699 | |
| 700 | −static int __exit i2c_imx_remove(struct platform_device *pdev) | |
| 700 | +static int i2c_imx_remove(struct platform_device *pdev) | |
| 701 | 701 | { |
| 702 | 702 | struct imx_i2c_struct *i2c_imx = platform_get_drvdata(pdev); |
| 703 | 703 | |
| @@ -715,7 +715,8 @@ static int __exit i2c_imx_remove(struct platform_device *pdev) · 11 unmodified lines | ||
| 715 | 715 | } |
| 716 | 716 | |
| 717 | 717 | static struct platform_driver i2c_imx_driver = { |
| 718 | − .remove = __exit_p(i2c_imx_remove), | |
| 718 | + .probe = i2c_imx_probe, | |
| 719 | + .remove = i2c_imx_remove, | |
| 719 | 720 | .driver = { |
| 720 | 721 | .name = DRIVER_NAME, |
| 721 | 722 | .owner = THIS_MODULE, |
| @@ -726,7 +727,7 @@ static struct platform_driver i2c_imx_driver = { · 4 unmodified lines | ||
| 726 | 727 | |
| 727 | 728 | static int __init i2c_adap_imx_init(void) |
| 728 | 729 | { |
| 729 | − return platform_driver_probe(&i2c_imx_driver, i2c_imx_probe); | |
| 730 | + return platform_driver_register(&i2c_imx_driver); | |
| 730 | 731 | } |
| 731 | 732 | subsys_initcall(i2c_adap_imx_init); |
| 732 | 733 | |
| @@ -780,12 +780,13 @@ static struct platform_driver mxs_i2c_driver = { · 779 unmodified lines | ||
| 780 | 780 | .owner = THIS_MODULE, |
| 781 | 781 | .of_match_table = mxs_i2c_dt_ids, |
| 782 | 782 | }, |
| 783 | + .probe = mxs_i2c_probe, | |
| 783 | 784 | .remove = mxs_i2c_remove, |
| 784 | 785 | }; |
| 785 | 786 | |
| 786 | 787 | static int __init mxs_i2c_init(void) |
| 787 | 788 | { |
| 788 | − return platform_driver_probe(&mxs_i2c_driver, mxs_i2c_probe); | |
| 789 | + return platform_driver_register(&mxs_i2c_driver); | |
| 789 | 790 | } |
| 790 | 791 | subsys_initcall(mxs_i2c_init); |
| 791 | 792 | |
| @@ -939,6 +939,9 @@ omap_i2c_isr_thread(int this_irq, void *dev_id) · 938 unmodified lines | ||
| 939 | 939 | /* |
| 940 | 940 | * ProDB0017052: Clear ARDY bit twice |
| 941 | 941 | */ |
| 942 | + if (stat & OMAP_I2C_STAT_ARDY) | |
| 943 | + omap_i2c_ack_stat(dev, OMAP_I2C_STAT_ARDY); | |
| 944 | + | |
| 942 | 945 | if (stat & (OMAP_I2C_STAT_ARDY | OMAP_I2C_STAT_NACK | |
| 943 | 946 | OMAP_I2C_STAT_AL)) { |
| 944 | 947 | omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_RRDY | |
| @@ -859,8 +859,7 @@ static const struct i2c_algorithm stu300_algo = { · 858 unmodified lines | ||
| 859 | 859 | .functionality = stu300_func, |
| 860 | 860 | }; |
| 861 | 861 | |
| 862 | −static int __init | |
| 863 | −stu300_probe(struct platform_device *pdev) | |
| 862 | +static int stu300_probe(struct platform_device *pdev) | |
| 864 | 863 | { |
| 865 | 864 | struct stu300_dev *dev; |
| 866 | 865 | struct i2c_adapter *adap; |
| @@ -966,8 +965,7 @@ static SIMPLE_DEV_PM_OPS(stu300_pm, stu300_suspend, stu300_resume); · 99 unmodified lines | ||
| 966 | 965 | #define STU300_I2C_PM NULL |
| 967 | 966 | #endif |
| 968 | 967 | |
| 969 | −static int __exit | |
| 970 | −stu300_remove(struct platform_device *pdev) | |
| 968 | +static int stu300_remove(struct platform_device *pdev) | |
| 971 | 969 | { |
| 972 | 970 | struct stu300_dev *dev = platform_get_drvdata(pdev); |
| 973 | 971 | |
| @@ -989,13 +987,14 @@ static struct platform_driver stu300_i2c_driver = { · 15 unmodified lines | ||
| 989 | 987 | .pm = STU300_I2C_PM, |
| 990 | 988 | .of_match_table = stu300_dt_match, |
| 991 | 989 | }, |
| 992 | − .remove = __exit_p(stu300_remove), | |
| 990 | + .probe = stu300_probe, | |
| 991 | + .remove = stu300_remove, | |
| 993 | 992 | |
| 994 | 993 | }; |
| 995 | 994 | |
| 996 | 995 | static int __init stu300_init(void) |
| 997 | 996 | { |
| 998 | − return platform_driver_probe(&stu300_i2c_driver, stu300_probe); | |
| 997 | + return platform_driver_register(&stu300_i2c_driver); | |
| 999 | 998 | } |
| 1000 | 999 | |
| 1001 | 1000 | static void __exit stu300_exit(void) |
| @@ -1134,6 +1134,9 @@ static void acpi_i2c_register_devices(struct i2c_adapter *adap) · 1133 unmodified lines | ||
| 1134 | 1134 | acpi_handle handle; |
| 1135 | 1135 | acpi_status status; |
| 1136 | 1136 | |
| 1137 | + if (!adap->dev.parent) | |
| 1138 | + return; | |
| 1139 | + | |
| 1137 | 1140 | handle = ACPI_HANDLE(adap->dev.parent); |
| 1138 | 1141 | if (!handle) |
| 1139 | 1142 | return; |
| @@ -200,7 +200,7 @@ static int i2c_arbitrator_probe(struct platform_device *pdev) · 199 unmodified lines | ||
| 200 | 200 | arb->parent = of_find_i2c_adapter_by_node(parent_np); |
| 201 | 201 | if (!arb->parent) { |
| 202 | 202 | dev_err(dev, "Cannot find parent bus\n"); |
| 203 | − return -EINVAL; | |
| 203 | + return -EPROBE_DEFER; | |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /* Actually add the mux adapter */ |
| @@ -66,7 +66,7 @@ static int i2c_mux_gpio_probe_dt(struct gpiomux *mux, · 65 unmodified lines | ||
| 66 | 66 | struct device_node *adapter_np, *child; |
| 67 | 67 | struct i2c_adapter *adapter; |
| 68 | 68 | unsigned *values, *gpios; |
| 69 | − int i = 0; | |
| 69 | + int i = 0, ret; | |
| 70 | 70 | |
| 71 | 71 | if (!np) |
| 72 | 72 | return -ENODEV; |
| @@ -79,7 +79,7 @@ static int i2c_mux_gpio_probe_dt(struct gpiomux *mux, · 6 unmodified lines | ||
| 79 | 79 | adapter = of_find_i2c_adapter_by_node(adapter_np); |
| 80 | 80 | if (!adapter) { |
| 81 | 81 | dev_err(&pdev->dev, "Cannot find parent bus\n"); |
| 82 | − return -ENODEV; | |
| 82 | + return -EPROBE_DEFER; | |
| 83 | 83 | } |
| 84 | 84 | mux->data.parent = i2c_adapter_id(adapter); |
| 85 | 85 | put_device(&adapter->dev); |
| @@ -116,8 +116,12 @@ static int i2c_mux_gpio_probe_dt(struct gpiomux *mux, · 30 unmodified lines | ||
| 116 | 116 | return -ENOMEM; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | − for (i = 0; i < mux->data.n_gpios; i++) | |
| 120 | − gpios[i] = of_get_named_gpio(np, "mux-gpios", i); | |
| 119 | + for (i = 0; i < mux->data.n_gpios; i++) { | |
| 120 | + ret = of_get_named_gpio(np, "mux-gpios", i); | |
| 121 | + if (ret < 0) | |
| 122 | + return ret; | |
| 123 | + gpios[i] = ret; | |
| 124 | + } | |
| 121 | 125 | |
| 122 | 126 | mux->data.gpios = gpios; |
| 123 | 127 | |
| @@ -177,7 +181,7 @@ static int i2c_mux_gpio_probe(struct platform_device *pdev) · 53 unmodified lines | ||
| 177 | 181 | if (!parent) { |
| 178 | 182 | dev_err(&pdev->dev, "Parent adapter (%d) not found\n", |
| 179 | 183 | mux->data.parent); |
| 180 | − return -ENODEV; | |
| 184 | + return -EPROBE_DEFER; | |
| 181 | 185 | } |
| 182 | 186 | |
| 183 | 187 | mux->parent = parent; |
| @@ -113,7 +113,7 @@ static int i2c_mux_pinctrl_parse_dt(struct i2c_mux_pinctrl *mux, · 112 unmodified lines | ||
| 113 | 113 | adapter = of_find_i2c_adapter_by_node(adapter_np); |
| 114 | 114 | if (!adapter) { |
| 115 | 115 | dev_err(mux->dev, "Cannot find parent bus\n"); |
| 116 | − return -ENODEV; | |
| 116 | + return -EPROBE_DEFER; | |
| 117 | 117 | } |
| 118 | 118 | mux->pdata->parent_bus_num = i2c_adapter_id(adapter); |
| 119 | 119 | put_device(&adapter->dev); |
| @@ -211,7 +211,7 @@ static int i2c_mux_pinctrl_probe(struct platform_device *pdev) · 91 unmodified lines | ||
| 211 | 211 | if (!mux->parent) { |
| 212 | 212 | dev_err(&pdev->dev, "Parent adapter (%d) not found\n", |
| 213 | 213 | mux->pdata->parent_bus_num); |
| 214 | − ret = -ENODEV; | |
| 214 | + ret = -EPROBE_DEFER; | |
| 215 | 215 | goto err; |
| 216 | 216 | } |
| 217 | 217 | |