From patchwork Tue Oct 18 18:16:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bean Huo X-Patchwork-Id: 4289 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp2097881wrs; Tue, 18 Oct 2022 11:19:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4LScWXkPWTdNU8yJUqZxY7diNuvKzSwQ/JFcie1hd0gzUTaNrQcUVKpdSdFXEp2/zhV5q9 X-Received: by 2002:a17:90a:e291:b0:20a:acde:1c43 with SMTP id d17-20020a17090ae29100b0020aacde1c43mr5007809pjz.62.1666117196480; Tue, 18 Oct 2022 11:19:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666117196; cv=none; d=google.com; s=arc-20160816; b=ZbBG3WHD4dyPNPiB/4IGVNmwKAUxmyMQfXJFWN3rgcrCwxUQ9axoWJf6PNPB3XflVW hDUXVX31pIMmHeFSZ3tC87CJaPT0bnb4WesxBfB37mVgt+Th8DALB3s1YpbhfCuqb254 4F8IyoVHjJhuLGcoKvy1MLy/qj4t6BmKO0Sp/RkovK8k1vkDTSRO7KbXWFXbA2rMiLcD yNaC/oHhSeXnrLwOSFI6JMHvs2/RUYn1OjF4rJAB8UhlX0K9W0q/eJ39V5H6yFSzNVnj t1CVBYxxtbTQOwfAyM7fMq6+g1dVIKcL1R9F2Op2lv3q1z5kHPT239QdjiwfxckWdR4j dMYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=S91eEeMsyosroXGbKbWQ4sKh+HjZ4BdVLK1HuQ79ma4=; b=Mypsk7057Ul0Z6LPAO120NnXmvhksKv+fswBRIj92nIAcEUOpmh5m8dR7T0NLbVgnH EOW74LcxefP68uNTmvAFV4MQE8Imyup8IXAhfKE9KvN892ToWEzl44him8Qr7Sxhp724 6ZDUTxnmAqkCaS+kMNIaXatOXogrweq5GQYApZ2I4WkgP3pskAe+RRrTG6rcwm7CZ3T4 e1RzgSa2Hvp8sKXna3FDTpNEf8AaNAEdI6TZkc+AbvCblit41gcBqhwRNN9gG6xC7e2K idR1/dcPIE2JPE1zxMK9TjYKulFU3zQZRxwBAP5Qf4FPu464//jcHy7ER0H4CCAA82AL wvoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@iokpp.de header.s=strato-dkim-0002 header.b=SMvpMKHA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v9-20020a63b949000000b0045a2b6e1192si16048901pgo.233.2022.10.18.11.19.36; Tue, 18 Oct 2022 11:19:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@iokpp.de header.s=strato-dkim-0002 header.b=SMvpMKHA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230041AbiJRSQz (ORCPT + 99 others); Tue, 18 Oct 2022 14:16:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229835AbiJRSQr (ORCPT ); Tue, 18 Oct 2022 14:16:47 -0400 Received: from mo4-p02-ob.smtp.rzone.de (mo4-p02-ob.smtp.rzone.de [85.215.255.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F25227D1EF; Tue, 18 Oct 2022 11:16:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1666116999; s=strato-dkim-0002; d=iokpp.de; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=S91eEeMsyosroXGbKbWQ4sKh+HjZ4BdVLK1HuQ79ma4=; b=SMvpMKHAiIhPyP5VZ0gU8sdbi+TgCK//2f6arD8TC8fRW2PhXWkxHSZ667C2Vqlge8 93fbl9Bnogr5fqRNtQZvkQxDrx5DQNDDtD4NK4LGUg2lH1t57hxG5o7M7f9cBRA3MATX V3e+wAcWVaJq/KdjOK3NuR8pSXUv067QZ3lXaNzfdUM5yPFbzcbKMGImDXAMEZfxeY90 W24yPp4XN67Zck90rj2HGg+w0f5v6WRlVPFimpAcUntjhdudqanc9KzUojurGNrvbz6O xw12dIVIzBTk7JOZc9hKsyMoncVwfcND6+f4+2fJVvuasdHS1IxT4PW+5q3aPHkVCIls yo8Q== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":LmkFe0i9dN8c2t4QQyGBB/NDXvjDB6pBSedrgBzPc9DUyubU4DD2QzemV2tdlNlNRZBXiUw=" X-RZG-CLASS-ID: mo01 Received: from linux.micron.com by smtp.strato.de (RZmta 48.2.0 AUTH) with ESMTPSA id zad98cy9IIGcYST (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Tue, 18 Oct 2022 20:16:38 +0200 (CEST) From: Bean Huo To: alim.akhtar@samsung.com, avri.altman@wdc.com, asutoshd@codeaurora.org, jejb@linux.ibm.com, martin.petersen@oracle.com, stanley.chu@mediatek.com, beanhuo@micron.com, bvanassche@acm.org, tomas.winkler@intel.com, cang@codeaurora.org, daejun7.park@samsung.com, huobean@gmail.com Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/3] scsi: ufs: core: Remove unnecessary if statement Date: Tue, 18 Oct 2022 20:16:25 +0200 Message-Id: <20221018181627.326657-2-beanhuo@iokpp.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221018181627.326657-1-beanhuo@iokpp.de> References: <20221018181627.326657-1-beanhuo@iokpp.de> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747050505217627871?= X-GMAIL-MSGID: =?utf-8?q?1747050505217627871?= From: Bean Huo LUs with WB potential support are properly checked in ufshcd_wb_probe() before calling ufshcd_read_unit_desc_param(), so remove this unnecessary if-checkup in ufs_is_valid_unit_desc_lun() to match its function definition. Signed-off-by: Bean Huo --- drivers/ufs/core/ufs-sysfs.c | 3 +-- drivers/ufs/core/ufshcd-priv.h | 6 +----- drivers/ufs/core/ufshcd.c | 2 +- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/ufs/core/ufs-sysfs.c b/drivers/ufs/core/ufs-sysfs.c index 53aea56d1de1..eb6b278c4e79 100644 --- a/drivers/ufs/core/ufs-sysfs.c +++ b/drivers/ufs/core/ufs-sysfs.c @@ -1234,8 +1234,7 @@ static ssize_t _pname##_show(struct device *dev, \ struct scsi_device *sdev = to_scsi_device(dev); \ struct ufs_hba *hba = shost_priv(sdev->host); \ u8 lun = ufshcd_scsi_to_upiu_lun(sdev->lun); \ - if (!ufs_is_valid_unit_desc_lun(&hba->dev_info, lun, \ - _duname##_DESC_PARAM##_puname)) \ + if (!ufs_is_valid_unit_desc_lun(&hba->dev_info, lun)) \ return -EINVAL; \ return ufs_sysfs_read_desc_param(hba, QUERY_DESC_IDN_##_duname, \ lun, _duname##_DESC_PARAM##_puname, buf, _size); \ diff --git a/drivers/ufs/core/ufshcd-priv.h b/drivers/ufs/core/ufshcd-priv.h index f68ca33f6ac7..a9e8e1f5afe7 100644 --- a/drivers/ufs/core/ufshcd-priv.h +++ b/drivers/ufs/core/ufshcd-priv.h @@ -293,16 +293,12 @@ static inline int ufshcd_rpm_put(struct ufs_hba *hba) * @lun: LU number to check * @return: true if the lun has a matching unit descriptor, false otherwise */ -static inline bool ufs_is_valid_unit_desc_lun(struct ufs_dev_info *dev_info, - u8 lun, u8 param_offset) +static inline bool ufs_is_valid_unit_desc_lun(struct ufs_dev_info *dev_info, u8 lun) { if (!dev_info || !dev_info->max_lu_supported) { pr_err("Max General LU supported by UFS isn't initialized\n"); return false; } - /* WB is available only for the logical unit from 0 to 7 */ - if (param_offset == UNIT_DESC_PARAM_WB_BUF_ALLOC_UNITS) - return lun < UFS_UPIU_MAX_WB_LUN_ID; return lun == UFS_UPIU_RPMB_WLUN || (lun < dev_info->max_lu_supported); } diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 7c15cbc737b4..85679e8a043b 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -3609,7 +3609,7 @@ static inline int ufshcd_read_unit_desc_param(struct ufs_hba *hba, * Unit descriptors are only available for general purpose LUs (LUN id * from 0 to 7) and RPMB Well known LU. */ - if (!ufs_is_valid_unit_desc_lun(&hba->dev_info, lun, param_offset)) + if (!ufs_is_valid_unit_desc_lun(&hba->dev_info, lun)) return -EOPNOTSUPP; return ufshcd_read_desc_param(hba, QUERY_DESC_IDN_UNIT, lun,