Commit 17f5f84d authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] crapectomy - last users of kernel_scsi_ioctl() gone

Last 3 users of kernel_scsi_ioctl() eliminated; two of them used to read
partition table by issuing a READ6 via ioctl (instead of just calling
scsi_bios_ptable() as every other ->biosparam() instance does).

The last one was doing a very quaint access to fields of scsi_device by
issuing SCSI_IOCLT_GET_LUN and then shuffling bits in the result.  Down
with that insanity...
parent adf791bd
...@@ -87,6 +87,7 @@ ...@@ -87,6 +87,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/mca.h> #include <linux/mca.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <scsi/scsicam.h>
#include <linux/mca-legacy.h> #include <linux/mca-legacy.h>
#include <asm/io.h> #include <asm/io.h>
...@@ -1337,23 +1338,14 @@ static int fd_mcs_bus_reset(Scsi_Cmnd * SCpnt) { ...@@ -1337,23 +1338,14 @@ static int fd_mcs_bus_reset(Scsi_Cmnd * SCpnt) {
static int fd_mcs_biosparam(struct scsi_device * disk, struct block_device *bdev, static int fd_mcs_biosparam(struct scsi_device * disk, struct block_device *bdev,
sector_t capacity, int *info_array) sector_t capacity, int *info_array)
{ {
unsigned char buf[512 + sizeof(int) * 2]; unsigned char *p = scsi_bios_ptable(bdev);
int size = capacity; int size = capacity;
int *sizes = (int *) buf;
unsigned char *data = (unsigned char *) (sizes + 2);
unsigned char do_read[] = { READ_6, 0, 0, 0, 1, 0 };
int retcode;
/* BIOS >= 3.4 for MCA cards */ /* BIOS >= 3.4 for MCA cards */
/* This algorithm was provided by Future Domain (much thanks!). */ /* This algorithm was provided by Future Domain (much thanks!). */
sizes[0] = 0; /* zero bytes out */ if (p && p[65] == 0xaa && p[64] == 0x55 /* Partition table valid */
sizes[1] = 512; /* one sector in */ && p[4]) { /* Partition type */
memcpy(data, do_read, sizeof(do_read));
retcode = kernel_scsi_ioctl(disk, SCSI_IOCTL_SEND_COMMAND, (void *) buf);
if (!retcode /* SCSI command ok */
&& data[511] == 0xaa && data[510] == 0x55 /* Partition table valid */
&& data[0x1c2]) { /* Partition type */
/* The partition table layout is as follows: /* The partition table layout is as follows:
Start: 0x1b3h Start: 0x1b3h
...@@ -1383,8 +1375,8 @@ static int fd_mcs_biosparam(struct scsi_device * disk, struct block_device *bdev ...@@ -1383,8 +1375,8 @@ static int fd_mcs_biosparam(struct scsi_device * disk, struct block_device *bdev
Future Domain algorithm, but it seemed to be a reasonable thing Future Domain algorithm, but it seemed to be a reasonable thing
to do, especially in the Linux and BSD worlds. */ to do, especially in the Linux and BSD worlds. */
info_array[0] = data[0x1c3] + 1; /* heads */ info_array[0] = p[5] + 1; /* heads */
info_array[1] = data[0x1c4] & 0x3f; /* sectors */ info_array[1] = p[6] & 0x3f; /* sectors */
} else { } else {
/* Note that this new method guarantees that there will always be /* Note that this new method guarantees that there will always be
less than 1024 cylinders on a platter. This is good for drives less than 1024 cylinders on a platter. This is good for drives
...@@ -1403,6 +1395,7 @@ static int fd_mcs_biosparam(struct scsi_device * disk, struct block_device *bdev ...@@ -1403,6 +1395,7 @@ static int fd_mcs_biosparam(struct scsi_device * disk, struct block_device *bdev
} }
/* For both methods, compute the cylinders */ /* For both methods, compute the cylinders */
info_array[2] = (unsigned int) size / (info_array[0] * info_array[1]); info_array[2] = (unsigned int) size / (info_array[0] * info_array[1]);
kfree(p);
return 0; return 0;
} }
......
...@@ -279,6 +279,7 @@ ...@@ -279,6 +279,7 @@
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <scsi/scsicam.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/system.h> #include <asm/system.h>
...@@ -1564,12 +1565,7 @@ static int fdomain_16x0_biosparam(struct scsi_device *sdev, ...@@ -1564,12 +1565,7 @@ static int fdomain_16x0_biosparam(struct scsi_device *sdev,
sector_t capacity, int *info_array) sector_t capacity, int *info_array)
{ {
int drive; int drive;
unsigned char buf[512 + sizeof (Scsi_Ioctl_Command)];
Scsi_Ioctl_Command *sic = (Scsi_Ioctl_Command *) buf;
int size = capacity; int size = capacity;
unsigned char *data = sic->data;
unsigned char do_read[] = { READ_6, 0, 0, 0, 1, 0 };
int retcode;
unsigned long offset; unsigned long offset;
struct drive_info { struct drive_info {
unsigned short cylinders; unsigned short cylinders;
...@@ -1657,16 +1653,10 @@ static int fdomain_16x0_biosparam(struct scsi_device *sdev, ...@@ -1657,16 +1653,10 @@ static int fdomain_16x0_biosparam(struct scsi_device *sdev,
info_array[2] = i.cylinders; info_array[2] = i.cylinders;
} else { /* 3.4 BIOS (and up?) */ } else { /* 3.4 BIOS (and up?) */
/* This algorithm was provided by Future Domain (much thanks!). */ /* This algorithm was provided by Future Domain (much thanks!). */
unsigned char *p = scsi_bios_ptable(bdev);
sic->inlen = 0; /* zero bytes out */ if (p && p[65] == 0xaa && p[64] == 0x55 /* Partition table valid */
sic->outlen = 512; /* one sector in */ && p[4]) { /* Partition type */
memcpy( data, do_read, sizeof( do_read ) );
retcode = kernel_scsi_ioctl( sdev,
SCSI_IOCTL_SEND_COMMAND,
sic );
if (!retcode /* SCSI command ok */
&& data[511] == 0xaa && data[510] == 0x55 /* Partition table valid */
&& data[0x1c2]) { /* Partition type */
/* The partition table layout is as follows: /* The partition table layout is as follows:
...@@ -1697,8 +1687,8 @@ static int fdomain_16x0_biosparam(struct scsi_device *sdev, ...@@ -1697,8 +1687,8 @@ static int fdomain_16x0_biosparam(struct scsi_device *sdev,
Future Domain algorithm, but it seemed to be a reasonable thing Future Domain algorithm, but it seemed to be a reasonable thing
to do, especially in the Linux and BSD worlds. */ to do, especially in the Linux and BSD worlds. */
info_array[0] = data[0x1c3] + 1; /* heads */ info_array[0] = p[5] + 1; /* heads */
info_array[1] = data[0x1c4] & 0x3f; /* sectors */ info_array[1] = p[6] & 0x3f; /* sectors */
} else { } else {
/* Note that this new method guarantees that there will always be /* Note that this new method guarantees that there will always be
...@@ -1718,6 +1708,7 @@ static int fdomain_16x0_biosparam(struct scsi_device *sdev, ...@@ -1718,6 +1708,7 @@ static int fdomain_16x0_biosparam(struct scsi_device *sdev,
} }
/* For both methods, compute the cylinders */ /* For both methods, compute the cylinders */
info_array[2] = (unsigned int)size / (info_array[0] * info_array[1] ); info_array[2] = (unsigned int)size / (info_array[0] * info_array[1] );
kfree(p);
} }
return 0; return 0;
......
...@@ -1936,10 +1936,10 @@ static void nsp_cs_config(dev_link_t *link) ...@@ -1936,10 +1936,10 @@ static void nsp_cs_config(dev_link_t *link)
nsp_dbg(NSP_DEBUG_INIT, "host=0x%p", host); nsp_dbg(NSP_DEBUG_INIT, "host=0x%p", host);
for (dev = host->host_queue; dev != NULL; dev = dev->next) { for (dev = host->host_queue; dev != NULL; dev = dev->next) {
unsigned long arg[2], id; unsigned long id;
kernel_scsi_ioctl(dev, SCSI_IOCTL_GET_IDLUN, arg); id = (dev->id & 0x0f) + ((dev->lun & 0x0f) << 4) +
id = (arg[0] & 0x0f) + ((arg[0] >> 4) & 0xf0) + ((dev->channel & 0x0f) << 8) +
((arg[0] >> 8) & 0xf00) + ((arg[0] >> 12) & 0xf000); ((dev->host->host_no & 0x0f) << 12);
node = &info->node[info->ndev]; node = &info->node[info->ndev];
node->minor = 0; node->minor = 0;
switch (dev->type) { switch (dev->type) {
......
...@@ -447,19 +447,3 @@ int scsi_ioctl(struct scsi_device *sdev, int cmd, void __user *arg) ...@@ -447,19 +447,3 @@ int scsi_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)
} }
return -EINVAL; return -EINVAL;
} }
/*
* Just like scsi_ioctl, only callable from kernel space with no
* fs segment fiddling.
*/
int kernel_scsi_ioctl(struct scsi_device *sdev, int cmd, void *arg)
{
mm_segment_t oldfs;
int tmp;
oldfs = get_fs();
set_fs(get_ds());
tmp = scsi_ioctl(sdev, cmd, arg);
set_fs(oldfs);
return tmp;
}
...@@ -53,7 +53,6 @@ EXPORT_SYMBOL(print_msg); ...@@ -53,7 +53,6 @@ EXPORT_SYMBOL(print_msg);
EXPORT_SYMBOL(print_status); EXPORT_SYMBOL(print_status);
EXPORT_SYMBOL(scsi_sense_key_string); EXPORT_SYMBOL(scsi_sense_key_string);
EXPORT_SYMBOL(scsi_extd_sense_format); EXPORT_SYMBOL(scsi_extd_sense_format);
EXPORT_SYMBOL(kernel_scsi_ioctl);
EXPORT_SYMBOL(print_Scsi_Cmnd); EXPORT_SYMBOL(print_Scsi_Cmnd);
EXPORT_SYMBOL(scsi_block_when_processing_errors); EXPORT_SYMBOL(scsi_block_when_processing_errors);
EXPORT_SYMBOL(scsi_ioctl_send_command); EXPORT_SYMBOL(scsi_ioctl_send_command);
......
...@@ -41,7 +41,6 @@ typedef struct scsi_fctargaddress { ...@@ -41,7 +41,6 @@ typedef struct scsi_fctargaddress {
} Scsi_FCTargAddress; } Scsi_FCTargAddress;
extern int scsi_ioctl(struct scsi_device *, int, void __user *); extern int scsi_ioctl(struct scsi_device *, int, void __user *);
extern int kernel_scsi_ioctl(struct scsi_device *, int , void *);
extern int scsi_ioctl_send_command(struct scsi_device *, extern int scsi_ioctl_send_command(struct scsi_device *,
struct scsi_ioctl_command __user *); struct scsi_ioctl_command __user *);
......
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