scsi: arcmsr: Spin off duplicate code
authorChing Huang <ching2048@areca.com.tw>
Tue, 5 Dec 2017 02:11:23 +0000 (10:11 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 7 Dec 2017 00:32:41 +0000 (19:32 -0500)
Spin off duplicate code of timer init for message isr BH in arcmsr_probe
and arcmsr_resume as a function arcmsr_init_get_devmap_timer.

Signed-off-by: Ching Huang <ching2048@areca.com.tw>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/arcmsr/arcmsr_hba.c

index c63d6757fee551a1bec1400ef52ac265bb5bf990..05fc77640df741ba75f8fbcc3172b29d6d5f018f 100644 (file)
@@ -857,6 +857,17 @@ out_free_irq:
        return FAILED;
 }
 
+static void arcmsr_init_get_devmap_timer(struct AdapterControlBlock *pacb)
+{
+       INIT_WORK(&pacb->arcmsr_do_message_isr_bh, arcmsr_message_isr_bh_fn);
+       atomic_set(&pacb->rq_map_token, 16);
+       atomic_set(&pacb->ante_token_value, 16);
+       pacb->fw_flag = FW_NORMAL;
+       timer_setup(&pacb->eternal_timer, arcmsr_request_device_map, 0);
+       pacb->eternal_timer.expires = jiffies + msecs_to_jiffies(6 * HZ);
+       add_timer(&pacb->eternal_timer);
+}
+
 static void arcmsr_init_set_datetime_timer(struct AdapterControlBlock *pacb)
 {
        timer_setup(&pacb->refresh_timer, arcmsr_set_iop_datetime, 0);
@@ -946,13 +957,7 @@ static int arcmsr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        if (arcmsr_request_irq(pdev, acb) == FAILED)
                goto scsi_host_remove;
        arcmsr_iop_init(acb);
-       INIT_WORK(&acb->arcmsr_do_message_isr_bh, arcmsr_message_isr_bh_fn);
-       atomic_set(&acb->rq_map_token, 16);
-       atomic_set(&acb->ante_token_value, 16);
-       acb->fw_flag = FW_NORMAL;
-       timer_setup(&acb->eternal_timer, arcmsr_request_device_map, 0);
-       acb->eternal_timer.expires = jiffies + msecs_to_jiffies(6 * HZ);
-       add_timer(&acb->eternal_timer);
+       arcmsr_init_get_devmap_timer(acb);
        if (set_date_time)
                arcmsr_init_set_datetime_timer(acb);
        if(arcmsr_alloc_sysfs_attr(acb))
@@ -1043,13 +1048,7 @@ static int arcmsr_resume(struct pci_dev *pdev)
        if (arcmsr_request_irq(pdev, acb) == FAILED)
                goto controller_stop;
        arcmsr_iop_init(acb);
-       INIT_WORK(&acb->arcmsr_do_message_isr_bh, arcmsr_message_isr_bh_fn);
-       atomic_set(&acb->rq_map_token, 16);
-       atomic_set(&acb->ante_token_value, 16);
-       acb->fw_flag = FW_NORMAL;
-       timer_setup(&acb->eternal_timer, arcmsr_request_device_map, 0);
-       acb->eternal_timer.expires = jiffies + msecs_to_jiffies(6 * HZ);
-       add_timer(&acb->eternal_timer);
+       arcmsr_init_get_devmap_timer(acb);
        if (set_date_time)
                arcmsr_init_set_datetime_timer(acb);
        return 0;