From patchwork Wed Apr 18 15:01:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 10348341 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 19C5460244 for ; Wed, 18 Apr 2018 15:03:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D2AD22299 for ; Wed, 18 Apr 2018 15:03:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0BA2228681; Wed, 18 Apr 2018 15:03:38 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, 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 2968C28389 for ; Wed, 18 Apr 2018 15:03:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753365AbeDRPD2 (ORCPT ); Wed, 18 Apr 2018 11:03:28 -0400 Received: from mx2.suse.de ([195.135.220.15]:39644 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752648AbeDRPD1 (ORCPT ); Wed, 18 Apr 2018 11:03:27 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 3FF7BAF1B; Wed, 18 Apr 2018 15:03:25 +0000 (UTC) From: Johannes Thumshirn To: "Martin K . Petersen" Cc: Bart Van Assche , Hannes Reinecke , James Bottomley , Linux SCSI Mailinglist , Douglas Gilbert , Johannes Thumshirn Subject: [VERY EARLY RFC 04/13] scsi: add enum for driver byte codes Date: Wed, 18 Apr 2018 17:01:07 +0200 Message-Id: <20180418150116.18807-5-jthumshirn@suse.de> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180418150116.18807-1-jthumshirn@suse.de> References: <20180418150116.18807-1-jthumshirn@suse.de> 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 Add enum for driver byte codes and adopt set_driver_byte()'s signature. Signed-off-by: Johannes Thumshirn Suggested-by: Bart Van Assche --- include/scsi/scsi.h | 33 ++++++++++++++++++++------------- include/scsi/scsi_cmnd.h | 3 ++- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h index 4dfc5e11a5b2..2694faafaddf 100644 --- a/include/scsi/scsi.h +++ b/include/scsi/scsi.h @@ -161,21 +161,24 @@ enum scsi_host_byte { DID_ALLOC_FAILURE, /* Space allocation on the device failed */ DID_MEDIUM_ERROR, /* Medium error */ }; -#define DRIVER_OK 0x00 /* Driver status */ -/* - * These indicate the error that occurred, and what is available. - */ +enum scsi_driver_byte { + DRIVER_OK, /* Driver status */ -#define DRIVER_BUSY 0x01 -#define DRIVER_SOFT 0x02 -#define DRIVER_MEDIA 0x03 -#define DRIVER_ERROR 0x04 + /* + * These indicate the error that occurred, and what is available. + */ -#define DRIVER_INVALID 0x05 -#define DRIVER_TIMEOUT 0x06 -#define DRIVER_HARD 0x07 -#define DRIVER_SENSE 0x08 + DRIVER_BUSY, + DRIVER_SOFT, + DRIVER_MEDIA, + DRIVER_ERROR, + + DRIVER_INVALID, + DRIVER_TIMEOUT, + DRIVER_HARD, + DRIVER_SENSE, +}; /* * Internal return values. @@ -215,7 +218,11 @@ static inline enum scsi_host_byte host_byte(int result) { return (result >> 16) & 0xff; } -#define driver_byte(result) (((result) >> 24) & 0xff) + +static inline enum scsi_driver_byte driver_byte(int result) +{ + return (result >> 24) & 0xff; +} #define sense_class(sense) (((sense) >> 4) & 0x7) #define sense_error(sense) ((sense) & 0xf) diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index b678cd99b12b..da8ea89ccc0a 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -348,7 +348,8 @@ static inline void set_host_byte(struct scsi_cmnd *cmd, cmd->result = (cmd->result & 0xff00ffff) | (status << 16); } -static inline void set_driver_byte(struct scsi_cmnd *cmd, char status) +static inline void set_driver_byte(struct scsi_cmnd *cmd, + enum scsi_driver_byte status) { cmd->result = (cmd->result & 0x00ffffff) | (status << 24); }