isci: audit usage of BUG_ON macro in isci driver
authorBartosz Barcinski <Bartosz.Barcinski@intel.com>
Wed, 13 Apr 2011 00:28:43 +0000 (17:28 -0700)
committerDan Williams <dan.j.williams@intel.com>
Sun, 3 Jul 2011 11:00:37 +0000 (04:00 -0700)
Removes unnecessary usage of BUG_ON macro, excluding core directory.
In some cases macro is unnecesary, check is done in caller function.
In other cases macro is replaced by if construction with
appropriate warning.

Signed-off-by: Maciej Patelczyk <maciej.patelczyk@intel.com>
[changed some survivable bug conditions to WARN_ONCE]
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/scsi/isci/core/scic_sds_request.c
drivers/scsi/isci/init.c
drivers/scsi/isci/port.c
drivers/scsi/isci/remote_device.c
drivers/scsi/isci/request.c
drivers/scsi/isci/request.h
drivers/scsi/isci/task.c

index 64aa9c60836f70f9d4dda022bda016c0415e42dc..a6ee155c6825233418a715f0f9b0b38b5e488e29 100644 (file)
@@ -1635,7 +1635,6 @@ static void scic_sds_request_completed_state_enter(
        struct isci_host *ihost = sci_object_get_association(scic);
        struct isci_request *ireq = sci_object_get_association(sci_req);
 
-
        SET_STATE_HANDLER(sci_req,
                          scic_sds_request_state_handler_table,
                          SCI_BASE_REQUEST_STATE_COMPLETED);
index 5e63ae6a75d115f9a9816a3ee960471ecee421b7..5da9a6925cd7c2b2c932c7c92d55e8034d54437d 100644 (file)
@@ -362,8 +362,6 @@ static int isci_setup_interrupts(struct pci_dev *pdev)
                else
                        isr = isci_msix_isr;
 
-               BUG_ON(!isci_host);
-
                err = devm_request_irq(&pdev->dev, msix->vector, isr, 0,
                                       DRV_NAME"-msix", isci_host);
                if (!err)
@@ -379,13 +377,11 @@ static int isci_setup_interrupts(struct pci_dev *pdev)
                pci_disable_msix(pdev);
                goto intx;
        }
-
        return 0;
 
  intx:
        err = devm_request_irq(&pdev->dev, pdev->irq, isci_intx_isr,
                               IRQF_SHARED, DRV_NAME"-intx", pdev);
-
        return err;
 }
 
index b675a94f4a73b391475a0cd8e797eb3e6eeea1b0..cf78cf0a6749ea7d5d6a150754de8b979d11760f 100644 (file)
@@ -178,6 +178,7 @@ void isci_port_link_up(
        unsigned long success = true;
 
        BUG_ON(isci_phy->isci_port != NULL);
+
        isci_phy->isci_port = isci_port;
 
        dev_dbg(&isci_host->pdev->dev,
index 320850cf46f2fb7885b1d266089c992570443eb9..9301e25dff31adc39505b055467287c30637bc42 100644 (file)
@@ -202,8 +202,6 @@ static enum sci_status isci_remote_device_construct(
 
        sci_object_set_association(to_sci_dev(isci_device), isci_device);
 
-       BUG_ON(port->isci_host == NULL);
-
        /* start the device. */
        status = scic_remote_device_start(to_sci_dev(isci_device),
                                          ISCI_REMOTE_DEVICE_START_TIMEOUT);
@@ -257,8 +255,12 @@ isci_remote_device_alloc(struct isci_host *ihost, struct isci_port *iport)
                return NULL;
        }
 
-       BUG_ON(!list_empty(&idev->reqs_in_process));
-       BUG_ON(!list_empty(&idev->node));
+       if (WARN_ONCE(!list_empty(&idev->reqs_in_process), "found requests in process\n"))
+               return NULL;
+
+       if (WARN_ONCE(!list_empty(&idev->node), "found non-idle remote device\n"))
+               return NULL;
+
        isci_remote_device_change_state(idev, isci_freed);
 
        return idev;
index 37ffedc94ac02107c7989407c61891a9f8a46c1f..a90c299b723a0c1703b3f21739a353aefbafc917 100644 (file)
@@ -472,7 +472,6 @@ int isci_request_execute(
 
  out:
        if (status != SCI_SUCCESS) {
-
                /* release dma memory on failure. */
                isci_request_free(isci_host, request);
                request = NULL;
index 0c08da6bcd8a9c4995b7a07fc0c89250e72de2e5..642b21166fc620d1138e7c9676a109163abf0e69 100644 (file)
@@ -193,8 +193,6 @@ static inline enum isci_request_status isci_request_change_started_to_newstate(
        enum isci_request_status old_state;
        unsigned long flags;
 
-       BUG_ON(isci_request == NULL);
-
        spin_lock_irqsave(&isci_request->state_lock, flags);
 
        old_state = isci_request->status;
@@ -243,7 +241,8 @@ static inline void isci_request_free(
        struct isci_host *isci_host,
        struct isci_request *isci_request)
 {
-       BUG_ON(isci_request == NULL);
+       if (!isci_request)
+               return;
 
        /* release the dma memory if we fail. */
        dma_pool_free(isci_host->dma_pool, isci_request,
index b88101e195d17bad6dd80f66619f0b74abdd18f1..c79968db871cc7a687fef1804817eed1747e2153 100644 (file)
@@ -272,7 +272,7 @@ static enum sci_status isci_task_request_build(
 {
        struct scic_sds_remote_device *sci_device;
        enum sci_status status = SCI_FAILURE;
-       struct isci_request *request;
+       struct isci_request *request = NULL;
        struct isci_remote_device *isci_device;
 /*     struct sci_sas_identify_address_frame_protocols dev_protocols; */
        struct smp_discover_response_protocols dev_protocols;
@@ -372,8 +372,6 @@ static void isci_tmf_timeout_cb(void *tmf_request_arg)
        struct isci_tmf *tmf = isci_request_access_tmf(request);
        enum sci_status status;
 
-       BUG_ON(request->ttype != tmf_task);
-
        /* This task management request has timed-out.  Terminate the request
         * so that the request eventually completes to the requestor in the
         * request completion callback path.
@@ -1121,8 +1119,11 @@ static void isci_abort_task_process_cb(
                 * request state was already set to "aborted" by the abort
                 * task function.
                 */
-               BUG_ON((old_request->status != aborted)
-                       && (old_request->status != completed));
+               if ((old_request->status != aborted)
+                       && (old_request->status != completed))
+                       dev_err(&old_request->isci_host->pdev->dev,
+                               "%s: Bad request status (%d): tmf=%p, old_request=%p\n",
+                               __func__, old_request->status, tmf, old_request);
                break;
 
        case isci_tmf_timed_out: