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

From: Pavel Emelyanov
Date: Wed Mar 05 2008 - 12:40:05 EST


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@xxxxxxxxxx>

---
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

--
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/