Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp6358802pxb; Thu, 27 Jan 2022 12:03:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJxzt/0iUpT9kQZ3emqhUfykM7qmFSyqpOai38jLgeY0UCjZMah9bmwWcXWQXKCJ8KEksnno X-Received: by 2002:a17:90b:2251:: with SMTP id hk17mr15708606pjb.210.1643313822270; Thu, 27 Jan 2022 12:03:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643313822; cv=none; d=google.com; s=arc-20160816; b=oMGajYt3rYIKfPiVVe4Hn/8w9hUlGZr0PobXX8YllpsF2o0rIoUHZU2aK232z3gZwD AQYzkgHpyLufaXCBSbphqD2s3WEY0JVAPR+VFMuF/ocSLFBTtcoXMgxRwj7HkW1f9o+b KMn2etOahgqfqxiZbLyiG7zFSeZKGTN4VTAwzW7yqgzdCv9rxIUV3k8O9/Oxlp42pK6B Xd3LnYjR+uTbb0c+0KSsyhgLwongqbqoeT0hMYdbUcgMARWxXIIZdaVADkA7ngibZUxU LtaYmOXGpE0rYkjbu9Z8zmBHldriQfidjc+rpyVrkrM5OJrkt6N4Go5Hfp6En0WvVSz8 0vTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=hpmrceh9Hvtf1qNV/pP9VE/DeLyArJZlU6b1C/+awzo=; b=fUcFXfdbCygw60nUZw2THdUJZ0vRjuEU7Os3Qk+SDCgp0vhXwRnnAiUhqsNY4rBl7e QoQz6/YphyKGvByg34PUxtNhJVbGk55NHQrUHc25rqe7jEePFxYl5dUZIuQa9gN85azm OqRdIyXnf7ovQbCCqA7huMDp2WuA4UKS9G3daZcV35Gpk/t0+hqj/0+m6781mENw3zJk nT+PlBMwotgT5SKSyaK/AWsYMlSbI5xO/sC5yrY2l/r/yJGF19fLKVLYwv4fBta9Q8z6 giwat7P3HT1Yg6ukZLDZdHEV5pcQcOa2awJ4NN04WaNVNdF/pH49jWO3QmGsoNdhHDXT soxQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j9si3034170pfc.94.2022.01.27.12.03.30; Thu, 27 Jan 2022 12:03:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240411AbiA0Lbv (ORCPT + 99 others); Thu, 27 Jan 2022 06:31:51 -0500 Received: from szxga03-in.huawei.com ([45.249.212.189]:32125 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240384AbiA0Lbs (ORCPT ); Thu, 27 Jan 2022 06:31:48 -0500 Received: from dggeme756-chm.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Jkyym27Hmz8wgG; Thu, 27 Jan 2022 19:28:48 +0800 (CST) Received: from [10.40.193.166] (10.40.193.166) by dggeme756-chm.china.huawei.com (10.3.19.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.21; Thu, 27 Jan 2022 19:31:46 +0800 Subject: Re: [PATCH 01/16] scsi: libsas: Use enum for response frame DATAPRES field To: John Garry , , , , , References: <1643110372-85470-1-git-send-email-john.garry@huawei.com> <1643110372-85470-2-git-send-email-john.garry@huawei.com> CC: , , , , , , , From: "chenxiang (M)" Message-ID: <4a2986a4-8293-2a25-8ee1-109ff8aa0bc3@hisilicon.com> Date: Thu, 27 Jan 2022 19:31:46 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <1643110372-85470-2-git-send-email-john.garry@huawei.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.40.193.166] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggeme756-chm.china.huawei.com (10.3.19.102) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi John, 在 2022/1/25 19:32, John Garry 写道: > As defined in table 126 of the SAS spec 1.1, use an enum for the DATAPRES > field, which makes reading the code easier. > > Signed-off-by: John Garry > --- > drivers/scsi/libsas/sas_task.c | 12 +++++++++--- > 1 file changed, 9 insertions(+), 3 deletions(-) > > diff --git a/drivers/scsi/libsas/sas_task.c b/drivers/scsi/libsas/sas_task.c > index 2966ead1d421..7240fd22b154 100644 > --- a/drivers/scsi/libsas/sas_task.c > +++ b/drivers/scsi/libsas/sas_task.c > @@ -7,6 +7,12 @@ > #include > #include > > +enum { > + NO_DATA = 0, > + RESPONSE_DATA = 1, > + SENSE_DATA = 2, > +}; > + I find that iu->datapres is also used in other drivers with 0/1/2, and maybe it is worth to replace all of them with those enum. 2 290 /home/chenxiang/kernel_next/kernel-dev/drivers/scsi/aic94xx/aic94xx_tmf.c <<>> if (ru->datapres == 1) 5 1055 /home/chenxiang/kernel_next/kernel-dev/drivers/scsi/isci/request.c <<>> if (datapres == 1 || datapres == 2) { 6 1740 /home/chenxiang/kernel_next/kernel-dev/drivers/scsi/isci/request.c <<>> if (resp_iu->datapres == 0x01 || 7 1741 /home/chenxiang/kernel_next/kernel-dev/drivers/scsi/isci/request.c <<>> resp_iu->datapres == 0x02) { 17 1641 /home/chenxiang/kernel_next/kernel-dev/drivers/scsi/mvsas/mv_sas.c <<>> iu->datapres = 2; > /* fill task_status_struct based on SSP response frame */ > void sas_ssp_task_response(struct device *dev, struct sas_task *task, > struct ssp_response_iu *iu) > @@ -15,11 +21,11 @@ void sas_ssp_task_response(struct device *dev, struct sas_task *task, > > tstat->resp = SAS_TASK_COMPLETE; > > - if (iu->datapres == 0) > + if (iu->datapres == NO_DATA) > tstat->stat = iu->status; > - else if (iu->datapres == 1) > + else if (iu->datapres == RESPONSE_DATA) > tstat->stat = iu->resp_data[3]; > - else if (iu->datapres == 2) { > + else if (iu->datapres == SENSE_DATA) { > tstat->stat = SAS_SAM_STAT_CHECK_CONDITION; > tstat->buf_valid_size = > min_t(int, SAS_STATUS_BUF_SIZE,