From a885c8c4316e1c1d2d2c8755da3f3d14f852528d Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sun, 8 Jan 2006 01:02:50 -0800 Subject: [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 Cc: Jens Axboe Cc: Cc: Jeff Dike Cc: Paolo Giarrusso Cc: Bartlomiej Zolnierkiewicz Cc: Neil Brown Cc: Markus Lidel Cc: Russell King Cc: David Woodhouse Cc: Martin Schwidefsky Cc: James Bottomley Signed-off-by: Adrian Bunk Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/acorn/block/mfmhd.c | 36 +++++++----------------------------- 1 file changed, 7 insertions(+), 29 deletions(-) (limited to 'drivers/acorn/block/mfmhd.c') diff --git a/drivers/acorn/block/mfmhd.c b/drivers/acorn/block/mfmhd.c index 4b65f74d66b1..ce074f6f3369 100644 --- a/drivers/acorn/block/mfmhd.c +++ b/drivers/acorn/block/mfmhd.c @@ -129,19 +129,6 @@ static DEFINE_SPINLOCK(mfm_lock); #define MAJOR_NR MFM_ACORN_MAJOR #define QUEUE (mfm_queue) #define CURRENT elv_next_request(mfm_queue) -/* - * This sort of stuff should be in a header file shared with ide.c, hd.c, xd.c etc - */ -#ifndef HDIO_GETGEO -#define HDIO_GETGEO 0x301 -struct hd_geometry { - unsigned char heads; - unsigned char sectors; - unsigned short cylinders; - unsigned long start; -}; -#endif - /* * Configuration section @@ -1153,22 +1140,13 @@ static int mfm_initdrives(void) * The 'front' end of the mfm driver follows... */ -static int mfm_ioctl(struct inode *inode, struct file *file, u_int cmd, u_long arg) +static int mfm_getgeo(struct block_device *bdev, struct hd_geometry *geo) { - struct mfm_info *p = inode->i_bdev->bd_disk->private_data; - struct hd_geometry *geo = (struct hd_geometry *) arg; - if (cmd != HDIO_GETGEO) - return -EINVAL; - if (!arg) - return -EINVAL; - if (put_user (p->heads, &geo->heads)) - return -EFAULT; - if (put_user (p->sectors, &geo->sectors)) - return -EFAULT; - if (put_user (p->cylinders, &geo->cylinders)) - return -EFAULT; - if (put_user (get_start_sect(inode->i_bdev), &geo->start)) - return -EFAULT; + struct mfm_info *p = bdev->bd_disk->private_data; + + geo->heads = p->heads; + geo->sectors = p->sectors; + geo->cylinders = p->cylinders; return 0; } @@ -1219,7 +1197,7 @@ void xd_set_geometry(struct block_device *bdev, unsigned char secsptrack, static struct block_device_operations mfm_fops = { .owner = THIS_MODULE, - .ioctl = mfm_ioctl, + .getgeo = mfm_getgeo, }; /* -- cgit v1.2.1