This is required so that we give up the last reference to the device.
Also, this makes superhyway_device_release actually used.

Signed-off-by: Levente Kurusa <le...@linux.com>
---
 drivers/sh/superhyway/superhyway.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/sh/superhyway/superhyway.c 
b/drivers/sh/superhyway/superhyway.c
index 2d9e7f3..765cf7d 100644
--- a/drivers/sh/superhyway/superhyway.c
+++ b/drivers/sh/superhyway/superhyway.c
@@ -54,6 +54,7 @@ int superhyway_add_device(unsigned long base, struct 
superhyway_device *sdev,
                          struct superhyway_bus *bus)
 {
        struct superhyway_device *dev = sdev;
+       int rc = 0;
 
        if (!dev) {
                dev = kzalloc(sizeof(struct superhyway_device), GFP_KERNEL);
@@ -86,8 +87,11 @@ int superhyway_add_device(unsigned long base, struct 
superhyway_device *sdev,
        dev_set_name(&dev->dev, "%02x", superhyway_devices);
 
        superhyway_devices++;
+       rc = device_register(&dev->dev);
+       if (rc)
+               put_device(&dev->dev);
 
-       return device_register(&dev->dev);
+       return rc;
 }
 
 int superhyway_add_devices(struct superhyway_bus *bus,
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to