hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/scsi/megaraid.c
....@@ -1,13 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 *
34 * Linux MegaRAID device driver
45 *
56 * Copyright (c) 2002 LSI Logic Corporation.
6
- *
7
- * This program is free software; you can redistribute it and/or
8
- * modify it under the terms of the GNU General Public License
9
- * as published by the Free Software Foundation; either version
10
- * 2 of the License, or (at your option) any later version.
117 *
128 * Copyright (c) 2002 Red Hat, Inc. All rights reserved.
139 * - fixes
....@@ -28,7 +24,6 @@
2824 * This driver is supported by LSI Logic, with assistance from Red Hat, Dell,
2925 * and others. Please send updates to the mailing list
3026 * linux-scsi@vger.kernel.org .
31
- *
3227 */
3328
3429 #include <linux/mm.h>
....@@ -129,7 +124,7 @@
129124
130125 /**
131126 * mega_setup_mailbox()
132
- * @adapter - pointer to our soft state
127
+ * @adapter: pointer to our soft state
133128 *
134129 * Allocates a 8 byte aligned memory for the handshake mailbox.
135130 */
....@@ -138,8 +133,10 @@
138133 {
139134 unsigned long align;
140135
141
- adapter->una_mbox64 = pci_alloc_consistent(adapter->dev,
142
- sizeof(mbox64_t), &adapter->una_mbox64_dma);
136
+ adapter->una_mbox64 = dma_alloc_coherent(&adapter->dev->dev,
137
+ sizeof(mbox64_t),
138
+ &adapter->una_mbox64_dma,
139
+ GFP_KERNEL);
143140
144141 if( !adapter->una_mbox64 ) return -1;
145142
....@@ -227,8 +224,9 @@
227224 mraid_inquiry *inq;
228225 dma_addr_t dma_handle;
229226
230
- ext_inq = pci_alloc_consistent(adapter->dev,
231
- sizeof(mraid_ext_inquiry), &dma_handle);
227
+ ext_inq = dma_alloc_coherent(&adapter->dev->dev,
228
+ sizeof(mraid_ext_inquiry),
229
+ &dma_handle, GFP_KERNEL);
232230
233231 if( ext_inq == NULL ) return -1;
234232
....@@ -248,8 +246,9 @@
248246 mega_8_to_40ld(inq, inquiry3,
249247 (mega_product_info *)&adapter->product_info);
250248
251
- pci_free_consistent(adapter->dev, sizeof(mraid_ext_inquiry),
252
- ext_inq, dma_handle);
249
+ dma_free_coherent(&adapter->dev->dev,
250
+ sizeof(mraid_ext_inquiry), ext_inq,
251
+ dma_handle);
253252
254253 } else { /*adapter supports 40ld */
255254 adapter->flag |= BOARD_40LD;
....@@ -258,9 +257,10 @@
258257 * get product_info, which is static information and will be
259258 * unchanged
260259 */
261
- prod_info_dma_handle = pci_map_single(adapter->dev, (void *)
262
- &adapter->product_info,
263
- sizeof(mega_product_info), PCI_DMA_FROMDEVICE);
260
+ prod_info_dma_handle = dma_map_single(&adapter->dev->dev,
261
+ (void *)&adapter->product_info,
262
+ sizeof(mega_product_info),
263
+ DMA_FROM_DEVICE);
264264
265265 mbox->m_out.xferaddr = prod_info_dma_handle;
266266
....@@ -272,8 +272,8 @@
272272 "Product_info cmd failed with error: %d\n",
273273 retval);
274274
275
- pci_unmap_single(adapter->dev, prod_info_dma_handle,
276
- sizeof(mega_product_info), PCI_DMA_FROMDEVICE);
275
+ dma_unmap_single(&adapter->dev->dev, prod_info_dma_handle,
276
+ sizeof(mega_product_info), DMA_FROM_DEVICE);
277277 }
278278
279279
....@@ -352,7 +352,7 @@
352352
353353 /**
354354 * mega_runpendq()
355
- * @adapter - pointer to our soft state
355
+ * @adapter: pointer to our soft state
356356 *
357357 * Runs through the list of pending requests.
358358 */
....@@ -418,8 +418,8 @@
418418
419419 /**
420420 * mega_allocate_scb()
421
- * @adapter - pointer to our soft state
422
- * @cmd - scsi command from the mid-layer
421
+ * @adapter: pointer to our soft state
422
+ * @cmd: scsi command from the mid-layer
423423 *
424424 * Allocate a SCB structure. This is the central structure for controller
425425 * commands.
....@@ -449,9 +449,9 @@
449449
450450 /**
451451 * mega_get_ldrv_num()
452
- * @adapter - pointer to our soft state
453
- * @cmd - scsi mid layer command
454
- * @channel - channel on the controller
452
+ * @adapter: pointer to our soft state
453
+ * @cmd: scsi mid layer command
454
+ * @channel: channel on the controller
455455 *
456456 * Calculate the logical drive number based on the information in scsi command
457457 * and the channel number.
....@@ -496,9 +496,9 @@
496496
497497 if (adapter->support_random_del && adapter->read_ldidmap )
498498 switch (cmd->cmnd[0]) {
499
- case READ_6: /* fall through */
500
- case WRITE_6: /* fall through */
501
- case READ_10: /* fall through */
499
+ case READ_6:
500
+ case WRITE_6:
501
+ case READ_10:
502502 case WRITE_10:
503503 ldrv_num += 0x80;
504504 }
....@@ -508,9 +508,9 @@
508508
509509 /**
510510 * mega_build_cmd()
511
- * @adapter - pointer to our soft state
512
- * @cmd - Prepare using this scsi command
513
- * @busy - busy flag if no resources
511
+ * @adapter: pointer to our soft state
512
+ * @cmd: Prepare using this scsi command
513
+ * @busy: busy flag if no resources
514514 *
515515 * Prepares a command and scatter gather list for the controller. This routine
516516 * also finds out if the commands is intended for a logical drive or a
....@@ -522,7 +522,6 @@
522522 static scb_t *
523523 mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy)
524524 {
525
- mega_ext_passthru *epthru;
526525 mega_passthru *pthru;
527526 scb_t *scb;
528527 mbox_t *mbox;
....@@ -651,7 +650,7 @@
651650 scb->raw_mbox[2] = MEGA_RESERVATION_STATUS;
652651 scb->raw_mbox[3] = ldrv_num;
653652
654
- scb->dma_direction = PCI_DMA_NONE;
653
+ scb->dma_direction = DMA_NONE;
655654
656655 return scb;
657656 #else
....@@ -715,7 +714,7 @@
715714 mbox->m_out.cmd = MEGA_MBOXCMD_PASSTHRU;
716715 }
717716
718
- scb->dma_direction = PCI_DMA_FROMDEVICE;
717
+ scb->dma_direction = DMA_FROM_DEVICE;
719718
720719 pthru->numsgelements = mega_build_sglist(adapter, scb,
721720 &pthru->dataxferaddr, &pthru->dataxferlen);
....@@ -845,10 +844,10 @@
845844 * If it is a read command
846845 */
847846 if( (*cmd->cmnd & 0x0F) == 0x08 ) {
848
- scb->dma_direction = PCI_DMA_FROMDEVICE;
847
+ scb->dma_direction = DMA_FROM_DEVICE;
849848 }
850849 else {
851
- scb->dma_direction = PCI_DMA_TODEVICE;
850
+ scb->dma_direction = DMA_TO_DEVICE;
852851 }
853852
854853 /* Calculate Scatter-Gather info */
....@@ -858,7 +857,7 @@
858857 return scb;
859858
860859 #if MEGA_HAVE_CLUSTERING
861
- case RESERVE: /* Fall through */
860
+ case RESERVE:
862861 case RELEASE:
863862
864863 /*
....@@ -883,7 +882,7 @@
883882
884883 scb->raw_mbox[3] = ldrv_num;
885884
886
- scb->dma_direction = PCI_DMA_NONE;
885
+ scb->dma_direction = DMA_NONE;
887886
888887 return scb;
889888 #endif
....@@ -910,7 +909,7 @@
910909
911910 if( adapter->support_ext_cdb ) {
912911
913
- epthru = mega_prepare_extpassthru(adapter, scb, cmd,
912
+ mega_prepare_extpassthru(adapter, scb, cmd,
914913 channel, target);
915914
916915 mbox->m_out.cmd = MEGA_MBOXCMD_EXTPTHRU;
....@@ -942,11 +941,11 @@
942941
943942 /**
944943 * mega_prepare_passthru()
945
- * @adapter - pointer to our soft state
946
- * @scb - our scsi control block
947
- * @cmd - scsi command from the mid-layer
948
- * @channel - actual channel on the controller
949
- * @target - actual id on the controller.
944
+ * @adapter: pointer to our soft state
945
+ * @scb: our scsi control block
946
+ * @cmd: scsi command from the mid-layer
947
+ * @channel: actual channel on the controller
948
+ * @target: actual id on the controller.
950949 *
951950 * prepare a command for the scsi physical devices.
952951 */
....@@ -977,7 +976,7 @@
977976 memcpy(pthru->cdb, cmd->cmnd, cmd->cmd_len);
978977
979978 /* Not sure about the direction */
980
- scb->dma_direction = PCI_DMA_BIDIRECTIONAL;
979
+ scb->dma_direction = DMA_BIDIRECTIONAL;
981980
982981 /* Special Code for Handling READ_CAPA/ INQ using bounce buffers */
983982 switch (cmd->cmnd[0]) {
....@@ -993,7 +992,7 @@
993992
994993 adapter->flag |= (1L << cmd->device->channel);
995994 }
996
- /* Fall through */
995
+ fallthrough;
997996 default:
998997 pthru->numsgelements = mega_build_sglist(adapter, scb,
999998 &pthru->dataxferaddr, &pthru->dataxferlen);
....@@ -1005,11 +1004,11 @@
10051004
10061005 /**
10071006 * mega_prepare_extpassthru()
1008
- * @adapter - pointer to our soft state
1009
- * @scb - our scsi control block
1010
- * @cmd - scsi command from the mid-layer
1011
- * @channel - actual channel on the controller
1012
- * @target - actual id on the controller.
1007
+ * @adapter: pointer to our soft state
1008
+ * @scb: our scsi control block
1009
+ * @cmd: scsi command from the mid-layer
1010
+ * @channel: actual channel on the controller
1011
+ * @target: actual id on the controller.
10131012 *
10141013 * prepare a command for the scsi physical devices. This rountine prepares
10151014 * commands for devices which can take extended CDBs (>10 bytes)
....@@ -1041,7 +1040,7 @@
10411040 memcpy(epthru->cdb, cmd->cmnd, cmd->cmd_len);
10421041
10431042 /* Not sure about the direction */
1044
- scb->dma_direction = PCI_DMA_BIDIRECTIONAL;
1043
+ scb->dma_direction = DMA_BIDIRECTIONAL;
10451044
10461045 switch(cmd->cmnd[0]) {
10471046 case INQUIRY:
....@@ -1056,7 +1055,7 @@
10561055
10571056 adapter->flag |= (1L << cmd->device->channel);
10581057 }
1059
- /* Fall through */
1058
+ fallthrough;
10601059 default:
10611060 epthru->numsgelements = mega_build_sglist(adapter, scb,
10621061 &epthru->dataxferaddr, &epthru->dataxferlen);
....@@ -1090,8 +1089,8 @@
10901089
10911090 /**
10921091 * issue_scb()
1093
- * @adapter - pointer to our soft state
1094
- * @scb - scsi control block
1092
+ * @adapter: pointer to our soft state
1093
+ * @scb: scsi control block
10951094 *
10961095 * Post a command to the card if the mailbox is available, otherwise return
10971096 * busy. We also take the scb from the pending list if the mailbox is
....@@ -1171,8 +1170,8 @@
11711170
11721171 /**
11731172 * issue_scb_block()
1174
- * @adapter - pointer to our soft state
1175
- * @raw_mbox - the mailbox
1173
+ * @adapter: pointer to our soft state
1174
+ * @raw_mbox: the mailbox
11761175 *
11771176 * Issue a scb in synchronous and non-interrupt mode
11781177 */
....@@ -1252,8 +1251,8 @@
12521251
12531252 /**
12541253 * megaraid_isr_iomapped()
1255
- * @irq - irq
1256
- * @devp - pointer to our soft state
1254
+ * @irq: irq
1255
+ * @devp: pointer to our soft state
12571256 *
12581257 * Interrupt service routine for io-mapped controllers.
12591258 * Find out if our device is interrupting. If yes, acknowledge the interrupt
....@@ -1328,8 +1327,8 @@
13281327
13291328 /**
13301329 * megaraid_isr_memmapped()
1331
- * @irq - irq
1332
- * @devp - pointer to our soft state
1330
+ * @irq: irq
1331
+ * @devp: pointer to our soft state
13331332 *
13341333 * Interrupt service routine for memory-mapped controllers.
13351334 * Find out if our device is interrupting. If yes, acknowledge the interrupt
....@@ -1406,10 +1405,10 @@
14061405 }
14071406 /**
14081407 * mega_cmd_done()
1409
- * @adapter - pointer to our soft state
1410
- * @completed - array of ids of completed commands
1411
- * @nstatus - number of completed commands
1412
- * @status - status of the last command completed
1408
+ * @adapter: pointer to our soft state
1409
+ * @completed: array of ids of completed commands
1410
+ * @nstatus: number of completed commands
1411
+ * @status: status of the last command completed
14131412 *
14141413 * Complete the commands and call the scsi mid-layer callback hooks.
14151414 */
....@@ -1444,6 +1443,7 @@
14441443 */
14451444 if (cmdid == CMDID_INT_CMDS) {
14461445 scb = &adapter->int_scb;
1446
+ cmd = scb->cmd;
14471447
14481448 list_del_init(&scb->list);
14491449 scb->state = SCB_FREE;
....@@ -1819,25 +1819,25 @@
18191819 scb = &adapter->scb_list[i];
18201820
18211821 if( scb->sgl64 ) {
1822
- pci_free_consistent(adapter->dev,
1823
- sizeof(mega_sgl64) * adapter->sglen,
1824
- scb->sgl64,
1825
- scb->sgl_dma_addr);
1822
+ dma_free_coherent(&adapter->dev->dev,
1823
+ sizeof(mega_sgl64) * adapter->sglen,
1824
+ scb->sgl64, scb->sgl_dma_addr);
18261825
18271826 scb->sgl64 = NULL;
18281827 }
18291828
18301829 if( scb->pthru ) {
1831
- pci_free_consistent(adapter->dev, sizeof(mega_passthru),
1832
- scb->pthru, scb->pthru_dma_addr);
1830
+ dma_free_coherent(&adapter->dev->dev,
1831
+ sizeof(mega_passthru), scb->pthru,
1832
+ scb->pthru_dma_addr);
18331833
18341834 scb->pthru = NULL;
18351835 }
18361836
18371837 if( scb->epthru ) {
1838
- pci_free_consistent(adapter->dev,
1839
- sizeof(mega_ext_passthru),
1840
- scb->epthru, scb->epthru_dma_addr);
1838
+ dma_free_coherent(&adapter->dev->dev,
1839
+ sizeof(mega_ext_passthru),
1840
+ scb->epthru, scb->epthru_dma_addr);
18411841
18421842 scb->epthru = NULL;
18431843 }
....@@ -1926,9 +1926,9 @@
19261926
19271927 /**
19281928 * megaraid_abort_and_reset()
1929
- * @adapter - megaraid soft state
1930
- * @cmd - scsi command to be aborted or reset
1931
- * @aor - abort or reset flag
1929
+ * @adapter: megaraid soft state
1930
+ * @cmd: scsi command to be aborted or reset
1931
+ * @aor: abort or reset flag
19321932 *
19331933 * Try to locate the scsi command in the pending queue. If found and is not
19341934 * issued to the controller, abort/reset it. Otherwise return failure
....@@ -2010,7 +2010,7 @@
20102010
20112011 memcpy(*pdev, adapter->dev, sizeof(struct pci_dev));
20122012
2013
- if( pci_set_dma_mask(*pdev, DMA_BIT_MASK(32)) != 0 ) {
2013
+ if (dma_set_mask(&(*pdev)->dev, DMA_BIT_MASK(32)) != 0) {
20142014 kfree(*pdev);
20152015 return -1;
20162016 }
....@@ -2026,22 +2026,24 @@
20262026
20272027 /**
20282028 * mega_allocate_inquiry()
2029
- * @dma_handle - handle returned for dma address
2030
- * @pdev - handle to pci device
2029
+ * @dma_handle: handle returned for dma address
2030
+ * @pdev: handle to pci device
20312031 *
20322032 * allocates memory for inquiry structure
20332033 */
20342034 static inline void *
20352035 mega_allocate_inquiry(dma_addr_t *dma_handle, struct pci_dev *pdev)
20362036 {
2037
- return pci_alloc_consistent(pdev, sizeof(mega_inquiry3), dma_handle);
2037
+ return dma_alloc_coherent(&pdev->dev, sizeof(mega_inquiry3),
2038
+ dma_handle, GFP_KERNEL);
20382039 }
20392040
20402041
20412042 static inline void
20422043 mega_free_inquiry(void *inquiry, dma_addr_t dma_handle, struct pci_dev *pdev)
20432044 {
2044
- pci_free_consistent(pdev, sizeof(mega_inquiry3), inquiry, dma_handle);
2045
+ dma_free_coherent(&pdev->dev, sizeof(mega_inquiry3), inquiry,
2046
+ dma_handle);
20452047 }
20462048
20472049
....@@ -2050,8 +2052,8 @@
20502052
20512053 /**
20522054 * proc_show_config()
2053
- * @m - Synthetic file construction data
2054
- * @v - File iterator
2055
+ * @m: Synthetic file construction data
2056
+ * @v: File iterator
20552057 *
20562058 * Display configuration information about the controller.
20572059 */
....@@ -2114,8 +2116,8 @@
21142116
21152117 /**
21162118 * proc_show_stat()
2117
- * @m - Synthetic file construction data
2118
- * @v - File iterator
2119
+ * @m: Synthetic file construction data
2120
+ * @v: File iterator
21192121 *
21202122 * Display statistical information about the I/O activity.
21212123 */
....@@ -2148,8 +2150,8 @@
21482150
21492151 /**
21502152 * proc_show_mbox()
2151
- * @m - Synthetic file construction data
2152
- * @v - File iterator
2153
+ * @m: Synthetic file construction data
2154
+ * @v: File iterator
21532155 *
21542156 * Display mailbox information for the last command issued. This information
21552157 * is good for debugging.
....@@ -2176,8 +2178,8 @@
21762178
21772179 /**
21782180 * proc_show_rebuild_rate()
2179
- * @m - Synthetic file construction data
2180
- * @v - File iterator
2181
+ * @m: Synthetic file construction data
2182
+ * @v: File iterator
21812183 *
21822184 * Display current rebuild rate
21832185 */
....@@ -2219,8 +2221,8 @@
22192221
22202222 /**
22212223 * proc_show_battery()
2222
- * @m - Synthetic file construction data
2223
- * @v - File iterator
2224
+ * @m: Synthetic file construction data
2225
+ * @v: File iterator
22242226 *
22252227 * Display information about the battery module on the controller.
22262228 */
....@@ -2322,9 +2324,9 @@
23222324
23232325 /**
23242326 * proc_show_pdrv()
2325
- * @m - Synthetic file construction data
2326
- * @page - buffer to write the data in
2327
- * @adapter - pointer to our soft state
2327
+ * @m: Synthetic file construction data
2328
+ * @adapter: pointer to our soft state
2329
+ * @channel: channel
23282330 *
23292331 * Display information about the physical drives.
23302332 */
....@@ -2355,7 +2357,8 @@
23552357 }
23562358
23572359
2358
- scsi_inq = pci_alloc_consistent(pdev, 256, &scsi_inq_dma_handle);
2360
+ scsi_inq = dma_alloc_coherent(&pdev->dev, 256, &scsi_inq_dma_handle,
2361
+ GFP_KERNEL);
23592362 if( scsi_inq == NULL ) {
23602363 seq_puts(m, "memory not available for scsi inq.\n");
23612364 goto free_inquiry;
....@@ -2428,7 +2431,7 @@
24282431 }
24292432
24302433 free_pci:
2431
- pci_free_consistent(pdev, 256, scsi_inq, scsi_inq_dma_handle);
2434
+ dma_free_coherent(&pdev->dev, 256, scsi_inq, scsi_inq_dma_handle);
24322435 free_inquiry:
24332436 mega_free_inquiry(inquiry, dma_handle, pdev);
24342437 free_pdev:
....@@ -2438,8 +2441,8 @@
24382441
24392442 /**
24402443 * proc_show_pdrv_ch0()
2441
- * @m - Synthetic file construction data
2442
- * @v - File iterator
2444
+ * @m: Synthetic file construction data
2445
+ * @v: File iterator
24432446 *
24442447 * Display information about the physical drives on physical channel 0.
24452448 */
....@@ -2452,8 +2455,8 @@
24522455
24532456 /**
24542457 * proc_show_pdrv_ch1()
2455
- * @m - Synthetic file construction data
2456
- * @v - File iterator
2458
+ * @m: Synthetic file construction data
2459
+ * @v: File iterator
24572460 *
24582461 * Display information about the physical drives on physical channel 1.
24592462 */
....@@ -2466,8 +2469,8 @@
24662469
24672470 /**
24682471 * proc_show_pdrv_ch2()
2469
- * @m - Synthetic file construction data
2470
- * @v - File iterator
2472
+ * @m: Synthetic file construction data
2473
+ * @v: File iterator
24712474 *
24722475 * Display information about the physical drives on physical channel 2.
24732476 */
....@@ -2480,8 +2483,8 @@
24802483
24812484 /**
24822485 * proc_show_pdrv_ch3()
2483
- * @m - Synthetic file construction data
2484
- * @v - File iterator
2486
+ * @m: Synthetic file construction data
2487
+ * @v: File iterator
24852488 *
24862489 * Display information about the physical drives on physical channel 3.
24872490 */
....@@ -2494,10 +2497,10 @@
24942497
24952498 /**
24962499 * proc_show_rdrv()
2497
- * @m - Synthetic file construction data
2498
- * @adapter - pointer to our soft state
2499
- * @start - starting logical drive to display
2500
- * @end - ending logical drive to display
2500
+ * @m: Synthetic file construction data
2501
+ * @adapter: pointer to our soft state
2502
+ * @start: starting logical drive to display
2503
+ * @end: ending logical drive to display
25012504 *
25022505 * We do not print the inquiry information since its already available through
25032506 * /proc/scsi/scsi interface
....@@ -2548,8 +2551,8 @@
25482551 raid_inq.logdrv_info.num_ldrv;
25492552 }
25502553
2551
- disk_array = pci_alloc_consistent(pdev, array_sz,
2552
- &disk_array_dma_handle);
2554
+ disk_array = dma_alloc_coherent(&pdev->dev, array_sz,
2555
+ &disk_array_dma_handle, GFP_KERNEL);
25532556
25542557 if( disk_array == NULL ) {
25552558 seq_puts(m, "memory not available.\n");
....@@ -2668,8 +2671,8 @@
26682671 }
26692672
26702673 free_pci:
2671
- pci_free_consistent(pdev, array_sz, disk_array,
2672
- disk_array_dma_handle);
2674
+ dma_free_coherent(&pdev->dev, array_sz, disk_array,
2675
+ disk_array_dma_handle);
26732676 free_inquiry:
26742677 mega_free_inquiry(inquiry, dma_handle, pdev);
26752678 free_pdev:
....@@ -2679,8 +2682,8 @@
26792682
26802683 /**
26812684 * proc_show_rdrv_10()
2682
- * @m - Synthetic file construction data
2683
- * @v - File iterator
2685
+ * @m: Synthetic file construction data
2686
+ * @v: File iterator
26842687 *
26852688 * Display real time information about the logical drives 0 through 9.
26862689 */
....@@ -2693,8 +2696,8 @@
26932696
26942697 /**
26952698 * proc_show_rdrv_20()
2696
- * @m - Synthetic file construction data
2697
- * @v - File iterator
2699
+ * @m: Synthetic file construction data
2700
+ * @v: File iterator
26982701 *
26992702 * Display real time information about the logical drives 0 through 9.
27002703 */
....@@ -2707,8 +2710,8 @@
27072710
27082711 /**
27092712 * proc_show_rdrv_30()
2710
- * @m - Synthetic file construction data
2711
- * @v - File iterator
2713
+ * @m: Synthetic file construction data
2714
+ * @v: File iterator
27122715 *
27132716 * Display real time information about the logical drives 0 through 9.
27142717 */
....@@ -2721,8 +2724,8 @@
27212724
27222725 /**
27232726 * proc_show_rdrv_40()
2724
- * @m - Synthetic file construction data
2725
- * @v - File iterator
2727
+ * @m: Synthetic file construction data
2728
+ * @v: File iterator
27262729 *
27272730 * Display real time information about the logical drives 0 through 9.
27282731 */
....@@ -2734,8 +2737,8 @@
27342737
27352738 /**
27362739 * mega_create_proc_entry()
2737
- * @index - index in soft state array
2738
- * @parent - parent node for this /proc entry
2740
+ * @index: index in soft state array
2741
+ * @parent: parent node for this /proc entry
27392742 *
27402743 * Creates /proc entries for our controllers.
27412744 */
....@@ -2790,7 +2793,7 @@
27902793 #endif
27912794
27922795
2793
-/**
2796
+/*
27942797 * megaraid_biosparam()
27952798 *
27962799 * Return the disk geometry for a particular disk
....@@ -2800,11 +2803,9 @@
28002803 sector_t capacity, int geom[])
28012804 {
28022805 adapter_t *adapter;
2803
- unsigned char *bh;
28042806 int heads;
28052807 int sectors;
28062808 int cylinders;
2807
- int rval;
28082809
28092810 /* Get pointer to host config structure */
28102811 adapter = (adapter_t *)sdev->host->hostdata;
....@@ -2831,15 +2832,8 @@
28312832 geom[2] = cylinders;
28322833 }
28332834 else {
2834
- bh = scsi_bios_ptable(bdev);
2835
-
2836
- if( bh ) {
2837
- rval = scsi_partsize(bh, capacity,
2838
- &geom[2], &geom[0], &geom[1]);
2839
- kfree(bh);
2840
- if( rval != -1 )
2841
- return rval;
2842
- }
2835
+ if (scsi_partsize(bdev, capacity, geom))
2836
+ return 0;
28432837
28442838 dev_info(&adapter->dev->dev,
28452839 "invalid partition on this disk on channel %d\n",
....@@ -2868,7 +2862,7 @@
28682862
28692863 /**
28702864 * mega_init_scb()
2871
- * @adapter - pointer to our soft state
2865
+ * @adapter: pointer to our soft state
28722866 *
28732867 * Allocate memory for the various pointers in the scb structures:
28742868 * scatter-gather list pointer, passthru and extended passthru structure
....@@ -2896,9 +2890,9 @@
28962890
28972891 scb->idx = i;
28982892
2899
- scb->sgl64 = pci_alloc_consistent(adapter->dev,
2900
- sizeof(mega_sgl64) * adapter->sglen,
2901
- &scb->sgl_dma_addr);
2893
+ scb->sgl64 = dma_alloc_coherent(&adapter->dev->dev,
2894
+ sizeof(mega_sgl64) * adapter->sglen,
2895
+ &scb->sgl_dma_addr, GFP_KERNEL);
29022896
29032897 scb->sgl = (mega_sglist *)scb->sgl64;
29042898
....@@ -2908,9 +2902,9 @@
29082902 return -1;
29092903 }
29102904
2911
- scb->pthru = pci_alloc_consistent(adapter->dev,
2912
- sizeof(mega_passthru),
2913
- &scb->pthru_dma_addr);
2905
+ scb->pthru = dma_alloc_coherent(&adapter->dev->dev,
2906
+ sizeof(mega_passthru),
2907
+ &scb->pthru_dma_addr, GFP_KERNEL);
29142908
29152909 if( !scb->pthru ) {
29162910 dev_warn(&adapter->dev->dev, "RAID: Can't allocate passthru\n");
....@@ -2918,9 +2912,9 @@
29182912 return -1;
29192913 }
29202914
2921
- scb->epthru = pci_alloc_consistent(adapter->dev,
2922
- sizeof(mega_ext_passthru),
2923
- &scb->epthru_dma_addr);
2915
+ scb->epthru = dma_alloc_coherent(&adapter->dev->dev,
2916
+ sizeof(mega_ext_passthru),
2917
+ &scb->epthru_dma_addr, GFP_KERNEL);
29242918
29252919 if( !scb->epthru ) {
29262920 dev_warn(&adapter->dev->dev,
....@@ -2948,8 +2942,8 @@
29482942
29492943 /**
29502944 * megadev_open()
2951
- * @inode - unused
2952
- * @filep - unused
2945
+ * @inode: unused
2946
+ * @filep: unused
29532947 *
29542948 * Routines for the character/ioctl interface to the driver. Find out if this
29552949 * is a valid open.
....@@ -2968,10 +2962,9 @@
29682962
29692963 /**
29702964 * megadev_ioctl()
2971
- * @inode - Our device inode
2972
- * @filep - unused
2973
- * @cmd - ioctl command
2974
- * @arg - user buffer
2965
+ * @filep: Our device file
2966
+ * @cmd: ioctl command
2967
+ * @arg: user buffer
29752968 *
29762969 * ioctl entry point for our private ioctl interface. We move the data in from
29772970 * the user space, prepare the command (if necessary, convert the old MIMD
....@@ -2991,13 +2984,12 @@
29912984 void *data = NULL; /* data to be transferred */
29922985 dma_addr_t data_dma_hndl; /* dma handle for data xfer area */
29932986 megacmd_t mc;
2994
- megastat_t __user *ustats;
2995
- int num_ldrv;
2987
+#if MEGA_HAVE_STATS
2988
+ megastat_t __user *ustats = NULL;
2989
+ int num_ldrv = 0;
2990
+#endif
29962991 u32 uxferaddr = 0;
29972992 struct pci_dev *pdev;
2998
-
2999
- ustats = NULL; /* avoid compilation warnings */
3000
- num_ldrv = 0;
30012993
30022994 /*
30032995 * Make sure only USCSICMD are issued through this interface.
....@@ -3162,9 +3154,9 @@
31623154 if( uioc.uioc_rmbox[0] == MEGA_MBOXCMD_PASSTHRU ) {
31633155 /* Passthru commands */
31643156
3165
- pthru = pci_alloc_consistent(pdev,
3166
- sizeof(mega_passthru),
3167
- &pthru_dma_hndl);
3157
+ pthru = dma_alloc_coherent(&pdev->dev,
3158
+ sizeof(mega_passthru),
3159
+ &pthru_dma_hndl, GFP_KERNEL);
31683160
31693161 if( pthru == NULL ) {
31703162 free_local_pdev(pdev);
....@@ -3182,9 +3174,9 @@
31823174 if( copy_from_user(pthru, upthru,
31833175 sizeof(mega_passthru)) ) {
31843176
3185
- pci_free_consistent(pdev,
3186
- sizeof(mega_passthru), pthru,
3187
- pthru_dma_hndl);
3177
+ dma_free_coherent(&pdev->dev,
3178
+ sizeof(mega_passthru),
3179
+ pthru, pthru_dma_hndl);
31883180
31893181 free_local_pdev(pdev);
31903182
....@@ -3195,15 +3187,16 @@
31953187 * Is there a data transfer
31963188 */
31973189 if( pthru->dataxferlen ) {
3198
- data = pci_alloc_consistent(pdev,
3199
- pthru->dataxferlen,
3200
- &data_dma_hndl);
3190
+ data = dma_alloc_coherent(&pdev->dev,
3191
+ pthru->dataxferlen,
3192
+ &data_dma_hndl,
3193
+ GFP_KERNEL);
32013194
32023195 if( data == NULL ) {
3203
- pci_free_consistent(pdev,
3204
- sizeof(mega_passthru),
3205
- pthru,
3206
- pthru_dma_hndl);
3196
+ dma_free_coherent(&pdev->dev,
3197
+ sizeof(mega_passthru),
3198
+ pthru,
3199
+ pthru_dma_hndl);
32073200
32083201 free_local_pdev(pdev);
32093202
....@@ -3268,13 +3261,13 @@
32683261
32693262 freemem_and_return:
32703263 if( pthru->dataxferlen ) {
3271
- pci_free_consistent(pdev,
3272
- pthru->dataxferlen, data,
3273
- data_dma_hndl);
3264
+ dma_free_coherent(&pdev->dev,
3265
+ pthru->dataxferlen, data,
3266
+ data_dma_hndl);
32743267 }
32753268
3276
- pci_free_consistent(pdev, sizeof(mega_passthru),
3277
- pthru, pthru_dma_hndl);
3269
+ dma_free_coherent(&pdev->dev, sizeof(mega_passthru),
3270
+ pthru, pthru_dma_hndl);
32783271
32793272 free_local_pdev(pdev);
32803273
....@@ -3287,8 +3280,10 @@
32873280 * Is there a data transfer
32883281 */
32893282 if( uioc.xferlen ) {
3290
- data = pci_alloc_consistent(pdev,
3291
- uioc.xferlen, &data_dma_hndl);
3283
+ data = dma_alloc_coherent(&pdev->dev,
3284
+ uioc.xferlen,
3285
+ &data_dma_hndl,
3286
+ GFP_KERNEL);
32923287
32933288 if( data == NULL ) {
32943289 free_local_pdev(pdev);
....@@ -3308,9 +3303,9 @@
33083303 if( copy_from_user(data, (char __user *)(unsigned long) uxferaddr,
33093304 uioc.xferlen) ) {
33103305
3311
- pci_free_consistent(pdev,
3312
- uioc.xferlen,
3313
- data, data_dma_hndl);
3306
+ dma_free_coherent(&pdev->dev,
3307
+ uioc.xferlen, data,
3308
+ data_dma_hndl);
33143309
33153310 free_local_pdev(pdev);
33163311
....@@ -3331,9 +3326,9 @@
33313326
33323327 if( rval ) {
33333328 if( uioc.xferlen ) {
3334
- pci_free_consistent(pdev,
3335
- uioc.xferlen, data,
3336
- data_dma_hndl);
3329
+ dma_free_coherent(&pdev->dev,
3330
+ uioc.xferlen, data,
3331
+ data_dma_hndl);
33373332 }
33383333
33393334 free_local_pdev(pdev);
....@@ -3353,9 +3348,8 @@
33533348 }
33543349
33553350 if( uioc.xferlen ) {
3356
- pci_free_consistent(pdev,
3357
- uioc.xferlen, data,
3358
- data_dma_hndl);
3351
+ dma_free_coherent(&pdev->dev, uioc.xferlen,
3352
+ data, data_dma_hndl);
33593353 }
33603354
33613355 free_local_pdev(pdev);
....@@ -3384,8 +3378,8 @@
33843378
33853379 /**
33863380 * mega_m_to_n()
3387
- * @arg - user address
3388
- * @uioc - new ioctl structure
3381
+ * @arg: user address
3382
+ * @uioc: new ioctl structure
33893383 *
33903384 * A thin layer to convert older mimd interface ioctl structure to NIT ioctl
33913385 * structure
....@@ -3512,8 +3506,8 @@
35123506
35133507 /*
35143508 * mega_n_to_m()
3515
- * @arg - user address
3516
- * @mc - mailbox command
3509
+ * @arg: user address
3510
+ * @mc: mailbox command
35173511 *
35183512 * Updates the status information to the application, depending on application
35193513 * conforms to older mimd ioctl interface or newer NIT ioctl interface
....@@ -3579,7 +3573,7 @@
35793573
35803574 /**
35813575 * mega_is_bios_enabled()
3582
- * @adapter - pointer to our soft state
3576
+ * @adapter: pointer to our soft state
35833577 *
35843578 * issue command to find out if the BIOS is enabled for this controller
35853579 */
....@@ -3588,7 +3582,6 @@
35883582 {
35893583 unsigned char raw_mbox[sizeof(struct mbox_out)];
35903584 mbox_t *mbox;
3591
- int ret;
35923585
35933586 mbox = (mbox_t *)raw_mbox;
35943587
....@@ -3601,8 +3594,7 @@
36013594 raw_mbox[0] = IS_BIOS_ENABLED;
36023595 raw_mbox[2] = GET_BIOS;
36033596
3604
-
3605
- ret = issue_scb_block(adapter, raw_mbox);
3597
+ issue_scb_block(adapter, raw_mbox);
36063598
36073599 return *(char *)adapter->mega_buffer;
36083600 }
....@@ -3610,7 +3602,7 @@
36103602
36113603 /**
36123604 * mega_enum_raid_scsi()
3613
- * @adapter - pointer to our soft state
3605
+ * @adapter: pointer to our soft state
36143606 *
36153607 * Find out what channels are RAID/SCSI. This information is used to
36163608 * differentiate the virtual channels and physical channels and to support
....@@ -3665,7 +3657,7 @@
36653657
36663658 /**
36673659 * mega_get_boot_drv()
3668
- * @adapter - pointer to our soft state
3660
+ * @adapter: pointer to our soft state
36693661 *
36703662 * Find out which device is the boot device. Note, any logical drive or any
36713663 * phyical device (e.g., a CDROM) can be designated as a boot device.
....@@ -3732,7 +3724,7 @@
37323724
37333725 /**
37343726 * mega_support_random_del()
3735
- * @adapter - pointer to our soft state
3727
+ * @adapter: pointer to our soft state
37363728 *
37373729 * Find out if this controller supports random deletion and addition of
37383730 * logical drives
....@@ -3762,7 +3754,7 @@
37623754
37633755 /**
37643756 * mega_support_ext_cdb()
3765
- * @adapter - pointer to our soft state
3757
+ * @adapter: pointer to our soft state
37663758 *
37673759 * Find out if this firmware support cdblen > 10
37683760 */
....@@ -3790,8 +3782,8 @@
37903782
37913783 /**
37923784 * mega_del_logdrv()
3793
- * @adapter - pointer to our soft state
3794
- * @logdrv - logical drive to be deleted
3785
+ * @adapter: pointer to our soft state
3786
+ * @logdrv: logical drive to be deleted
37953787 *
37963788 * Delete the specified logical drive. It is the responsibility of the user
37973789 * app to let the OS know about this operation.
....@@ -3876,7 +3868,7 @@
38763868
38773869 /**
38783870 * mega_get_max_sgl()
3879
- * @adapter - pointer to our soft state
3871
+ * @adapter: pointer to our soft state
38803872 *
38813873 * Find out the maximum number of scatter-gather elements supported by this
38823874 * version of the firmware
....@@ -3922,7 +3914,7 @@
39223914
39233915 /**
39243916 * mega_support_cluster()
3925
- * @adapter - pointer to our soft state
3917
+ * @adapter: pointer to our soft state
39263918 *
39273919 * Find out if this firmware support cluster calls.
39283920 */
....@@ -3964,8 +3956,8 @@
39643956 #ifdef CONFIG_PROC_FS
39653957 /**
39663958 * mega_adapinq()
3967
- * @adapter - pointer to our soft state
3968
- * @dma_handle - DMA address of the buffer
3959
+ * @adapter: pointer to our soft state
3960
+ * @dma_handle: DMA address of the buffer
39693961 *
39703962 * Issue internal commands while interrupts are available.
39713963 * We only issue direct mailbox commands from within the driver. ioctl()
....@@ -3997,11 +3989,12 @@
39973989 }
39983990
39993991
4000
-/** mega_internal_dev_inquiry()
4001
- * @adapter - pointer to our soft state
4002
- * @ch - channel for this device
4003
- * @tgt - ID of this device
4004
- * @buf_dma_handle - DMA address of the buffer
3992
+/**
3993
+ * mega_internal_dev_inquiry()
3994
+ * @adapter: pointer to our soft state
3995
+ * @ch: channel for this device
3996
+ * @tgt: ID of this device
3997
+ * @buf_dma_handle: DMA address of the buffer
40053998 *
40063999 * Issue the scsi inquiry for the specified device.
40074000 */
....@@ -4022,8 +4015,8 @@
40224015 */
40234016 if( make_local_pdev(adapter, &pdev) != 0 ) return -1;
40244017
4025
- pthru = pci_alloc_consistent(pdev, sizeof(mega_passthru),
4026
- &pthru_dma_handle);
4018
+ pthru = dma_alloc_coherent(&pdev->dev, sizeof(mega_passthru),
4019
+ &pthru_dma_handle, GFP_KERNEL);
40274020
40284021 if( pthru == NULL ) {
40294022 free_local_pdev(pdev);
....@@ -4059,8 +4052,8 @@
40594052
40604053 rval = mega_internal_command(adapter, &mc, pthru);
40614054
4062
- pci_free_consistent(pdev, sizeof(mega_passthru), pthru,
4063
- pthru_dma_handle);
4055
+ dma_free_coherent(&pdev->dev, sizeof(mega_passthru), pthru,
4056
+ pthru_dma_handle);
40644057
40654058 free_local_pdev(pdev);
40664059
....@@ -4070,9 +4063,9 @@
40704063
40714064 /**
40724065 * mega_internal_command()
4073
- * @adapter - pointer to our soft state
4074
- * @mc - the mailbox command
4075
- * @pthru - Passthru structure for DCDB commands
4066
+ * @adapter: pointer to our soft state
4067
+ * @mc: the mailbox command
4068
+ * @pthru: Passthru structure for DCDB commands
40764069 *
40774070 * Issue the internal commands in interrupt mode.
40784071 * The last argument is the address of the passthru structure if the command
....@@ -4148,7 +4141,6 @@
41484141 .this_id = DEFAULT_INITIATOR_ID,
41494142 .sg_tablesize = MAX_SGLIST,
41504143 .cmd_per_lun = DEF_CMD_PER_LUN,
4151
- .use_clustering = ENABLE_CLUSTERING,
41524144 .eh_abort_handler = megaraid_abort,
41534145 .eh_device_reset_handler = megaraid_reset,
41544146 .eh_bus_reset_handler = megaraid_reset,
....@@ -4286,8 +4278,10 @@
42864278 /*
42874279 * Allocate buffer to issue internal commands.
42884280 */
4289
- adapter->mega_buffer = pci_alloc_consistent(adapter->dev,
4290
- MEGA_BUFFER_SIZE, &adapter->buf_dma_handle);
4281
+ adapter->mega_buffer = dma_alloc_coherent(&adapter->dev->dev,
4282
+ MEGA_BUFFER_SIZE,
4283
+ &adapter->buf_dma_handle,
4284
+ GFP_KERNEL);
42914285 if (!adapter->mega_buffer) {
42924286 dev_warn(&pdev->dev, "out of RAM\n");
42934287 goto out_host_put;
....@@ -4446,10 +4440,10 @@
44464440
44474441 /* Set the Mode of addressing to 64 bit if we can */
44484442 if ((adapter->flag & BOARD_64BIT) && (sizeof(dma_addr_t) == 8)) {
4449
- pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
4443
+ dma_set_mask(&pdev->dev, DMA_BIT_MASK(64));
44504444 adapter->has_64bit_addr = 1;
44514445 } else {
4452
- pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
4446
+ dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
44534447 adapter->has_64bit_addr = 0;
44544448 }
44554449
....@@ -4488,15 +4482,15 @@
44884482 return 0;
44894483
44904484 out_free_mbox:
4491
- pci_free_consistent(adapter->dev, sizeof(mbox64_t),
4492
- adapter->una_mbox64, adapter->una_mbox64_dma);
4485
+ dma_free_coherent(&adapter->dev->dev, sizeof(mbox64_t),
4486
+ adapter->una_mbox64, adapter->una_mbox64_dma);
44934487 out_free_irq:
44944488 free_irq(adapter->host->irq, adapter);
44954489 out_free_scb_list:
44964490 kfree(adapter->scb_list);
44974491 out_free_cmd_buffer:
4498
- pci_free_consistent(adapter->dev, MEGA_BUFFER_SIZE,
4499
- adapter->mega_buffer, adapter->buf_dma_handle);
4492
+ dma_free_coherent(&adapter->dev->dev, MEGA_BUFFER_SIZE,
4493
+ adapter->mega_buffer, adapter->buf_dma_handle);
45004494 out_host_put:
45014495 scsi_host_put(host);
45024496 out_iounmap:
....@@ -4570,11 +4564,11 @@
45704564 sprintf(buf, "hba%d", adapter->host->host_no);
45714565 remove_proc_subtree(buf, mega_proc_dir_entry);
45724566
4573
- pci_free_consistent(adapter->dev, MEGA_BUFFER_SIZE,
4574
- adapter->mega_buffer, adapter->buf_dma_handle);
4567
+ dma_free_coherent(&adapter->dev->dev, MEGA_BUFFER_SIZE,
4568
+ adapter->mega_buffer, adapter->buf_dma_handle);
45754569 kfree(adapter->scb_list);
4576
- pci_free_consistent(adapter->dev, sizeof(mbox64_t),
4577
- adapter->una_mbox64, adapter->una_mbox64_dma);
4570
+ dma_free_coherent(&adapter->dev->dev, sizeof(mbox64_t),
4571
+ adapter->una_mbox64, adapter->una_mbox64_dma);
45784572
45794573 scsi_host_put(host);
45804574 pci_disable_device(pdev);
....@@ -4641,7 +4635,7 @@
46414635 * major number allocation.
46424636 */
46434637 major = register_chrdev(0, "megadev_legacy", &megadev_fops);
4644
- if (!major) {
4638
+ if (major < 0) {
46454639 printk(KERN_WARNING
46464640 "megaraid: failed to register char device\n");
46474641 }