| .. | .. |
|---|
| 40 | 40 | * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.c#155 $ |
|---|
| 41 | 41 | */ |
|---|
| 42 | 42 | |
|---|
| 43 | | -#ifdef __linux__ |
|---|
| 44 | 43 | #include "aic7xxx_osm.h" |
|---|
| 45 | 44 | #include "aic7xxx_inline.h" |
|---|
| 46 | 45 | #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 |
|---|
| 52 | 46 | |
|---|
| 53 | 47 | /***************************** Lookup Tables **********************************/ |
|---|
| 54 | 48 | static const char *const ahc_chip_names[] = { |
|---|
| .. | .. |
|---|
| 67 | 61 | "aic7892", |
|---|
| 68 | 62 | "aic7899" |
|---|
| 69 | 63 | }; |
|---|
| 70 | | -static const u_int num_chip_names = ARRAY_SIZE(ahc_chip_names); |
|---|
| 71 | 64 | |
|---|
| 72 | 65 | /* |
|---|
| 73 | 66 | * Hardware error codes. |
|---|
| .. | .. |
|---|
| 1673 | 1666 | printk("\tCRC Value Mismatch\n"); |
|---|
| 1674 | 1667 | if ((sstat2 & CRCENDERR) != 0) |
|---|
| 1675 | 1668 | printk("\tNo terminal CRC packet " |
|---|
| 1676 | | - "recevied\n"); |
|---|
| 1669 | + "received\n"); |
|---|
| 1677 | 1670 | if ((sstat2 & CRCREQERR) != 0) |
|---|
| 1678 | 1671 | printk("\tIllegal CRC packet " |
|---|
| 1679 | 1672 | "request\n"); |
|---|
| .. | .. |
|---|
| 1841 | 1834 | printerror = 0; |
|---|
| 1842 | 1835 | } else if (ahc_sent_msg(ahc, AHCMSG_1B, |
|---|
| 1843 | 1836 | 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 |
|---|
| 1859 | 1837 | ahc_compile_devinfo(&devinfo, |
|---|
| 1860 | 1838 | initiator_role_id, |
|---|
| 1861 | 1839 | target, |
|---|
| .. | .. |
|---|
| 2200 | 2178 | if (channel == 'B') |
|---|
| 2201 | 2179 | scsi_id += 8; |
|---|
| 2202 | 2180 | tstate = ahc->enabled_targets[scsi_id]; |
|---|
| 2203 | | - if (tstate != NULL) |
|---|
| 2204 | | - kfree(tstate); |
|---|
| 2181 | + kfree(tstate); |
|---|
| 2205 | 2182 | ahc->enabled_targets[scsi_id] = NULL; |
|---|
| 2206 | 2183 | } |
|---|
| 2207 | 2184 | #endif |
|---|
| .. | .. |
|---|
| 2427 | 2404 | *bus_width = MSG_EXT_WDTR_BUS_16_BIT; |
|---|
| 2428 | 2405 | break; |
|---|
| 2429 | 2406 | } |
|---|
| 2430 | | - /* FALLTHROUGH */ |
|---|
| 2407 | + fallthrough; |
|---|
| 2431 | 2408 | case MSG_EXT_WDTR_BUS_8_BIT: |
|---|
| 2432 | 2409 | *bus_width = MSG_EXT_WDTR_BUS_8_BIT; |
|---|
| 2433 | 2410 | break; |
|---|
| .. | .. |
|---|
| 3622 | 3599 | break; |
|---|
| 3623 | 3600 | case MSG_MESSAGE_REJECT: |
|---|
| 3624 | 3601 | response = ahc_handle_msg_reject(ahc, devinfo); |
|---|
| 3625 | | - /* FALLTHROUGH */ |
|---|
| 3602 | + fallthrough; |
|---|
| 3626 | 3603 | case MSG_NOOP: |
|---|
| 3627 | 3604 | done = MSGLOOP_MSGCOMPLETE; |
|---|
| 3628 | 3605 | break; |
|---|
| .. | .. |
|---|
| 4406 | 4383 | struct ahc_softc *ahc; |
|---|
| 4407 | 4384 | int i; |
|---|
| 4408 | 4385 | |
|---|
| 4409 | | -#ifndef __FreeBSD__ |
|---|
| 4410 | | - ahc = kmalloc(sizeof(*ahc), GFP_ATOMIC); |
|---|
| 4386 | + ahc = kzalloc(sizeof(*ahc), GFP_ATOMIC); |
|---|
| 4411 | 4387 | if (!ahc) { |
|---|
| 4412 | 4388 | printk("aic7xxx: cannot malloc softc!\n"); |
|---|
| 4413 | 4389 | kfree(name); |
|---|
| 4414 | 4390 | return NULL; |
|---|
| 4415 | 4391 | } |
|---|
| 4416 | | -#else |
|---|
| 4417 | | - ahc = device_get_softc((device_t)platform_arg); |
|---|
| 4418 | | -#endif |
|---|
| 4419 | | - memset(ahc, 0, sizeof(*ahc)); |
|---|
| 4392 | + |
|---|
| 4420 | 4393 | ahc->seep_config = kmalloc(sizeof(*ahc->seep_config), GFP_ATOMIC); |
|---|
| 4421 | 4394 | if (ahc->seep_config == NULL) { |
|---|
| 4422 | | -#ifndef __FreeBSD__ |
|---|
| 4423 | 4395 | kfree(ahc); |
|---|
| 4424 | | -#endif |
|---|
| 4425 | 4396 | kfree(name); |
|---|
| 4426 | 4397 | return (NULL); |
|---|
| 4427 | 4398 | } |
|---|
| .. | .. |
|---|
| 4481 | 4452 | void |
|---|
| 4482 | 4453 | ahc_set_name(struct ahc_softc *ahc, char *name) |
|---|
| 4483 | 4454 | { |
|---|
| 4484 | | - if (ahc->name != NULL) |
|---|
| 4485 | | - kfree(ahc->name); |
|---|
| 4455 | + kfree(ahc->name); |
|---|
| 4486 | 4456 | ahc->name = name; |
|---|
| 4487 | 4457 | } |
|---|
| 4488 | 4458 | |
|---|
| .. | .. |
|---|
| 4495 | 4465 | default: |
|---|
| 4496 | 4466 | case 5: |
|---|
| 4497 | 4467 | ahc_shutdown(ahc); |
|---|
| 4498 | | - /* FALLTHROUGH */ |
|---|
| 4468 | + fallthrough; |
|---|
| 4499 | 4469 | case 4: |
|---|
| 4500 | 4470 | ahc_dmamap_unload(ahc, ahc->shared_data_dmat, |
|---|
| 4501 | 4471 | ahc->shared_data_dmamap); |
|---|
| 4502 | | - /* FALLTHROUGH */ |
|---|
| 4472 | + fallthrough; |
|---|
| 4503 | 4473 | case 3: |
|---|
| 4504 | 4474 | ahc_dmamem_free(ahc, ahc->shared_data_dmat, ahc->qoutfifo, |
|---|
| 4505 | 4475 | ahc->shared_data_dmamap); |
|---|
| 4506 | 4476 | ahc_dmamap_destroy(ahc, ahc->shared_data_dmat, |
|---|
| 4507 | 4477 | ahc->shared_data_dmamap); |
|---|
| 4508 | | - /* FALLTHROUGH */ |
|---|
| 4478 | + fallthrough; |
|---|
| 4509 | 4479 | case 2: |
|---|
| 4510 | 4480 | ahc_dma_tag_destroy(ahc, ahc->shared_data_dmat); |
|---|
| 4511 | 4481 | case 1: |
|---|
| 4512 | | -#ifndef __linux__ |
|---|
| 4513 | | - ahc_dma_tag_destroy(ahc, ahc->buffer_dmat); |
|---|
| 4514 | | -#endif |
|---|
| 4515 | 4482 | break; |
|---|
| 4516 | 4483 | case 0: |
|---|
| 4517 | 4484 | break; |
|---|
| 4518 | 4485 | } |
|---|
| 4519 | 4486 | |
|---|
| 4520 | | -#ifndef __linux__ |
|---|
| 4521 | | - ahc_dma_tag_destroy(ahc, ahc->parent_dmat); |
|---|
| 4522 | | -#endif |
|---|
| 4523 | 4487 | ahc_platform_free(ahc); |
|---|
| 4524 | 4488 | ahc_fini_scbdata(ahc); |
|---|
| 4525 | 4489 | for (i = 0; i < AHC_NUM_TARGETS; i++) { |
|---|
| .. | .. |
|---|
| 4549 | 4513 | kfree(ahc->black_hole); |
|---|
| 4550 | 4514 | } |
|---|
| 4551 | 4515 | #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); |
|---|
| 4557 | 4518 | kfree(ahc); |
|---|
| 4558 | | -#endif |
|---|
| 4559 | 4519 | return; |
|---|
| 4560 | 4520 | } |
|---|
| 4561 | 4521 | |
|---|
| .. | .. |
|---|
| 4933 | 4893 | } |
|---|
| 4934 | 4894 | ahc_dma_tag_destroy(ahc, scb_data->sg_dmat); |
|---|
| 4935 | 4895 | } |
|---|
| 4896 | + fallthrough; |
|---|
| 4936 | 4897 | case 6: |
|---|
| 4937 | 4898 | ahc_dmamap_unload(ahc, scb_data->sense_dmat, |
|---|
| 4938 | 4899 | scb_data->sense_dmamap); |
|---|
| 4900 | + fallthrough; |
|---|
| 4939 | 4901 | case 5: |
|---|
| 4940 | 4902 | ahc_dmamem_free(ahc, scb_data->sense_dmat, scb_data->sense, |
|---|
| 4941 | 4903 | scb_data->sense_dmamap); |
|---|
| 4942 | 4904 | ahc_dmamap_destroy(ahc, scb_data->sense_dmat, |
|---|
| 4943 | 4905 | scb_data->sense_dmamap); |
|---|
| 4906 | + fallthrough; |
|---|
| 4944 | 4907 | case 4: |
|---|
| 4945 | 4908 | ahc_dma_tag_destroy(ahc, scb_data->sense_dmat); |
|---|
| 4909 | + fallthrough; |
|---|
| 4946 | 4910 | case 3: |
|---|
| 4947 | 4911 | ahc_dmamap_unload(ahc, scb_data->hscb_dmat, |
|---|
| 4948 | 4912 | scb_data->hscb_dmamap); |
|---|
| 4913 | + fallthrough; |
|---|
| 4949 | 4914 | case 2: |
|---|
| 4950 | 4915 | ahc_dmamem_free(ahc, scb_data->hscb_dmat, scb_data->hscbs, |
|---|
| 4951 | 4916 | scb_data->hscb_dmamap); |
|---|
| 4952 | 4917 | ahc_dmamap_destroy(ahc, scb_data->hscb_dmat, |
|---|
| 4953 | 4918 | scb_data->hscb_dmamap); |
|---|
| 4919 | + fallthrough; |
|---|
| 4954 | 4920 | case 1: |
|---|
| 4955 | 4921 | ahc_dma_tag_destroy(ahc, scb_data->hscb_dmat); |
|---|
| 4956 | 4922 | break; |
|---|
| 4957 | 4923 | case 0: |
|---|
| 4958 | 4924 | break; |
|---|
| 4959 | 4925 | } |
|---|
| 4960 | | - if (scb_data->scbarray != NULL) |
|---|
| 4961 | | - kfree(scb_data->scbarray); |
|---|
| 4926 | + kfree(scb_data->scbarray); |
|---|
| 4962 | 4927 | } |
|---|
| 4963 | 4928 | |
|---|
| 4964 | 4929 | static void |
|---|
| .. | .. |
|---|
| 5005 | 4970 | newcount = min(newcount, (AHC_SCB_MAX_ALLOC - scb_data->numscbs)); |
|---|
| 5006 | 4971 | for (i = 0; i < newcount; i++) { |
|---|
| 5007 | 4972 | struct scb_platform_data *pdata; |
|---|
| 5008 | | -#ifndef __linux__ |
|---|
| 5009 | | - int error; |
|---|
| 5010 | | -#endif |
|---|
| 4973 | + |
|---|
| 5011 | 4974 | pdata = kmalloc(sizeof(*pdata), GFP_ATOMIC); |
|---|
| 5012 | 4975 | if (pdata == NULL) |
|---|
| 5013 | 4976 | break; |
|---|
| .. | .. |
|---|
| 5021 | 4984 | next_scb->sg_list_phys = physaddr + sizeof(struct ahc_dma_seg); |
|---|
| 5022 | 4985 | next_scb->ahc_softc = ahc; |
|---|
| 5023 | 4986 | 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 |
|---|
| 5030 | 4987 | next_scb->hscb = &scb_data->hscbs[scb_data->numscbs]; |
|---|
| 5031 | 4988 | next_scb->hscb->tag = ahc->scb_data->numscbs; |
|---|
| 5032 | 4989 | SLIST_INSERT_HEAD(&ahc->scb_data->free_scbs, |
|---|
| .. | .. |
|---|
| 5324 | 5281 | */ |
|---|
| 5325 | 5282 | if ((AHC_TMODE_ENABLE & (0x1 << ahc->unit)) == 0) |
|---|
| 5326 | 5283 | 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 |
|---|
| 5345 | 5284 | |
|---|
| 5346 | 5285 | ahc->init_level++; |
|---|
| 5347 | 5286 | |
|---|
| .. | .. |
|---|
| 6041 | 5980 | if ((scb->flags & SCB_ACTIVE) == 0) |
|---|
| 6042 | 5981 | printk("Inactive SCB in Waiting List\n"); |
|---|
| 6043 | 5982 | ahc_done(ahc, scb); |
|---|
| 6044 | | - /* FALLTHROUGH */ |
|---|
| 6045 | 5983 | } |
|---|
| 5984 | + fallthrough; |
|---|
| 6046 | 5985 | case SEARCH_REMOVE: |
|---|
| 6047 | 5986 | next = ahc_rem_wscb(ahc, next, prev); |
|---|
| 6048 | 5987 | break; |
|---|
| .. | .. |
|---|
| 6940 | 6879 | if (cs_count != 0) { |
|---|
| 6941 | 6880 | |
|---|
| 6942 | 6881 | 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); |
|---|
| 6944 | 6883 | if (ahc->critical_sections == NULL) |
|---|
| 6945 | 6884 | panic("ahc_loadseq: Could not malloc"); |
|---|
| 6946 | | - memcpy(ahc->critical_sections, cs_table, cs_count); |
|---|
| 6947 | 6885 | } |
|---|
| 6948 | 6886 | ahc_outb(ahc, SEQCTL, PERRORDIS|FAILDIS|FASTMODE); |
|---|
| 6949 | 6887 | |
|---|
| .. | .. |
|---|
| 7047 | 6985 | } |
|---|
| 7048 | 6986 | address -= address_offset; |
|---|
| 7049 | 6987 | fmt3_ins->address = address; |
|---|
| 7050 | | - /* FALLTHROUGH */ |
|---|
| 7051 | 6988 | } |
|---|
| 6989 | + fallthrough; |
|---|
| 7052 | 6990 | case AIC_OP_OR: |
|---|
| 7053 | 6991 | case AIC_OP_AND: |
|---|
| 7054 | 6992 | case AIC_OP_XOR: |
|---|
| .. | .. |
|---|
| 7074 | 7012 | fmt1_ins->opcode = AIC_OP_AND; |
|---|
| 7075 | 7013 | fmt1_ins->immediate = 0xff; |
|---|
| 7076 | 7014 | } |
|---|
| 7077 | | - /* FALLTHROUGH */ |
|---|
| 7015 | + fallthrough; |
|---|
| 7078 | 7016 | case AIC_OP_ROL: |
|---|
| 7079 | 7017 | if ((ahc->features & AHC_ULTRA2) != 0) { |
|---|
| 7080 | 7018 | int i, count; |
|---|