diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2007-05-21 16:08:01 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-01-24 23:40:36 -0500 |
commit | edfaa7c36574f1bf09c65ad602412db9da5f96bf (patch) | |
tree | d591b80ff9229e4845e41d68e2f4c5aadb017027 /include/linux/genhd.h | |
parent | 09f82ea92822a7bbb7e816508abbda47ed54a77f (diff) |
Driver core: convert block from raw kobjects to core devices
This moves the block devices to /sys/class/block. It will create a
flat list of all block devices, with the disks and partitions in one
directory. For compatibility /sys/block is created and contains symlinks
to the disks.
/sys/class/block
|-- sda -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda
|-- sda1 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1
|-- sda10 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda10
|-- sda5 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5
|-- sda6 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda6
|-- sda7 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda7
|-- sda8 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda8
|-- sda9 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda9
`-- sr0 -> ../../devices/pci0000:00/0000:00:1f.2/host1/target1:0:0/1:0:0:0/block/sr0
/sys/block/
|-- sda -> ../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda
`-- sr0 -> ../devices/pci0000:00/0000:00:1f.2/host1/target1:0:0/1:0:0:0/block/sr0
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'include/linux/genhd.h')
-rw-r--r-- | include/linux/genhd.h | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/include/linux/genhd.h b/include/linux/genhd.h index a47b8025d399..1dbea0ac5693 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h | |||
@@ -10,9 +10,19 @@ | |||
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/types.h> | 12 | #include <linux/types.h> |
13 | #include <linux/kdev_t.h> | ||
13 | 14 | ||
14 | #ifdef CONFIG_BLOCK | 15 | #ifdef CONFIG_BLOCK |
15 | 16 | ||
17 | #define kobj_to_dev(k) container_of(k, struct device, kobj) | ||
18 | #define dev_to_disk(device) container_of(device, struct gendisk, dev) | ||
19 | #define dev_to_part(device) container_of(device, struct hd_struct, dev) | ||
20 | |||
21 | extern struct device_type disk_type; | ||
22 | extern struct device_type part_type; | ||
23 | extern struct kobject *block_depr; | ||
24 | extern struct class block_class; | ||
25 | |||
16 | enum { | 26 | enum { |
17 | /* These three have identical behaviour; use the second one if DOS FDISK gets | 27 | /* These three have identical behaviour; use the second one if DOS FDISK gets |
18 | confused about extended/logical partitions starting past cylinder 1023. */ | 28 | confused about extended/logical partitions starting past cylinder 1023. */ |
@@ -84,7 +94,7 @@ struct partition { | |||
84 | struct hd_struct { | 94 | struct hd_struct { |
85 | sector_t start_sect; | 95 | sector_t start_sect; |
86 | sector_t nr_sects; | 96 | sector_t nr_sects; |
87 | struct kobject kobj; | 97 | struct device dev; |
88 | struct kobject *holder_dir; | 98 | struct kobject *holder_dir; |
89 | unsigned ios[2], sectors[2]; /* READs and WRITEs */ | 99 | unsigned ios[2], sectors[2]; /* READs and WRITEs */ |
90 | int policy, partno; | 100 | int policy, partno; |
@@ -117,15 +127,14 @@ struct gendisk { | |||
117 | * disks that can't be partitioned. */ | 127 | * disks that can't be partitioned. */ |
118 | char disk_name[32]; /* name of major driver */ | 128 | char disk_name[32]; /* name of major driver */ |
119 | struct hd_struct **part; /* [indexed by minor] */ | 129 | struct hd_struct **part; /* [indexed by minor] */ |
120 | int part_uevent_suppress; | ||
121 | struct block_device_operations *fops; | 130 | struct block_device_operations *fops; |
122 | struct request_queue *queue; | 131 | struct request_queue *queue; |
123 | void *private_data; | 132 | void *private_data; |
124 | sector_t capacity; | 133 | sector_t capacity; |
125 | 134 | ||
126 | int flags; | 135 | int flags; |
127 | struct device *driverfs_dev; | 136 | struct device *driverfs_dev; // FIXME: remove |
128 | struct kobject kobj; | 137 | struct device dev; |
129 | struct kobject *holder_dir; | 138 | struct kobject *holder_dir; |
130 | struct kobject *slave_dir; | 139 | struct kobject *slave_dir; |
131 | 140 | ||
@@ -143,13 +152,6 @@ struct gendisk { | |||
143 | struct work_struct async_notify; | 152 | struct work_struct async_notify; |
144 | }; | 153 | }; |
145 | 154 | ||
146 | /* Structure for sysfs attributes on block devices */ | ||
147 | struct disk_attribute { | ||
148 | struct attribute attr; | ||
149 | ssize_t (*show)(struct gendisk *, char *); | ||
150 | ssize_t (*store)(struct gendisk *, const char *, size_t); | ||
151 | }; | ||
152 | |||
153 | /* | 155 | /* |
154 | * Macros to operate on percpu disk statistics: | 156 | * Macros to operate on percpu disk statistics: |
155 | * | 157 | * |
@@ -411,7 +413,8 @@ struct unixware_disklabel { | |||
411 | #define ADDPART_FLAG_RAID 1 | 413 | #define ADDPART_FLAG_RAID 1 |
412 | #define ADDPART_FLAG_WHOLEDISK 2 | 414 | #define ADDPART_FLAG_WHOLEDISK 2 |
413 | 415 | ||
414 | char *disk_name (struct gendisk *hd, int part, char *buf); | 416 | extern dev_t blk_lookup_devt(const char *name); |
417 | extern char *disk_name (struct gendisk *hd, int part, char *buf); | ||
415 | 418 | ||
416 | extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev); | 419 | extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev); |
417 | extern void add_partition(struct gendisk *, int, sector_t, sector_t, int); | 420 | extern void add_partition(struct gendisk *, int, sector_t, sector_t, int); |
@@ -423,12 +426,12 @@ extern struct gendisk *alloc_disk(int minors); | |||
423 | extern struct kobject *get_disk(struct gendisk *disk); | 426 | extern struct kobject *get_disk(struct gendisk *disk); |
424 | extern void put_disk(struct gendisk *disk); | 427 | extern void put_disk(struct gendisk *disk); |
425 | extern void genhd_media_change_notify(struct gendisk *disk); | 428 | extern void genhd_media_change_notify(struct gendisk *disk); |
426 | extern void blk_register_region(dev_t dev, unsigned long range, | 429 | extern void blk_register_region(dev_t devt, unsigned long range, |
427 | struct module *module, | 430 | struct module *module, |
428 | struct kobject *(*probe)(dev_t, int *, void *), | 431 | struct kobject *(*probe)(dev_t, int *, void *), |
429 | int (*lock)(dev_t, void *), | 432 | int (*lock)(dev_t, void *), |
430 | void *data); | 433 | void *data); |
431 | extern void blk_unregister_region(dev_t dev, unsigned long range); | 434 | extern void blk_unregister_region(dev_t devt, unsigned long range); |
432 | 435 | ||
433 | static inline struct block_device *bdget_disk(struct gendisk *disk, int index) | 436 | static inline struct block_device *bdget_disk(struct gendisk *disk, int index) |
434 | { | 437 | { |
@@ -441,6 +444,12 @@ static inline struct block_device *bdget_disk(struct gendisk *disk, int index) | |||
441 | 444 | ||
442 | static inline void printk_all_partitions(void) { } | 445 | static inline void printk_all_partitions(void) { } |
443 | 446 | ||
447 | static inline dev_t blk_lookup_devt(const char *name) | ||
448 | { | ||
449 | dev_t devt = MKDEV(0, 0); | ||
450 | return devt; | ||
451 | } | ||
452 | |||
444 | #endif /* CONFIG_BLOCK */ | 453 | #endif /* CONFIG_BLOCK */ |
445 | 454 | ||
446 | #endif | 455 | #endif |