From patchwork Wed Dec 7 20:46:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asutosh Das X-Patchwork-Id: 31035 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp397304wrr; Wed, 7 Dec 2022 12:48:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf6lC3x3sk90CkuzoObxAjczIxHFcB8o65qrOW0YE78OBfYN8LI8w891B99h2fzqpYz6uQDu X-Received: by 2002:a17:90a:784b:b0:219:f34e:67a7 with SMTP id y11-20020a17090a784b00b00219f34e67a7mr11823319pjl.24.1670446119822; Wed, 07 Dec 2022 12:48:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670446119; cv=none; d=google.com; s=arc-20160816; b=TNSdPR11yCn1/yZ55rVrcjRfb1nvKM2jYW8Hst6+nQBMADN9JSby4RbR/c6cEIARGX ELhyC31YZEF5QVcKUQun65L9+/QRj7Qpu0U0RmLnxFIHNpcdbOr9LuzrhPuQAzomLoLy t9s0Ni9mtIemeX/GLNt7tXU571x6Kb5bsaKadlBvI4TvrKkxLC8OHJMZWKG7MhFoUIM0 zRrwSE4u/kRciAzIeA44aLSIZ5Xm0nosgnl1kXniD76Um00zvcVpomO+o1u3h0p+8VCK tdTWzImYva2DpAbc6cCJCJrnX5WBIbiwj2AyTJQimiIPcj5NwDOf2ccsxqKqHKzXl5wf NdBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=7S4T/d7o/o3m7oWFT/7SEWHru8hmIy5SxOT8QbpPUxE=; b=aBnq8BiCofMxxnY1FMVf7/ehqNxYfkYcUF6Hbdwg/L5Zji2bgp0BHWDvq3nAcIftWZ Yh5JABc0Wm++o1lk3C4TW2MzxC3WAUOTs9KB7ABeqBLGo9nuPv/yUQtrpxlPcFHa0rfZ n/fwKbfuf27dW71HkcXA9xgi+hR+4dpFl5xl++VrWyykKH2eaG7SjMJZISlzxY1j+s5S vfBHGOMCrW8uXfFmZAymJ2R5Rm3bqWGOOAvfNvCRTXrO3lgQG1CHODQt8sU+T69UB6nw prRJF9K+VDzxAoof66RVs8n8D7tCUF/QdQXthhjdXS5ISuEnLJQQz7rqrc2UwqlGpW4b IZcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=ElUEE2f1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id be17-20020a056a001f1100b0056ec686183fsi20945812pfb.366.2022.12.07.12.48.26; Wed, 07 Dec 2022 12:48:39 -0800 (PST) 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=@quicinc.com header.s=qcppdkim1 header.b=ElUEE2f1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229954AbiLGUr3 (ORCPT + 99 others); Wed, 7 Dec 2022 15:47:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229865AbiLGUrY (ORCPT ); Wed, 7 Dec 2022 15:47:24 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89C6D6DCCD; Wed, 7 Dec 2022 12:47:14 -0800 (PST) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B7JvYBq028127; Wed, 7 Dec 2022 20:46:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=7S4T/d7o/o3m7oWFT/7SEWHru8hmIy5SxOT8QbpPUxE=; b=ElUEE2f1hyvqDX+Boq3hZgcRPVykO/Pt8NGUVqtu8hTmbp3HEUxFXzbmyrog4n/StMjW 5ukV4J0RRZD36sPRB+DSn4ke9AP56uSNagdKAHnJUlsbDxj41IZzw+RBGGIWuB7MxM+2 d+urTA4xdSn4PBYJOvtORXF+t2pXJ4dh7J/lrGPR6BEjhPx59zmdHcQ6NiIisEtR3epQ uDxhOY6+sRX9LPA8I52ZbXkyReYzBo49g+hFZiDtLH54PyIUab1b+/uucgnYS/4+y0oG kBOq1nvfbEGAeoz8Fzqlb687hP+ziI0jDwRGOjrcf7ZwcG196qwripxIyPhFsmS5/n3f Xg== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3maype0ab3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 07 Dec 2022 20:46:47 +0000 Received: from nasanex01a.na.qualcomm.com ([10.52.223.231]) by NASANPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 2B7KkkZp019065 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 7 Dec 2022 20:46:46 GMT Received: from asutoshd-linux1.qualcomm.com (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Wed, 7 Dec 2022 12:46:45 -0800 From: Asutosh Das To: , , CC: , , , , , , , , , Asutosh Das , , Alim Akhtar , "James E.J. Bottomley" , Jinyoung Choi , open list Subject: [PATCH v10 01/16] ufs: core: Optimize duplicate code to read extended feature Date: Wed, 7 Dec 2022 12:46:12 -0800 Message-ID: <08bb2c55df99717201238acb3a3b024b907309fb.1670445698.git.quic_asutoshd@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 5ZFfwJ3n5oTjZAdeQaLUCqIIfDsVaAcf X-Proofpoint-ORIG-GUID: 5ZFfwJ3n5oTjZAdeQaLUCqIIfDsVaAcf X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-07_09,2022-12-07_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 bulkscore=0 suspectscore=0 priorityscore=1501 adultscore=0 mlxlogscore=999 impostorscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212070174 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS 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?1751589710192321417?= X-GMAIL-MSGID: =?utf-8?q?1751589710192321417?= The code to parse the extended feature is duplicated twice in the ufs core. Replace the duplicated code with a function. Signed-off-by: Asutosh Das Reviewed-by: Bart Van Assche Reviewed-by: Manivannan Sadhasivam --- drivers/ufs/core/ufshcd.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 2dbe249..6ea22b5 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -215,6 +215,17 @@ ufs_get_desired_pm_lvl_for_dev_link_state(enum ufs_dev_pwr_mode dev_state, return UFS_PM_LVL_0; } +static unsigned int ufs_get_ext_ufs_feature(struct ufs_hba *hba, + const u8 *desc_buf) +{ + if (hba->desc_size[QUERY_DESC_IDN_DEVICE] < + DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP + 4) + return 0; + + return get_unaligned_be32(desc_buf + + DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP); +} + static const struct ufs_dev_quirk ufs_fixups[] = { /* UFS cards deviations table */ { .wmanufacturerid = UFS_VENDOR_MICRON, @@ -7608,13 +7619,7 @@ static void ufshcd_wb_probe(struct ufs_hba *hba, const u8 *desc_buf) (hba->dev_quirks & UFS_DEVICE_QUIRK_SUPPORT_EXTENDED_FEATURES))) goto wb_disabled; - if (hba->desc_size[QUERY_DESC_IDN_DEVICE] < - DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP + 4) - goto wb_disabled; - - ext_ufs_feature = get_unaligned_be32(desc_buf + - DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP); - + ext_ufs_feature = ufs_get_ext_ufs_feature(hba, desc_buf); if (!(ext_ufs_feature & UFS_DEV_WRITE_BOOSTER_SUP)) goto wb_disabled; @@ -7668,7 +7673,7 @@ static void ufshcd_temp_notif_probe(struct ufs_hba *hba, const u8 *desc_buf) if (!(hba->caps & UFSHCD_CAP_TEMP_NOTIF) || dev_info->wspecversion < 0x300) return; - ext_ufs_feature = get_unaligned_be32(desc_buf + DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP); + ext_ufs_feature = ufs_get_ext_ufs_feature(hba, desc_buf); if (ext_ufs_feature & UFS_DEV_LOW_TEMP_NOTIF) mask |= MASK_EE_TOO_LOW_TEMP;