From patchwork Wed Dec 27 04:34:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raghava Aditya Renukunta X-Patchwork-Id: 10133433 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 0B3756037D for ; Wed, 27 Dec 2017 04:35:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E836E2DA7F for ; Wed, 27 Dec 2017 04:35:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC9BA2DA63; Wed, 27 Dec 2017 04:35: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=ham 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 6F3FE2DA63 for ; Wed, 27 Dec 2017 04:35:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751883AbdL0Efv (ORCPT ); Tue, 26 Dec 2017 23:35:51 -0500 Received: from mail-dm3nam03on0046.outbound.protection.outlook.com ([104.47.41.46]:7296 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751840AbdL0EfT (ORCPT ); Tue, 26 Dec 2017 23:35:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mscc365.onmicrosoft.com; s=selector1-microsemi-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=PCXMmlP0lR9jdQgyF/vAuK0FPiKeXrTFeFcr/tHHrCo=; b=Q4Jkt/5TNH/O4GC/xUiOaD26yyq/bK7kbBhunRN2rD6IPTXoqWYFD+ZR/BnoNz1fzlPX/C/qhj4vIg8bzh5Kp4mM1b/M7pFsMsT3zJ5+yedY8NZjCtMbUiKhdQNZstxUtV2MxtZYHH016TH4HuYP7v0MI4NK8559E6Dh3UiBHpA= Received: from CY4PR02CA0006.namprd02.prod.outlook.com (10.169.188.16) by SN1PR0201MB1839.namprd02.prod.outlook.com (10.162.228.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.345.14; Wed, 27 Dec 2017 04:35:15 +0000 Received: from BL2FFO11FD049.protection.gbl (2a01:111:f400:7c09::140) by CY4PR02CA0006.outlook.office365.com (2603:10b6:903:18::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.366.8 via Frontend Transport; Wed, 27 Dec 2017 04:35:15 +0000 Authentication-Results: spf=pass (sender IP is 208.19.100.21) smtp.mailfrom=microsemi.com; wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=bestguesspass action=none header.from=microsemi.com; Received-SPF: Pass (protection.outlook.com: domain of microsemi.com designates 208.19.100.21 as permitted sender) receiver=protection.outlook.com; client-ip=208.19.100.21; helo=avsrvexchhts1.microsemi.net; Received: from avsrvexchhts1.microsemi.net (208.19.100.21) by BL2FFO11FD049.mail.protection.outlook.com (10.173.161.211) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.345.12 via Frontend Transport; Wed, 27 Dec 2017 04:34:55 +0000 Received: from localhost (10.181.72.13) by avsrvexchhts1.microsemi.net (10.100.34.105) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 26 Dec 2017 20:34:59 -0800 From: Raghava Aditya Renukunta To: , , CC: , , , "Guilherme G . Piccoli" , Bart Van Assche Subject: [PATCH v2 20/30] scsi: aacraid: Added macros to help loop through known buses and targets Date: Tue, 26 Dec 2017 20:34:41 -0800 Message-ID: <20171227043451.27813-21-RaghavaAditya.Renukunta@microsemi.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20171227043451.27813-1-RaghavaAditya.Renukunta@microsemi.com> References: <20171227043451.27813-1-RaghavaAditya.Renukunta@microsemi.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:208.19.100.21; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(39380400002)(376002)(346002)(39860400002)(396003)(2980300002)(438002)(189003)(199004)(97736004)(53936002)(47776003)(356003)(86362001)(6666003)(69596002)(2950100002)(316002)(77096006)(1076002)(51416003)(54906003)(76176011)(8676002)(106002)(5660300001)(106466001)(2906002)(8936002)(305945005)(110136005)(81156014)(81166006)(68736007)(76506005)(104016004)(50226002)(57986006)(4326008)(2201001)(50466002)(16586007)(72206003)(48376002)(478600001)(36756003); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR0201MB1839; H:avsrvexchhts1.microsemi.net; FPR:; SPF:Pass; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD049; 1:X7P1AK2L786uO22yvKIFyih0PNssus1X9snIc9B0e4a/S/jLSYRW42cTh2c/Z/Gd1wKnu3XgWVf4pVz8EGztYCkAuBA97C/ROWaLjBZR0NRr5Y8o+WyhhEZSVZVArgjb X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8711b471-ec8a-44e4-1a3d-08d54ce32e2d X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(4608076)(2017052603307)(7153060); SRVR:SN1PR0201MB1839; X-Microsoft-Exchange-Diagnostics: 1; SN1PR0201MB1839; 3:wsSL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KwzXTP5XqPfzv4mnAvCgEkHi/HETbgj3O2O1TmAjgVzxEK9xfAuNOLX0pNrOka6ZL9PPIEvl4wBhkv84toQfshUUCe5TJ1we8EDk+j6Qd0YSd3cg6rHQOz8abZNGFVMNEKT7bkMfi0iOsdUGr29b9KE9mGpQeFYQJuVm+3ubYGZypvzg7/zh0KKbwUcaqBufvG/fkqZB9UE6Qsg6aRVx6vsp2zHEBnAYtXj6LgAvxGlQwkCOELdL7/d5EyMs4bbGT2/7mCp3EZsRH3hRd6cRtSiLp1CfWkawO19dDRCybdecOXIxBUlqGEyy/Jvwst2sr9E4Tvr7G0B28OJSl5lICvvonn938vF4u6m6GCmyAGeYE8f0MWUpH0PDF7JR1O8M/TXBKk1n4YOsV4XO4vQ5RicNes9xXJnvtlgXf1x4dg3R6xjXBxiFj9hkDqFSmX9Y19S2d++anAKQgJzxHNsKRoYtITzvn8069HoMV8SZJllFhkB7n1VUOL1LU0AQTVhtOoHUGsiExebpZyc3tAD7HlpUPUja3pnraDCHpz9M= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(72170198267865); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(3231023)(944501075)(93006095)(93004095)(10201501046)(3002001)(6055026)(6041268)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011); SRVR:SN1PR0201MB1839; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:SN1PR0201MB1839; X-Microsoft-Exchange-Diagnostics: 1; SN1PR0201MB1839; 4:mjkrEZf/mJvY8p+NbqqDrIpbVzLXWCIJeN2pzokRJPLZDQlEEJzgnh96CteS8vlK4LXn9AnUmHKAuGBJS8+dhH4k+hlWzz5H47IRRCjHdI6AR0whyGq4F+MOTlzye/fso0w3JNyT7QPwVOrxYAl/HdOIG1Udc08daiKpkJeLQCWLOH56UxrHgsHCAY9JZt9QJY3sYuHOcdjtHWz/sA8hYYwRYC2Q7DTb7Y97oWGRblzTafwxVMWdUnxb7E1vVaibySTu6LvGXcRSYb2NIeL5ciTaayXVhpuMMWfRHTdWacdU0A8MCgquTxNi7wCxUb8U X-Forefront-PRVS: 0534947130 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR0201MB1839; 23:SGl1tBn2CdMiw9owZqbO0qC6rzdJcvH8GlLHecF?= =?us-ascii?Q?BakUFV6Bs75tizuGMCK7N0aWm9++1cc3A0sqrOWzdtnQMgT8dt4HV+X8gdGh?= =?us-ascii?Q?rgAYjilfbPlJ4zJ5pN4IRCcA7aNmx3aKOr9fHpBIaqrsAnIl777+UYy/5apC?= =?us-ascii?Q?CuOyOpxMnQzblSu2SOx/w19l2dutV6Qag4fptMdvMbXYeRRHV00PdYSmCHA2?= =?us-ascii?Q?sJhsRCaSoHTE+DGXGSOF3a2qLbSkleVELkUL8oLc4DKp8eluM9vsFulU1JNu?= =?us-ascii?Q?6SU/ogAizX4pNq2AArXailxJp637/2hBfLif2TclbYhhHfDKsZl57cFoxvcZ?= =?us-ascii?Q?paed6tPTJlGOED5+/e2mi/ifzOBidp6jSMINBd/2+HfXBcTUGXFJY98XLuD1?= =?us-ascii?Q?lpNXvXBToGwun/yHxOzwxjzl8BTDe+H7K856sE7ldUN9fcoeyC9DvVnXuSdP?= =?us-ascii?Q?lHWxSoU3/wp7OSc5Cij5ndXLIikyUHeUQXx80xVbCeYFw18IzGtv6IXmhxw3?= =?us-ascii?Q?9JG6YL3G+eNyh6P/l6ZVl4FZbqnut8f9Are5OObr7HVwDwbx1HuE5y4aNUYq?= =?us-ascii?Q?Yu3p2H3gvaDDGIghRiEAiSaGXiR9zpvcA+rnNhp1BNm/waNDaeJ5N9nzk5T2?= =?us-ascii?Q?9b0LkuaGLBkHJQS3pYgdQStWxSbCzmFpRIoQPgSiuZ8ylYGLYkpmpZISX+ii?= =?us-ascii?Q?IQ6vh4yfFuc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sEeaqHwDB/+bo95w79Win1EyC0lvtNLSTfTO+99JDThgIHknnlARatdg0gASn4Tpr/GuzGTrVF6JE=; 7:D2LRq+u0PZyxgnsWuMF6pJ06u9dBSrsgiRowMeV+GGCDHjcHIcK4wqnhQR9uzQeL9mCLiEu/4xgVV3lsW9zUGS/1cNh4eFLL0hWcDADIdbc8tR5Vq2WGl7PPFnP7H9rLqFbMYw2U0POyLcB0oWVRF0AwgIVGfh+uXSwA726noDWaNK1Wp46JY0H3DWIuqxbpT5oGIegdDQ3gTuGnaN716gTrB3i+U0aAfY3J647O0CYNQ2Mkl7fKdIA58SGy+o9h SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: microsemi.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Dec 2017 04:34:55.5512 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8711b471-ec8a-44e4-1a3d-08d54ce32e2d X-MS-Exchange-CrossTenant-Id: f267a5c8-86d8-4cc9-af71-1fd2c67c8fad X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f267a5c8-86d8-4cc9-af71-1fd2c67c8fad; Ip=[208.19.100.21]; Helo=[avsrvexchhts1.microsemi.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR0201MB1839 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 Added macros to loop through the MAX SUPPORTED Buses and Targets. This will make the code a bit easier to read. Signed-off-by: Raghava Aditya Renukunta --- Changes in V2: None drivers/scsi/aacraid/aacraid.h | 4 ++++ drivers/scsi/aacraid/commsup.c | 34 +++++++++++++++++----------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index 17c6cdd..a8fe1e1 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -117,9 +117,13 @@ enum { /* Thor: 5 phys. buses: #0: empty, 1-4: 256 targets each */ #define AAC_MAX_BUSES 5 #define AAC_MAX_TARGETS 256 +#define AAC_BUS_TARGET_LOOP (AAC_MAX_BUSES * AAC_MAX_TARGETS) #define AAC_MAX_NATIVE_SIZE 2048 #define FW_ERROR_BUFFER_SIZE 512 +#define get_bus_number(x) (x/AAC_MAX_TARGETS) +#define get_target_number(x) (x%AAC_MAX_TARGETS) + /* Thor AIF events */ #define SA_AIF_HOTPLUG (1<<1) #define SA_AIF_HARDWARE (1<<2) diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index ed79159..8966371 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -1890,31 +1890,31 @@ static int aac_is_safw_target_valid(struct aac_dev *dev, int bus, int target) static void aac_resolve_luns(struct aac_dev *dev) { + int i; int bus, target, channel; struct scsi_device *sdev; - for (bus = 0; bus < AAC_MAX_BUSES; bus++) { - for (target = 0; target < AAC_MAX_TARGETS; target++) { + for (i = 0; i < AAC_BUS_TARGET_LOOP; i++) { - if (bus == CONTAINER_CHANNEL) - channel = CONTAINER_CHANNEL; - else - channel = aac_phys_to_logical(bus); + bus = get_bus_number(i); + target = get_target_number(i); - sdev = scsi_device_lookup(dev->scsi_host_ptr, channel, - target, 0); + if (bus == CONTAINER_CHANNEL) + channel = CONTAINER_CHANNEL; + else + channel = aac_phys_to_logical(bus); - if (!sdev && aac_is_safw_target_valid(dev, bus, target)) - scsi_add_device(dev->scsi_host_ptr, channel, - target, 0); - else if (sdev && aac_is_safw_target_valid(dev, - bus, target)) - scsi_remove_device(sdev); + sdev = scsi_device_lookup(dev->scsi_host_ptr, channel, + target, 0); - if (sdev) - scsi_device_put(sdev); + if (!sdev && aac_is_safw_target_valid(dev, bus, target)) + scsi_add_device(dev->scsi_host_ptr, channel, + target, 0); + else if (sdev && aac_is_safw_target_valid(dev, bus, target)) + scsi_remove_device(sdev); - } + if (sdev) + scsi_device_put(sdev); } }