bcma: use (get|put)_device when probing/removing device driver
authorRafał Miłecki <rafal@milecki.pl>
Sat, 28 Jan 2017 13:31:22 +0000 (14:31 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 20 Jun 2017 12:04:24 +0000 (14:04 +0200)
commit a971df0b9d04674e325346c17de9a895425ca5e1 upstream.

This allows tracking device state and e.g. makes devm work as expected.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Willy Tarreau <w@1wt.eu>
drivers/bcma/main.c

index f72f52b4b1dde78311ff4872f57eaf8d838ad456..65e36873656b0fb33e452471472cf063b0bc3bd8 100644 (file)
@@ -432,8 +432,11 @@ static int bcma_device_probe(struct device *dev)
                                               drv);
        int err = 0;
 
+       get_device(dev);
        if (adrv->probe)
                err = adrv->probe(core);
+       if (err)
+               put_device(dev);
 
        return err;
 }
@@ -446,6 +449,7 @@ static int bcma_device_remove(struct device *dev)
 
        if (adrv->remove)
                adrv->remove(core);
+       put_device(dev);
 
        return 0;
 }