diff options
author | Christoph Hellwig <hch@lst.de> | 2006-01-08 04:02:50 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-08 23:13:54 -0500 |
commit | a885c8c4316e1c1d2d2c8755da3f3d14f852528d (patch) | |
tree | e4f4e7a7657c0944d11c259f8f17ffcd6b2da0f5 /drivers/block/floppy.c | |
parent | 5b0ed2c64d8fdafb5fcfb3baabdd288628b1ff9b (diff) |
[PATCH] Add block_device_operations.getgeo block device method
HDIO_GETGEO is implemented in most block drivers, and all of them have to
duplicate the code to copy the structure to userspace, as well as getting
the start sector. This patch moves that to common code [1] and adds a
->getgeo method to fill out the raw kernel hd_geometry structure. For many
drivers this means ->ioctl can go away now.
[1] the s390 block drivers are odd in this respect. xpram sets ->start
to 4 always which seems more than odd, and the dasd driver shifts
the start offset around, probably because of it's non-standard
sector size.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@suse.de>
Cc: <mike.miller@hp.com>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Paolo Giarrusso <blaisorblade@yahoo.it>
Cc: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>
Cc: Neil Brown <neilb@cse.unsw.edu.au>
Cc: Markus Lidel <Markus.Lidel@shadowconnect.com>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: James Bottomley <James.Bottomley@steeleye.com>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/block/floppy.c')
-rw-r--r-- | drivers/block/floppy.c | 35 |
1 files changed, 18 insertions, 17 deletions
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 | }; |