aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ipack/carriers
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/carriers
parentipack: add ipack_get_device() ipack_put_device() (diff)
downloadlinux-dev-e926301b39a07f587ff8c66354a2e2ee4c29162c.tar.xz
linux-dev-e926301b39a07f587ff8c66354a2e2ee4c29162c.zip
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/carriers')
-rw-r--r--drivers/ipack/carriers/tpci200.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/drivers/ipack/carriers/tpci200.c b/drivers/ipack/carriers/tpci200.c
index 0246b1fddffe..c276fde318e5 100644
--- a/drivers/ipack/carriers/tpci200.c
+++ b/drivers/ipack/carriers/tpci200.c
@@ -480,6 +480,7 @@ static void tpci200_release_device(struct ipack_device *dev)
static int tpci200_create_device(struct tpci200_board *tpci200, int i)
{
+ int ret;
enum ipack_space space;
struct ipack_device *dev =
kzalloc(sizeof(struct ipack_device), GFP_KERNEL);
@@ -495,7 +496,18 @@ static int tpci200_create_device(struct tpci200_board *tpci200, int i)
+ tpci200_space_interval[space] * i;
dev->region[space].size = tpci200_space_size[space];
}
- return ipack_device_register(dev);
+
+ ret = ipack_device_init(dev);
+ if (ret < 0) {
+ ipack_put_device(dev);
+ return ret;
+ }
+
+ ret = ipack_device_add(dev);
+ if (ret < 0)
+ ipack_put_device(dev);
+
+ return ret;
}
static int tpci200_pci_probe(struct pci_dev *pdev,