Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp750815rdb; Thu, 18 Jan 2024 19:24:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IGw54zV49zzn22l/lKX9k8654IrZm7uZML7rNKzm5GVi8BrLaXj9m+8rlk660p5zbhf3/yk X-Received: by 2002:aa7:d587:0:b0:559:6abf:96f1 with SMTP id r7-20020aa7d587000000b005596abf96f1mr1163252edq.12.1705634646766; Thu, 18 Jan 2024 19:24:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705634646; cv=pass; d=google.com; s=arc-20160816; b=G3GGphuAROQICvYwVFb4yVhkmi1b9/jIQ+0WVE0v7GZONRh8YIaJbiS/C1dGK7FNQx zH/81sslV3d+JrlYU5fm7VGy3WO6Z2SgvEjtCNoayAnmC7vltk+t1Mwpty+X7yGMtWyY 81M3gOvRWEgZnDIQvx+uzfXTWlGSiNGwNcTW0BuukO3c47hX+2LxYsi5PK31gTT/nLQi h49N7rrqKQMIFHVYTibWX/kKk2xg286sjmtgkq+R0ofaAA1/cSb0Wg/pqydWxXlISHAU NL7cNt6k35bslw4csX9iR9UulJ+x4RKFiZ2xS+xvooT76/5vIITdcsWBgq9aV2vysvuU LvWg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=eG0cw3V2V7bP1GdeOMsXcfVKOjDgrWaClaMQX8x+Rcc=; fh=eSQnxfYZD66NgboVDB7L9mVH46SSiFzLE3y556oFJtg=; b=dmFmTp6pskZ8/8uKB5hZgPtsLwQOXJKUmcm5AntDTpK173dY0RRwrChPo+j4hQLHYG UVCM7SjoAuTIvzBmIq4tkg+Ul5U8OOqD7X5V3tGHuBcj3Qa7WBuBrvhvYwdKInvSd08R cInG8wUATjKFoBlp28j7Mrqed37dy4W411Vd5FrbvW381IGDCEnayjQdHBSN/tNOsOwY R/+SQkPwV5eG7paPPePwW+KMSkiZ/BEr4P8ZXLKuUV+XSsInuiDSd9vAt7wK6ycCKX1N rchrBHr7Tf40xtNOpiLiTvykgITF0kZPM4BZ65pDlMxyA19seIyhZKMLciiyDoxE3brD 4uLQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=moCEPN6T; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-30725-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30725-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id bl16-20020a056402211000b00558a6a24849si7783407edb.72.2024.01.18.19.24.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 19:24:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30725-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=moCEPN6T; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-30725-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30725-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 5338F1F2350F for ; Fri, 19 Jan 2024 03:24:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D0E0F3C35; Fri, 19 Jan 2024 03:23:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="moCEPN6T" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A668186F; Fri, 19 Jan 2024 03:23:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705634629; cv=none; b=SKfC4Zstmz0L0LdgAahAdY3QA0rRkAXvyQj7rpk8tzxvfMWiRZRGxtqiL5n/50VWgmm6wGzgk+JT+cIB8cw/aOFqW/ffdtJIRrcxr5ENCwUxhFWucpFlGXkamZC9uW1qrrlbwPW4YkalgO7DabSKOLLj5OO2EOoGEQqjE+s9zrU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705634629; c=relaxed/simple; bh=Uewh1FnrdtUjaw3IbQp5/cVxlxfhVTRPnk+3maWKx+g=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=khZAeISMvl4xQQNnOce9uezdmtkkmydrbhIAJIkhIlmjvki/kjnenXNvzI8dyFhvqvwRk2EBx25RCRGQo2xRZLEcnZSKRJ8atBbouMlOp7Bsvk/egqDPdf3YsuRVBp8hJ/o/+YF3zhwWb4GH6Ij0VDGVynPJpBrLC2+8BAqT1L0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=moCEPN6T; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40J0f8bZ031574; Fri, 19 Jan 2024 03:23:33 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=eG0cw3V2V7bP1GdeOMsX cfVKOjDgrWaClaMQX8x+Rcc=; b=moCEPN6Tu3lLFU3iTIFnjd9XAojWFiCJfjkW N+ISLLzZYSWQnUjSIwWnDkgeIrihb9EsrpMNp/I0RR8ZQa0jlLvi2rNCOyQFzDWc dfljbvPajztqrUfo7GXbLJ3f/I9Wve5yIObYX/GN6i0tgv+JgjYrY9Cz+IxPLe04 LxY61RU5ULvFVh6IBU83kk+smcPYYzs2uQ5k+2s/3rUSc/JVn1+LSjXhT2FAON5j P+6mJzlP+KDrJp8wLxBmRsgxjLDQzthu3gs0YGgDg8gajybFn1tMfSF1dhDQsonI hN26aoFjgpmYX5ESAc6fm+oeSdANIL/UkPAPPR98OSOfjcDyEg== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vq403hue3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Jan 2024 03:23:33 +0000 (GMT) Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 40J3NWCx005461 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Jan 2024 03:23:32 GMT Received: from taozha-gv.qualcomm.com (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 18 Jan 2024 19:23:27 -0800 From: Tao Zhang To: Mathieu Poirier , Suzuki K Poulose , Alexander Shishkin , Konrad Dybcio , Mike Leach , Rob Herring , Krzysztof Kozlowski CC: Tao Zhang , Jinlong Mao , Leo Yan , Greg Kroah-Hartman , , , , , Tingwei Zhang , Yuanfang Zhang , Trilok Soni , Song Chai , , Subject: [PATCH v4 01/10] coresight-tpdm: Optimize the store function of tpdm simple dataset Date: Fri, 19 Jan 2024 11:22:54 +0800 Message-ID: <1705634583-17631-2-git-send-email-quic_taozha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1705634583-17631-1-git-send-email-quic_taozha@quicinc.com> References: <1705634583-17631-1-git-send-email-quic_taozha@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: YKVaIyHCUjWlngrNat9x1vbWd0xlDZWy X-Proofpoint-ORIG-GUID: YKVaIyHCUjWlngrNat9x1vbWd0xlDZWy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-18_12,2024-01-17_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 lowpriorityscore=0 priorityscore=1501 mlxscore=0 bulkscore=0 phishscore=0 spamscore=0 adultscore=0 mlxlogscore=882 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2401190012 Replace spin lock/unlock to avoid forgetting to unlock when the function exits. And refine methods for handling various conditions. Signed-off-by: Tao Zhang --- drivers/hwtracing/coresight/coresight-tpdm.c | 39 ++++++++++---------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-tpdm.c b/drivers/hwtracing/coresight/coresight-tpdm.c index bd13a548375c..0427c0fc0bf3 100644 --- a/drivers/hwtracing/coresight/coresight-tpdm.c +++ b/drivers/hwtracing/coresight/coresight-tpdm.c @@ -77,51 +77,50 @@ static ssize_t tpdm_simple_dataset_store(struct device *dev, size_t size) { unsigned long val; - ssize_t ret = size; + ssize_t ret = -EINVAL; struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent); struct tpdm_dataset_attribute *tpdm_attr = container_of(attr, struct tpdm_dataset_attribute, attr); if (kstrtoul(buf, 0, &val)) - return -EINVAL; + return ret; - spin_lock(&drvdata->spinlock); + guard(spinlock)(&drvdata->spinlock); switch (tpdm_attr->mem) { case DSB_TRIG_PATT: - if (tpdm_attr->idx < TPDM_DSB_MAX_PATT) + if (tpdm_attr->idx < TPDM_DSB_MAX_PATT) { drvdata->dsb->trig_patt[tpdm_attr->idx] = val; - else - ret = -EINVAL; + ret = size; + } break; case DSB_TRIG_PATT_MASK: - if (tpdm_attr->idx < TPDM_DSB_MAX_PATT) + if (tpdm_attr->idx < TPDM_DSB_MAX_PATT) { drvdata->dsb->trig_patt_mask[tpdm_attr->idx] = val; - else - ret = -EINVAL; + ret = size; + } break; case DSB_PATT: - if (tpdm_attr->idx < TPDM_DSB_MAX_PATT) + if (tpdm_attr->idx < TPDM_DSB_MAX_PATT) { drvdata->dsb->patt_val[tpdm_attr->idx] = val; - else - ret = -EINVAL; + ret = size; + } break; case DSB_PATT_MASK: - if (tpdm_attr->idx < TPDM_DSB_MAX_PATT) + if (tpdm_attr->idx < TPDM_DSB_MAX_PATT) { drvdata->dsb->patt_mask[tpdm_attr->idx] = val; - else - ret = -EINVAL; + ret = size; + } break; case DSB_MSR: - if (tpdm_attr->idx < drvdata->dsb_msr_num) + if (tpdm_attr->idx < drvdata->dsb_msr_num) { drvdata->dsb->msr[tpdm_attr->idx] = val; - else - ret = -EINVAL; + ret = size; + } break; default: - ret = -EINVAL; + break; } - spin_unlock(&drvdata->spinlock); return ret; } -- 2.17.1