From patchwork Thu Dec 21 17:34:11 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: 10128133 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 36F0C60318 for ; Thu, 21 Dec 2017 17:35:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 252ED29CE3 for ; Thu, 21 Dec 2017 17:35:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 184A129D38; Thu, 21 Dec 2017 17:35:39 +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 9B65829CE3 for ; Thu, 21 Dec 2017 17:35:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755143AbdLURfh (ORCPT ); Thu, 21 Dec 2017 12:35:37 -0500 Received: from mail-cys01nam02on0069.outbound.protection.outlook.com ([104.47.37.69]:53597 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754566AbdLURev (ORCPT ); Thu, 21 Dec 2017 12:34:51 -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=ls2a0ZCDaPAC/UFh8hDwG4TL4SnBeP4SIRYz/5Svjjs=; b=fQ7RX9oNU5B99/QW1+lBrgJ+K1pMGMSfLhXbxqtPnZ3omUdQwVXOKns4FxPmn1y2BCXCMqbEL1ad/oIXe5vq4EfdxeWOGA6AzZ905TA4uo0Vm41Uf8EdYPfrkhO8mjwid6PcoVzz0SKQ94oKDnxKZJaS69xrtDGcgaTjIlgUyxo= Received: from MWHPR02CA0056.namprd02.prod.outlook.com (2603:10b6:301:60::45) by BN1PR02MB136.namprd02.prod.outlook.com (2a01:111:e400:20::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.345.14; Thu, 21 Dec 2017 17:34:48 +0000 Received: from BN1BFFO11FD036.protection.gbl (2a01:111:f400:7c10::1:157) by MWHPR02CA0056.outlook.office365.com (2603:10b6:301:60::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.323.15 via Frontend Transport; Thu, 21 Dec 2017 17:34:47 +0000 Authentication-Results: spf=pass (sender IP is 208.19.100.21) smtp.mailfrom=microsemi.com; linux.vnet.ibm.com; dkim=none (message not signed) header.d=none; linux.vnet.ibm.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 BN1BFFO11FD036.mail.protection.outlook.com (10.58.144.99) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.302.6 via Frontend Transport; Thu, 21 Dec 2017 17:34:32 +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; Thu, 21 Dec 2017 09:34:27 -0800 From: Raghava Aditya Renukunta To: , , CC: , , , "Guilherme G . Piccoli" Subject: [PATCH 20/29] scsi: aacraid: Added macros to help loop through known buses and targets Date: Thu, 21 Dec 2017 09:34:11 -0800 Message-ID: <20171221173420.8213-21-RaghavaAditya.Renukunta@microsemi.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20171221173420.8213-1-RaghavaAditya.Renukunta@microsemi.com> References: <20171221173420.8213-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)(376002)(396003)(39380400002)(346002)(39860400002)(2980300002)(438002)(189003)(199004)(97736004)(106002)(316002)(86362001)(69596002)(2950100002)(50226002)(104016004)(36756003)(6666003)(77096006)(8936002)(16586007)(478600001)(2201001)(53936002)(54906003)(72206003)(110136005)(81156014)(5660300001)(47776003)(1076002)(305945005)(8676002)(51416003)(356003)(4326008)(2906002)(50466002)(76506005)(106466001)(68736007)(57986006)(48376002)(81166006)(76176011); DIR:OUT; SFP:1101; SCL:1; SRVR:BN1PR02MB136; H:avsrvexchhts1.microsemi.net; FPR:; SPF:Pass; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD036; 1:6BLu63tcB5ZmvEP6rlgVly/EspBvgap2ImhIv3mMKExZ5PW+PfzuZ53/+DU40aWX8sUNTx2defkRN4u2/4LX+XbQji3etYUfSvfuVo4NPl+Un7hHha83cPbHIBDRdPrt X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dfa01b3b-d048-4c1a-5a1c-08d5489918ea X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(4608076)(2017052603307)(7153060); SRVR:BN1PR02MB136; X-Microsoft-Exchange-Diagnostics: 1; BN1PR02MB136; 3:1t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Ifu486OvXTogGZ7yDQyIohpg6LgTWqF0Oq14s5ldIcOeH5Iolid/B3F3Thr8SQPFXcL2RPXaZivL7FR+9SsBCV/cPoDWEyDuVSlvoYOorgmWKFNmx69keoaI/8l/m2Allxay5M34ecDx+jLGKgvSpFkd7gryl7kUi8J7gJkL0b4UmpXvMP8rtGPCT92ADjOZs+nCF9Gfht+U8lrk9+i2gRiOlZY42oiVq5nqmwnTGOHTAHfHCAZEY86wFafdmPVAjlYZNcdMUK7tJ3OVFJuIbAyK3IGh4LJXf6WQ6PIotD7AyWn660DcISZqahXAtPMkIo6G5ocOl8ldGaTFjkQHmGTXGQWA75rq9hRQ6O5zyCxvG11H+pTaz+BirOxPDyyzYyb5O5bDU+jDLa6pGbq643qqBDnx+dZ+zHQqGUKAN6FPt8keghICIT7i+6jSrTTkpOB3DsxWGr8MiJj+dVaKvXGwCKcGC/PoO0ENOLjwklSNkulAE3JSNBkfuDnYlcbC+qBWOxYm1KhPCGd7l3ZNCaOEp1E3iIzphEmsBvRTD1/TSHOG2GR19dER8nBgaEBuBBCB0s= 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)(3002001)(93006095)(93004095)(3231023)(10201501046)(6055026)(6041268)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011); SRVR:BN1PR02MB136; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:BN1PR02MB136; X-Microsoft-Exchange-Diagnostics: 1; BN1PR02MB136; 4:cWl8JOtmhnYSjx1O6WEKsBBPX1x93G1Wrebhn4vflimZk/wTmMxGGBBHxcG5aR1isXp88QSnvh606BYXYUnY3ZxVComgQz8U0pG8tvGde3PdI+WDbC7pB8AxoxxGmz2PjhOiBhK9+T+UclOAFYNxhvrJT6wmOYOkN60O2Jll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4jSZpTfWlet6xsK7wPJDtxxbeQHnIYXJ2ZdXECtFcd42wesTTM91A8RoEgMG8GKzgmojUnojMiE1V2DHnMoDoRh16Jxg=; 7:2AXY5JF5fI0b/rTUhreAFw2G4jlw9bXTOQ32GWi/4PmNdXnRA0KjaSG+SS5k3gNR1ShxOq5L8NzY4WD/Q3YK5OmpJ+Kxo1K1asW6ijYIa1bC/ekj13C8JrfrK4YMYLgrPVxFjhL8G8D/68LwgP6uaFZ5akxrzBFGAwROnk9QFHCrhLarJ2A1xGGCbfw/LnSP7aNlBCLpo++JxVtVpUvdWUpuP+EaqxATy5uvSDiALs54MP+LvES+BiiO0I8tDSkB SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: microsemi.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2017 17:34:32.4725 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dfa01b3b-d048-4c1a-5a1c-08d5489918ea 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: BN1PR02MB136 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 --- 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); } }