summaryrefslogtreecommitdiffstats
path: root/include/linux/genhd.h
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2008-08-25 19:56:05 +0900
committerJens Axboe <jens.axboe@oracle.com>2008-10-09 08:56:07 +0200
commited9e1982347b36573cd622ee5f4e2a7ccd79b3fd (patch)
tree79d834094d655ec97cfc0a382a9207ebc8e711a5 /include/linux/genhd.h
parent870d6656126add8e383645732b03df2b7ccd4f94 (diff)
block: implement and use {disk|part}_to_dev()
Implement {disk|part}_to_dev() and use them to access generic device instead of directly dereferencing {disk|part}->dev. To make sure no user is left behind, rename generic devices fields to __dev. This is in preparation of unifying partition 0 handling with other partitions. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'include/linux/genhd.h')
-rw-r--r--include/linux/genhd.h20
1 files changed, 11 insertions, 9 deletions
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 6fc53242406..e4e18c509ac 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -15,9 +15,11 @@
#ifdef CONFIG_BLOCK
-#define kobj_to_dev(k) container_of(k, struct device, kobj)
-#define dev_to_disk(device) container_of(device, struct gendisk, dev)
-#define dev_to_part(device) container_of(device, struct hd_struct, dev)
+#define kobj_to_dev(k) container_of((k), struct device, kobj)
+#define dev_to_disk(device) container_of((device), struct gendisk, __dev)
+#define dev_to_part(device) container_of((device), struct hd_struct, __dev)
+#define disk_to_dev(disk) (&((disk)->__dev))
+#define part_to_dev(part) (&((part)->__dev))
extern struct device_type part_type;
extern struct kobject *block_depr;
@@ -88,7 +90,7 @@ struct disk_stats {
struct hd_struct {
sector_t start_sect;
sector_t nr_sects;
- struct device dev;
+ struct device __dev;
struct kobject *holder_dir;
int policy, partno;
#ifdef CONFIG_FAIL_MAKE_REQUEST
@@ -139,7 +141,7 @@ struct gendisk {
int flags;
struct device *driverfs_dev; // FIXME: remove
- struct device dev;
+ struct device __dev;
struct kobject *holder_dir;
struct kobject *slave_dir;
@@ -163,7 +165,7 @@ struct gendisk {
static inline struct gendisk *part_to_disk(struct hd_struct *part)
{
if (likely(part))
- return dev_to_disk((part)->dev.parent);
+ return dev_to_disk(part_to_dev(part)->parent);
return NULL;
}
@@ -174,12 +176,12 @@ static inline int disk_max_parts(struct gendisk *disk)
static inline dev_t disk_devt(struct gendisk *disk)
{
- return disk->dev.devt;
+ return disk_to_dev(disk)->devt;
}
static inline dev_t part_devt(struct hd_struct *part)
{
- return part->dev.devt;
+ return part_to_dev(part)->devt;
}
extern struct hd_struct *disk_get_part(struct gendisk *disk, int partno);
@@ -187,7 +189,7 @@ extern struct hd_struct *disk_get_part(struct gendisk *disk, int partno);
static inline void disk_put_part(struct hd_struct *part)
{
if (likely(part))
- put_device(&part->dev);
+ put_device(part_to_dev(part));
}
/*