aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/arm/scsi.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/scsi/arm/scsi.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'drivers/scsi/arm/scsi.h')
-rw-r--r--drivers/scsi/arm/scsi.h115
1 files changed, 115 insertions, 0 deletions
diff --git a/drivers/scsi/arm/scsi.h b/drivers/scsi/arm/scsi.h
new file mode 100644
index 000000000000..2f1b3f4bf954
--- /dev/null
+++ b/drivers/scsi/arm/scsi.h
@@ -0,0 +1,115 @@
1/*
2 * linux/drivers/acorn/scsi/scsi.h
3 *
4 * Copyright (C) 2002 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Commonly used scsi driver functions.
11 */
12
13#define BELT_AND_BRACES
14
15/*
16 * The scatter-gather list handling. This contains all
17 * the yucky stuff that needs to be fixed properly.
18 */
19static inline int copy_SCp_to_sg(struct scatterlist *sg, Scsi_Pointer *SCp, int max)
20{
21 int bufs = SCp->buffers_residual;
22
23 BUG_ON(bufs + 1 > max);
24
25 sg->page = virt_to_page(SCp->ptr);
26 sg->offset = offset_in_page(SCp->ptr);
27 sg->length = SCp->this_residual;
28
29 if (bufs)
30 memcpy(sg + 1, SCp->buffer + 1,
31 sizeof(struct scatterlist) * bufs);
32 return bufs + 1;
33}
34
35static inline int next_SCp(Scsi_Pointer *SCp)
36{
37 int ret = SCp->buffers_residual;
38 if (ret) {
39 SCp->buffer++;
40 SCp->buffers_residual--;
41 SCp->ptr = (char *)
42 (page_address(SCp->buffer->page) +
43 SCp->buffer->offset);
44 SCp->this_residual = SCp->buffer->length;
45 } else {
46 SCp->ptr = NULL;
47 SCp->this_residual = 0;
48 }
49 return ret;
50}
51
52static inline unsigned char get_next_SCp_byte(Scsi_Pointer *SCp)
53{
54 char c = *SCp->ptr;
55
56 SCp->ptr += 1;
57 SCp->this_residual -= 1;
58
59 return c;
60}
61
62static inline void put_next_SCp_byte(Scsi_Pointer *SCp, unsigned char c)
63{
64 *SCp->ptr = c;
65 SCp->ptr += 1;
66 SCp->this_residual -= 1;
67}
68
69static inline void init_SCp(Scsi_Cmnd *SCpnt)
70{
71 memset(&SCpnt->SCp, 0, sizeof(struct scsi_pointer));
72
73 if (SCpnt->use_sg) {
74 unsigned long len = 0;
75 int buf;
76
77 SCpnt->SCp.buffer = (struct scatterlist *) SCpnt->buffer;
78 SCpnt->SCp.buffers_residual = SCpnt->use_sg - 1;
79 SCpnt->SCp.ptr = (char *)
80 (page_address(SCpnt->SCp.buffer->page) +
81 SCpnt->SCp.buffer->offset);
82 SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length;
83
84#ifdef BELT_AND_BRACES
85 /*
86 * Calculate correct buffer length. Some commands
87 * come in with the wrong request_bufflen.
88 */
89 for (buf = 0; buf <= SCpnt->SCp.buffers_residual; buf++)
90 len += SCpnt->SCp.buffer[buf].length;
91
92 if (SCpnt->request_bufflen != len)
93 printk(KERN_WARNING "scsi%d.%c: bad request buffer "
94 "length %d, should be %ld\n", SCpnt->device->host->host_no,
95 '0' + SCpnt->device->id, SCpnt->request_bufflen, len);
96 SCpnt->request_bufflen = len;
97#endif
98 } else {
99 SCpnt->SCp.ptr = (unsigned char *)SCpnt->request_buffer;
100 SCpnt->SCp.this_residual = SCpnt->request_bufflen;
101 }
102
103 /*
104 * If the upper SCSI layers pass a buffer, but zero length,
105 * we aren't interested in the buffer pointer.
106 */
107 if (SCpnt->SCp.this_residual == 0 && SCpnt->SCp.ptr) {
108#if 0 //def BELT_AND_BRACES
109 printk(KERN_WARNING "scsi%d.%c: zero length buffer passed for "
110 "command ", SCpnt->host->host_no, '0' + SCpnt->target);
111 print_command(SCpnt->cmnd);
112#endif
113 SCpnt->SCp.ptr = NULL;
114 }
115}