diff options
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/DAC960.c | 35 | ||||
-rw-r--r-- | drivers/block/acsi.c | 26 | ||||
-rw-r--r-- | drivers/block/amiflop.c | 23 | ||||
-rw-r--r-- | drivers/block/aoe/aoeblk.c | 26 | ||||
-rw-r--r-- | drivers/block/cciss.c | 31 | ||||
-rw-r--r-- | drivers/block/cpqarray.c | 36 | ||||
-rw-r--r-- | drivers/block/floppy.c | 35 | ||||
-rw-r--r-- | drivers/block/paride/pd.c | 34 | ||||
-rw-r--r-- | drivers/block/paride/pf.c | 50 | ||||
-rw-r--r-- | drivers/block/ps2esdi.c | 25 | ||||
-rw-r--r-- | drivers/block/sx8.c | 35 | ||||
-rw-r--r-- | drivers/block/umem.c | 41 | ||||
-rw-r--r-- | drivers/block/viodasd.c | 44 | ||||
-rw-r--r-- | drivers/block/xd.c | 25 |
14 files changed, 196 insertions, 270 deletions
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c index 21097a39a057..179c68a3cef3 100644 --- a/drivers/block/DAC960.c +++ b/drivers/block/DAC960.c | |||
@@ -92,34 +92,28 @@ static int DAC960_open(struct inode *inode, struct file *file) | |||
92 | return 0; | 92 | return 0; |
93 | } | 93 | } |
94 | 94 | ||
95 | static int DAC960_ioctl(struct inode *inode, struct file *file, | 95 | static int DAC960_getgeo(struct block_device *bdev, struct hd_geometry *geo) |
96 | unsigned int cmd, unsigned long arg) | ||
97 | { | 96 | { |
98 | struct gendisk *disk = inode->i_bdev->bd_disk; | 97 | struct gendisk *disk = bdev->bd_disk; |
99 | DAC960_Controller_T *p = disk->queue->queuedata; | 98 | DAC960_Controller_T *p = disk->queue->queuedata; |
100 | int drive_nr = (long)disk->private_data; | 99 | int drive_nr = (long)disk->private_data; |
101 | struct hd_geometry g; | ||
102 | struct hd_geometry __user *loc = (struct hd_geometry __user *)arg; | ||
103 | |||
104 | if (cmd != HDIO_GETGEO || !loc) | ||
105 | return -EINVAL; | ||
106 | 100 | ||
107 | if (p->FirmwareType == DAC960_V1_Controller) { | 101 | if (p->FirmwareType == DAC960_V1_Controller) { |
108 | g.heads = p->V1.GeometryTranslationHeads; | 102 | geo->heads = p->V1.GeometryTranslationHeads; |
109 | g.sectors = p->V1.GeometryTranslationSectors; | 103 | geo->sectors = p->V1.GeometryTranslationSectors; |
110 | g.cylinders = p->V1.LogicalDriveInformation[drive_nr]. | 104 | geo->cylinders = p->V1.LogicalDriveInformation[drive_nr]. |
111 | LogicalDriveSize / (g.heads * g.sectors); | 105 | LogicalDriveSize / (geo->heads * geo->sectors); |
112 | } else { | 106 | } else { |
113 | DAC960_V2_LogicalDeviceInfo_T *i = | 107 | DAC960_V2_LogicalDeviceInfo_T *i = |
114 | p->V2.LogicalDeviceInformation[drive_nr]; | 108 | p->V2.LogicalDeviceInformation[drive_nr]; |
115 | switch (i->DriveGeometry) { | 109 | switch (i->DriveGeometry) { |
116 | case DAC960_V2_Geometry_128_32: | 110 | case DAC960_V2_Geometry_128_32: |
117 | g.heads = 128; | 111 | geo->heads = 128; |
118 | g.sectors = 32; | 112 | geo->sectors = 32; |
119 | break; | 113 | break; |
120 | case DAC960_V2_Geometry_255_63: | 114 | case DAC960_V2_Geometry_255_63: |
121 | g.heads = 255; | 115 | geo->heads = 255; |
122 | g.sectors = 63; | 116 | geo->sectors = 63; |
123 | break; | 117 | break; |
124 | default: | 118 | default: |
125 | DAC960_Error("Illegal Logical Device Geometry %d\n", | 119 | DAC960_Error("Illegal Logical Device Geometry %d\n", |
@@ -127,12 +121,11 @@ static int DAC960_ioctl(struct inode *inode, struct file *file, | |||
127 | return -EINVAL; | 121 | return -EINVAL; |
128 | } | 122 | } |
129 | 123 | ||
130 | g.cylinders = i->ConfigurableDeviceSize / (g.heads * g.sectors); | 124 | geo->cylinders = i->ConfigurableDeviceSize / |
125 | (geo->heads * geo->sectors); | ||
131 | } | 126 | } |
132 | 127 | ||
133 | g.start = get_start_sect(inode->i_bdev); | 128 | return 0; |
134 | |||
135 | return copy_to_user(loc, &g, sizeof g) ? -EFAULT : 0; | ||
136 | } | 129 | } |
137 | 130 | ||
138 | static int DAC960_media_changed(struct gendisk *disk) | 131 | static int DAC960_media_changed(struct gendisk *disk) |
@@ -157,7 +150,7 @@ static int DAC960_revalidate_disk(struct gendisk *disk) | |||
157 | static struct block_device_operations DAC960_BlockDeviceOperations = { | 150 | static struct block_device_operations DAC960_BlockDeviceOperations = { |
158 | .owner = THIS_MODULE, | 151 | .owner = THIS_MODULE, |
159 | .open = DAC960_open, | 152 | .open = DAC960_open, |
160 | .ioctl = DAC960_ioctl, | 153 | .getgeo = DAC960_getgeo, |
161 | .media_changed = DAC960_media_changed, | 154 | .media_changed = DAC960_media_changed, |
162 | .revalidate_disk = DAC960_revalidate_disk, | 155 | .revalidate_disk = DAC960_revalidate_disk, |
163 | }; | 156 | }; |
diff --git a/drivers/block/acsi.c b/drivers/block/acsi.c index 5d2d649f7e8d..196c0ec9cd54 100644 --- a/drivers/block/acsi.c +++ b/drivers/block/acsi.c | |||
@@ -1079,6 +1079,19 @@ static void redo_acsi_request( void ) | |||
1079 | * | 1079 | * |
1080 | ***********************************************************************/ | 1080 | ***********************************************************************/ |
1081 | 1081 | ||
1082 | static int acsi_getgeo(struct block_device *bdev, struct hd_geometry *geo) | ||
1083 | { | ||
1084 | struct acsi_info_struct *aip = bdev->bd_disk->private_data; | ||
1085 | |||
1086 | /* | ||
1087 | * Just fake some geometry here, it's nonsense anyway | ||
1088 | * To make it easy, use Adaptec's usual 64/32 mapping | ||
1089 | */ | ||
1090 | geo->heads = 64; | ||
1091 | geo->sectors = 32; | ||
1092 | geo->cylinders = aip->size >> 11; | ||
1093 | return 0; | ||
1094 | } | ||
1082 | 1095 | ||
1083 | static int acsi_ioctl( struct inode *inode, struct file *file, | 1096 | static int acsi_ioctl( struct inode *inode, struct file *file, |
1084 | unsigned int cmd, unsigned long arg ) | 1097 | unsigned int cmd, unsigned long arg ) |
@@ -1086,18 +1099,6 @@ static int acsi_ioctl( struct inode *inode, struct file *file, | |||
1086 | struct gendisk *disk = inode->i_bdev->bd_disk; | 1099 | struct gendisk *disk = inode->i_bdev->bd_disk; |
1087 | struct acsi_info_struct *aip = disk->private_data; | 1100 | struct acsi_info_struct *aip = disk->private_data; |
1088 | switch (cmd) { | 1101 | switch (cmd) { |
1089 | case HDIO_GETGEO: | ||
1090 | /* HDIO_GETGEO is supported more for getting the partition's | ||
1091 | * start sector... */ | ||
1092 | { struct hd_geometry *geo = (struct hd_geometry *)arg; | ||
1093 | /* just fake some geometry here, it's nonsense anyway; to make it | ||
1094 | * easy, use Adaptec's usual 64/32 mapping */ | ||
1095 | put_user( 64, &geo->heads ); | ||
1096 | put_user( 32, &geo->sectors ); | ||
1097 | put_user( aip->size >> 11, &geo->cylinders ); | ||
1098 | put_user(get_start_sect(inode->i_bdev), &geo->start); | ||
1099 | return 0; | ||
1100 | } | ||
1101 | case SCSI_IOCTL_GET_IDLUN: | 1102 | case SCSI_IOCTL_GET_IDLUN: |
1102 | /* SCSI compatible GET_IDLUN call to get target's ID and LUN number */ | 1103 | /* SCSI compatible GET_IDLUN call to get target's ID and LUN number */ |
1103 | put_user( aip->target | (aip->lun << 8), | 1104 | put_user( aip->target | (aip->lun << 8), |
@@ -1592,6 +1593,7 @@ static struct block_device_operations acsi_fops = { | |||
1592 | .open = acsi_open, | 1593 | .open = acsi_open, |
1593 | .release = acsi_release, | 1594 | .release = acsi_release, |
1594 | .ioctl = acsi_ioctl, | 1595 | .ioctl = acsi_ioctl, |
1596 | .getgeo = acsi_getgeo, | ||
1595 | .media_changed = acsi_media_change, | 1597 | .media_changed = acsi_media_change, |
1596 | .revalidate_disk= acsi_revalidate, | 1598 | .revalidate_disk= acsi_revalidate, |
1597 | }; | 1599 | }; |
diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c index 0acbfff8ad28..cb2a545e57dc 100644 --- a/drivers/block/amiflop.c +++ b/drivers/block/amiflop.c | |||
@@ -1424,6 +1424,16 @@ static void do_fd_request(request_queue_t * q) | |||
1424 | redo_fd_request(); | 1424 | redo_fd_request(); |
1425 | } | 1425 | } |
1426 | 1426 | ||
1427 | static int fd_getgeo(struct block_device *bdev, struct hd_geometry *geo) | ||
1428 | { | ||
1429 | int drive = MINOR(bdev->bd_dev) & 3; | ||
1430 | |||
1431 | geo->heads = unit[drive].type->heads; | ||
1432 | geo->sectors = unit[drive].dtype->sects * unit[drive].type->sect_mult; | ||
1433 | geo->cylinders = unit[drive].type->tracks; | ||
1434 | return 0; | ||
1435 | } | ||
1436 | |||
1427 | static int fd_ioctl(struct inode *inode, struct file *filp, | 1437 | static int fd_ioctl(struct inode *inode, struct file *filp, |
1428 | unsigned int cmd, unsigned long param) | 1438 | unsigned int cmd, unsigned long param) |
1429 | { | 1439 | { |
@@ -1431,18 +1441,6 @@ static int fd_ioctl(struct inode *inode, struct file *filp, | |||
1431 | static struct floppy_struct getprm; | 1441 | static struct floppy_struct getprm; |
1432 | 1442 | ||
1433 | switch(cmd){ | 1443 | switch(cmd){ |
1434 | case HDIO_GETGEO: | ||
1435 | { | ||
1436 | struct hd_geometry loc; | ||
1437 | loc.heads = unit[drive].type->heads; | ||
1438 | loc.sectors = unit[drive].dtype->sects * unit[drive].type->sect_mult; | ||
1439 | loc.cylinders = unit[drive].type->tracks; | ||
1440 | loc.start = 0; | ||
1441 | if (copy_to_user((void *)param, (void *)&loc, | ||
1442 | sizeof(struct hd_geometry))) | ||
1443 | return -EFAULT; | ||
1444 | break; | ||
1445 | } | ||
1446 | case FDFMTBEG: | 1444 | case FDFMTBEG: |
1447 | get_fdc(drive); | 1445 | get_fdc(drive); |
1448 | if (fd_ref[drive] > 1) { | 1446 | if (fd_ref[drive] > 1) { |
@@ -1652,6 +1650,7 @@ static struct block_device_operations floppy_fops = { | |||
1652 | .open = floppy_open, | 1650 | .open = floppy_open, |
1653 | .release = floppy_release, | 1651 | .release = floppy_release, |
1654 | .ioctl = fd_ioctl, | 1652 | .ioctl = fd_ioctl, |
1653 | .getgeo = fd_getgeo, | ||
1655 | .media_changed = amiga_floppy_change, | 1654 | .media_changed = amiga_floppy_change, |
1656 | }; | 1655 | }; |
1657 | 1656 | ||
diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c index 0e97fcb9f3a1..c05ee8bffd97 100644 --- a/drivers/block/aoe/aoeblk.c +++ b/drivers/block/aoe/aoeblk.c | |||
@@ -169,38 +169,26 @@ aoeblk_make_request(request_queue_t *q, struct bio *bio) | |||
169 | return 0; | 169 | return 0; |
170 | } | 170 | } |
171 | 171 | ||
172 | /* This ioctl implementation expects userland to have the device node | ||
173 | * permissions set so that only priviledged users can open an aoe | ||
174 | * block device directly. | ||
175 | */ | ||
176 | static int | 172 | static int |
177 | aoeblk_ioctl(struct inode *inode, struct file *filp, uint cmd, ulong arg) | 173 | aoeblk_getgeo(struct block_device *bdev, struct hd_geometry *geo) |
178 | { | 174 | { |
179 | struct aoedev *d; | 175 | struct aoedev *d = bdev->bd_disk->private_data; |
180 | |||
181 | if (!arg) | ||
182 | return -EINVAL; | ||
183 | 176 | ||
184 | d = inode->i_bdev->bd_disk->private_data; | ||
185 | if ((d->flags & DEVFL_UP) == 0) { | 177 | if ((d->flags & DEVFL_UP) == 0) { |
186 | printk(KERN_ERR "aoe: aoeblk_ioctl: disk not up\n"); | 178 | printk(KERN_ERR "aoe: aoeblk_ioctl: disk not up\n"); |
187 | return -ENODEV; | 179 | return -ENODEV; |
188 | } | 180 | } |
189 | 181 | ||
190 | if (cmd == HDIO_GETGEO) { | 182 | geo->cylinders = d->geo.cylinders; |
191 | d->geo.start = get_start_sect(inode->i_bdev); | 183 | geo->heads = d->geo.heads; |
192 | if (!copy_to_user((void __user *) arg, &d->geo, sizeof d->geo)) | 184 | geo->sectors = d->geo.sectors; |
193 | return 0; | 185 | return 0; |
194 | return -EFAULT; | ||
195 | } | ||
196 | printk(KERN_INFO "aoe: aoeblk_ioctl: unknown ioctl %d\n", cmd); | ||
197 | return -EINVAL; | ||
198 | } | 186 | } |
199 | 187 | ||
200 | static struct block_device_operations aoe_bdops = { | 188 | static struct block_device_operations aoe_bdops = { |
201 | .open = aoeblk_open, | 189 | .open = aoeblk_open, |
202 | .release = aoeblk_release, | 190 | .release = aoeblk_release, |
203 | .ioctl = aoeblk_ioctl, | 191 | .getgeo = aoeblk_getgeo, |
204 | .owner = THIS_MODULE, | 192 | .owner = THIS_MODULE, |
205 | }; | 193 | }; |
206 | 194 | ||
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index d2815b7a9150..bdb9c2717d40 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c | |||
@@ -153,6 +153,7 @@ static int cciss_open(struct inode *inode, struct file *filep); | |||
153 | static int cciss_release(struct inode *inode, struct file *filep); | 153 | static int cciss_release(struct inode *inode, struct file *filep); |
154 | static int cciss_ioctl(struct inode *inode, struct file *filep, | 154 | static int cciss_ioctl(struct inode *inode, struct file *filep, |
155 | unsigned int cmd, unsigned long arg); | 155 | unsigned int cmd, unsigned long arg); |
156 | static int cciss_getgeo(struct block_device *bdev, struct hd_geometry *geo); | ||
156 | 157 | ||
157 | static int revalidate_allvol(ctlr_info_t *host); | 158 | static int revalidate_allvol(ctlr_info_t *host); |
158 | static int cciss_revalidate(struct gendisk *disk); | 159 | static int cciss_revalidate(struct gendisk *disk); |
@@ -194,6 +195,7 @@ static struct block_device_operations cciss_fops = { | |||
194 | .open = cciss_open, | 195 | .open = cciss_open, |
195 | .release = cciss_release, | 196 | .release = cciss_release, |
196 | .ioctl = cciss_ioctl, | 197 | .ioctl = cciss_ioctl, |
198 | .getgeo = cciss_getgeo, | ||
197 | #ifdef CONFIG_COMPAT | 199 | #ifdef CONFIG_COMPAT |
198 | .compat_ioctl = cciss_compat_ioctl, | 200 | .compat_ioctl = cciss_compat_ioctl, |
199 | #endif | 201 | #endif |
@@ -633,6 +635,20 @@ static int cciss_ioctl32_big_passthru(struct file *file, unsigned cmd, unsigned | |||
633 | return err; | 635 | return err; |
634 | } | 636 | } |
635 | #endif | 637 | #endif |
638 | |||
639 | static int cciss_getgeo(struct block_device *bdev, struct hd_geometry *geo) | ||
640 | { | ||
641 | drive_info_struct *drv = get_drv(bdev->bd_disk); | ||
642 | |||
643 | if (!drv->cylinders) | ||
644 | return -ENXIO; | ||
645 | |||
646 | geo->heads = drv->heads; | ||
647 | geo->sectors = drv->sectors; | ||
648 | geo->cylinders = drv->cylinders; | ||
649 | return 0; | ||
650 | } | ||
651 | |||
636 | /* | 652 | /* |
637 | * ioctl | 653 | * ioctl |
638 | */ | 654 | */ |
@@ -651,21 +667,6 @@ static int cciss_ioctl(struct inode *inode, struct file *filep, | |||
651 | #endif /* CCISS_DEBUG */ | 667 | #endif /* CCISS_DEBUG */ |
652 | 668 | ||
653 | switch(cmd) { | 669 | switch(cmd) { |
654 | case HDIO_GETGEO: | ||
655 | { | ||
656 | struct hd_geometry driver_geo; | ||
657 | if (drv->cylinders) { | ||
658 | driver_geo.heads = drv->heads; | ||
659 | driver_geo.sectors = drv->sectors; | ||
660 | driver_geo.cylinders = drv->cylinders; | ||
661 | } else | ||
662 | return -ENXIO; | ||
663 | driver_geo.start= get_start_sect(inode->i_bdev); | ||
664 | if (copy_to_user(argp, &driver_geo, sizeof(struct hd_geometry))) | ||
665 | return -EFAULT; | ||
666 | return(0); | ||
667 | } | ||
668 | |||
669 | case CCISS_GETPCIINFO: | 670 | case CCISS_GETPCIINFO: |
670 | { | 671 | { |
671 | cciss_pci_info_struct pciinfo; | 672 | cciss_pci_info_struct pciinfo; |
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c index 9bddb6874873..9f0664dd3800 100644 --- a/drivers/block/cpqarray.c +++ b/drivers/block/cpqarray.c | |||
@@ -160,6 +160,7 @@ static int sendcmd( | |||
160 | static int ida_open(struct inode *inode, struct file *filep); | 160 | static int ida_open(struct inode *inode, struct file *filep); |
161 | static int ida_release(struct inode *inode, struct file *filep); | 161 | static int ida_release(struct inode *inode, struct file *filep); |
162 | static int ida_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, unsigned long arg); | 162 | static int ida_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, unsigned long arg); |
163 | static int ida_getgeo(struct block_device *bdev, struct hd_geometry *geo); | ||
163 | static int ida_ctlr_ioctl(ctlr_info_t *h, int dsk, ida_ioctl_t *io); | 164 | static int ida_ctlr_ioctl(ctlr_info_t *h, int dsk, ida_ioctl_t *io); |
164 | 165 | ||
165 | static void do_ida_request(request_queue_t *q); | 166 | static void do_ida_request(request_queue_t *q); |
@@ -199,6 +200,7 @@ static struct block_device_operations ida_fops = { | |||
199 | .open = ida_open, | 200 | .open = ida_open, |
200 | .release = ida_release, | 201 | .release = ida_release, |
201 | .ioctl = ida_ioctl, | 202 | .ioctl = ida_ioctl, |
203 | .getgeo = ida_getgeo, | ||
202 | .revalidate_disk= ida_revalidate, | 204 | .revalidate_disk= ida_revalidate, |
203 | }; | 205 | }; |
204 | 206 | ||
@@ -1124,6 +1126,23 @@ static void ida_timer(unsigned long tdata) | |||
1124 | h->misc_tflags = 0; | 1126 | h->misc_tflags = 0; |
1125 | } | 1127 | } |
1126 | 1128 | ||
1129 | static int ida_getgeo(struct block_device *bdev, struct hd_geometry *geo) | ||
1130 | { | ||
1131 | drv_info_t *drv = get_drv(bdev->bd_disk); | ||
1132 | |||
1133 | if (drv->cylinders) { | ||
1134 | geo->heads = drv->heads; | ||
1135 | geo->sectors = drv->sectors; | ||
1136 | geo->cylinders = drv->cylinders; | ||
1137 | } else { | ||
1138 | geo->heads = 0xff; | ||
1139 | geo->sectors = 0x3f; | ||
1140 | geo->cylinders = drv->nr_blks / (0xff*0x3f); | ||
1141 | } | ||
1142 | |||
1143 | return 0; | ||
1144 | } | ||
1145 | |||
1127 | /* | 1146 | /* |
1128 | * ida_ioctl does some miscellaneous stuff like reporting drive geometry, | 1147 | * ida_ioctl does some miscellaneous stuff like reporting drive geometry, |
1129 | * setting readahead and submitting commands from userspace to the controller. | 1148 | * setting readahead and submitting commands from userspace to the controller. |
@@ -1133,27 +1152,10 @@ static int ida_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, | |||
1133 | drv_info_t *drv = get_drv(inode->i_bdev->bd_disk); | 1152 | drv_info_t *drv = get_drv(inode->i_bdev->bd_disk); |
1134 | ctlr_info_t *host = get_host(inode->i_bdev->bd_disk); | 1153 | ctlr_info_t *host = get_host(inode->i_bdev->bd_disk); |
1135 | int error; | 1154 | int error; |
1136 | int diskinfo[4]; | ||
1137 | struct hd_geometry __user *geo = (struct hd_geometry __user *)arg; | ||
1138 | ida_ioctl_t __user *io = (ida_ioctl_t __user *)arg; | 1155 | ida_ioctl_t __user *io = (ida_ioctl_t __user *)arg; |
1139 | ida_ioctl_t *my_io; | 1156 | ida_ioctl_t *my_io; |
1140 | 1157 | ||
1141 | switch(cmd) { | 1158 | switch(cmd) { |
1142 | case HDIO_GETGEO: | ||
1143 | if (drv->cylinders) { | ||
1144 | diskinfo[0] = drv->heads; | ||
1145 | diskinfo[1] = drv->sectors; | ||
1146 | diskinfo[2] = drv->cylinders; | ||
1147 | } else { | ||
1148 | diskinfo[0] = 0xff; | ||
1149 | diskinfo[1] = 0x3f; | ||
1150 | diskinfo[2] = drv->nr_blks / (0xff*0x3f); | ||
1151 | } | ||
1152 | put_user(diskinfo[0], &geo->heads); | ||
1153 | put_user(diskinfo[1], &geo->sectors); | ||
1154 | put_user(diskinfo[2], &geo->cylinders); | ||
1155 | put_user(get_start_sect(inode->i_bdev), &geo->start); | ||
1156 | return 0; | ||
1157 | case IDAGETDRVINFO: | 1159 | case IDAGETDRVINFO: |
1158 | if (copy_to_user(&io->c.drv, drv, sizeof(drv_info_t))) | 1160 | if (copy_to_user(&io->c.drv, drv, sizeof(drv_info_t))) |
1159 | return -EFAULT; | 1161 | return -EFAULT; |
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index a5b857c5c4b8..b86613b21cf1 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c | |||
@@ -3445,6 +3445,23 @@ static int get_floppy_geometry(int drive, int type, struct floppy_struct **g) | |||
3445 | return 0; | 3445 | return 0; |
3446 | } | 3446 | } |
3447 | 3447 | ||
3448 | static int fd_getgeo(struct block_device *bdev, struct hd_geometry *geo) | ||
3449 | { | ||
3450 | int drive = (long)bdev->bd_disk->private_data; | ||
3451 | int type = ITYPE(drive_state[drive].fd_device); | ||
3452 | struct floppy_struct *g; | ||
3453 | int ret; | ||
3454 | |||
3455 | ret = get_floppy_geometry(drive, type, &g); | ||
3456 | if (ret) | ||
3457 | return ret; | ||
3458 | |||
3459 | geo->heads = g->head; | ||
3460 | geo->sectors = g->sect; | ||
3461 | geo->cylinders = g->track; | ||
3462 | return 0; | ||
3463 | } | ||
3464 | |||
3448 | static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, | 3465 | static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, |
3449 | unsigned long param) | 3466 | unsigned long param) |
3450 | { | 3467 | { |
@@ -3474,23 +3491,6 @@ static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, | |||
3474 | cmd = FDEJECT; | 3491 | cmd = FDEJECT; |
3475 | } | 3492 | } |
3476 | 3493 | ||
3477 | /* generic block device ioctls */ | ||
3478 | switch (cmd) { | ||
3479 | /* the following have been inspired by the corresponding | ||
3480 | * code for other block devices. */ | ||
3481 | struct floppy_struct *g; | ||
3482 | case HDIO_GETGEO: | ||
3483 | { | ||
3484 | struct hd_geometry loc; | ||
3485 | ECALL(get_floppy_geometry(drive, type, &g)); | ||
3486 | loc.heads = g->head; | ||
3487 | loc.sectors = g->sect; | ||
3488 | loc.cylinders = g->track; | ||
3489 | loc.start = 0; | ||
3490 | return _COPYOUT(loc); | ||
3491 | } | ||
3492 | } | ||
3493 | |||
3494 | /* convert the old style command into a new style command */ | 3494 | /* convert the old style command into a new style command */ |
3495 | if ((cmd & 0xff00) == 0x0200) { | 3495 | if ((cmd & 0xff00) == 0x0200) { |
3496 | ECALL(normalize_ioctl(&cmd, &size)); | 3496 | ECALL(normalize_ioctl(&cmd, &size)); |
@@ -3938,6 +3938,7 @@ static struct block_device_operations floppy_fops = { | |||
3938 | .open = floppy_open, | 3938 | .open = floppy_open, |
3939 | .release = floppy_release, | 3939 | .release = floppy_release, |
3940 | .ioctl = fd_ioctl, | 3940 | .ioctl = fd_ioctl, |
3941 | .getgeo = fd_getgeo, | ||
3941 | .media_changed = check_floppy_change, | 3942 | .media_changed = check_floppy_change, |
3942 | .revalidate_disk = floppy_revalidate, | 3943 | .revalidate_disk = floppy_revalidate, |
3943 | }; | 3944 | }; |
diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c index fa49d62626ba..62d2464c12f2 100644 --- a/drivers/block/paride/pd.c +++ b/drivers/block/paride/pd.c | |||
@@ -747,32 +747,33 @@ static int pd_open(struct inode *inode, struct file *file) | |||
747 | return 0; | 747 | return 0; |
748 | } | 748 | } |
749 | 749 | ||
750 | static int pd_getgeo(struct block_device *bdev, struct hd_geometry *geo) | ||
751 | { | ||
752 | struct pd_unit *disk = bdev->bd_disk->private_data; | ||
753 | |||
754 | if (disk->alt_geom) { | ||
755 | geo->heads = PD_LOG_HEADS; | ||
756 | geo->sectors = PD_LOG_SECTS; | ||
757 | geo->cylinders = disk->capacity / (geo->heads * geo->sectors); | ||
758 | } else { | ||
759 | geo->heads = disk->heads; | ||
760 | geo->sectors = disk->sectors; | ||
761 | geo->cylinders = disk->cylinders; | ||
762 | } | ||
763 | |||
764 | return 0; | ||
765 | } | ||
766 | |||
750 | static int pd_ioctl(struct inode *inode, struct file *file, | 767 | static int pd_ioctl(struct inode *inode, struct file *file, |
751 | unsigned int cmd, unsigned long arg) | 768 | unsigned int cmd, unsigned long arg) |
752 | { | 769 | { |
753 | struct pd_unit *disk = inode->i_bdev->bd_disk->private_data; | 770 | struct pd_unit *disk = inode->i_bdev->bd_disk->private_data; |
754 | struct hd_geometry __user *geo = (struct hd_geometry __user *) arg; | ||
755 | struct hd_geometry g; | ||
756 | 771 | ||
757 | switch (cmd) { | 772 | switch (cmd) { |
758 | case CDROMEJECT: | 773 | case CDROMEJECT: |
759 | if (disk->access == 1) | 774 | if (disk->access == 1) |
760 | pd_special_command(disk, pd_eject); | 775 | pd_special_command(disk, pd_eject); |
761 | return 0; | 776 | return 0; |
762 | case HDIO_GETGEO: | ||
763 | if (disk->alt_geom) { | ||
764 | g.heads = PD_LOG_HEADS; | ||
765 | g.sectors = PD_LOG_SECTS; | ||
766 | g.cylinders = disk->capacity / (g.heads * g.sectors); | ||
767 | } else { | ||
768 | g.heads = disk->heads; | ||
769 | g.sectors = disk->sectors; | ||
770 | g.cylinders = disk->cylinders; | ||
771 | } | ||
772 | g.start = get_start_sect(inode->i_bdev); | ||
773 | if (copy_to_user(geo, &g, sizeof(struct hd_geometry))) | ||
774 | return -EFAULT; | ||
775 | return 0; | ||
776 | default: | 777 | default: |
777 | return -EINVAL; | 778 | return -EINVAL; |
778 | } | 779 | } |
@@ -815,6 +816,7 @@ static struct block_device_operations pd_fops = { | |||
815 | .open = pd_open, | 816 | .open = pd_open, |
816 | .release = pd_release, | 817 | .release = pd_release, |
817 | .ioctl = pd_ioctl, | 818 | .ioctl = pd_ioctl, |
819 | .getgeo = pd_getgeo, | ||
818 | .media_changed = pd_check_media, | 820 | .media_changed = pd_check_media, |
819 | .revalidate_disk= pd_revalidate | 821 | .revalidate_disk= pd_revalidate |
820 | }; | 822 | }; |
diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c index e9746af29b9f..852b564e903a 100644 --- a/drivers/block/paride/pf.c +++ b/drivers/block/paride/pf.c | |||
@@ -205,6 +205,7 @@ static int pf_open(struct inode *inode, struct file *file); | |||
205 | static void do_pf_request(request_queue_t * q); | 205 | static void do_pf_request(request_queue_t * q); |
206 | static int pf_ioctl(struct inode *inode, struct file *file, | 206 | static int pf_ioctl(struct inode *inode, struct file *file, |
207 | unsigned int cmd, unsigned long arg); | 207 | unsigned int cmd, unsigned long arg); |
208 | static int pf_getgeo(struct block_device *bdev, struct hd_geometry *geo); | ||
208 | 209 | ||
209 | static int pf_release(struct inode *inode, struct file *file); | 210 | static int pf_release(struct inode *inode, struct file *file); |
210 | 211 | ||
@@ -266,6 +267,7 @@ static struct block_device_operations pf_fops = { | |||
266 | .open = pf_open, | 267 | .open = pf_open, |
267 | .release = pf_release, | 268 | .release = pf_release, |
268 | .ioctl = pf_ioctl, | 269 | .ioctl = pf_ioctl, |
270 | .getgeo = pf_getgeo, | ||
269 | .media_changed = pf_check_media, | 271 | .media_changed = pf_check_media, |
270 | }; | 272 | }; |
271 | 273 | ||
@@ -313,34 +315,34 @@ static int pf_open(struct inode *inode, struct file *file) | |||
313 | return 0; | 315 | return 0; |
314 | } | 316 | } |
315 | 317 | ||
316 | static int pf_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) | 318 | static int pf_getgeo(struct block_device *bdev, struct hd_geometry *geo) |
317 | { | 319 | { |
318 | struct pf_unit *pf = inode->i_bdev->bd_disk->private_data; | 320 | struct pf_unit *pf = bdev->bd_disk->private_data; |
319 | struct hd_geometry __user *geo = (struct hd_geometry __user *) arg; | 321 | sector_t capacity = get_capacity(pf->disk); |
320 | struct hd_geometry g; | 322 | |
321 | sector_t capacity; | ||
322 | |||
323 | if (cmd == CDROMEJECT) { | ||
324 | if (pf->access == 1) { | ||
325 | pf_eject(pf); | ||
326 | return 0; | ||
327 | } | ||
328 | return -EBUSY; | ||
329 | } | ||
330 | if (cmd != HDIO_GETGEO) | ||
331 | return -EINVAL; | ||
332 | capacity = get_capacity(pf->disk); | ||
333 | if (capacity < PF_FD_MAX) { | 323 | if (capacity < PF_FD_MAX) { |
334 | g.cylinders = sector_div(capacity, PF_FD_HDS * PF_FD_SPT); | 324 | geo->cylinders = sector_div(capacity, PF_FD_HDS * PF_FD_SPT); |
335 | g.heads = PF_FD_HDS; | 325 | geo->heads = PF_FD_HDS; |
336 | g.sectors = PF_FD_SPT; | 326 | geo->sectors = PF_FD_SPT; |
337 | } else { | 327 | } else { |
338 | g.cylinders = sector_div(capacity, PF_HD_HDS * PF_HD_SPT); | 328 | geo->cylinders = sector_div(capacity, PF_HD_HDS * PF_HD_SPT); |
339 | g.heads = PF_HD_HDS; | 329 | geo->heads = PF_HD_HDS; |
340 | g.sectors = PF_HD_SPT; | 330 | geo->sectors = PF_HD_SPT; |
341 | } | 331 | } |
342 | if (copy_to_user(geo, &g, sizeof(g))) | 332 | |
343 | return -EFAULT; | 333 | return 0; |
334 | } | ||
335 | |||
336 | static int pf_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) | ||
337 | { | ||
338 | struct pf_unit *pf = inode->i_bdev->bd_disk->private_data; | ||
339 | |||
340 | if (cmd != CDROMEJECT) | ||
341 | return -EINVAL; | ||
342 | |||
343 | if (pf->access != 1) | ||
344 | return -EBUSY; | ||
345 | pf_eject(pf); | ||
344 | return 0; | 346 | return 0; |
345 | } | 347 | } |
346 | 348 | ||
diff --git a/drivers/block/ps2esdi.c b/drivers/block/ps2esdi.c index 29d1518be72a..43415f69839f 100644 --- a/drivers/block/ps2esdi.c +++ b/drivers/block/ps2esdi.c | |||
@@ -81,8 +81,7 @@ static void (*current_int_handler) (u_int) = NULL; | |||
81 | static void ps2esdi_normal_interrupt_handler(u_int); | 81 | static void ps2esdi_normal_interrupt_handler(u_int); |
82 | static void ps2esdi_initial_reset_int_handler(u_int); | 82 | static void ps2esdi_initial_reset_int_handler(u_int); |
83 | static void ps2esdi_geometry_int_handler(u_int); | 83 | static void ps2esdi_geometry_int_handler(u_int); |
84 | static int ps2esdi_ioctl(struct inode *inode, struct file *file, | 84 | static int ps2esdi_getgeo(struct block_device *bdev, struct hd_geometry *geo); |
85 | u_int cmd, u_long arg); | ||
86 | 85 | ||
87 | static int ps2esdi_read_status_words(int num_words, int max_words, u_short * buffer); | 86 | static int ps2esdi_read_status_words(int num_words, int max_words, u_short * buffer); |
88 | 87 | ||
@@ -132,7 +131,7 @@ static struct ps2esdi_i_struct ps2esdi_info[MAX_HD] = | |||
132 | static struct block_device_operations ps2esdi_fops = | 131 | static struct block_device_operations ps2esdi_fops = |
133 | { | 132 | { |
134 | .owner = THIS_MODULE, | 133 | .owner = THIS_MODULE, |
135 | .ioctl = ps2esdi_ioctl, | 134 | .getgeo = ps2esdi_getgeo, |
136 | }; | 135 | }; |
137 | 136 | ||
138 | static struct gendisk *ps2esdi_gendisk[2]; | 137 | static struct gendisk *ps2esdi_gendisk[2]; |
@@ -1058,21 +1057,13 @@ static void dump_cmd_complete_status(u_int int_ret_code) | |||
1058 | 1057 | ||
1059 | } | 1058 | } |
1060 | 1059 | ||
1061 | static int ps2esdi_ioctl(struct inode *inode, | 1060 | static int ps2esdi_getgeo(struct block_device *bdev, struct hd_geometry *geo) |
1062 | struct file *file, u_int cmd, u_long arg) | ||
1063 | { | 1061 | { |
1064 | struct ps2esdi_i_struct *p = inode->i_bdev->bd_disk->private_data; | 1062 | struct ps2esdi_i_struct *p = bdev->bd_disk->private_data; |
1065 | struct ps2esdi_geometry geom; | 1063 | |
1066 | 1064 | geo->heads = p->head; | |
1067 | if (cmd != HDIO_GETGEO) | 1065 | geo->sectors = p->sect; |
1068 | return -EINVAL; | 1066 | geo->cylinders = p->cyl; |
1069 | memset(&geom, 0, sizeof(geom)); | ||
1070 | geom.heads = p->head; | ||
1071 | geom.sectors = p->sect; | ||
1072 | geom.cylinders = p->cyl; | ||
1073 | geom.start = get_start_sect(inode->i_bdev); | ||
1074 | if (copy_to_user((void __user *)arg, &geom, sizeof(geom))) | ||
1075 | return -EFAULT; | ||
1076 | return 0; | 1067 | return 0; |
1077 | } | 1068 | } |
1078 | 1069 | ||
diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c index 9251f4131b53..c0cdc182a8b0 100644 --- a/drivers/block/sx8.c +++ b/drivers/block/sx8.c | |||
@@ -407,8 +407,7 @@ struct carm_array_info { | |||
407 | 407 | ||
408 | static int carm_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); | 408 | static int carm_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); |
409 | static void carm_remove_one (struct pci_dev *pdev); | 409 | static void carm_remove_one (struct pci_dev *pdev); |
410 | static int carm_bdev_ioctl(struct inode *ino, struct file *fil, | 410 | static int carm_bdev_getgeo(struct block_device *bdev, struct hd_geometry *geo); |
411 | unsigned int cmd, unsigned long arg); | ||
412 | 411 | ||
413 | static struct pci_device_id carm_pci_tbl[] = { | 412 | static struct pci_device_id carm_pci_tbl[] = { |
414 | { PCI_VENDOR_ID_PROMISE, 0x8000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, | 413 | { PCI_VENDOR_ID_PROMISE, 0x8000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, |
@@ -426,7 +425,7 @@ static struct pci_driver carm_driver = { | |||
426 | 425 | ||
427 | static struct block_device_operations carm_bd_ops = { | 426 | static struct block_device_operations carm_bd_ops = { |
428 | .owner = THIS_MODULE, | 427 | .owner = THIS_MODULE, |
429 | .ioctl = carm_bdev_ioctl, | 428 | .getgeo = carm_bdev_getgeo, |
430 | }; | 429 | }; |
431 | 430 | ||
432 | static unsigned int carm_host_id; | 431 | static unsigned int carm_host_id; |
@@ -434,32 +433,14 @@ static unsigned long carm_major_alloc; | |||
434 | 433 | ||
435 | 434 | ||
436 | 435 | ||
437 | static int carm_bdev_ioctl(struct inode *ino, struct file *fil, | 436 | static int carm_bdev_getgeo(struct block_device *bdev, struct hd_geometry *geo) |
438 | unsigned int cmd, unsigned long arg) | ||
439 | { | 437 | { |
440 | void __user *usermem = (void __user *) arg; | 438 | struct carm_port *port = bdev->bd_disk->private_data; |
441 | struct carm_port *port = ino->i_bdev->bd_disk->private_data; | ||
442 | struct hd_geometry geom; | ||
443 | 439 | ||
444 | switch (cmd) { | 440 | geo->heads = (u8) port->dev_geom_head; |
445 | case HDIO_GETGEO: | 441 | geo->sectors = (u8) port->dev_geom_sect; |
446 | if (!usermem) | 442 | geo->cylinders = port->dev_geom_cyl; |
447 | return -EINVAL; | 443 | return 0; |
448 | |||
449 | geom.heads = (u8) port->dev_geom_head; | ||
450 | geom.sectors = (u8) port->dev_geom_sect; | ||
451 | geom.cylinders = port->dev_geom_cyl; | ||
452 | geom.start = get_start_sect(ino->i_bdev); | ||
453 | |||
454 | if (copy_to_user(usermem, &geom, sizeof(geom))) | ||
455 | return -EFAULT; | ||
456 | return 0; | ||
457 | |||
458 | default: | ||
459 | break; | ||
460 | } | ||
461 | |||
462 | return -EOPNOTSUPP; | ||
463 | } | 444 | } |
464 | 445 | ||
465 | static const u32 msg_sizes[] = { 32, 64, 128, CARM_MSG_SIZE }; | 446 | static const u32 msg_sizes[] = { 32, 64, 128, CARM_MSG_SIZE }; |
diff --git a/drivers/block/umem.c b/drivers/block/umem.c index 0f48301342da..15299e7a1ade 100644 --- a/drivers/block/umem.c +++ b/drivers/block/umem.c | |||
@@ -809,34 +809,23 @@ static int mm_revalidate(struct gendisk *disk) | |||
809 | set_capacity(disk, card->mm_size << 1); | 809 | set_capacity(disk, card->mm_size << 1); |
810 | return 0; | 810 | return 0; |
811 | } | 811 | } |
812 | /* | 812 | |
813 | ----------------------------------------------------------------------------------- | 813 | static int mm_getgeo(struct block_device *bdev, struct hd_geometry *geo) |
814 | -- mm_ioctl | ||
815 | ----------------------------------------------------------------------------------- | ||
816 | */ | ||
817 | static int mm_ioctl(struct inode *i, struct file *f, unsigned int cmd, unsigned long arg) | ||
818 | { | 814 | { |
819 | if (cmd == HDIO_GETGEO) { | 815 | struct cardinfo *card = bdev->bd_disk->private_data; |
820 | struct cardinfo *card = i->i_bdev->bd_disk->private_data; | 816 | int size = card->mm_size * (1024 / MM_HARDSECT); |
821 | int size = card->mm_size * (1024 / MM_HARDSECT); | ||
822 | struct hd_geometry geo; | ||
823 | /* | ||
824 | * get geometry: we have to fake one... trim the size to a | ||
825 | * multiple of 2048 (1M): tell we have 32 sectors, 64 heads, | ||
826 | * whatever cylinders. | ||
827 | */ | ||
828 | geo.heads = 64; | ||
829 | geo.sectors = 32; | ||
830 | geo.start = get_start_sect(i->i_bdev); | ||
831 | geo.cylinders = size / (geo.heads * geo.sectors); | ||
832 | |||
833 | if (copy_to_user((void __user *) arg, &geo, sizeof(geo))) | ||
834 | return -EFAULT; | ||
835 | return 0; | ||
836 | } | ||
837 | 817 | ||
838 | return -EINVAL; | 818 | /* |
819 | * get geometry: we have to fake one... trim the size to a | ||
820 | * multiple of 2048 (1M): tell we have 32 sectors, 64 heads, | ||
821 | * whatever cylinders. | ||
822 | */ | ||
823 | geo->heads = 64; | ||
824 | geo->sectors = 32; | ||
825 | geo->cylinders = size / (geo->heads * geo->sectors); | ||
826 | return 0; | ||
839 | } | 827 | } |
828 | |||
840 | /* | 829 | /* |
841 | ----------------------------------------------------------------------------------- | 830 | ----------------------------------------------------------------------------------- |
842 | -- mm_check_change | 831 | -- mm_check_change |
@@ -855,7 +844,7 @@ static int mm_check_change(struct gendisk *disk) | |||
855 | */ | 844 | */ |
856 | static struct block_device_operations mm_fops = { | 845 | static struct block_device_operations mm_fops = { |
857 | .owner = THIS_MODULE, | 846 | .owner = THIS_MODULE, |
858 | .ioctl = mm_ioctl, | 847 | .getgeo = mm_getgeo, |
859 | .revalidate_disk= mm_revalidate, | 848 | .revalidate_disk= mm_revalidate, |
860 | .media_changed = mm_check_change, | 849 | .media_changed = mm_check_change, |
861 | }; | 850 | }; |
diff --git a/drivers/block/viodasd.c b/drivers/block/viodasd.c index 063f0304a163..d1aaf31bd97e 100644 --- a/drivers/block/viodasd.c +++ b/drivers/block/viodasd.c | |||
@@ -247,43 +247,17 @@ static int viodasd_release(struct inode *ino, struct file *fil) | |||
247 | 247 | ||
248 | /* External ioctl entry point. | 248 | /* External ioctl entry point. |
249 | */ | 249 | */ |
250 | static int viodasd_ioctl(struct inode *ino, struct file *fil, | 250 | static int viodasd_getgeo(struct block_device *bdev, struct hd_geometry *geo) |
251 | unsigned int cmd, unsigned long arg) | ||
252 | { | 251 | { |
253 | unsigned char sectors; | 252 | struct gendisk *disk = bdev->bd_disk; |
254 | unsigned char heads; | 253 | struct viodasd_device *d = disk->private_data; |
255 | unsigned short cylinders; | ||
256 | struct hd_geometry *geo; | ||
257 | struct gendisk *gendisk; | ||
258 | struct viodasd_device *d; | ||
259 | 254 | ||
260 | switch (cmd) { | 255 | geo->sectors = d->sectors ? d->sectors : 0; |
261 | case HDIO_GETGEO: | 256 | geo->heads = d->tracks ? d->tracks : 64; |
262 | geo = (struct hd_geometry *)arg; | 257 | geo->cylinders = d->cylinders ? d->cylinders : |
263 | if (geo == NULL) | 258 | get_capacity(disk) / (geo->cylinders * geo->heads); |
264 | return -EINVAL; | ||
265 | if (!access_ok(VERIFY_WRITE, geo, sizeof(*geo))) | ||
266 | return -EFAULT; | ||
267 | gendisk = ino->i_bdev->bd_disk; | ||
268 | d = gendisk->private_data; | ||
269 | sectors = d->sectors; | ||
270 | if (sectors == 0) | ||
271 | sectors = 32; | ||
272 | heads = d->tracks; | ||
273 | if (heads == 0) | ||
274 | heads = 64; | ||
275 | cylinders = d->cylinders; | ||
276 | if (cylinders == 0) | ||
277 | cylinders = get_capacity(gendisk) / (sectors * heads); | ||
278 | if (__put_user(sectors, &geo->sectors) || | ||
279 | __put_user(heads, &geo->heads) || | ||
280 | __put_user(cylinders, &geo->cylinders) || | ||
281 | __put_user(get_start_sect(ino->i_bdev), &geo->start)) | ||
282 | return -EFAULT; | ||
283 | return 0; | ||
284 | } | ||
285 | 259 | ||
286 | return -EINVAL; | 260 | return 0; |
287 | } | 261 | } |
288 | 262 | ||
289 | /* | 263 | /* |
@@ -293,7 +267,7 @@ static struct block_device_operations viodasd_fops = { | |||
293 | .owner = THIS_MODULE, | 267 | .owner = THIS_MODULE, |
294 | .open = viodasd_open, | 268 | .open = viodasd_open, |
295 | .release = viodasd_release, | 269 | .release = viodasd_release, |
296 | .ioctl = viodasd_ioctl, | 270 | .getgeo = viodasd_getgeo, |
297 | }; | 271 | }; |
298 | 272 | ||
299 | /* | 273 | /* |
diff --git a/drivers/block/xd.c b/drivers/block/xd.c index 68b6d7b154cf..97f5dab24b5a 100644 --- a/drivers/block/xd.c +++ b/drivers/block/xd.c | |||
@@ -128,9 +128,12 @@ static DEFINE_SPINLOCK(xd_lock); | |||
128 | 128 | ||
129 | static struct gendisk *xd_gendisk[2]; | 129 | static struct gendisk *xd_gendisk[2]; |
130 | 130 | ||
131 | static int xd_getgeo(struct block_device *bdev, struct hd_geometry *geo); | ||
132 | |||
131 | static struct block_device_operations xd_fops = { | 133 | static struct block_device_operations xd_fops = { |
132 | .owner = THIS_MODULE, | 134 | .owner = THIS_MODULE, |
133 | .ioctl = xd_ioctl, | 135 | .ioctl = xd_ioctl, |
136 | .getgeo = xd_getgeo, | ||
134 | }; | 137 | }; |
135 | static DECLARE_WAIT_QUEUE_HEAD(xd_wait_int); | 138 | static DECLARE_WAIT_QUEUE_HEAD(xd_wait_int); |
136 | static u_char xd_drives, xd_irq = 5, xd_dma = 3, xd_maxsectors; | 139 | static u_char xd_drives, xd_irq = 5, xd_dma = 3, xd_maxsectors; |
@@ -330,22 +333,20 @@ static void do_xd_request (request_queue_t * q) | |||
330 | } | 333 | } |
331 | } | 334 | } |
332 | 335 | ||
336 | static int xd_getgeo(struct block_device *bdev, struct hd_geometry *geo) | ||
337 | { | ||
338 | XD_INFO *p = bdev->bd_disk->private_data; | ||
339 | |||
340 | geo->heads = p->heads; | ||
341 | geo->sectors = p->sectors; | ||
342 | geo->cylinders = p->cylinders; | ||
343 | return 0; | ||
344 | } | ||
345 | |||
333 | /* xd_ioctl: handle device ioctl's */ | 346 | /* xd_ioctl: handle device ioctl's */ |
334 | static int xd_ioctl (struct inode *inode,struct file *file,u_int cmd,u_long arg) | 347 | static int xd_ioctl (struct inode *inode,struct file *file,u_int cmd,u_long arg) |
335 | { | 348 | { |
336 | XD_INFO *p = inode->i_bdev->bd_disk->private_data; | ||
337 | |||
338 | switch (cmd) { | 349 | switch (cmd) { |
339 | case HDIO_GETGEO: | ||
340 | { | ||
341 | struct hd_geometry g; | ||
342 | struct hd_geometry __user *geom= (void __user *)arg; | ||
343 | g.heads = p->heads; | ||
344 | g.sectors = p->sectors; | ||
345 | g.cylinders = p->cylinders; | ||
346 | g.start = get_start_sect(inode->i_bdev); | ||
347 | return copy_to_user(geom, &g, sizeof(g)) ? -EFAULT : 0; | ||
348 | } | ||
349 | case HDIO_SET_DMA: | 350 | case HDIO_SET_DMA: |
350 | if (!capable(CAP_SYS_ADMIN)) return -EACCES; | 351 | if (!capable(CAP_SYS_ADMIN)) return -EACCES; |
351 | if (xdc_busy) return -EBUSY; | 352 | if (xdc_busy) return -EBUSY; |