aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/linux/genhd.h13
1 files changed, 8 insertions, 5 deletions
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 1cf828148ec6..ff293ec8b3f7 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -16,9 +16,9 @@
16#ifdef CONFIG_BLOCK 16#ifdef CONFIG_BLOCK
17 17
18#define kobj_to_dev(k) container_of((k), struct device, kobj) 18#define kobj_to_dev(k) container_of((k), struct device, kobj)
19#define dev_to_disk(device) container_of((device), struct gendisk, __dev) 19#define dev_to_disk(device) container_of((device), struct gendisk, part0.__dev)
20#define dev_to_part(device) container_of((device), struct hd_struct, __dev) 20#define dev_to_part(device) container_of((device), struct hd_struct, __dev)
21#define disk_to_dev(disk) (&((disk)->__dev)) 21#define disk_to_dev(disk) (&(disk)->part0.__dev)
22#define part_to_dev(part) (&((part)->__dev)) 22#define part_to_dev(part) (&((part)->__dev))
23 23
24extern struct device_type part_type; 24extern struct device_type part_type;
@@ -141,7 +141,6 @@ struct gendisk {
141 141
142 int flags; 142 int flags;
143 struct device *driverfs_dev; // FIXME: remove 143 struct device *driverfs_dev; // FIXME: remove
144 struct device __dev;
145 struct kobject *holder_dir; 144 struct kobject *holder_dir;
146 struct kobject *slave_dir; 145 struct kobject *slave_dir;
147 146
@@ -164,8 +163,12 @@ struct gendisk {
164 163
165static inline struct gendisk *part_to_disk(struct hd_struct *part) 164static inline struct gendisk *part_to_disk(struct hd_struct *part)
166{ 165{
167 if (likely(part)) 166 if (likely(part)) {
168 return dev_to_disk(part_to_dev(part)->parent); 167 if (part->partno)
168 return dev_to_disk(part_to_dev(part)->parent);
169 else
170 return dev_to_disk(part_to_dev(part));
171 }
169 return NULL; 172 return NULL;
170} 173}
171 174