diff options
Diffstat (limited to 'include/linux/genhd.h')
-rw-r--r-- | include/linux/genhd.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/include/linux/genhd.h b/include/linux/genhd.h index e7bf84240..c07a473d1 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -11,6 +11,7 @@ #include <linux/config.h> #include <linux/types.h> +#include <linux/major.h> /* These three have identical behaviour; use the second one if DOS fdisk gets confused about extended/logical partitions starting past cylinder 1023. */ @@ -233,6 +234,35 @@ extern void devfs_register_partitions (struct gendisk *dev, int minor, int get_hardsect_size(kdev_t dev); +/* + * FIXME: this should use genhd->minor_shift, but that is slow to look up. + */ +static inline unsigned int disk_index (kdev_t dev) +{ + int major = MAJOR(dev); + int minor = MINOR(dev); + unsigned int index; + + switch (major) { + case DAC960_MAJOR+0: + index = (minor & 0x00f8) >> 3; + break; + case SCSI_DISK0_MAJOR: + index = (minor & 0x00f0) >> 4; + break; + case IDE0_MAJOR: /* same as HD_MAJOR */ + case XT_DISK_MAJOR: + index = (minor & 0x0040) >> 6; + break; + case IDE1_MAJOR: + index = ((minor & 0x0040) >> 6) + 2; + break; + default: + return 0; + } + return index; +} + #endif #endif |