From patchwork Wed Dec 13 08:33:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ching Huang X-Patchwork-Id: 10109505 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 2AF0C60327 for ; Wed, 13 Dec 2017 08:33:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D0EB29090 for ; Wed, 13 Dec 2017 08:33:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11A2D2909C; Wed, 13 Dec 2017 08:33:57 +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 82A8B29090 for ; Wed, 13 Dec 2017 08:33:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751947AbdLMIdp (ORCPT ); Wed, 13 Dec 2017 03:33:45 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:46749 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751898AbdLMIdk (ORCPT ); Wed, 13 Dec 2017 03:33:40 -0500 Received: by mail-pg0-f66.google.com with SMTP id b11so955723pgu.13 for ; Wed, 13 Dec 2017 00:33:40 -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=03B9UF76np6n2Msy6ORWLy/CjWK6UfY+LFR2GQHlDS0=; b=Yov4D7mVCzxQrH7IorPukPQZly20ZGS/WGUckbi6TuG+3iDe4Ybk6SIjOJ5hq5KScv sLdAxs1hb/Fm8ZXMz2MKt9Yus/ITGtT27t9xzm93Qhj0X2xr7tE63UUMtZtC83giY476 aYqVQHQoUNFCfQpuklDjJd/aG5z7204em1FG8R8dBAMnU6rlrUQ01g6ywn0FGIqJooTh BeWlFI7kkmcrOsKjz3ia16HZ2XGG6SMbYBZV5wATvaXX+yDxVx1rkWe4g7fXF7nZGwdN ZFPMFCS/Jj8u3RYHV275+2Z6y+6B43Z3NVf9EAQnbcKgHMCzZUakjYNhDehfMKfwTLZY /49Q== 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=03B9UF76np6n2Msy6ORWLy/CjWK6UfY+LFR2GQHlDS0=; b=ahvhE0b1nObfL+bkxXD8coPD8KNxOb9H2BZOjiE+N0OX3VHm1UOgN/Mu0M5HHC/uo5 05ylV7clTkUIEoVFxfEMPIraxJw+gnnazVmWHx/X0LXgNeUGbM1iVxSo5LXGiKSLvNd1 o9LZTzKclyE8C/CJMTF4isor0K6l7limeLc71fXXgonUGOWsSgIaiQbGtw0NMMxCaEda eG+o3BQTjKrOri5ImeqflSgXzlcgh/dXK0STt5WjCy6ZZtOJnVYW8UOknJ+fED2bqt6q qNKXG3+ccwVAZnwva5mgK30f2upSlx6dEeL9GzLO0Ps6DeSxbmW0q6+5AeawB1RuxfVn 9aaQ== X-Gm-Message-State: AKGB3mL9LLbRVN47UbsV1er86AXUkySLR78X3de0JQTJPNPx9TH8SXU7 a4mlN1+25t8zXatYC1UlHQe82T1o X-Google-Smtp-Source: ACJfBouYU0S+0mnqcT+yrAYYFRmBjJv+jD5w9b+bjJ6mlutJIDx407cs8UnfY7qcRhkCnzwOGTzndA== X-Received: by 10.98.144.88 with SMTP id a85mr5263002pfe.127.1513154019435; Wed, 13 Dec 2017 00:33:39 -0800 (PST) Received: from [192.168.0.130] (60-248-88-209.HINET-IP.hinet.net. [60.248.88.209]) by smtp.gmail.com with ESMTPSA id c191sm2304751pfg.24.2017.12.13.00.33.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Dec 2017 00:33:38 -0800 (PST) Subject: [PATCH 5/4] scsi: arcmsr: simplify arcmsr_request_device_map routine 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: Wed, 13 Dec 2017 16:33:36 +0800 Message-ID: <1513154016.8691.9.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 arcmsr_request_device_map routine Signed-off-by: Ching Huang diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c index 95c9f08..4774559 100755 --- a/drivers/scsi/arcmsr/arcmsr_hba.c +++ b/drivers/scsi/arcmsr/arcmsr_hba.c @@ -122,9 +122,6 @@ static void arcmsr_stop_adapter_bgrb(struct AdapterControlBlock *acb); static void arcmsr_hbaA_flush_cache(struct AdapterControlBlock *acb); static void arcmsr_hbaB_flush_cache(struct AdapterControlBlock *acb); static void arcmsr_request_device_map(struct timer_list *t); -static void arcmsr_hbaA_request_device_map(struct AdapterControlBlock *acb); -static void arcmsr_hbaB_request_device_map(struct AdapterControlBlock *acb); -static void arcmsr_hbaC_request_device_map(struct AdapterControlBlock *acb); static void arcmsr_message_isr_bh_fn(struct work_struct *work); static bool arcmsr_get_firmware_spec(struct AdapterControlBlock *acb); static void arcmsr_start_adapter_bgrb(struct AdapterControlBlock *acb); @@ -3789,113 +3786,12 @@ static void arcmsr_wait_firmware_ready(struct AdapterControlBlock *acb) } } -static void arcmsr_hbaA_request_device_map(struct AdapterControlBlock *acb) -{ - struct MessageUnit_A __iomem *reg = acb->pmuA; - if (unlikely(atomic_read(&acb->rq_map_token) == 0) || ((acb->acb_flags & ACB_F_BUS_RESET) != 0 ) || ((acb->acb_flags & ACB_F_ABORT) != 0 )){ - mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6 * HZ)); - return; - } else { - acb->fw_flag = FW_NORMAL; - if (atomic_read(&acb->ante_token_value) == atomic_read(&acb->rq_map_token)){ - atomic_set(&acb->rq_map_token, 16); - } - atomic_set(&acb->ante_token_value, atomic_read(&acb->rq_map_token)); - if (atomic_dec_and_test(&acb->rq_map_token)) { - mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6 * HZ)); - return; - } - writel(ARCMSR_INBOUND_MESG0_GET_CONFIG, ®->inbound_msgaddr0); - acb->acb_flags |= ACB_F_MSG_GET_CONFIG; - mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6 * HZ)); - } - return; -} - -static void arcmsr_hbaB_request_device_map(struct AdapterControlBlock *acb) -{ - struct MessageUnit_B *reg = acb->pmuB; - if (unlikely(atomic_read(&acb->rq_map_token) == 0) || ((acb->acb_flags & ACB_F_BUS_RESET) != 0 ) || ((acb->acb_flags & ACB_F_ABORT) != 0 )){ - mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6 * HZ)); - return; - } else { - acb->fw_flag = FW_NORMAL; - if (atomic_read(&acb->ante_token_value) == atomic_read(&acb->rq_map_token)) { - atomic_set(&acb->rq_map_token, 16); - } - atomic_set(&acb->ante_token_value, atomic_read(&acb->rq_map_token)); - if (atomic_dec_and_test(&acb->rq_map_token)) { - mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6 * HZ)); - return; - } - writel(ARCMSR_MESSAGE_GET_CONFIG, reg->drv2iop_doorbell); - acb->acb_flags |= ACB_F_MSG_GET_CONFIG; - mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6 * HZ)); - } - return; -} - -static void arcmsr_hbaC_request_device_map(struct AdapterControlBlock *acb) -{ - struct MessageUnit_C __iomem *reg = acb->pmuC; - if (unlikely(atomic_read(&acb->rq_map_token) == 0) || ((acb->acb_flags & ACB_F_BUS_RESET) != 0) || ((acb->acb_flags & ACB_F_ABORT) != 0)) { - mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6 * HZ)); - return; - } else { - acb->fw_flag = FW_NORMAL; - if (atomic_read(&acb->ante_token_value) == atomic_read(&acb->rq_map_token)) { - atomic_set(&acb->rq_map_token, 16); - } - atomic_set(&acb->ante_token_value, atomic_read(&acb->rq_map_token)); - if (atomic_dec_and_test(&acb->rq_map_token)) { - mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6 * HZ)); - return; - } - writel(ARCMSR_INBOUND_MESG0_GET_CONFIG, ®->inbound_msgaddr0); - writel(ARCMSR_HBCMU_DRV2IOP_MESSAGE_CMD_DONE, ®->inbound_doorbell); - acb->acb_flags |= ACB_F_MSG_GET_CONFIG; - mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6 * HZ)); - } - return; -} - -static void arcmsr_hbaD_request_device_map(struct AdapterControlBlock *acb) -{ - struct MessageUnit_D *reg = acb->pmuD; - - if (unlikely(atomic_read(&acb->rq_map_token) == 0) || - ((acb->acb_flags & ACB_F_BUS_RESET) != 0) || - ((acb->acb_flags & ACB_F_ABORT) != 0)) { - mod_timer(&acb->eternal_timer, - jiffies + msecs_to_jiffies(6 * HZ)); - } else { - acb->fw_flag = FW_NORMAL; - if (atomic_read(&acb->ante_token_value) == - atomic_read(&acb->rq_map_token)) { - atomic_set(&acb->rq_map_token, 16); - } - atomic_set(&acb->ante_token_value, - atomic_read(&acb->rq_map_token)); - if (atomic_dec_and_test(&acb->rq_map_token)) { - mod_timer(&acb->eternal_timer, jiffies + - msecs_to_jiffies(6 * HZ)); - return; - } - writel(ARCMSR_INBOUND_MESG0_GET_CONFIG, - reg->inbound_msgaddr0); - acb->acb_flags |= ACB_F_MSG_GET_CONFIG; - mod_timer(&acb->eternal_timer, jiffies + - msecs_to_jiffies(6 * HZ)); - } -} - -static void arcmsr_hbaE_request_device_map(struct AdapterControlBlock *acb) +static void arcmsr_request_device_map(struct timer_list *t) { - struct MessageUnit_E __iomem *reg = acb->pmuE; - + struct AdapterControlBlock *acb = from_timer(acb, t, eternal_timer); if (unlikely(atomic_read(&acb->rq_map_token) == 0) || - ((acb->acb_flags & ACB_F_BUS_RESET) != 0) || - ((acb->acb_flags & ACB_F_ABORT) != 0)) { + (acb->acb_flags & ACB_F_BUS_RESET) || + (acb->acb_flags & ACB_F_ABORT)) { mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6 * HZ)); } else { @@ -3911,37 +3807,40 @@ static void arcmsr_hbaE_request_device_map(struct AdapterControlBlock *acb) msecs_to_jiffies(6 * HZ)); return; } - writel(ARCMSR_INBOUND_MESG0_GET_CONFIG, ®->inbound_msgaddr0); - acb->out_doorbell ^= ARCMSR_HBEMU_DRV2IOP_MESSAGE_CMD_DONE; - writel(acb->out_doorbell, ®->iobound_doorbell); - acb->acb_flags |= ACB_F_MSG_GET_CONFIG; - mod_timer(&acb->eternal_timer, jiffies + - msecs_to_jiffies(6 * HZ)); - } -} - -static void arcmsr_request_device_map(struct timer_list *t) -{ - struct AdapterControlBlock *acb = from_timer(acb, t, eternal_timer); - switch (acb->adapter_type) { + switch (acb->adapter_type) { case ACB_ADAPTER_TYPE_A: { - arcmsr_hbaA_request_device_map(acb); - } - break; + struct MessageUnit_A __iomem *reg = acb->pmuA; + writel(ARCMSR_INBOUND_MESG0_GET_CONFIG, ®->inbound_msgaddr0); + break; + } case ACB_ADAPTER_TYPE_B: { - arcmsr_hbaB_request_device_map(acb); - } - break; + struct MessageUnit_B *reg = acb->pmuB; + writel(ARCMSR_MESSAGE_GET_CONFIG, reg->drv2iop_doorbell); + break; + } case ACB_ADAPTER_TYPE_C: { - arcmsr_hbaC_request_device_map(acb); + struct MessageUnit_C __iomem *reg = acb->pmuC; + writel(ARCMSR_INBOUND_MESG0_GET_CONFIG, ®->inbound_msgaddr0); + writel(ARCMSR_HBCMU_DRV2IOP_MESSAGE_CMD_DONE, ®->inbound_doorbell); + break; + } + case ACB_ADAPTER_TYPE_D: { + struct MessageUnit_D *reg = acb->pmuD; + writel(ARCMSR_INBOUND_MESG0_GET_CONFIG, reg->inbound_msgaddr0); + break; + } + case ACB_ADAPTER_TYPE_E: { + struct MessageUnit_E __iomem *reg = acb->pmuE; + writel(ARCMSR_INBOUND_MESG0_GET_CONFIG, ®->inbound_msgaddr0); + acb->out_doorbell ^= ARCMSR_HBEMU_DRV2IOP_MESSAGE_CMD_DONE; + writel(acb->out_doorbell, ®->iobound_doorbell); + break; + } + default: + return; } - break; - case ACB_ADAPTER_TYPE_D: - arcmsr_hbaD_request_device_map(acb); - break; - case ACB_ADAPTER_TYPE_E: - arcmsr_hbaE_request_device_map(acb); - break; + acb->acb_flags |= ACB_F_MSG_GET_CONFIG; + mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6 * HZ)); } }