From patchwork Wed Nov 9 19:41:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asutosh Das X-Patchwork-Id: 17779 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp527090wru; Wed, 9 Nov 2022 11:44:08 -0800 (PST) X-Google-Smtp-Source: AMsMyM47AC080lG37KGxKbvuGuCyjcMpXSgTyRMj1+OkeYquPVat0E75CYZtfuQzj6nBwuK1tjz3 X-Received: by 2002:a05:6402:b6b:b0:461:b9b2:6d58 with SMTP id cb11-20020a0564020b6b00b00461b9b26d58mr61784394edb.186.1668023047948; Wed, 09 Nov 2022 11:44:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668023047; cv=none; d=google.com; s=arc-20160816; b=FLdJajMJa6/VgN2IfLeyXj5MrQTIEbWLHhPPTZdCV8FRQbm6CfYvy89z9e13SplQAG zo5yCfupwKJ+4xnN9kfNNUJZvEJ3mg01wGYJzWw7qc+kxuGBhv75PNbSQd5SFm0gPNvm kW35sZra0NLJjl3RSI9c9A6KX9OrP6IWMKbpP0VizrdnnA8OtB4dYJKfFKIFaitOwCEG yB8H9zZzcaB5WikyHKlCfe51p97Td0HIrQqTeSMlDfo0uf0CaBsB7NNuouDUZ7bDkQvC HDoDIzxz2VWt56RBaB9oVYCEkVexf2EYw/xSFWwX6G84SpvGqUwcOmWDFCDnRysO2eNN OflQ== 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=PFoSja45MgEdGGsc+D92k6nx+InvI+1ckGwGv/IXQu8=; b=psvjw13ILNVDjmL6DP1LAdu/c4sN7UGVdhLbWXa6lbpnPPBrB3Us+d6f5hCBeYjQXN +5ib5O1KhEP/jPmRRq3wDbAv38T8XAzJWWoL6bKhVgYiamTrN9jKivsn3Ge8czoSZbaM mrtzfPmQbzGsK7IqDBmyfFwkdD+vokh2uZvE9kepZahwkN0AyS9JeNW5gsY1UKA3JESe ME/SSQBeYvMSIgMGCSOiXIv8cOFi/jiD63UzyT8FdMLHfB6maarijrKBSOZo/Z43yw0M 2E3hI56C2oewTZ4peCd1oToyK5jFfVS3EVQAGRLz+GH3I51dH8c0vWG54DQxyEGISPp8 1jVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="FNum/s5p"; 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 s6-20020a056402520600b00461d2ed78afsi20677829edd.563.2022.11.09.11.43.44; Wed, 09 Nov 2022 11:44:07 -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="FNum/s5p"; 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 S231828AbiKITnT (ORCPT + 99 others); Wed, 9 Nov 2022 14:43:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231815AbiKITnS (ORCPT ); Wed, 9 Nov 2022 14:43:18 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A904818B2A; Wed, 9 Nov 2022 11:43:16 -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 2A9Jh3fY017965; Wed, 9 Nov 2022 19:43:03 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=PFoSja45MgEdGGsc+D92k6nx+InvI+1ckGwGv/IXQu8=; b=FNum/s5pEszuueCG5w8FGqupdZVMvE/EQ/qdwQxFqaoBD1TfijlDdiPX6pthgUo08Nkg 65k/tGPalZWep5NIRy+HUyyaQo96hiT3tEU5CpcnVE3N9rLs7Hhpc9qoo0eiXhBxWsG+ hmQzEg6IxWvJEPyZ9q3AqlC2T7d142XP48PG1xDB1nWnOHkyhHMJvbQLsz8r46ETbNrQ fGMO2Z/tZImXn1FDwgjH/hns5+K1RQGeCDj3enwd4I+jOYZamX0agXOA8H5J3A26diny MvaodICvC9BJDy1CsAFTjZSqLUk4J5Ru0VRNrRNMzEVzkIfqYCSqA8apyUchTkdAzDag NQ== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3krgbk8bb7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Nov 2022 19:43:03 +0000 Received: from nasanex01a.na.qualcomm.com ([10.52.223.231]) by NASANPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 2A9Jh1ZB031542 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 9 Nov 2022 19:43:01 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.29; Wed, 9 Nov 2022 11:43:01 -0800 From: Asutosh Das To: , , CC: , , , , , , , , , Asutosh Das , , Alim Akhtar , "James E.J. Bottomley" , Jinyoung Choi , open list Subject: [PATCH v4 01/16] ufs: core: Optimize duplicate code to read extended feature Date: Wed, 9 Nov 2022 11:41:26 -0800 Message-ID: <0cf160f6fe7426340f8a5e68dc95edc751311e84.1668022680.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: nasanex01a.na.qualcomm.com (10.52.223.231) 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: zOrJDSN22hDgKLxdmdzmxRknWMXxVYw4 X-Proofpoint-ORIG-GUID: zOrJDSN22hDgKLxdmdzmxRknWMXxVYw4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-09_06,2022-11-09_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 adultscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 lowpriorityscore=0 bulkscore=0 impostorscore=0 priorityscore=1501 clxscore=1015 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211090148 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_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?1749048935249492534?= X-GMAIL-MSGID: =?utf-8?q?1749048935249492534?= 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 --- 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 768cb49..c9d7b78 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, @@ -7584,13 +7595,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; @@ -7644,7 +7649,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;