--- zzzz-none-000/linux-3.10.107/drivers/i2c/muxes/i2c-mux-gpio.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/i2c/muxes/i2c-mux-gpio.c 2021-02-04 17:41:59.000000000 +0000 @@ -12,11 +12,9 @@ #include #include #include -#include #include #include #include -#include #include struct gpiomux { @@ -67,7 +65,7 @@ struct device_node *adapter_np, *child; struct i2c_adapter *adapter; unsigned *values, *gpios; - int i = 0; + int i = 0, ret; if (!np) return -ENODEV; @@ -78,10 +76,10 @@ return -ENODEV; } adapter = of_find_i2c_adapter_by_node(adapter_np); - if (!adapter) { - dev_err(&pdev->dev, "Cannot find parent bus\n"); - return -ENODEV; - } + of_node_put(adapter_np); + if (!adapter) + return -EPROBE_DEFER; + mux->data.parent = i2c_adapter_id(adapter); put_device(&adapter->dev); @@ -117,8 +115,12 @@ return -ENOMEM; } - for (i = 0; i < mux->data.n_gpios; i++) - gpios[i] = of_get_named_gpio(np, "mux-gpios", i); + for (i = 0; i < mux->data.n_gpios; i++) { + ret = of_get_named_gpio(np, "mux-gpios", i); + if (ret < 0) + return ret; + gpios[i] = ret; + } mux->data.gpios = gpios; @@ -148,12 +150,14 @@ platform_set_drvdata(pdev, mux); - if (!pdev->dev.platform_data) { + if (!dev_get_platdata(&pdev->dev)) { ret = i2c_mux_gpio_probe_dt(mux, pdev); if (ret < 0) return ret; - } else - memcpy(&mux->data, pdev->dev.platform_data, sizeof(mux->data)); + } else { + memcpy(&mux->data, dev_get_platdata(&pdev->dev), + sizeof(mux->data)); + } /* * If a GPIO chip name is provided, the GPIO pin numbers provided are @@ -173,11 +177,8 @@ } parent = i2c_get_adapter(mux->data.parent); - if (!parent) { - dev_err(&pdev->dev, "Parent adapter (%d) not found\n", - mux->data.parent); - return -ENODEV; - } + if (!parent) + return -EPROBE_DEFER; mux->parent = parent; mux->gpio_base = gpio_base; @@ -276,9 +277,8 @@ .probe = i2c_mux_gpio_probe, .remove = i2c_mux_gpio_remove, .driver = { - .owner = THIS_MODULE, .name = "i2c-mux-gpio", - .of_match_table = of_match_ptr(i2c_mux_gpio_of_match), + .of_match_table = i2c_mux_gpio_of_match, }, };