hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/scsi/aha152x.c
....@@ -1,17 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /* aha152x.c -- Adaptec AHA-152x driver
23 * Author: Jürgen E. Fischer, fischer@norbit.de
34 * Copyright 1993-2004 Jürgen E. Fischer
4
- *
5
- * This program is free software; you can redistribute it and/or modify it
6
- * under the terms of the GNU General Public License as published by the
7
- * Free Software Foundation; either version 2, or (at your option) any
8
- * later version.
9
- *
10
- * This program is distributed in the hope that it will be useful, but
11
- * WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- * General Public License for more details.
14
- *
155 *
166 * $Id: aha152x.c,v 2.7 2004/01/24 11:42:59 fischer Exp $
177 *
....@@ -228,10 +218,9 @@
228218 * Revision 0.0 1993/08/14 19:54:25 root
229219 * empty function bodies; detect() works.
230220 *
231
- *
232221 **************************************************************************
233222
234
- see Documentation/scsi/aha152x.txt for configuration details
223
+ see Documentation/scsi/aha152x.rst for configuration details
235224
236225 **************************************************************************/
237226
....@@ -269,7 +258,7 @@
269258 /* DEFINES */
270259
271260 /* For PCMCIA cards, always use AUTOCONF */
272
-#if defined(PCMCIA) || defined(MODULE)
261
+#if defined(AHA152X_PCMCIA) || defined(MODULE)
273262 #if !defined(AUTOCONF)
274263 #define AUTOCONF
275264 #endif
....@@ -297,7 +286,7 @@
297286
298287 #define DELAY_DEFAULT 1000
299288
300
-#if defined(PCMCIA)
289
+#if defined(AHA152X_PCMCIA)
301290 #define IRQ_MIN 0
302291 #define IRQ_MAX 16
303292 #else
....@@ -328,7 +317,7 @@
328317 MODULE_DESCRIPTION(AHA152X_REVID);
329318 MODULE_LICENSE("GPL");
330319
331
-#if !defined(PCMCIA)
320
+#if !defined(AHA152X_PCMCIA)
332321 #if defined(MODULE)
333322 static int io[] = {0, 0};
334323 module_param_hw_array(io, int, ioport, NULL, 0);
....@@ -391,7 +380,7 @@
391380 MODULE_DEVICE_TABLE(isapnp, id_table);
392381 #endif /* ISAPNP */
393382
394
-#endif /* !PCMCIA */
383
+#endif /* !AHA152X_PCMCIA */
395384
396385 static struct scsi_host_template aha152x_driver_template;
397386
....@@ -863,7 +852,7 @@
863852 if (shpnt->irq)
864853 free_irq(shpnt->irq, shpnt);
865854
866
-#if !defined(PCMCIA)
855
+#if !defined(AHA152X_PCMCIA)
867856 if (shpnt->io_port)
868857 release_region(shpnt->io_port, IO_RANGE);
869858 #endif
....@@ -948,7 +937,6 @@
948937 SCp.ptr : buffer pointer
949938 SCp.this_residual : buffer length
950939 SCp.buffer : next buffer
951
- SCp.buffers_residual : left buffers in list
952940 SCp.phase : current state of the command */
953941
954942 if ((phase & resetting) || !scsi_sglist(SCpnt)) {
....@@ -956,13 +944,11 @@
956944 SCpnt->SCp.this_residual = 0;
957945 scsi_set_resid(SCpnt, 0);
958946 SCpnt->SCp.buffer = NULL;
959
- SCpnt->SCp.buffers_residual = 0;
960947 } else {
961948 scsi_set_resid(SCpnt, scsi_bufflen(SCpnt));
962949 SCpnt->SCp.buffer = scsi_sglist(SCpnt);
963950 SCpnt->SCp.ptr = SG_ADDRESS(SCpnt->SCp.buffer);
964951 SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length;
965
- SCpnt->SCp.buffers_residual = scsi_sg_count(SCpnt) - 1;
966952 }
967953
968954 DO_LOCK(flags);
....@@ -1263,7 +1249,7 @@
12631249 "aha152x: unable to verify geometry for disk with >1GB.\n"
12641250 " Using default translation. Please verify yourself.\n"
12651251 " Perhaps you need to enable extended translation in the driver.\n"
1266
- " See Documentation/scsi/aha152x.txt for details.\n");
1252
+ " See Documentation/scsi/aha152x.rst for details.\n");
12671253 }
12681254 } else {
12691255 info_array[0] = info[0];
....@@ -2030,10 +2016,9 @@
20302016 }
20312017
20322018 if (CURRENT_SC->SCp.this_residual == 0 &&
2033
- CURRENT_SC->SCp.buffers_residual > 0) {
2019
+ !sg_is_last(CURRENT_SC->SCp.buffer)) {
20342020 /* advance to next buffer */
2035
- CURRENT_SC->SCp.buffers_residual--;
2036
- CURRENT_SC->SCp.buffer++;
2021
+ CURRENT_SC->SCp.buffer = sg_next(CURRENT_SC->SCp.buffer);
20372022 CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer);
20382023 CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length;
20392024 }
....@@ -2045,8 +2030,7 @@
20452030 fifodata, GETPORT(FIFOSTAT));
20462031 SETPORT(DMACNTRL0, ENDMA|_8BIT);
20472032 while(fifodata>0) {
2048
- int data;
2049
- data=GETPORT(DATAPORT);
2033
+ GETPORT(DATAPORT);
20502034 fifodata--;
20512035 DATA_LEN++;
20522036 }
....@@ -2136,10 +2120,10 @@
21362120 CMD_INC_RESID(CURRENT_SC, -2 * data_count);
21372121 }
21382122
2139
- if(CURRENT_SC->SCp.this_residual==0 && CURRENT_SC->SCp.buffers_residual>0) {
2123
+ if (CURRENT_SC->SCp.this_residual == 0 &&
2124
+ !sg_is_last(CURRENT_SC->SCp.buffer)) {
21402125 /* advance to next buffer */
2141
- CURRENT_SC->SCp.buffers_residual--;
2142
- CURRENT_SC->SCp.buffer++;
2126
+ CURRENT_SC->SCp.buffer = sg_next(CURRENT_SC->SCp.buffer);
21432127 CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer);
21442128 CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length;
21452129 }
....@@ -2158,22 +2142,26 @@
21582142 static void datao_end(struct Scsi_Host *shpnt)
21592143 {
21602144 if(TESTLO(DMASTAT, DFIFOEMP)) {
2161
- int data_count = (DATA_LEN - scsi_get_resid(CURRENT_SC)) -
2162
- GETSTCNT();
2145
+ u32 datao_cnt = GETSTCNT();
2146
+ int datao_out = DATA_LEN - scsi_get_resid(CURRENT_SC);
2147
+ int done;
2148
+ struct scatterlist *sg = scsi_sglist(CURRENT_SC);
21632149
2164
- CMD_INC_RESID(CURRENT_SC, data_count);
2150
+ CMD_INC_RESID(CURRENT_SC, datao_out - datao_cnt);
21652151
2166
- data_count -= CURRENT_SC->SCp.ptr -
2167
- SG_ADDRESS(CURRENT_SC->SCp.buffer);
2168
- while(data_count>0) {
2169
- CURRENT_SC->SCp.buffer--;
2170
- CURRENT_SC->SCp.buffers_residual++;
2171
- data_count -= CURRENT_SC->SCp.buffer->length;
2152
+ done = scsi_bufflen(CURRENT_SC) - scsi_get_resid(CURRENT_SC);
2153
+ /* Locate the first SG entry not yet sent */
2154
+ while (done > 0 && !sg_is_last(sg)) {
2155
+ if (done < sg->length)
2156
+ break;
2157
+ done -= sg->length;
2158
+ sg = sg_next(sg);
21722159 }
2173
- CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer) -
2174
- data_count;
2175
- CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length +
2176
- data_count;
2160
+
2161
+ CURRENT_SC->SCp.buffer = sg;
2162
+ CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer) + done;
2163
+ CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length -
2164
+ done;
21772165 }
21782166
21792167 SETPORT(SXFRCTL0, CH1|CLRCH1|CLRSTCNT);
....@@ -2501,7 +2489,7 @@
25012489
25022490 seq_printf(m, "); resid=%d; residual=%d; buffers=%d; phase |",
25032491 scsi_get_resid(ptr), ptr->SCp.this_residual,
2504
- ptr->SCp.buffers_residual);
2492
+ sg_nents(ptr->SCp.buffer) - 1);
25052493
25062494 if (ptr->SCp.phase & not_issued)
25072495 seq_puts(m, "not issued|");
....@@ -2920,11 +2908,11 @@
29202908 .can_queue = 1,
29212909 .this_id = 7,
29222910 .sg_tablesize = SG_ALL,
2923
- .use_clustering = DISABLE_CLUSTERING,
2911
+ .dma_boundary = PAGE_SIZE - 1,
29242912 .slave_alloc = aha152x_adjust_queue,
29252913 };
29262914
2927
-#if !defined(PCMCIA)
2915
+#if !defined(AHA152X_PCMCIA)
29282916 static int setup_count;
29292917 static struct aha152x_setup setup[2];
29302918
....@@ -3379,17 +3367,15 @@
33793367 setup[setup_count].synchronous = ints[0] >= 6 ? ints[6] : 1;
33803368 setup[setup_count].delay = ints[0] >= 7 ? ints[7] : DELAY_DEFAULT;
33813369 setup[setup_count].ext_trans = ints[0] >= 8 ? ints[8] : 0;
3382
- if (ints[0] > 8) { /*}*/
3370
+ if (ints[0] > 8)
33833371 printk(KERN_NOTICE "aha152x: usage: aha152x=<IOBASE>[,<IRQ>[,<SCSI ID>"
33843372 "[,<RECONNECT>[,<PARITY>[,<SYNCHRONOUS>[,<DELAY>[,<EXT_TRANS>]]]]]]]\n");
3385
- } else {
3373
+ else
33863374 setup_count++;
3387
- return 0;
3388
- }
33893375
33903376 return 1;
33913377 }
33923378 __setup("aha152x=", aha152x_setup);
33933379 #endif
33943380
3395
-#endif /* !PCMCIA */
3381
+#endif /* !AHA152X_PCMCIA */