Commit c509ddbb authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] pd.c cleanups

Removed cruft from pd_ioctl() and friends.
parent d01cb174
...@@ -287,8 +287,6 @@ static void pd_doorlock(struct pd_unit *disk, int func); ...@@ -287,8 +287,6 @@ static void pd_doorlock(struct pd_unit *disk, int func);
static int pd_check_media(kdev_t dev); static int pd_check_media(kdev_t dev);
static void pd_eject(struct pd_unit *disk); static void pd_eject(struct pd_unit *disk);
/* 'unit' must be defined in all functions - either as a local or a param */
static char pd_scratch[512]; /* scratch block buffer */ static char pd_scratch[512]; /* scratch block buffer */
/* the variables below are used mainly in the I/O request engine, which /* the variables below are used mainly in the I/O request engine, which
...@@ -368,11 +366,8 @@ static int pd_ioctl(struct inode *inode, struct file *file, ...@@ -368,11 +366,8 @@ static int pd_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
struct hd_geometry *geo = (struct hd_geometry *) arg; struct hd_geometry *geo = (struct hd_geometry *) arg;
int err, unit = DEVICE_NR(inode->i_rdev); struct hd_geometry g;
struct pd_unit *disk = pd + unit; struct pd_unit *disk = pd + DEVICE_NR(inode->i_rdev);
if (!disk->present)
return -ENODEV;
switch (cmd) { switch (cmd) {
case CDROMEJECT: case CDROMEJECT:
...@@ -380,23 +375,18 @@ static int pd_ioctl(struct inode *inode, struct file *file, ...@@ -380,23 +375,18 @@ static int pd_ioctl(struct inode *inode, struct file *file,
pd_eject(disk); pd_eject(disk);
return 0; return 0;
case HDIO_GETGEO: case HDIO_GETGEO:
if (!geo)
return -EINVAL;
err = verify_area(VERIFY_WRITE, geo, sizeof (*geo));
if (err)
return err;
if (disk->alt_geom) { if (disk->alt_geom) {
put_user(disk->capacity / (PD_LOG_HEADS * PD_LOG_SECTS), g.heads = PD_LOG_HEADS;
(short *) &geo->cylinders); g.sectors = PD_LOG_SECTS;
put_user(PD_LOG_HEADS, (char *) &geo->heads); g.cylinders = disk->capacity / (g.heads * g.sectors);
put_user(PD_LOG_SECTS, (char *) &geo->sectors);
} else { } else {
put_user(disk->cylinders, (short *) &geo->cylinders); g.heads = disk->heads;
put_user(disk->heads, (char *) &geo->heads); g.sectors = disk->sectors;
put_user(disk->sectors, (char *) &geo->sectors); g.cylinders = disk->cylinders;
} }
put_user(get_start_sect(inode->i_bdev), (long *) &geo->start); g.start = get_start_sect(inode->i_bdev);
if (copy_to_user(geo, &g, sizeof(struct hd_geometry)))
return -EFAULT;
return 0; return 0;
default: default:
return -EINVAL; return -EINVAL;
...@@ -418,8 +408,6 @@ static int pd_check_media(kdev_t dev) ...@@ -418,8 +408,6 @@ static int pd_check_media(kdev_t dev)
{ {
int r, unit = DEVICE_NR(dev); int r, unit = DEVICE_NR(dev);
struct pd_unit *disk = pd + unit; struct pd_unit *disk = pd + unit;
if (unit >= PD_UNITS || (!disk->present))
return -ENODEV;
if (!disk->removable) if (!disk->removable)
return 0; return 0;
pd_media_check(disk); pd_media_check(disk);
...@@ -432,8 +420,6 @@ static int pd_revalidate(kdev_t dev) ...@@ -432,8 +420,6 @@ static int pd_revalidate(kdev_t dev)
{ {
int unit = DEVICE_NR(dev); int unit = DEVICE_NR(dev);
struct pd_unit *disk = pd + unit; struct pd_unit *disk = pd + unit;
if (unit >= PD_UNITS || !disk->present)
return -ENODEV;
if (pd_identify(disk)) if (pd_identify(disk))
set_capacity(disk->gd, disk->capacity); set_capacity(disk->gd, disk->capacity);
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment