Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2072838imu; Fri, 14 Dec 2018 05:26:23 -0800 (PST) X-Google-Smtp-Source: AFSGD/W+IRiJTK2Xrr1vXngFfws5XTrMiI6HVT4kfnZSpjQuQVJJt8Qpuy8kWzwcuc1gEROocIxI X-Received: by 2002:a63:ea4f:: with SMTP id l15mr2703944pgk.102.1544793983923; Fri, 14 Dec 2018 05:26:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544793983; cv=none; d=google.com; s=arc-20160816; b=WFTiJRyTgOJPvbcgk+b1co2tPdySbTzdeUlYidL3oe3wJBCbwJ64Odj/0GBX8Lbqyl NXiuCr/1s+i0pGOdp1Rs6uCg6jbD50saTNiD0q2Sb+5FYidTP8IM32yBzvYXcLjC1oe5 Tjg3u1/n+1qciXDWhWZvERgEBCf3lmuK/XwP7mGC+/LHN953RBUawS2aLAzc+vjuOEfk QRe4zwR73SpHbK6iHafWxzOnXlWf+nLuWqa7xjBB3kzo+v2d8a+CkiQj1jowV10bdkNU 7A35A5sUMQezkO6e5QKbDd/BerwCWrjEdpm9yUFEK2iZdzExHrMwsTtC8wJPMypox9qn fwog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4KVQAMYtSk3kTC8WUhk9uJTZ+iHzEPKOa2DOw3MKqAw=; b=q71Ne1VXpkZQv9jLumzhVpM3MqaNQmc+uWp7ect+ywPX1cRSK2mb4k2XVzOeKDz1cX 3s2MbiXA+76SuX5KgqzN+AW+zcbQDWJVEe2RRdxD4D83J2JPAyOv8QQZXz+CUmr5C/eF i2FN2nmUT0Src4RKbZCmkaufIA5FzLMvIVF9axZsG7MiSMhRx5KyGV5hTwG5jMlzwx/M 6BIyMhs5C/1fc2nppQ9j14i9logcgGmTI4uEw6NFRW0c4EBFbVGdxwqepXBfmYZc748x IjFN2dGjPwz4VTDyxWcZFb0xuZxYxDxf5DntZ4rZM9Z0GIH8sLJ+yit0Jhd+yyZXtnw0 9rVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hkRfxKsM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d3si2567088pla.122.2018.12.14.05.26.01; Fri, 14 Dec 2018 05:26:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hkRfxKsM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729952AbeLNNW1 (ORCPT + 99 others); Fri, 14 Dec 2018 08:22:27 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:45111 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729641AbeLNNWY (ORCPT ); Fri, 14 Dec 2018 08:22:24 -0500 Received: by mail-lf1-f68.google.com with SMTP id b20so4224896lfa.12; Fri, 14 Dec 2018 05:22:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4KVQAMYtSk3kTC8WUhk9uJTZ+iHzEPKOa2DOw3MKqAw=; b=hkRfxKsM1mpK6uF+LIOJZQXQdEh6bAgVtoczOPFH8HDy3POU4V/o77NyHerSnCDnpB zDy2JsGyiW7+/dbkojQIHh23cOD/thplXG5Vkuwy5Yudph+0Jm9QBTIyJ3LCI9ZoFQKU Ia9OLBB4MkZigrvd9lZO254NdXtFScPnq1ISt92AOj41omxMZHLXYbf5pseD/wt8pJC9 acW5xATBLymdR8aKLFlEGeW02rFSXZxumo8+OGBJRa3oNwNx60Fdcp0ySSeCz353gsFW 1Qboam3z5jcG5fg6RQcKoXtoMNEiwkpmuFHa1dJUazNHXjuJmO6JgPKotmrdsMAhFGjR IPdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4KVQAMYtSk3kTC8WUhk9uJTZ+iHzEPKOa2DOw3MKqAw=; b=H9+kNNdSLEV5DzNQLby1ldHFY7VlB6hXqyWvOsJW5iWFAJjMPS+RlODF5BWYoGUGI3 0IO6cjbgVY+GHzWBILC/HMv0Zd6WbAtiPsyA3/FDTfaPGAzdURciw7UmbLuSaYd/Xig5 bclk32Y3OiveAXRXVXcSsXhHakIL0yS3r+PjqVguPVs80iS8rzSqscRXJj4xDId4i+4c Ap39T9wHGw6TQhpVZoCyrJ/xUQNXtFjczpMKZdXNmlkpeggzgO0LHQIcSsp0nM+6jR1I rHh4WUTaERlfyFqTdBjsVboEOElJygs/IUaNRw4rJGnGBNzruGj414xdFZm7fJuQxibA UBFg== X-Gm-Message-State: AA+aEWZmTpX7M0Gdm7IWUKfYSuRlZa/GuWdRgJu2PjxsACrP0dvFbezQ 0ZimQCg34AfvIQLmGCD5UWT/V24r9OinbgYY X-Received: by 2002:a19:9653:: with SMTP id y80mr1828139lfd.66.1544793741773; Fri, 14 Dec 2018 05:22:21 -0800 (PST) Received: from localhost.localdomain (pool-109-191-228-208.is74.ru. [109.191.228.208]) by smtp.gmail.com with ESMTPSA id u79-v6sm944101lje.36.2018.12.14.05.22.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Dec 2018 05:22:21 -0800 (PST) From: Ivan Mironov To: linux-scsi@vger.kernel.org, mironov.ivan@gmail.com Cc: linux-kernel@vger.kernel.org, Don Brace , "James E.J. Bottomley" , "Martin K. Petersen" , esc.storagedev@microsemi.com Subject: [PATCH 1/6] scsi: hpsa: Add function to check if device is a disk or a zoned device Date: Fri, 14 Dec 2018 18:21:10 +0500 Message-Id: <20181214132115.21440-2-mironov.ivan@gmail.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181214132115.21440-1-mironov.ivan@gmail.com> References: <20181214132115.21440-1-mironov.ivan@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This check is used multiple times within the driver. New function makes conditional statements a bit shorter and more readable. Signed-off-by: Ivan Mironov --- drivers/scsi/hpsa.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index c9cccf35e9d7..fc06b790f16b 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c @@ -768,6 +768,11 @@ static ssize_t sas_address_show(struct device *dev, return snprintf(buf, PAGE_SIZE, "0x%016llx\n", sas_address); } +static inline bool is_disk_or_zbc(const struct hpsa_scsi_dev_t *hdev) +{ + return hdev->devtype == TYPE_DISK || hdev->devtype == TYPE_ZBC; +} + static ssize_t host_show_hp_ssd_smart_path_enabled(struct device *dev, struct device_attribute *attr, char *buf) { @@ -788,7 +793,7 @@ static ssize_t host_show_hp_ssd_smart_path_enabled(struct device *dev, offload_enabled = hdev->offload_enabled; spin_unlock_irqrestore(&h->lock, flags); - if (hdev->devtype == TYPE_DISK || hdev->devtype == TYPE_ZBC) + if (is_disk_or_zbc(hdev)) return snprintf(buf, 20, "%d\n", offload_enabled); else return snprintf(buf, 40, "%s\n", @@ -855,8 +860,7 @@ static ssize_t path_info_show(struct device *dev, PAGE_SIZE - output_len, "PORT: %.2s ", phys_connector); - if ((hdev->devtype == TYPE_DISK || hdev->devtype == TYPE_ZBC) && - hdev->expose_device) { + if (is_disk_or_zbc(hdev) && hdev->expose_device) { if (box == 0 || box == 0xFF) { output_len += scnprintf(buf + output_len, PAGE_SIZE - output_len, @@ -1715,8 +1719,7 @@ static void hpsa_figure_phys_disk_ptrs(struct ctlr_info *h, for (j = 0; j < ndevices; j++) { if (dev[j] == NULL) continue; - if (dev[j]->devtype != TYPE_DISK && - dev[j]->devtype != TYPE_ZBC) + if (!is_disk_or_zbc(dev[j])) continue; if (is_logical_device(dev[j])) continue; @@ -1770,8 +1773,7 @@ static void hpsa_update_log_drive_phys_drive_ptrs(struct ctlr_info *h, for (i = 0; i < ndevices; i++) { if (dev[i] == NULL) continue; - if (dev[i]->devtype != TYPE_DISK && - dev[i]->devtype != TYPE_ZBC) + if (!is_disk_or_zbc(dev[i])) continue; if (!is_logical_device(dev[i])) continue; @@ -3965,9 +3967,8 @@ static int hpsa_update_device_info(struct ctlr_info *h, scsi_device_type(this_device->devtype), this_device->model); - if ((this_device->devtype == TYPE_DISK || - this_device->devtype == TYPE_ZBC) && - is_logical_dev_addr_mode(scsi3addr)) { + if (is_disk_or_zbc(this_device) && + is_logical_dev_addr_mode(scsi3addr)) { unsigned char volume_offline; hpsa_get_raid_level(h, scsi3addr, &this_device->raid_level); -- 2.19.2