summaryrefslogtreecommitdiffstats
path: root/drivers/ipack/ipack.c
diff options
context:
space:
mode:
authorSamuel Iglesias Gonsalvez <siglesias@igalia.com>2013-03-08 09:21:47 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-03-15 12:23:09 -0700
commite926301b39a07f587ff8c66354a2e2ee4c29162c (patch)
tree407121dd6ef41bfa48681e2ed4f7f48bf85b5f40 /drivers/ipack/ipack.c
parentfa882867ae5f8543eb304a1667563f1c99514475 (diff)
downloadlinux-e926301b39a07f587ff8c66354a2e2ee4c29162c.tar.bz2
ipack: split ipack_device_register() in several functions
One function is ipack_device_init(). If it fails, the caller should execute ipack_put_device(). The second function is ipack_device_add that only adds the device. If it fails, the caller should execute ipack_put_device(). Then the device is removed with refcount = 0, as device_register() kernel documentation says. ipack_device_del() is added to remove the device. Signed-off-by: Samuel Iglesias Gonsalvez <siglesias@igalia.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/ipack/ipack.c')
-rw-r--r--drivers/ipack/ipack.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/drivers/ipack/ipack.c b/drivers/ipack/ipack.c
index 4f913aa88971..6e066c53acce 100644
--- a/drivers/ipack/ipack.c
+++ b/drivers/ipack/ipack.c
@@ -227,7 +227,7 @@ static int ipack_unregister_bus_member(struct device *dev, void *data)
struct ipack_bus_device *bus = data;
if (idev->bus == bus)
- ipack_device_unregister(idev);
+ ipack_device_del(idev);
return 1;
}
@@ -419,7 +419,7 @@ out:
return ret;
}
-int ipack_device_register(struct ipack_device *dev)
+int ipack_device_init(struct ipack_device *dev)
{
int ret;
@@ -428,6 +428,7 @@ int ipack_device_register(struct ipack_device *dev)
dev->dev.parent = dev->bus->parent;
dev_set_name(&dev->dev,
"ipack-dev.%u.%u", dev->bus->bus_nr, dev->slot);
+ device_initialize(&dev->dev);
if (dev->bus->ops->set_clockrate(dev, 8))
dev_warn(&dev->dev, "failed to switch to 8 MHz operation for reading of device ID.\n");
@@ -447,19 +448,22 @@ int ipack_device_register(struct ipack_device *dev)
dev_err(&dev->dev, "failed to switch to 32 MHz operation.\n");
}
- ret = device_register(&dev->dev);
- if (ret < 0)
- kfree(dev->id);
+ return 0;
+}
+EXPORT_SYMBOL_GPL(ipack_device_init);
- return ret;
+int ipack_device_add(struct ipack_device *dev)
+{
+ return device_add(&dev->dev);
}
-EXPORT_SYMBOL_GPL(ipack_device_register);
+EXPORT_SYMBOL_GPL(ipack_device_add);
-void ipack_device_unregister(struct ipack_device *dev)
+void ipack_device_del(struct ipack_device *dev)
{
- device_unregister(&dev->dev);
+ device_del(&dev->dev);
+ ipack_put_device(dev);
}
-EXPORT_SYMBOL_GPL(ipack_device_unregister);
+EXPORT_SYMBOL_GPL(ipack_device_del);
void ipack_get_device(struct ipack_device *dev)
{