From patchwork Tue Dec 12 10:53:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ching Huang X-Patchwork-Id: 10106631 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 860CE6032B for ; Tue, 12 Dec 2017 10:53:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8690E29B7D for ; Tue, 12 Dec 2017 10:53:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7ABEF29B80; Tue, 12 Dec 2017 10:53:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C823729B7D for ; Tue, 12 Dec 2017 10:53:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751585AbdLLKxj (ORCPT ); Tue, 12 Dec 2017 05:53:39 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:42788 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751507AbdLLKxi (ORCPT ); Tue, 12 Dec 2017 05:53:38 -0500 Received: by mail-pf0-f193.google.com with SMTP id d23so13910255pfe.9 for ; Tue, 12 Dec 2017 02:53:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=areca-com-tw.20150623.gappssmtp.com; s=20150623; h=subject:from:to:cc:date:message-id:mime-version :content-transfer-encoding; bh=o9CHGqD1kPGtFBfoz2OVq2U/zPOu6zeMshXjQiC/z8I=; b=c3M1oVVZxleLDa23M9QZb2zvKbZbLwd+MBPTEjUJN28ZM+ACSPxHbDqdWZftSMWhso 2M9og/PNtUknAdCegUT5fmDgcMMxQ+JV7AdXpvP9vn/VevQRlPaDwd7GVYZ8EN0NP8Nv PCICJWNtTLTt74rjChmioVhvabFFneMhwL2LGEhMNdCiJyQej9HBHmXmDZQJn+k5IuMI 75f/M4WPKToyUmZvNett/dracIUEbIfTLPOy0aXRx+w8ptW4Ug4iQkgmnrjLRLv3nByf HAV8RvAgusZHnI20rhq0KlbuorNvBHUQg9lwVKGAGPA07CUwmTpQ+ypfducwRCQVZKHo uvXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:date:message-id:mime-version :content-transfer-encoding; bh=o9CHGqD1kPGtFBfoz2OVq2U/zPOu6zeMshXjQiC/z8I=; b=V4rL6OaARf6vUNzKIMgqUEXvkI2sB9jSOnmQ9KYtmeUDRFOklHZzFZQscElfIaEGnR eZUxMKmgPWjx7+mRmksZVDIuo63r3E2pOVmiK85/JJ1R9Tq5iWtFXZDVPSnb+qiSt948 M4VAkoHZJHzlx12nNF9UHZlKcMCb7XsxNzZrGPfcHfXOsPjpEB/Ar0E/TNcdW+QwbOv2 BXYZzHy2wte6vZ8TZBwp44g6NxRJ5E5pPB4AL7QL4mlIRc7BMrOpPWrZ8AUuxXJkcDNp FdmnhLr8wKwJFsUnHnQaekIus27yixKPk44Nmckiu19y2mzFAzZdZn9ECuKBx3Euk5ma 1dPw== X-Gm-Message-State: AKGB3mJAznKybK6SM/d3MaYud5TX1uXshYZ9feq0IpbSyptMH9G0AfI8 KzspWVCWVvByo6coy7SItjRP2Q== X-Google-Smtp-Source: ACJfBouXfvLVc4uAE8cM8Ig31w7mw7PCkr565i1VgVnJ4cve/8ZPdhaXgJv+EIJZqgBoxaivKvP8qA== X-Received: by 10.159.218.146 with SMTP id w18mr1809596plp.57.1513076017719; Tue, 12 Dec 2017 02:53:37 -0800 (PST) Received: from [192.168.0.110] (60-248-88-209.HINET-IP.hinet.net. [60.248.88.209]) by smtp.gmail.com with ESMTPSA id l21sm31340485pgc.76.2017.12.12.02.53.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Dec 2017 02:53:36 -0800 (PST) Subject: [PATCH 4/4] scsi: arcmsr: simplify all arcmsr_hbaX_get_config routine by call a new get_adapter_config function From: Ching Huang To: martin.petersen@oracle.com, James.Bottomley@HansenPartnership.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: dan.carpenter@oracle.com, hch@infradead.org, colin.king@canonical.com Date: Tue, 12 Dec 2017 18:53:33 +0800 Message-ID: <1513076013.5249.27.camel@Centos6.3-64> Mime-Version: 1.0 X-Mailer: Evolution 2.32.3 (2.32.3-37.el6) Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ching Huang simplify all arcmsr_hbaX_get_config routine by call a new get_adapter_config function Signed-off-by: Ching Huang diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c index b7a56e8..95c9f08 100755 --- a/drivers/scsi/arcmsr/arcmsr_hba.c +++ b/drivers/scsi/arcmsr/arcmsr_hba.c @@ -2956,75 +2956,66 @@ static int arcmsr_queue_command_lck(struct scsi_cmnd *cmd, static DEF_SCSI_QCMD(arcmsr_queue_command) -static bool arcmsr_hbaA_get_config(struct AdapterControlBlock *acb) +static void arcmsr_get_adapter_config(struct AdapterControlBlock *pACB, uint32_t *rwbuffer) { - struct MessageUnit_A __iomem *reg = acb->pmuA; - char *acb_firm_model = acb->firm_model; - char *acb_firm_version = acb->firm_version; - char *acb_device_map = acb->device_map; - char __iomem *iop_firm_model = (char __iomem *)(®->message_rwbuffer[15]); - char __iomem *iop_firm_version = (char __iomem *)(®->message_rwbuffer[17]); - char __iomem *iop_device_map = (char __iomem *)(®->message_rwbuffer[21]); int count; - arcmsr_wait_firmware_ready(acb); - writel(ARCMSR_INBOUND_MESG0_GET_CONFIG, ®->inbound_msgaddr0); - if (!arcmsr_hbaA_wait_msgint_ready(acb)) { - printk(KERN_NOTICE "arcmsr%d: wait 'get adapter firmware \ - miscellaneous data' timeout \n", acb->host->host_no); - return false; - } - count = 8; - while (count){ - *acb_firm_model = readb(iop_firm_model); + uint32_t *acb_firm_model = (uint32_t *)pACB->firm_model; + uint32_t *acb_firm_version = (uint32_t *)pACB->firm_version; + uint32_t *acb_device_map = (uint32_t *)pACB->device_map; + uint32_t *firm_model = &rwbuffer[15]; + uint32_t *firm_version = &rwbuffer[17]; + uint32_t *device_map = &rwbuffer[21]; + + count = 2; + while (count) { + *acb_firm_model = readl(firm_model); acb_firm_model++; - iop_firm_model++; + firm_model++; count--; } - - count = 16; - while (count){ - *acb_firm_version = readb(iop_firm_version); + count = 4; + while (count) { + *acb_firm_version = readl(firm_version); acb_firm_version++; - iop_firm_version++; + firm_version++; count--; } - - count=16; - while(count){ - *acb_device_map = readb(iop_device_map); + count = 4; + while (count) { + *acb_device_map = readl(device_map); acb_device_map++; - iop_device_map++; + device_map++; count--; } + pACB->signature = readl(&rwbuffer[0]); + pACB->firm_request_len = readl(&rwbuffer[1]); + pACB->firm_numbers_queue = readl(&rwbuffer[2]); + pACB->firm_sdram_size = readl(&rwbuffer[3]); + pACB->firm_hd_channels = readl(&rwbuffer[4]); + pACB->firm_cfg_version = readl(&rwbuffer[25]); pr_notice("Areca RAID Controller%d: Model %s, F/W %s\n", - acb->host->host_no, - acb->firm_model, - acb->firm_version); - acb->signature = readl(®->message_rwbuffer[0]); - acb->firm_request_len = readl(®->message_rwbuffer[1]); - acb->firm_numbers_queue = readl(®->message_rwbuffer[2]); - acb->firm_sdram_size = readl(®->message_rwbuffer[3]); - acb->firm_hd_channels = readl(®->message_rwbuffer[4]); - acb->firm_cfg_version = readl(®->message_rwbuffer[25]); /*firm_cfg_version,25,100-103*/ + pACB->host->host_no, + pACB->firm_model, + pACB->firm_version); +} + +static bool arcmsr_hbaA_get_config(struct AdapterControlBlock *acb) +{ + struct MessageUnit_A __iomem *reg = acb->pmuA; + + arcmsr_wait_firmware_ready(acb); + writel(ARCMSR_INBOUND_MESG0_GET_CONFIG, ®->inbound_msgaddr0); + if (!arcmsr_hbaA_wait_msgint_ready(acb)) { + printk(KERN_NOTICE "arcmsr%d: wait 'get adapter firmware \ + miscellaneous data' timeout \n", acb->host->host_no); + return false; + } + arcmsr_get_adapter_config(acb, reg->message_rwbuffer); return true; } static bool arcmsr_hbaB_get_config(struct AdapterControlBlock *acb) { struct MessageUnit_B *reg = acb->pmuB; - char *acb_firm_model = acb->firm_model; - char *acb_firm_version = acb->firm_version; - char *acb_device_map = acb->device_map; - char __iomem *iop_firm_model; - /*firm_model,15,60-67*/ - char __iomem *iop_firm_version; - /*firm_version,17,68-83*/ - char __iomem *iop_device_map; - /*firm_version,21,84-99*/ - int count; - - iop_firm_model = (char __iomem *)(®->message_rwbuffer[15]); /*firm_model,15,60-67*/ - iop_firm_version = (char __iomem *)(®->message_rwbuffer[17]); /*firm_version,17,68-83*/ - iop_device_map = (char __iomem *)(®->message_rwbuffer[21]); /*firm_version,21,84-99*/ arcmsr_wait_firmware_ready(acb); writel(ARCMSR_MESSAGE_START_DRIVER_MODE, reg->drv2iop_doorbell); @@ -3038,46 +3029,7 @@ static bool arcmsr_hbaB_get_config(struct AdapterControlBlock *acb) miscellaneous data' timeout \n", acb->host->host_no); return false; } - count = 8; - while (count){ - *acb_firm_model = readb(iop_firm_model); - acb_firm_model++; - iop_firm_model++; - count--; - } - count = 16; - while (count){ - *acb_firm_version = readb(iop_firm_version); - acb_firm_version++; - iop_firm_version++; - count--; - } - - count = 16; - while(count){ - *acb_device_map = readb(iop_device_map); - acb_device_map++; - iop_device_map++; - count--; - } - - pr_notice("Areca RAID Controller%d: Model %s, F/W %s\n", - acb->host->host_no, - acb->firm_model, - acb->firm_version); - - acb->signature = readl(®->message_rwbuffer[0]); - /*firm_signature,1,00-03*/ - acb->firm_request_len = readl(®->message_rwbuffer[1]); - /*firm_request_len,1,04-07*/ - acb->firm_numbers_queue = readl(®->message_rwbuffer[2]); - /*firm_numbers_queue,2,08-11*/ - acb->firm_sdram_size = readl(®->message_rwbuffer[3]); - /*firm_sdram_size,3,12-15*/ - acb->firm_hd_channels = readl(®->message_rwbuffer[4]); - /*firm_ide_channels,4,16-19*/ - acb->firm_cfg_version = readl(®->message_rwbuffer[25]); /*firm_cfg_version,25,100-103*/ - /*firm_ide_channels,4,16-19*/ + arcmsr_get_adapter_config(acb, reg->message_rwbuffer); return true; } @@ -3085,11 +3037,7 @@ static bool arcmsr_hbaC_get_config(struct AdapterControlBlock *pACB) { uint32_t intmask_org; struct MessageUnit_C __iomem *reg = pACB->pmuC; - char *acb_firm_model = pACB->firm_model; - char *acb_firm_version = pACB->firm_version; - char __iomem *iop_firm_model = (char __iomem *)(®->msgcode_rwbuffer[15]); /*firm_model,15,60-67*/ - char __iomem *iop_firm_version = (char __iomem *)(®->msgcode_rwbuffer[17]); /*firm_version,17,68-83*/ - int count; + /* disable all outbound interrupt */ intmask_org = readl(®->host_int_mask); /* disable outbound message0 int */ writel(intmask_org|ARCMSR_HBCMU_ALL_INTMASKENABLE, ®->host_int_mask); @@ -3104,47 +3052,14 @@ static bool arcmsr_hbaC_get_config(struct AdapterControlBlock *pACB) miscellaneous data' timeout \n", pACB->host->host_no); return false; } - count = 8; - while (count) { - *acb_firm_model = readb(iop_firm_model); - acb_firm_model++; - iop_firm_model++; - count--; - } - count = 16; - while (count) { - *acb_firm_version = readb(iop_firm_version); - acb_firm_version++; - iop_firm_version++; - count--; - } - pr_notice("Areca RAID Controller%d: Model %s, F/W %s\n", - pACB->host->host_no, - pACB->firm_model, - pACB->firm_version); - pACB->firm_request_len = readl(®->msgcode_rwbuffer[1]); /*firm_request_len,1,04-07*/ - pACB->firm_numbers_queue = readl(®->msgcode_rwbuffer[2]); /*firm_numbers_queue,2,08-11*/ - pACB->firm_sdram_size = readl(®->msgcode_rwbuffer[3]); /*firm_sdram_size,3,12-15*/ - pACB->firm_hd_channels = readl(®->msgcode_rwbuffer[4]); /*firm_ide_channels,4,16-19*/ - pACB->firm_cfg_version = readl(®->msgcode_rwbuffer[25]); /*firm_cfg_version,25,100-103*/ - /*all interrupt service will be enable at arcmsr_iop_init*/ + arcmsr_get_adapter_config(pACB, reg->msgcode_rwbuffer); return true; } static bool arcmsr_hbaD_get_config(struct AdapterControlBlock *acb) { - char *acb_firm_model = acb->firm_model; - char *acb_firm_version = acb->firm_version; - char *acb_device_map = acb->device_map; - char __iomem *iop_firm_model; - char __iomem *iop_firm_version; - char __iomem *iop_device_map; - u32 count; struct MessageUnit_D *reg = acb->pmuD; - iop_firm_model = (char __iomem *)(®->msgcode_rwbuffer[15]); - iop_firm_version = (char __iomem *)(®->msgcode_rwbuffer[17]); - iop_device_map = (char __iomem *)(®->msgcode_rwbuffer[21]); if (readl(acb->pmuD->outbound_doorbell) & ARCMSR_ARC1214_IOP2DRV_MESSAGE_CMD_DONE) { writel(ARCMSR_ARC1214_IOP2DRV_MESSAGE_CMD_DONE, @@ -3159,54 +3074,14 @@ static bool arcmsr_hbaD_get_config(struct AdapterControlBlock *acb) "miscellaneous data timeout\n", acb->host->host_no); return false; } - count = 8; - while (count) { - *acb_firm_model = readb(iop_firm_model); - acb_firm_model++; - iop_firm_model++; - count--; - } - count = 16; - while (count) { - *acb_firm_version = readb(iop_firm_version); - acb_firm_version++; - iop_firm_version++; - count--; - } - count = 16; - while (count) { - *acb_device_map = readb(iop_device_map); - acb_device_map++; - iop_device_map++; - count--; - } - acb->signature = readl(®->msgcode_rwbuffer[0]); - /*firm_signature,1,00-03*/ - acb->firm_request_len = readl(®->msgcode_rwbuffer[1]); - /*firm_request_len,1,04-07*/ - acb->firm_numbers_queue = readl(®->msgcode_rwbuffer[2]); - /*firm_numbers_queue,2,08-11*/ - acb->firm_sdram_size = readl(®->msgcode_rwbuffer[3]); - /*firm_sdram_size,3,12-15*/ - acb->firm_hd_channels = readl(®->msgcode_rwbuffer[4]); - /*firm_hd_channels,4,16-19*/ - acb->firm_cfg_version = readl(®->msgcode_rwbuffer[25]); - pr_notice("Areca RAID Controller%d: Model %s, F/W %s\n", - acb->host->host_no, - acb->firm_model, - acb->firm_version); + arcmsr_get_adapter_config(acb, reg->msgcode_rwbuffer); return true; } static bool arcmsr_hbaE_get_config(struct AdapterControlBlock *pACB) { - char *acb_firm_model = pACB->firm_model; - char *acb_firm_version = pACB->firm_version; struct MessageUnit_E __iomem *reg = pACB->pmuE; - char __iomem *iop_firm_model = (char __iomem *)(®->msgcode_rwbuffer[15]); - char __iomem *iop_firm_version = (char __iomem *)(®->msgcode_rwbuffer[17]); uint32_t intmask_org; - int count; /* disable all outbound interrupt */ intmask_org = readl(®->host_int_mask); /* disable outbound message0 int */ @@ -3225,29 +3100,7 @@ static bool arcmsr_hbaE_get_config(struct AdapterControlBlock *pACB) "miscellaneous data timeout\n", pACB->host->host_no); return false; } - count = 8; - while (count) { - *acb_firm_model = readb(iop_firm_model); - acb_firm_model++; - iop_firm_model++; - count--; - } - count = 16; - while (count) { - *acb_firm_version = readb(iop_firm_version); - acb_firm_version++; - iop_firm_version++; - count--; - } - pACB->firm_request_len = readl(®->msgcode_rwbuffer[1]); - pACB->firm_numbers_queue = readl(®->msgcode_rwbuffer[2]); - pACB->firm_sdram_size = readl(®->msgcode_rwbuffer[3]); - pACB->firm_hd_channels = readl(®->msgcode_rwbuffer[4]); - pACB->firm_cfg_version = readl(®->msgcode_rwbuffer[25]); - pr_notice("Areca RAID Controller%d: Model %s, F/W %s\n", - pACB->host->host_no, - pACB->firm_model, - pACB->firm_version); + arcmsr_get_adapter_config(pACB, reg->msgcode_rwbuffer); return true; }