gpu: host1x: Call ->remove() only when a device is bound
authorThierry Reding <treding@nvidia.com>
Wed, 5 Nov 2014 10:43:26 +0000 (11:43 +0100)
committerThierry Reding <treding@nvidia.com>
Fri, 23 Jan 2015 11:07:00 +0000 (12:07 +0100)
When a driver's ->probe() function fails, the host1x bus must not call
its ->remove() function because the driver will already have cleaned up
in the error handling path in ->probe().

Signed-off-by: Thierry Reding <treding@nvidia.com>
drivers/gpu/host1x/bus.c
include/linux/host1x.h

index aaf54859adb05c4c7ffaffabb51bb333e09d1528..e4182e68e29caf00012b449897ac6e2439d93b6b 100644 (file)
@@ -116,7 +116,10 @@ static void host1x_subdev_register(struct host1x_device *device,
        if (list_empty(&device->subdevs)) {
                err = device->driver->probe(device);
                if (err < 0)
-                       dev_err(&device->dev, "probe failed: %d\n", err);
+                       dev_err(&device->dev, "probe failed for %ps: %d\n",
+                               device->driver, err);
+               else
+                       device->bound = true;
        }
 }
 
@@ -130,10 +133,12 @@ static void __host1x_subdev_unregister(struct host1x_device *device,
         * If all subdevices have been activated, we're about to remove the
         * first active subdevice, so unload the driver first.
         */
-       if (list_empty(&device->subdevs)) {
+       if (list_empty(&device->subdevs) && device->bound) {
                err = device->driver->remove(device);
                if (err < 0)
                        dev_err(&device->dev, "remove failed: %d\n", err);
+
+               device->bound = false;
        }
 
        /*
index bb9840fd1e18855305241daca6cc6a68ce18a066..7890b553d12ec074421ded87a6722bec730fe5ee 100644 (file)
@@ -272,6 +272,8 @@ struct host1x_device {
 
        struct mutex clients_lock;
        struct list_head clients;
+
+       bool bound;
 };
 
 static inline struct host1x_device *to_host1x_device(struct device *dev)