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);
static int pd_check_media(kdev_t dev);
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 */
/* 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,
unsigned int cmd, unsigned long arg)
{
struct hd_geometry *geo = (struct hd_geometry *) arg;
int err, unit = DEVICE_NR(inode->i_rdev);
struct pd_unit *disk = pd + unit;
if (!disk->present)
return -ENODEV;
struct hd_geometry g;
struct pd_unit *disk = pd + DEVICE_NR(inode->i_rdev);
switch (cmd) {
case CDROMEJECT:
......@@ -380,23 +375,18 @@ static int pd_ioctl(struct inode *inode, struct file *file,
pd_eject(disk);
return 0;
case HDIO_GETGEO:
if (!geo)
return -EINVAL;
err = verify_area(VERIFY_WRITE, geo, sizeof (*geo));
if (err)
return err;
if (disk->alt_geom) {
put_user(disk->capacity / (PD_LOG_HEADS * PD_LOG_SECTS),
(short *) &geo->cylinders);
put_user(PD_LOG_HEADS, (char *) &geo->heads);
put_user(PD_LOG_SECTS, (char *) &geo->sectors);
g.heads = PD_LOG_HEADS;
g.sectors = PD_LOG_SECTS;
g.cylinders = disk->capacity / (g.heads * g.sectors);
} else {
put_user(disk->cylinders, (short *) &geo->cylinders);
put_user(disk->heads, (char *) &geo->heads);
put_user(disk->sectors, (char *) &geo->sectors);
g.heads = disk->heads;
g.sectors = disk->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;
default:
return -EINVAL;
......@@ -418,8 +408,6 @@ static int pd_check_media(kdev_t dev)
{
int r, unit = DEVICE_NR(dev);
struct pd_unit *disk = pd + unit;
if (unit >= PD_UNITS || (!disk->present))
return -ENODEV;
if (!disk->removable)
return 0;
pd_media_check(disk);
......@@ -432,8 +420,6 @@ static int pd_revalidate(kdev_t dev)
{
int unit = DEVICE_NR(dev);
struct pd_unit *disk = pd + unit;
if (unit >= PD_UNITS || !disk->present)
return -ENODEV;
if (pd_identify(disk))
set_capacity(disk->gd, disk->capacity);
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