git://ftp.safe.ca
/
safe
/
jmp
/
linux-2.6
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[SCSI] dpt_i2o: remove dead code
[safe/jmp/linux-2.6]
/
drivers
/
scsi
/
ch.c
diff --git
a/drivers/scsi/ch.c
b/drivers/scsi/ch.c
index
53b3955
..
2a2cc6c
100644
(file)
--- a/
drivers/scsi/ch.c
+++ b/
drivers/scsi/ch.c
@@
-7,12
+7,10
@@
#define VERSION "0.25"
#define VERSION "0.25"
-#include <linux/config.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/kernel.h>
-#include <linux/sched.h>
#include <linux/mm.h>
#include <linux/major.h>
#include <linux/string.h>
#include <linux/mm.h>
#include <linux/major.h>
#include <linux/string.h>
@@
-20,9
+18,9
@@
#include <linux/interrupt.h>
#include <linux/blkdev.h>
#include <linux/completion.h>
#include <linux/interrupt.h>
#include <linux/blkdev.h>
#include <linux/completion.h>
-#include <linux/ioctl32.h>
#include <linux/compat.h>
#include <linux/chio.h> /* here are all the ioctls */
#include <linux/compat.h>
#include <linux/chio.h> /* here are all the ioctls */
+#include <linux/mutex.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
@@
-30,7
+28,7
@@
#include <scsi/scsi_ioctl.h>
#include <scsi/scsi_host.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_ioctl.h>
#include <scsi/scsi_host.h>
#include <scsi/scsi_device.h>
-#include <scsi/scsi_
request
.h>
+#include <scsi/scsi_
eh
.h>
#include <scsi/scsi_dbg.h>
#define CH_DT_MAX 16
#include <scsi/scsi_dbg.h>
#define CH_DT_MAX 16
@@
-39,6
+37,7
@@
MODULE_DESCRIPTION("device driver for scsi media changer devices");
MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org>");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("device driver for scsi media changer devices");
MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org>");
MODULE_LICENSE("GPL");
+MODULE_ALIAS_CHARDEV_MAJOR(SCSI_CHANGER_MAJOR);
static int init = 1;
module_param(init, int, 0444);
static int init = 1;
module_param(init, int, 0444);
@@
-75,7
+74,7
@@
static int vendor_counts[CH_TYPES-4];
module_param_array(vendor_firsts, int, NULL, 0444);
module_param_array(vendor_counts, int, NULL, 0444);
module_param_array(vendor_firsts, int, NULL, 0444);
module_param_array(vendor_counts, int, NULL, 0444);
-static c
har *
vendor_labels[CH_TYPES-4] = {
+static c
onst char *
vendor_labels[CH_TYPES-4] = {
"v0", "v1", "v2", "v3"
};
// module_param_string_array(vendor_labels, NULL, 0444);
"v0", "v1", "v2", "v3"
};
// module_param_string_array(vendor_labels, NULL, 0444);
@@
-112,11
+111,11
@@
typedef struct {
u_int counts[CH_TYPES];
u_int unit_attention;
u_int voltags;
u_int counts[CH_TYPES];
u_int unit_attention;
u_int voltags;
- struct
semaphore
lock;
+ struct
mutex
lock;
} scsi_changer;
static LIST_HEAD(ch_devlist);
} scsi_changer;
static LIST_HEAD(ch_devlist);
-static
spinlock_t ch_devlist_lock = SPIN_LOCK_UNLOCKED
;
+static
DEFINE_SPINLOCK(ch_devlist_lock)
;
static int ch_devcount;
static struct scsi_driver ch_template =
static int ch_devcount;
static struct scsi_driver ch_template =
@@
-129,7
+128,7
@@
static struct scsi_driver ch_template =
},
};
},
};
-static struct file_operations changer_fops =
+static
const
struct file_operations changer_fops =
{
.owner = THIS_MODULE,
.open = ch_open,
{
.owner = THIS_MODULE,
.open = ch_open,
@@
-140,7
+139,7
@@
static struct file_operations changer_fops =
#endif
};
#endif
};
-static struct {
+static
const
struct {
unsigned char sense;
unsigned char asc;
unsigned char ascq;
unsigned char sense;
unsigned char asc;
unsigned char ascq;
@@
-180,17
+179,17
@@
static struct {
/* ------------------------------------------------------------------- */
/* ------------------------------------------------------------------- */
-static int ch_find_errno(
unsigned char *sense_buffe
r)
+static int ch_find_errno(
struct scsi_sense_hdr *sshd
r)
{
int i,errno = 0;
/* Check to see if additional sense information is available */
{
int i,errno = 0;
/* Check to see if additional sense information is available */
- if (s
ense_buffer[7] > 5
&&
- s
ense_buffer[12]
!= 0) {
+ if (s
csi_sense_valid(sshdr)
&&
+ s
shdr->asc
!= 0) {
for (i = 0; err[i].errno != 0; i++) {
for (i = 0; err[i].errno != 0; i++) {
- if (err[i].sense == s
ense_buffer[ 2]
&&
- err[i].asc == s
ense_buffer[12]
&&
- err[i].ascq == s
ense_buffer[13]
) {
+ if (err[i].sense == s
shdr->sense_key
&&
+ err[i].asc == s
shdr->asc
&&
+ err[i].ascq == s
shdr->ascq
) {
errno = -err[i].errno;
break;
}
errno = -err[i].errno;
break;
}
@@
-206,13
+205,9
@@
ch_do_scsi(scsi_changer *ch, unsigned char *cmd,
void *buffer, unsigned buflength,
enum dma_data_direction direction)
{
void *buffer, unsigned buflength,
enum dma_data_direction direction)
{
- int errno, retries = 0, timeout;
- struct scsi_
request *s
r;
+ int errno, retries = 0, timeout
, result
;
+ struct scsi_
sense_hdr sshd
r;
- sr = scsi_allocate_request(ch->device, GFP_KERNEL);
- if (NULL == sr)
- return -ENOMEM;
-
timeout = (cmd[0] == INITIALIZE_ELEMENT_STATUS)
? timeout_init : timeout_move;
timeout = (cmd[0] == INITIALIZE_ELEMENT_STATUS)
? timeout_init : timeout_move;
@@
-223,16
+218,17
@@
ch_do_scsi(scsi_changer *ch, unsigned char *cmd,
__scsi_print_command(cmd);
}
__scsi_print_command(cmd);
}
- scsi_wait_req(sr, cmd, buffer, buflength,
- timeout * HZ, MAX_RETRIES);
+ result = scsi_execute_req(ch->device, cmd, direction, buffer,
+ buflength, &sshdr, timeout * HZ,
+ MAX_RETRIES);
- dprintk("result: 0x%x\n",
sr->sr_
result);
- if (driver_byte(
sr->sr_
result) & DRIVER_SENSE) {
+ dprintk("result: 0x%x\n",result);
+ if (driver_byte(result) & DRIVER_SENSE) {
if (debug)
if (debug)
- scsi_print_
req_sense(ch->name, s
r);
- errno = ch_find_errno(
sr->sr_sense_buffe
r);
+ scsi_print_
sense_hdr(ch->name, &sshd
r);
+ errno = ch_find_errno(
&sshd
r);
- switch(s
r->sr_sense_buffer[2] & 0xf
) {
+ switch(s
shdr.sense_key
) {
case UNIT_ATTENTION:
ch->unit_attention = 1;
if (retries++ < 3)
case UNIT_ATTENTION:
ch->unit_attention = 1;
if (retries++ < 3)
@@
-240,7
+236,6
@@
ch_do_scsi(scsi_changer *ch, unsigned char *cmd,
break;
}
}
break;
}
}
- scsi_release_request(sr);
return errno;
}
return errno;
}
@@
-564,13
+559,13
@@
ch_set_voltag(scsi_changer *ch, u_int elem,
return result;
}
return result;
}
-static int ch_gstatus(scsi_changer *ch, int type, unsigned char *dest)
+static int ch_gstatus(scsi_changer *ch, int type, unsigned char
__user
*dest)
{
int retval = 0;
u_char data[16];
unsigned int i;
{
int retval = 0;
u_char data[16];
unsigned int i;
-
down
(&ch->lock);
+
mutex_lock
(&ch->lock);
for (i = 0; i < ch->counts[type]; i++) {
if (0 != ch_read_element_status
(ch, ch->firsts[type]+i,data)) {
for (i = 0; i < ch->counts[type]; i++) {
if (0 != ch_read_element_status
(ch, ch->firsts[type]+i,data)) {
@@
-587,7
+582,7
@@
static int ch_gstatus(scsi_changer *ch, int type, unsigned char *dest)
if (0 != retval)
break;
}
if (0 != retval)
break;
}
-
up
(&ch->lock);
+
mutex_unlock
(&ch->lock);
return retval;
}
return retval;
}
@@
-638,6
+633,7
@@
static int ch_ioctl(struct inode * inode, struct file * file,
{
scsi_changer *ch = file->private_data;
int retval;
{
scsi_changer *ch = file->private_data;
int retval;
+ void __user *argp = (void __user *)arg;
switch (cmd) {
case CHIOGPARAMS:
switch (cmd) {
case CHIOGPARAMS:
@@
-650,7
+646,7
@@
static int ch_ioctl(struct inode * inode, struct file * file,
params.cp_nportals = ch->counts[CHET_IE];
params.cp_ndrives = ch->counts[CHET_DT];
params.cp_nportals = ch->counts[CHET_IE];
params.cp_ndrives = ch->counts[CHET_DT];
- if (copy_to_user(
(void *) arg
, ¶ms, sizeof(params)))
+ if (copy_to_user(
argp
, ¶ms, sizeof(params)))
return -EFAULT;
return 0;
}
return -EFAULT;
return 0;
}
@@
-675,7
+671,7
@@
static int ch_ioctl(struct inode * inode, struct file * file,
vparams.cvp_n4 = ch->counts[CHET_V4];
strncpy(vparams.cvp_label4,vendor_labels[3],16);
}
vparams.cvp_n4 = ch->counts[CHET_V4];
strncpy(vparams.cvp_label4,vendor_labels[3],16);
}
- if (copy_to_user(
(void *) arg
, &vparams, sizeof(vparams)))
+ if (copy_to_user(
argp
, &vparams, sizeof(vparams)))
return -EFAULT;
return 0;
}
return -EFAULT;
return 0;
}
@@
-684,18
+680,18
@@
static int ch_ioctl(struct inode * inode, struct file * file,
{
struct changer_position pos;
{
struct changer_position pos;
- if (copy_from_user(&pos,
(void*)arg
, sizeof (pos)))
+ if (copy_from_user(&pos,
argp
, sizeof (pos)))
return -EFAULT;
if (0 != ch_checkrange(ch, pos.cp_type, pos.cp_unit)) {
dprintk("CHIOPOSITION: invalid parameter\n");
return -EBADSLT;
}
return -EFAULT;
if (0 != ch_checkrange(ch, pos.cp_type, pos.cp_unit)) {
dprintk("CHIOPOSITION: invalid parameter\n");
return -EBADSLT;
}
-
down
(&ch->lock);
+
mutex_lock
(&ch->lock);
retval = ch_position(ch,0,
ch->firsts[pos.cp_type] + pos.cp_unit,
pos.cp_flags & CP_INVERT);
retval = ch_position(ch,0,
ch->firsts[pos.cp_type] + pos.cp_unit,
pos.cp_flags & CP_INVERT);
-
up
(&ch->lock);
+
mutex_unlock
(&ch->lock);
return retval;
}
return retval;
}
@@
-703,7
+699,7
@@
static int ch_ioctl(struct inode * inode, struct file * file,
{
struct changer_move mv;
{
struct changer_move mv;
- if (copy_from_user(&mv,
(void*)arg
, sizeof (mv)))
+ if (copy_from_user(&mv,
argp
, sizeof (mv)))
return -EFAULT;
if (0 != ch_checkrange(ch, mv.cm_fromtype, mv.cm_fromunit) ||
return -EFAULT;
if (0 != ch_checkrange(ch, mv.cm_fromtype, mv.cm_fromunit) ||
@@
-712,12
+708,12
@@
static int ch_ioctl(struct inode * inode, struct file * file,
return -EBADSLT;
}
return -EBADSLT;
}
-
down
(&ch->lock);
+
mutex_lock
(&ch->lock);
retval = ch_move(ch,0,
ch->firsts[mv.cm_fromtype] + mv.cm_fromunit,
ch->firsts[mv.cm_totype] + mv.cm_tounit,
mv.cm_flags & CM_INVERT);
retval = ch_move(ch,0,
ch->firsts[mv.cm_fromtype] + mv.cm_fromunit,
ch->firsts[mv.cm_totype] + mv.cm_tounit,
mv.cm_flags & CM_INVERT);
-
up
(&ch->lock);
+
mutex_unlock
(&ch->lock);
return retval;
}
return retval;
}
@@
-725,7
+721,7
@@
static int ch_ioctl(struct inode * inode, struct file * file,
{
struct changer_exchange mv;
{
struct changer_exchange mv;
- if (copy_from_user(&mv,
(void*)arg
, sizeof (mv)))
+ if (copy_from_user(&mv,
argp
, sizeof (mv)))
return -EFAULT;
if (0 != ch_checkrange(ch, mv.ce_srctype, mv.ce_srcunit ) ||
return -EFAULT;
if (0 != ch_checkrange(ch, mv.ce_srctype, mv.ce_srcunit ) ||
@@
-735,14
+731,14
@@
static int ch_ioctl(struct inode * inode, struct file * file,
return -EBADSLT;
}
return -EBADSLT;
}
-
down
(&ch->lock);
+
mutex_lock
(&ch->lock);
retval = ch_exchange
(ch,0,
ch->firsts[mv.ce_srctype] + mv.ce_srcunit,
ch->firsts[mv.ce_fdsttype] + mv.ce_fdstunit,
ch->firsts[mv.ce_sdsttype] + mv.ce_sdstunit,
mv.ce_flags & CE_INVERT1, mv.ce_flags & CE_INVERT2);
retval = ch_exchange
(ch,0,
ch->firsts[mv.ce_srctype] + mv.ce_srcunit,
ch->firsts[mv.ce_fdsttype] + mv.ce_fdstunit,
ch->firsts[mv.ce_sdsttype] + mv.ce_sdstunit,
mv.ce_flags & CE_INVERT1, mv.ce_flags & CE_INVERT2);
-
up
(&ch->lock);
+
mutex_unlock
(&ch->lock);
return retval;
}
return retval;
}
@@
-750,7
+746,7
@@
static int ch_ioctl(struct inode * inode, struct file * file,
{
struct changer_element_status ces;
{
struct changer_element_status ces;
- if (copy_from_user(&ces,
(void*)arg
, sizeof (ces)))
+ if (copy_from_user(&ces,
argp
, sizeof (ces)))
return -EFAULT;
if (ces.ces_type < 0 || ces.ces_type >= CH_TYPES)
return -EINVAL;
return -EFAULT;
if (ces.ces_type < 0 || ces.ces_type >= CH_TYPES)
return -EINVAL;
@@
-766,7
+762,7
@@
static int ch_ioctl(struct inode * inode, struct file * file,
unsigned int elem;
int result,i;
unsigned int elem;
int result,i;
- if (copy_from_user(&cge,
(void*)arg
, sizeof (cge)))
+ if (copy_from_user(&cge,
argp
, sizeof (cge)))
return -EFAULT;
if (0 != ch_checkrange(ch, cge.cge_type, cge.cge_unit))
return -EFAULT;
if (0 != ch_checkrange(ch, cge.cge_type, cge.cge_unit))
@@
-776,7
+772,7
@@
static int ch_ioctl(struct inode * inode, struct file * file,
buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
if (!buffer)
return -ENOMEM;
buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
if (!buffer)
return -ENOMEM;
-
down
(&ch->lock);
+
mutex_lock
(&ch->lock);
voltag_retry:
memset(cmd,0,sizeof(cmd));
voltag_retry:
memset(cmd,0,sizeof(cmd));
@@
-827,18
+823,18
@@
static int ch_ioctl(struct inode * inode, struct file * file,
goto voltag_retry;
}
kfree(buffer);
goto voltag_retry;
}
kfree(buffer);
-
up
(&ch->lock);
+
mutex_unlock
(&ch->lock);
- if (copy_to_user(
(void*)arg
, &cge, sizeof (cge)))
+ if (copy_to_user(
argp
, &cge, sizeof (cge)))
return -EFAULT;
return result;
}
case CHIOINITELEM:
{
return -EFAULT;
return result;
}
case CHIOINITELEM:
{
-
down
(&ch->lock);
+
mutex_lock
(&ch->lock);
retval = ch_init_elem(ch);
retval = ch_init_elem(ch);
-
up
(&ch->lock);
+
mutex_unlock
(&ch->lock);
return retval;
}
return retval;
}
@@
-847,7
+843,7
@@
static int ch_ioctl(struct inode * inode, struct file * file,
struct changer_set_voltag csv;
int elem;
struct changer_set_voltag csv;
int elem;
- if (copy_from_user(&csv,
(void*)arg
, sizeof(csv)))
+ if (copy_from_user(&csv,
argp
, sizeof(csv)))
return -EFAULT;
if (0 != ch_checkrange(ch, csv.csv_type, csv.csv_unit)) {
return -EFAULT;
if (0 != ch_checkrange(ch, csv.csv_type, csv.csv_unit)) {
@@
-855,17
+851,17
@@
static int ch_ioctl(struct inode * inode, struct file * file,
return -EBADSLT;
}
elem = ch->firsts[csv.csv_type] + csv.csv_unit;
return -EBADSLT;
}
elem = ch->firsts[csv.csv_type] + csv.csv_unit;
-
down
(&ch->lock);
+
mutex_lock
(&ch->lock);
retval = ch_set_voltag(ch, elem,
csv.csv_flags & CSV_AVOLTAG,
csv.csv_flags & CSV_CLEARTAG,
csv.csv_voltag);
retval = ch_set_voltag(ch, elem,
csv.csv_flags & CSV_AVOLTAG,
csv.csv_flags & CSV_CLEARTAG,
csv.csv_voltag);
-
up
(&ch->lock);
+
mutex_unlock
(&ch->lock);
return retval;
}
default:
return retval;
}
default:
- return scsi_ioctl(ch->device, cmd,
(void*)arg
);
+ return scsi_ioctl(ch->device, cmd,
argp
);
}
}
}
}
@@
-898,9
+894,9
@@
static long ch_ioctl_compat(struct file * file,
case CHIOGSTATUS32:
{
struct changer_element_status32 ces32;
case CHIOGSTATUS32:
{
struct changer_element_status32 ces32;
- unsigned char *data;
+ unsigned char
__user
*data;
- if (copy_from_user(&ces32, (void*)arg, sizeof (ces32)))
+ if (copy_from_user(&ces32, (void
__user
*)arg, sizeof (ces32)))
return -EFAULT;
if (ces32.ces_type < 0 || ces32.ces_type >= CH_TYPES)
return -EINVAL;
return -EFAULT;
if (ces32.ces_type < 0 || ces32.ces_type >= CH_TYPES)
return -EINVAL;
@@
-933,19
+929,17
@@
static int ch_probe(struct device *dev)
memset(ch,0,sizeof(*ch));
ch->minor = ch_devcount;
sprintf(ch->name,"ch%d",ch->minor);
memset(ch,0,sizeof(*ch));
ch->minor = ch_devcount;
sprintf(ch->name,"ch%d",ch->minor);
-
init_MUTEX
(&ch->lock);
+
mutex_init
(&ch->lock);
ch->device = sd;
ch_readconfig(ch);
if (init)
ch_init_elem(ch);
ch->device = sd;
ch_readconfig(ch);
if (init)
ch_init_elem(ch);
- class_device_create(ch_sysfs_class,
+ class_device_create(ch_sysfs_class,
NULL,
MKDEV(SCSI_CHANGER_MAJOR,ch->minor),
dev, "s%s", ch->name);
MKDEV(SCSI_CHANGER_MAJOR,ch->minor),
dev, "s%s", ch->name);
- printk(KERN_INFO "Attached scsi changer %s "
- "at scsi%d, channel %d, id %d, lun %d\n",
- ch->name, sd->host->host_no, sd->channel, sd->id, sd->lun);
+ sdev_printk(KERN_INFO, sd, "Attached scsi changer %s\n", ch->name);
spin_lock(&ch_devlist_lock);
list_add_tail(&ch->list,&ch_devlist);
spin_lock(&ch_devlist_lock);
list_add_tail(&ch->list,&ch_devlist);