forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/scsi/aic7xxx/aic7xxx_core.c
....@@ -40,15 +40,9 @@
4040 * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.c#155 $
4141 */
4242
43
-#ifdef __linux__
4443 #include "aic7xxx_osm.h"
4544 #include "aic7xxx_inline.h"
4645 #include "aicasm/aicasm_insformat.h"
47
-#else
48
-#include <dev/aic7xxx/aic7xxx_osm.h>
49
-#include <dev/aic7xxx/aic7xxx_inline.h>
50
-#include <dev/aic7xxx/aicasm/aicasm_insformat.h>
51
-#endif
5246
5347 /***************************** Lookup Tables **********************************/
5448 static const char *const ahc_chip_names[] = {
....@@ -67,7 +61,6 @@
6761 "aic7892",
6862 "aic7899"
6963 };
70
-static const u_int num_chip_names = ARRAY_SIZE(ahc_chip_names);
7164
7265 /*
7366 * Hardware error codes.
....@@ -1673,7 +1666,7 @@
16731666 printk("\tCRC Value Mismatch\n");
16741667 if ((sstat2 & CRCENDERR) != 0)
16751668 printk("\tNo terminal CRC packet "
1676
- "recevied\n");
1669
+ "received\n");
16771670 if ((sstat2 & CRCREQERR) != 0)
16781671 printk("\tIllegal CRC packet "
16791672 "request\n");
....@@ -1841,21 +1834,6 @@
18411834 printerror = 0;
18421835 } else if (ahc_sent_msg(ahc, AHCMSG_1B,
18431836 MSG_BUS_DEV_RESET, TRUE)) {
1844
-#ifdef __FreeBSD__
1845
- /*
1846
- * Don't mark the user's request for this BDR
1847
- * as completing with CAM_BDR_SENT. CAM3
1848
- * specifies CAM_REQ_CMP.
1849
- */
1850
- if (scb != NULL
1851
- && scb->io_ctx->ccb_h.func_code== XPT_RESET_DEV
1852
- && ahc_match_scb(ahc, scb, target, channel,
1853
- CAM_LUN_WILDCARD,
1854
- SCB_LIST_NULL,
1855
- ROLE_INITIATOR)) {
1856
- ahc_set_transaction_status(scb, CAM_REQ_CMP);
1857
- }
1858
-#endif
18591837 ahc_compile_devinfo(&devinfo,
18601838 initiator_role_id,
18611839 target,
....@@ -2200,8 +2178,7 @@
22002178 if (channel == 'B')
22012179 scsi_id += 8;
22022180 tstate = ahc->enabled_targets[scsi_id];
2203
- if (tstate != NULL)
2204
- kfree(tstate);
2181
+ kfree(tstate);
22052182 ahc->enabled_targets[scsi_id] = NULL;
22062183 }
22072184 #endif
....@@ -2427,7 +2404,7 @@
24272404 *bus_width = MSG_EXT_WDTR_BUS_16_BIT;
24282405 break;
24292406 }
2430
- /* FALLTHROUGH */
2407
+ fallthrough;
24312408 case MSG_EXT_WDTR_BUS_8_BIT:
24322409 *bus_width = MSG_EXT_WDTR_BUS_8_BIT;
24332410 break;
....@@ -3622,7 +3599,7 @@
36223599 break;
36233600 case MSG_MESSAGE_REJECT:
36243601 response = ahc_handle_msg_reject(ahc, devinfo);
3625
- /* FALLTHROUGH */
3602
+ fallthrough;
36263603 case MSG_NOOP:
36273604 done = MSGLOOP_MSGCOMPLETE;
36283605 break;
....@@ -4406,22 +4383,16 @@
44064383 struct ahc_softc *ahc;
44074384 int i;
44084385
4409
-#ifndef __FreeBSD__
4410
- ahc = kmalloc(sizeof(*ahc), GFP_ATOMIC);
4386
+ ahc = kzalloc(sizeof(*ahc), GFP_ATOMIC);
44114387 if (!ahc) {
44124388 printk("aic7xxx: cannot malloc softc!\n");
44134389 kfree(name);
44144390 return NULL;
44154391 }
4416
-#else
4417
- ahc = device_get_softc((device_t)platform_arg);
4418
-#endif
4419
- memset(ahc, 0, sizeof(*ahc));
4392
+
44204393 ahc->seep_config = kmalloc(sizeof(*ahc->seep_config), GFP_ATOMIC);
44214394 if (ahc->seep_config == NULL) {
4422
-#ifndef __FreeBSD__
44234395 kfree(ahc);
4424
-#endif
44254396 kfree(name);
44264397 return (NULL);
44274398 }
....@@ -4481,8 +4452,7 @@
44814452 void
44824453 ahc_set_name(struct ahc_softc *ahc, char *name)
44834454 {
4484
- if (ahc->name != NULL)
4485
- kfree(ahc->name);
4455
+ kfree(ahc->name);
44864456 ahc->name = name;
44874457 }
44884458
....@@ -4495,31 +4465,25 @@
44954465 default:
44964466 case 5:
44974467 ahc_shutdown(ahc);
4498
- /* FALLTHROUGH */
4468
+ fallthrough;
44994469 case 4:
45004470 ahc_dmamap_unload(ahc, ahc->shared_data_dmat,
45014471 ahc->shared_data_dmamap);
4502
- /* FALLTHROUGH */
4472
+ fallthrough;
45034473 case 3:
45044474 ahc_dmamem_free(ahc, ahc->shared_data_dmat, ahc->qoutfifo,
45054475 ahc->shared_data_dmamap);
45064476 ahc_dmamap_destroy(ahc, ahc->shared_data_dmat,
45074477 ahc->shared_data_dmamap);
4508
- /* FALLTHROUGH */
4478
+ fallthrough;
45094479 case 2:
45104480 ahc_dma_tag_destroy(ahc, ahc->shared_data_dmat);
45114481 case 1:
4512
-#ifndef __linux__
4513
- ahc_dma_tag_destroy(ahc, ahc->buffer_dmat);
4514
-#endif
45154482 break;
45164483 case 0:
45174484 break;
45184485 }
45194486
4520
-#ifndef __linux__
4521
- ahc_dma_tag_destroy(ahc, ahc->parent_dmat);
4522
-#endif
45234487 ahc_platform_free(ahc);
45244488 ahc_fini_scbdata(ahc);
45254489 for (i = 0; i < AHC_NUM_TARGETS; i++) {
....@@ -4549,13 +4513,9 @@
45494513 kfree(ahc->black_hole);
45504514 }
45514515 #endif
4552
- if (ahc->name != NULL)
4553
- kfree(ahc->name);
4554
- if (ahc->seep_config != NULL)
4555
- kfree(ahc->seep_config);
4556
-#ifndef __FreeBSD__
4516
+ kfree(ahc->name);
4517
+ kfree(ahc->seep_config);
45574518 kfree(ahc);
4558
-#endif
45594519 return;
45604520 }
45614521
....@@ -4933,32 +4893,37 @@
49334893 }
49344894 ahc_dma_tag_destroy(ahc, scb_data->sg_dmat);
49354895 }
4896
+ fallthrough;
49364897 case 6:
49374898 ahc_dmamap_unload(ahc, scb_data->sense_dmat,
49384899 scb_data->sense_dmamap);
4900
+ fallthrough;
49394901 case 5:
49404902 ahc_dmamem_free(ahc, scb_data->sense_dmat, scb_data->sense,
49414903 scb_data->sense_dmamap);
49424904 ahc_dmamap_destroy(ahc, scb_data->sense_dmat,
49434905 scb_data->sense_dmamap);
4906
+ fallthrough;
49444907 case 4:
49454908 ahc_dma_tag_destroy(ahc, scb_data->sense_dmat);
4909
+ fallthrough;
49464910 case 3:
49474911 ahc_dmamap_unload(ahc, scb_data->hscb_dmat,
49484912 scb_data->hscb_dmamap);
4913
+ fallthrough;
49494914 case 2:
49504915 ahc_dmamem_free(ahc, scb_data->hscb_dmat, scb_data->hscbs,
49514916 scb_data->hscb_dmamap);
49524917 ahc_dmamap_destroy(ahc, scb_data->hscb_dmat,
49534918 scb_data->hscb_dmamap);
4919
+ fallthrough;
49544920 case 1:
49554921 ahc_dma_tag_destroy(ahc, scb_data->hscb_dmat);
49564922 break;
49574923 case 0:
49584924 break;
49594925 }
4960
- if (scb_data->scbarray != NULL)
4961
- kfree(scb_data->scbarray);
4926
+ kfree(scb_data->scbarray);
49624927 }
49634928
49644929 static void
....@@ -5005,9 +4970,7 @@
50054970 newcount = min(newcount, (AHC_SCB_MAX_ALLOC - scb_data->numscbs));
50064971 for (i = 0; i < newcount; i++) {
50074972 struct scb_platform_data *pdata;
5008
-#ifndef __linux__
5009
- int error;
5010
-#endif
4973
+
50114974 pdata = kmalloc(sizeof(*pdata), GFP_ATOMIC);
50124975 if (pdata == NULL)
50134976 break;
....@@ -5021,12 +4984,6 @@
50214984 next_scb->sg_list_phys = physaddr + sizeof(struct ahc_dma_seg);
50224985 next_scb->ahc_softc = ahc;
50234986 next_scb->flags = SCB_FREE;
5024
-#ifndef __linux__
5025
- error = ahc_dmamap_create(ahc, ahc->buffer_dmat, /*flags*/0,
5026
- &next_scb->dmamap);
5027
- if (error != 0)
5028
- break;
5029
-#endif
50304987 next_scb->hscb = &scb_data->hscbs[scb_data->numscbs];
50314988 next_scb->hscb->tag = ahc->scb_data->numscbs;
50324989 SLIST_INSERT_HEAD(&ahc->scb_data->free_scbs,
....@@ -5324,24 +5281,6 @@
53245281 */
53255282 if ((AHC_TMODE_ENABLE & (0x1 << ahc->unit)) == 0)
53265283 ahc->features &= ~AHC_TARGETMODE;
5327
-
5328
-#ifndef __linux__
5329
- /* DMA tag for mapping buffers into device visible space. */
5330
- if (ahc_dma_tag_create(ahc, ahc->parent_dmat, /*alignment*/1,
5331
- /*boundary*/BUS_SPACE_MAXADDR_32BIT + 1,
5332
- /*lowaddr*/ahc->flags & AHC_39BIT_ADDRESSING
5333
- ? (dma_addr_t)0x7FFFFFFFFFULL
5334
- : BUS_SPACE_MAXADDR_32BIT,
5335
- /*highaddr*/BUS_SPACE_MAXADDR,
5336
- /*filter*/NULL, /*filterarg*/NULL,
5337
- /*maxsize*/(AHC_NSEG - 1) * PAGE_SIZE,
5338
- /*nsegments*/AHC_NSEG,
5339
- /*maxsegsz*/AHC_MAXTRANSFER_SIZE,
5340
- /*flags*/BUS_DMA_ALLOCNOW,
5341
- &ahc->buffer_dmat) != 0) {
5342
- return (ENOMEM);
5343
- }
5344
-#endif
53455284
53465285 ahc->init_level++;
53475286
....@@ -6041,8 +5980,8 @@
60415980 if ((scb->flags & SCB_ACTIVE) == 0)
60425981 printk("Inactive SCB in Waiting List\n");
60435982 ahc_done(ahc, scb);
6044
- /* FALLTHROUGH */
60455983 }
5984
+ fallthrough;
60465985 case SEARCH_REMOVE:
60475986 next = ahc_rem_wscb(ahc, next, prev);
60485987 break;
....@@ -6940,10 +6879,9 @@
69406879 if (cs_count != 0) {
69416880
69426881 cs_count *= sizeof(struct cs);
6943
- ahc->critical_sections = kmalloc(cs_count, GFP_ATOMIC);
6882
+ ahc->critical_sections = kmemdup(cs_table, cs_count, GFP_ATOMIC);
69446883 if (ahc->critical_sections == NULL)
69456884 panic("ahc_loadseq: Could not malloc");
6946
- memcpy(ahc->critical_sections, cs_table, cs_count);
69476885 }
69486886 ahc_outb(ahc, SEQCTL, PERRORDIS|FAILDIS|FASTMODE);
69496887
....@@ -7047,8 +6985,8 @@
70476985 }
70486986 address -= address_offset;
70496987 fmt3_ins->address = address;
7050
- /* FALLTHROUGH */
70516988 }
6989
+ fallthrough;
70526990 case AIC_OP_OR:
70536991 case AIC_OP_AND:
70546992 case AIC_OP_XOR:
....@@ -7074,7 +7012,7 @@
70747012 fmt1_ins->opcode = AIC_OP_AND;
70757013 fmt1_ins->immediate = 0xff;
70767014 }
7077
- /* FALLTHROUGH */
7015
+ fallthrough;
70787016 case AIC_OP_ROL:
70797017 if ((ahc->features & AHC_ULTRA2) != 0) {
70807018 int i, count;