]> git.baikalelectronics.ru Git - kernel.git/commitdiff
macintosh: therm_windtunnel: drop using attach_adapter
authorWolfram Sang <wsa@the-dreams.de>
Tue, 21 Aug 2018 15:02:39 +0000 (17:02 +0200)
committerWolfram Sang <wsa@the-dreams.de>
Fri, 24 Aug 2018 12:42:42 +0000 (14:42 +0200)
As we now have deferred probing, we can use a custom mechanism and
finally get rid of the legacy interface from the i2c core.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Acked-by: Michael Ellerman <mpe@ellerman.id.au>
drivers/macintosh/therm_windtunnel.c

index 68dcbcb4fc5bc2b33682d1bee513747656067d18..8c744578122a3e229079571b7bce093380c90662 100644 (file)
@@ -432,7 +432,6 @@ static struct i2c_driver g4fan_driver = {
        .driver = {
                .name   = "therm_windtunnel",
        },
-       .attach_adapter = do_attach,
        .probe          = do_probe,
        .remove         = do_remove,
        .id_table       = therm_windtunnel_id,
@@ -445,7 +444,29 @@ static struct i2c_driver g4fan_driver = {
 
 static int therm_of_probe(struct platform_device *dev)
 {
-       return i2c_add_driver( &g4fan_driver );
+       struct i2c_adapter *adap;
+       int ret, i = 0;
+
+       adap = i2c_get_adapter(0);
+       if (!adap)
+               return -EPROBE_DEFER;
+
+       ret = i2c_add_driver(&g4fan_driver);
+       if (ret) {
+               i2c_put_adapter(adap);
+               return ret;
+       }
+
+       /* We assume Macs have consecutive I2C bus numbers starting at 0 */
+       while (adap) {
+               do_attach(adap);
+               if (x.running)
+                       return 0;
+               i2c_put_adapter(adap);
+               adap = i2c_get_adapter(++i);
+       }
+
+       return -ENODEV;
 }
 
 static int