[PATCH 2/9] Cleanup the get_gendisk() a bit

Pavel Emelyanov
2008-03-05T17:40:04Z

The current implementation first converts kobj to device and
then checks for kobj not to be NULL. This is OK, since the
converting macros is a container_of one, but this does not
look very nice.

Besides, I'll have to add some code _before_ the kobj_lookup()
and thus will have to move the call to kobj_lookup lower.

So do this job here to make the further patching cleaner.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>

---
block/genhd.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/block/genhd.c b/block/genhd.c
index e8cf05a..9a7a903 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -212,10 +212,15 @@ void unlink_gendisk(struct gendisk *disk)
*/
struct gendisk *get_gendisk(dev_t devt, int *part)
{
- struct kobject *kobj = kobj_lookup(bdev_map, devt, part);
- struct device *dev = kobj_to_dev(kobj);
+ struct kobject *kobj;
+ struct device *dev;
+
+ kobj = kobj_lookup(bdev_map, devt, part);
+ if (kobj == NULL)
+ return NULL;

- return kobj ? dev_to_disk(dev) : NULL;
+ dev = kobj_to_dev(kobj);
+ return dev_to_disk(dev);
}

/*
--
1.5.3.4