Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6829979rwb; Tue, 22 Nov 2022 20:40:00 -0800 (PST) X-Google-Smtp-Source: AA0mqf58upEYEXGnZ+n386fepdF9KWP34/Bqk38hZz2SgQlCZ41ygIc1x3apPJfXhUwZ46haug6W X-Received: by 2002:a05:6402:2887:b0:460:f0c0:f9c8 with SMTP id eg7-20020a056402288700b00460f0c0f9c8mr13967080edb.181.1669178400076; Tue, 22 Nov 2022 20:40:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669178400; cv=none; d=google.com; s=arc-20160816; b=r+coeapW/t6n9RLuCQ9V3F8AVa+9csQnFEcJlNAHNkXUTzHXCTmJPcgjCL7nZP6c96 DfDEVgGV/wd/fkUbbe2FL8M/JcX/x2rGYdGHvjgaSrg7Sf8lu4bEneUanT7wH9JHqYui lKrvgdhnzb2WakscP8rHW1pNPV4/nkbkb3CZNriTM5VTcKwMRGWap0Sr55fJ3KqSpizt Nx0MZH5cvJqE4EHwPCKrNfl1P+/4D3EY4Ore65Z4rfs1p0i3aLAX5BANzsBsD+4WBiew wFLTiLeWfIEkJZr1ce5tJP48TFy4RySz3+TcUmewL9/Bn8A9GTpQhjq1E28lBE8Vv7XM ibBw== 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=O0vbz2BcD8nypc0T5V/ro0SgDRhVVY65U9mKEqdSH9g=; b=T9WV02sr89eVFm3iNFAXadlZCvW+Iq9g8N2OhBlKtR6/W8Yir5eNVvKxi0cQxucCYp G0yLKJ+riWgHmwMNREVVEZsKSs7M+ySGgVZ1+G9e3VH2hqsbUQZjGVszID9L9o+W3KD1 hgUdKDidbS8JUEkmM9iQZpreLX1BesSrE9ju4iI+tVgRxYmnQyH08ybZQf4hR1TIKI8k DMApImpvndu8VmcNzoPSxYMwzmrnvkEefRn5SfUuUVNi9igLFSEUDgHVM5v23Dwij5h3 Z0XtTnt6wxEtsxbgKzSwkum9UJ/RGaMk3H/PWjTht08afH0Lvcay7TI2AtWx7wOiXX9y 4QqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="n/eZhjeO"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n11-20020a170906118b00b007ae4717bf1esi10598203eja.99.2022.11.22.20.39.33; Tue, 22 Nov 2022 20:40:00 -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="n/eZhjeO"; 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 S235555AbiKWEMD (ORCPT + 89 others); Tue, 22 Nov 2022 23:12:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234338AbiKWEMA (ORCPT ); Tue, 22 Nov 2022 23:12:00 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 169CE6E571; Tue, 22 Nov 2022 20:11:58 -0800 (PST) Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AN3sGQ5020416; Wed, 23 Nov 2022 04:11:36 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=O0vbz2BcD8nypc0T5V/ro0SgDRhVVY65U9mKEqdSH9g=; b=n/eZhjeOKuX4JAifCYKZm7VTlCT44I0bXFSBpQJGVmOVXp1hheDBexCelvaxZPcKViNk bjDFSSJAUMF3wSvC5C+3aKyYCq7+AL/24uTTYq7SdrVeLUpeb/HJKolgPYP3JCvIkE4y slCVQywsp/bGjHJ6bbe9YlnTF4kcm8QEqt4buXuwoYRXljrCytoOAd+EG7e1VU43Wy/S RJAe8yhKbTvON7ReMPFMfmorFs8W/V5V1OC3BWfqH+/EaATp9bKsNksFOTAwiHpdGZ0M rDk4q9yZARVqZdaPNGVGAZ2I60CyOMYRtB3kqzYIbwEySLmWbT8RpLd/FUGc52zIE9Kb QA== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3m15se8px3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 04:11:35 +0000 Received: from nasanex01a.na.qualcomm.com ([10.52.223.231]) by NASANPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 2AN4BYJT022388 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 04:11:34 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; Tue, 22 Nov 2022 20:11:34 -0800 From: Asutosh Das To: , , CC: , , , , , , , , , Asutosh Das , , Alim Akhtar , "James E.J. Bottomley" , Jinyoung Choi , open list Subject: [PATCH v5 01/16] ufs: core: Optimize duplicate code to read extended feature Date: Tue, 22 Nov 2022 20:10:14 -0800 Message-ID: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain 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-ORIG-GUID: -OVg4znrBjpOVQPLA0Mbg5aj6sUD2xug X-Proofpoint-GUID: -OVg4znrBjpOVQPLA0Mbg5aj6sUD2xug 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-22_13,2022-11-18_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 suspectscore=0 impostorscore=0 spamscore=0 clxscore=1015 mlxlogscore=999 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211230030 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 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; -- 2.7.4