[PATCH 29/38] superhyway: maple: add missing put_device call

From: Levente Kurusa
Date: Thu Dec 19 2013 - 10:05:32 EST


This is required so that we give up the last reference to the device.
Also rework maple_release_device to use maple_free_dev instead, avoiding
same code being in two functions at the same time.

Signed-off-by: Levente Kurusa <levex@xxxxxxxxx>
---
drivers/sh/maple/maple.c | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/drivers/sh/maple/maple.c b/drivers/sh/maple/maple.c
index bec81c2..c4afb7e 100644
--- a/drivers/sh/maple/maple.c
+++ b/drivers/sh/maple/maple.c
@@ -134,16 +134,18 @@ static int maple_dma_done(void)
return (__raw_readl(MAPLE_STATE) & 1) == 0;
}

+static void maple_free_dev(struct maple_device *mdev)
+{
+ kmem_cache_free(maple_queue_cache, mdev->mq->recvbuf);
+ kfree(mdev->mq);
+ kfree(mdev);
+}
+
static void maple_release_device(struct device *dev)
{
struct maple_device *mdev;
- struct mapleq *mq;
-
mdev = to_maple_dev(dev);
- mq = mdev->mq;
- kmem_cache_free(maple_queue_cache, mq->recvbuf);
- kfree(mq);
- kfree(mdev);
+ maple_free_dev(mdev);
}

/**
@@ -234,13 +236,6 @@ static struct maple_device *maple_alloc_dev(int port, int unit)
return mdev;
}

-static void maple_free_dev(struct maple_device *mdev)
-{
- kmem_cache_free(maple_queue_cache, mdev->mq->recvbuf);
- kfree(mdev->mq);
- kfree(mdev);
-}
-
/* process the command queue into a maple command block
* terminating command has bit 32 of first long set to 0
*/
@@ -393,7 +388,7 @@ static void maple_attach_driver(struct maple_device *mdev)
dev_warn(&mdev->dev, "could not register device at"
" (%d, %d), with error 0x%X\n", mdev->unit,
mdev->port, error);
- maple_free_dev(mdev);
+ put_device(&mdev->dev);
mdev = NULL;
return;
}
--
1.8.3.1

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