From patchwork Wed Nov 15 02:33:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10058613 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 15F4C6023A for ; Wed, 15 Nov 2017 02:35:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09078298D2 for ; Wed, 15 Nov 2017 02:35:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EFE23298DD; Wed, 15 Nov 2017 02:35:36 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 077F8298D2 for ; Wed, 15 Nov 2017 02:35:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754450AbdKOCff (ORCPT ); Tue, 14 Nov 2017 21:35:35 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:42762 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753470AbdKOCfa (ORCPT ); Tue, 14 Nov 2017 21:35:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1510713330; x=1542249330; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=h1ipvSLwWGeVVsiNrBYGfeRNZ5KExuPDW28G2TIHsTw=; b=Yrq4OlD/llcKnUtvp8VOzZ6rizDEvYJ1qWDN1f3a3YXTpFx899lImc6S +FXN3oOLPwZxsg1HAOh4eW44a2ISi07BaEPaUiUE//UgZgmb+i+U/BtZB wh2BnQkql9WdTCoDBgNK/RcTu2NM+oaQYpk/HmDyB8sZTI/PWsEkB23TI 6DbgBPR1zzB/2eY3luNkiP8I0YANIZgwtLllT1G/JLIv8X1560+iqzxXQ ZF+XbYlAdvnYq6KQsrhUbPm9SldNssB+GymhXMGZmI3cWiiqkC1D+6NI7 6oheSAZHLbbdOnf4uOg/kj7ebx6B+uz31aoqSWrk3RRPMFNjOy8jNOnwm Q==; X-IronPort-AV: E=Sophos;i="5.44,397,1505750400"; d="scan'208";a="62471986" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 15 Nov 2017 10:35:29 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP; 14 Nov 2017 18:32:40 -0800 Received: from unknown (HELO MILHUBIP03.sdcorp.global.sandisk.com) ([10.177.9.96]) by uls-op-cesaip01.wdc.com with ESMTP; 14 Nov 2017 18:35:29 -0800 Received: from milsmgip11.sandisk.com (10.177.9.6) by MILHUBIP03.sdcorp.global.sandisk.com (10.177.9.96) with Microsoft SMTP Server id 14.3.319.2; Tue, 14 Nov 2017 18:35:28 -0800 X-AuditID: 0ab10959-41c5898000002c97-b0-5a0ba7f009e4 Received: from localhost.localdomain ( [10.177.8.100]) by (Symantec Messaging Gateway) with SMTP id F6.43.11415.0F7AB0A5; Tue, 14 Nov 2017 18:35:28 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" CC: , Bart Van Assche , Christoph Hellwig , Hannes Reinecke , "Johannes Thumshirn" Subject: [PATCH 3/3] Introduce a type for device information flags, namely bflags_t Date: Tue, 14 Nov 2017 18:33:17 -0800 Message-ID: <20171115023317.3595-4-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171115023317.3595-1-bart.vanassche@wdc.com> References: <20171115023317.3595-1-bart.vanassche@wdc.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJJMWRmVeSWpSXmKPExsXCtZEjRffDcu4og70neSwu/fnCaLHgzV42 i5WrjzJZrJqYZ/G4awarRff1HWwWy4//Y3Jg93hwaDOLx+6bDWweH5/eYvFYv+Uqi8fm09Ue nzfJebQf6GYKYI/isklJzcksSy3St0vgypjcfZStYF9xRdvXGcwNjKfjuhg5OSQETCQm797M 1MXIxSEksIhR4sPRY+wgCTYBPYlT8/YxgdgiArkSpx7eACtiFtjFKPHt2G02kISwQLDEvd1X WEFsFgFViXs9k1lAbF4BK4n/pw+xQ2yQl1j8fSdYPaeAtcTEP/vB4kJANW9Xf2OZwMi9gJFh FaNYbmZOcW56ZoGhoV5xYl5KZnG2XnJ+7iZGcOBwRu5gfDrR/BAjEwenVANjyi7BbQc+ff42 uTLonfFhyyId1ZQnS97vcHio9v97buKC6RITBLRXWmcsvbWudNKHJ6UZXt8WJIaptzWoVq7Z dH1WooHxTj+d9LpfToul4wq/CCv5r7+t/etS19GS/MdqsedXH1FUvP+Jz5a3U+qKqP7CxztD BUTkMu8KMs19F7ngtmfldalUJZbijERDLeai4kQAAyySU8wBAAA= MIME-Version: 1.0 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 Additionally, suppress recently introduced sparse warnings related to blacklist flags. Signed-off-by: Bart Van Assche Cc: Christoph Hellwig Cc: Hannes Reinecke Cc: Johannes Thumshirn --- drivers/scsi/scsi_devinfo.c | 20 +++++++-------- drivers/scsi/scsi_priv.h | 6 ++--- drivers/scsi/scsi_scan.c | 15 +++++------ drivers/scsi/scsi_sysfs.c | 4 +-- drivers/scsi/scsi_transport_spi.c | 6 ++--- include/scsi/scsi_device.h | 3 ++- include/scsi/scsi_devinfo.h | 52 ++++++++++++++++++++------------------- include/scsi/scsi_types.h | 6 +++++ 8 files changed, 60 insertions(+), 52 deletions(-) create mode 100644 include/scsi/scsi_types.h diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c index d195560a641c..575da174dad7 100644 --- a/drivers/scsi/scsi_devinfo.c +++ b/drivers/scsi/scsi_devinfo.c @@ -22,7 +22,7 @@ struct scsi_dev_info_list { struct list_head dev_info_list; char vendor[8]; char model[16]; - unsigned flags; + bflags_t flags; unsigned compatible; /* for use with scsi_static_device_list entries */ }; @@ -52,7 +52,7 @@ static struct { char *vendor; char *model; char *revision; /* revision known to be bad, unused */ - unsigned flags; + bflags_t flags; } scsi_static_device_list[] __initdata = { /* * The following devices are known not to tolerate a lun != 0 scan @@ -335,7 +335,7 @@ static void scsi_strcpy_devinfo(const char *name, char *to, size_t to_length, * Returns: 0 OK, -error on failure. **/ static int scsi_dev_info_list_add(int compatible, char *vendor, char *model, - char *strflags, int flags) + char *strflags, bflags_t flags) { return scsi_dev_info_list_add_keyed(compatible, vendor, model, strflags, flags, @@ -362,7 +362,7 @@ static int scsi_dev_info_list_add(int compatible, char *vendor, char *model, **/ int scsi_dev_info_list_add_keyed(int compatible, const char *vendor, const char *model, const char *strflags, - int flags, int key) + bflags_t flags, int key) { struct scsi_dev_info_list *devinfo; struct scsi_dev_info_list_table *devinfo_table = @@ -383,10 +383,8 @@ int scsi_dev_info_list_add_keyed(int compatible, const char *vendor, model, compatible); if (strflags) - devinfo->flags = simple_strtoul(strflags, NULL, 0); - else - devinfo->flags = flags; - + flags = (__force bflags_t)simple_strtoul(strflags, NULL, 0); + devinfo->flags = flags; devinfo->compatible = compatible; if (compatible) @@ -574,7 +572,7 @@ static int scsi_dev_info_list_add_str(char *dev_list) * settings. Called during scan time. **/ int scsi_get_device_flags(struct scsi_device *sdev, const unsigned char *vendor, - const unsigned char *model, unsigned int *flags) + const unsigned char *model, bflags_t *flags) { return scsi_get_device_flags_keyed(sdev, vendor, model, SCSI_DEVINFO_GLOBAL, flags); @@ -598,7 +596,7 @@ int scsi_get_device_flags(struct scsi_device *sdev, const unsigned char *vendor, int scsi_get_device_flags_keyed(struct scsi_device *sdev, const unsigned char *vendor, const unsigned char *model, - int key, unsigned int *flags) + int key, bflags_t *flags) { struct scsi_dev_info_list *devinfo; int err; @@ -620,7 +618,7 @@ int scsi_get_device_flags_keyed(struct scsi_device *sdev, } /* except for the global list, where we have an exception */ - *flags = sdev->sdev_bflags ? : scsi_default_dev_flags; + *flags = sdev->sdev_bflags ? : (__force bflags_t)scsi_default_dev_flags; return 0; } EXPORT_SYMBOL(scsi_get_device_flags_keyed); diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h index b82238577b19..e8b12e2ce2e3 100644 --- a/drivers/scsi/scsi_priv.h +++ b/drivers/scsi/scsi_priv.h @@ -53,14 +53,14 @@ enum { extern int scsi_get_device_flags(struct scsi_device *sdev, const unsigned char *vendor, const unsigned char *model, - unsigned int *flags); + bflags_t *flags); extern int scsi_get_device_flags_keyed(struct scsi_device *sdev, const unsigned char *vendor, const unsigned char *model, int key, - unsigned int *flags); + bflags_t *flags); extern int scsi_dev_info_list_add_keyed(int compatible, const char *vendor, const char *model, const char *strflags, - int flags, int key); + bflags_t flags, int key); extern int scsi_dev_info_list_del_keyed(char *vendor, char *model, int key); extern int scsi_dev_info_add_list(int key, const char *name); extern int scsi_dev_info_remove_list(int key); diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 5b9571f30d82..0a87ad88c6fb 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -566,7 +566,7 @@ EXPORT_SYMBOL(scsi_sanitize_inquiry_string); * are copied to the scsi_device any flags value is stored in *@bflags. **/ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result, - int result_len, int *bflags) + int result_len, bflags_t *bflags) { unsigned char scsi_cmd[MAX_COMMAND_SIZE]; int first_inquiry_len, try_inquiry_len, next_inquiry_len; @@ -770,7 +770,7 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result, * SCSI_SCAN_LUN_PRESENT: a new scsi_device was allocated and initialized **/ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result, - int *bflags, int async) + bflags_t *bflags, int async) { int ret; @@ -1049,14 +1049,15 @@ static unsigned char *scsi_inq_str(unsigned char *buf, unsigned char *inq, * - SCSI_SCAN_LUN_PRESENT: a new scsi_device was allocated and initialized **/ static int scsi_probe_and_add_lun(struct scsi_target *starget, - u64 lun, int *bflagsp, + u64 lun, bflags_t *bflagsp, struct scsi_device **sdevp, enum scsi_scan_mode rescan, void *hostdata) { struct scsi_device *sdev; unsigned char *result; - int bflags, res = SCSI_SCAN_NO_RESPONSE, result_len = 256; + bflags_t bflags; + int res = SCSI_SCAN_NO_RESPONSE, result_len = 256; struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); /* @@ -1202,7 +1203,7 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget, * Modifies sdevscan->lun. **/ static void scsi_sequential_lun_scan(struct scsi_target *starget, - int bflags, int scsi_level, + bflags_t bflags, int scsi_level, enum scsi_scan_mode rescan) { uint max_dev_lun; @@ -1293,7 +1294,7 @@ static void scsi_sequential_lun_scan(struct scsi_target *starget, * 0: scan completed (or no memory, so further scanning is futile) * 1: could not scan with REPORT LUN **/ -static int scsi_report_lun_scan(struct scsi_target *starget, int bflags, +static int scsi_report_lun_scan(struct scsi_target *starget, bflags_t bflags, enum scsi_scan_mode rescan) { unsigned char scsi_cmd[MAX_COMMAND_SIZE]; @@ -1539,7 +1540,7 @@ static void __scsi_scan_target(struct device *parent, unsigned int channel, unsigned int id, u64 lun, enum scsi_scan_mode rescan) { struct Scsi_Host *shost = dev_to_shost(parent); - int bflags = 0; + bflags_t bflags = 0; int res; struct scsi_target *starget; diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index cbc0fe2c5485..1bce5c7305ff 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -967,7 +967,7 @@ sdev_show_wwid(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR(wwid, S_IRUGO, sdev_show_wwid, NULL); -#define BLIST_FLAG_NAME(name) [ilog2(BLIST_##name)] = #name +#define BLIST_FLAG_NAME(name) [ilog2((__force u32)BLIST_##name)] = #name static const char *const sdev_bflags_name[] = { #include "scsi_devinfo_tbl.c" }; @@ -984,7 +984,7 @@ sdev_show_blacklist(struct device *dev, struct device_attribute *attr, for (i = 0; i < sizeof(sdev->sdev_bflags) * BITS_PER_BYTE; i++) { const char *name = NULL; - if (!(sdev->sdev_bflags & BIT(i))) + if (!((__force u32)sdev->sdev_bflags & BIT(i))) continue; if (i < ARRAY_SIZE(sdev_bflags_name) && sdev_bflags_name[i]) name = sdev_bflags_name[i]; diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c index 5f4cea2d07c8..c4ecdbbd458c 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c @@ -50,14 +50,14 @@ /* Our blacklist flags */ enum { - SPI_BLIST_NOIUS = 0x1, + SPI_BLIST_NOIUS = (__force bflags_t)0x1, }; /* blacklist table, modelled on scsi_devinfo.c */ static struct { char *vendor; char *model; - unsigned flags; + bflags_t flags; } spi_static_device_list[] __initdata = { {"HP", "Ultrium 3-SCSI", SPI_BLIST_NOIUS }, {"IBM", "ULTRIUM-TD3", SPI_BLIST_NOIUS }, @@ -221,7 +221,7 @@ static int spi_device_configure(struct transport_container *tc, { struct scsi_device *sdev = to_scsi_device(dev); struct scsi_target *starget = sdev->sdev_target; - unsigned int bflags = 0; + bflags_t bflags = 0; scsi_get_device_flags_keyed(sdev, &sdev->inquiry[8], &sdev->inquiry[16], SCSI_DEVINFO_SPI, &bflags); diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 1fb6ad3c5006..13f0def0dbfc 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -7,6 +7,7 @@ #include #include #include +#include #include struct device; @@ -141,7 +142,7 @@ struct scsi_device { unsigned char current_tag; /* current tag */ struct scsi_target *sdev_target; /* used only for single_lun */ - unsigned int sdev_bflags; /* black/white flags as also found in + bflags_t sdev_bflags; /* black/white flags as also found in * scsi_devinfo.[hc]. For now used only to * pass settings from slave_alloc to scsi * core. */ diff --git a/include/scsi/scsi_devinfo.h b/include/scsi/scsi_devinfo.h index 3cf125b56c3a..7e3001b3f262 100644 --- a/include/scsi/scsi_devinfo.h +++ b/include/scsi/scsi_devinfo.h @@ -5,56 +5,58 @@ * Flags for SCSI devices that need special treatment */ +#include + /* Only scan LUN 0 */ -#define BLIST_NOLUN ((__force __u32 __bitwise)(1 << 0)) +#define BLIST_NOLUN ((__force bflags_t)(1 << 0)) /* Known to have LUNs, force scanning. * DEPRECATED: Use max_luns=N */ -#define BLIST_FORCELUN ((__force __u32 __bitwise)(1 << 1)) +#define BLIST_FORCELUN ((__force bflags_t)(1 << 1)) /* Flag for broken handshaking */ -#define BLIST_BORKEN ((__force __u32 __bitwise)(1 << 2)) +#define BLIST_BORKEN ((__force bflags_t)(1 << 2)) /* unlock by special command */ -#define BLIST_KEY ((__force __u32 __bitwise)(1 << 3)) +#define BLIST_KEY ((__force bflags_t)(1 << 3)) /* Do not use LUNs in parallel */ -#define BLIST_SINGLELUN ((__force __u32 __bitwise)(1 << 4)) +#define BLIST_SINGLELUN ((__force bflags_t)(1 << 4)) /* Buggy Tagged Command Queuing */ -#define BLIST_NOTQ ((__force __u32 __bitwise)(1 << 5)) +#define BLIST_NOTQ ((__force bflags_t)(1 << 5)) /* Non consecutive LUN numbering */ -#define BLIST_SPARSELUN ((__force __u32 __bitwise)(1 << 6)) +#define BLIST_SPARSELUN ((__force bflags_t)(1 << 6)) /* Avoid LUNS >= 5 */ -#define BLIST_MAX5LUN ((__force __u32 __bitwise)(1 << 7)) +#define BLIST_MAX5LUN ((__force bflags_t)(1 << 7)) /* Treat as (removable) CD-ROM */ -#define BLIST_ISROM ((__force __u32 __bitwise)(1 << 8)) +#define BLIST_ISROM ((__force bflags_t)(1 << 8)) /* LUNs past 7 on a SCSI-2 device */ -#define BLIST_LARGELUN ((__force __u32 __bitwise)(1 << 9)) +#define BLIST_LARGELUN ((__force bflags_t)(1 << 9)) /* override additional length field */ -#define BLIST_INQUIRY_36 ((__force __u32 __bitwise)(1 << 10)) +#define BLIST_INQUIRY_36 ((__force bflags_t)(1 << 10)) /* do not do automatic start on add */ -#define BLIST_NOSTARTONADD ((__force __u32 __bitwise)(1 << 12)) +#define BLIST_NOSTARTONADD ((__force bflags_t)(1 << 12)) /* try REPORT_LUNS even for SCSI-2 devs (if HBA supports more than 8 LUNs) */ -#define BLIST_REPORTLUN2 ((__force __u32 __bitwise)(1 << 17)) +#define BLIST_REPORTLUN2 ((__force bflags_t)(1 << 17)) /* don't try REPORT_LUNS scan (SCSI-3 devs) */ -#define BLIST_NOREPORTLUN ((__force __u32 __bitwise)(1 << 18)) +#define BLIST_NOREPORTLUN ((__force bflags_t)(1 << 18)) /* don't use PREVENT-ALLOW commands */ -#define BLIST_NOT_LOCKABLE ((__force __u32 __bitwise)(1 << 19)) +#define BLIST_NOT_LOCKABLE ((__force bflags_t)(1 << 19)) /* device is actually for RAID config */ -#define BLIST_NO_ULD_ATTACH ((__force __u32 __bitwise)(1 << 20)) +#define BLIST_NO_ULD_ATTACH ((__force bflags_t)(1 << 20)) /* select without ATN */ -#define BLIST_SELECT_NO_ATN ((__force __u32 __bitwise)(1 << 21)) +#define BLIST_SELECT_NO_ATN ((__force bflags_t)(1 << 21)) /* retry HARDWARE_ERROR */ -#define BLIST_RETRY_HWERROR ((__force __u32 __bitwise)(1 << 22)) +#define BLIST_RETRY_HWERROR ((__force bflags_t)(1 << 22)) /* maximum 512 sector cdb length */ -#define BLIST_MAX_512 ((__force __u32 __bitwise)(1 << 23)) +#define BLIST_MAX_512 ((__force bflags_t)(1 << 23)) /* Disable T10 PI (DIF) */ -#define BLIST_NO_DIF ((__force __u32 __bitwise)(1 << 25)) +#define BLIST_NO_DIF ((__force bflags_t)(1 << 25)) /* Ignore SBC-3 VPD pages */ -#define BLIST_SKIP_VPD_PAGES ((__force __u32 __bitwise)(1 << 26)) +#define BLIST_SKIP_VPD_PAGES ((__force bflags_t)(1 << 26)) /* Attempt to read VPD pages */ -#define BLIST_TRY_VPD_PAGES ((__force __u32 __bitwise)(1 << 28)) +#define BLIST_TRY_VPD_PAGES ((__force bflags_t)(1 << 28)) /* don't try to issue RSOC */ -#define BLIST_NO_RSOC ((__force __u32 __bitwise)(1 << 29)) +#define BLIST_NO_RSOC ((__force bflags_t)(1 << 29)) /* maximum 1024 sector cdb length */ -#define BLIST_MAX_1024 ((__force __u32 __bitwise)(1 << 30)) +#define BLIST_MAX_1024 ((__force bflags_t)(1 << 30)) /* Use UNMAP limit for WRITE SAME */ -#define BLIST_UNMAP_LIMIT_WS ((__force __u32 __bitwise)(1 << 31)) +#define BLIST_UNMAP_LIMIT_WS ((__force bflags_t)(1 << 31)) #endif diff --git a/include/scsi/scsi_types.h b/include/scsi/scsi_types.h new file mode 100644 index 000000000000..3ed29c31270a --- /dev/null +++ b/include/scsi/scsi_types.h @@ -0,0 +1,6 @@ +#ifndef _SCSI_SCSI_TYPES_H_ +#define _SCSI_SCSI_TYPES_H_ + +typedef __u32 __bitwise bflags_t; + +#endif