From patchwork Mon Dec 4 18:36:33 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: 10091249 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 177876035E for ; Mon, 4 Dec 2017 18:36:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D80C28D5A for ; Mon, 4 Dec 2017 18:36:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0233D28D5F; Mon, 4 Dec 2017 18:36:40 +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 8DEC728D5A for ; Mon, 4 Dec 2017 18:36:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752073AbdLDSgj (ORCPT ); Mon, 4 Dec 2017 13:36:39 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:31911 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751934AbdLDSgg (ORCPT ); Mon, 4 Dec 2017 13:36:36 -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=1512412596; x=1543948596; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=AfK2quWr1nrkzIt9ZpRSPrd8TjikyZuH1KQ2hvjhO/I=; b=HaGL+rfhzUfcdhAhku61EsoYEiwoHVrbOqnFOFgJ8U1iYtPgFiP7pr/N cd3QHTpD443XBFNGy1w0R3V3KSFrHBszo3NMU/y3EgVvMoShbc3/BjIme x3Mn3qPSlCcbUWctiTRAhhqAUrMwmZCqoIq36bLg2zYUn6j/ELeHV01c+ LbAk7bbs55NIP0+yoJcryz7a9M8uKPwEMQcamr8lRXH/n1qgjm6+UxaS5 DEciyh4PRmHV+6zHXwlKk9BqqDHMJZ7p3xQoh7n+O1fr8ZqTeKMYbRIpC RrjFIa0JtWwKJbgLGhR+VwkxpLbtW6bxE1YFKwMs3833es4KhVgeF5Z/D w==; X-IronPort-AV: E=Sophos;i="5.45,359,1508774400"; d="scan'208";a="166825174" 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; 05 Dec 2017 02:36:35 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP; 04 Dec 2017 10:33:14 -0800 Received: from thinkpad-bart.sdcorp.global.sandisk.com (HELO thinkpad-bart.int.fusionio.com) ([10.11.166.51]) by uls-op-cesaip01.wdc.com with ESMTP; 04 Dec 2017 10:36:35 -0800 From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Christoph Hellwig , Hannes Reinecke , Johannes Thumshirn Subject: [PATCH 3/3] Introduce scsi_devinfo_key enumeration type Date: Mon, 4 Dec 2017 10:36:33 -0800 Message-Id: <20171204183633.32139-4-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171204183633.32139-1-bart.vanassche@wdc.com> References: <20171204183633.32139-1-bart.vanassche@wdc.com> 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 Since symbolic names for the device information keys alread exist, associate an enumeration type with these symbolic values. This change makes it clear what the valid values for the 'key' arguments are. Signed-off-by: Bart Van Assche Cc: Christoph Hellwig Cc: Hannes Reinecke Cc: Johannes Thumshirn --- drivers/scsi/scsi_devinfo.c | 14 ++++++++------ drivers/scsi/scsi_priv.h | 14 ++++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c index 4b33c001ae23..82bc807e1d50 100644 --- a/drivers/scsi/scsi_devinfo.c +++ b/drivers/scsi/scsi_devinfo.c @@ -361,7 +361,8 @@ static int scsi_dev_info_list_add(int compatible, char *vendor, char *model, * Returns: 0 OK, -error on failure. **/ int scsi_dev_info_list_add_keyed(int compatible, char *vendor, char *model, - char *strflags, blist_flags_t flags, int key) + char *strflags, blist_flags_t flags, + enum scsi_devinfo_key key) { struct scsi_dev_info_list *devinfo; struct scsi_dev_info_list_table *devinfo_table = @@ -410,7 +411,7 @@ EXPORT_SYMBOL(scsi_dev_info_list_add_keyed); * Returns: pointer to matching entry, or ERR_PTR on failure. **/ static struct scsi_dev_info_list *scsi_dev_info_list_find(const char *vendor, - const char *model, int key) + const char *model, enum scsi_devinfo_key key) { struct scsi_dev_info_list *devinfo; struct scsi_dev_info_list_table *devinfo_table = @@ -492,7 +493,8 @@ static struct scsi_dev_info_list *scsi_dev_info_list_find(const char *vendor, * * Returns: 0 OK, -error on failure. **/ -int scsi_dev_info_list_del_keyed(char *vendor, char *model, int key) +int scsi_dev_info_list_del_keyed(char *vendor, char *model, + enum scsi_devinfo_key key) { struct scsi_dev_info_list *found; @@ -594,7 +596,7 @@ blist_flags_t scsi_get_device_flags(struct scsi_device *sdev, blist_flags_t scsi_get_device_flags_keyed(struct scsi_device *sdev, const unsigned char *vendor, const unsigned char *model, - int key) + enum scsi_devinfo_key key) { struct scsi_dev_info_list *devinfo; @@ -776,7 +778,7 @@ void scsi_exit_devinfo(void) * Adds the requested list, returns zero on success, -EEXIST if the * key is already registered to a list, or other error on failure. */ -int scsi_dev_info_add_list(int key, const char *name) +int scsi_dev_info_add_list(enum scsi_devinfo_key key, const char *name) { struct scsi_dev_info_list_table *devinfo_table = scsi_devinfo_lookup_by_key(key); @@ -808,7 +810,7 @@ EXPORT_SYMBOL(scsi_dev_info_add_list); * frees the list itself. Returns 0 on success or -EINVAL if the key * can't be found. */ -int scsi_dev_info_remove_list(int key) +int scsi_dev_info_remove_list(enum scsi_devinfo_key key) { struct list_head *lh, *lh_next; struct scsi_dev_info_list_table *devinfo_table = diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h index a5946cd64caa..61024db5953d 100644 --- a/drivers/scsi/scsi_priv.h +++ b/drivers/scsi/scsi_priv.h @@ -45,7 +45,7 @@ static inline void scsi_log_completion(struct scsi_cmnd *cmd, int disposition) /* scsi_devinfo.c */ /* list of keys for the lists */ -enum { +enum scsi_devinfo_key { SCSI_DEVINFO_GLOBAL = 0, SCSI_DEVINFO_SPI, }; @@ -56,13 +56,15 @@ extern blist_flags_t scsi_get_device_flags(struct scsi_device *sdev, extern blist_flags_t scsi_get_device_flags_keyed(struct scsi_device *sdev, const unsigned char *vendor, const unsigned char *model, - int key); + enum scsi_devinfo_key key); extern int scsi_dev_info_list_add_keyed(int compatible, char *vendor, char *model, char *strflags, - blist_flags_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); + blist_flags_t flags, + enum scsi_devinfo_key key); +extern int scsi_dev_info_list_del_keyed(char *vendor, char *model, + enum scsi_devinfo_key key); +extern int scsi_dev_info_add_list(enum scsi_devinfo_key key, const char *name); +extern int scsi_dev_info_remove_list(enum scsi_devinfo_key key); extern int __init scsi_init_devinfo(void); extern void scsi_exit_devinfo(void);