From nobody Wed Dec 17 09:06:29 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9F37C1552E9 for ; Mon, 29 Jan 2024 15:41:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706542896; cv=none; b=Jff9dOKrHL8dwNhJlMzNmGltITZ4y1d+XYMoBtt7xCyvGBqE2x3ftGBpoXlBK01eGwxPYN75T853SWIqUvCVH85uA9jL5gS7KnxQe04EvfaUMKmwa19PWobOJLi1N/S2Y5U7bU9KVdzGZ7X8gPAJSKfJpGf5tove1s6/KFSiw68= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706542896; c=relaxed/simple; bh=mImXg8UpCITn7T6yfBNMloggvtr5MFhdUPNpoyuY0iM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GT/YyheBKPF2VqY96YS9ayK/eWr10nOYNJiv7MgG4u2/8m9aLR9CizPAXFHGnYy9VZehgHcknS5AiKoy+k45zK6p204b75gjX9dnAd76YpP4GZz2n8xuzV7i+oBCB5GeDdtCdEH+s/ku1l6MwKxLOqnX31v+KgqXbak2PduODAM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EEEC4DA7; Mon, 29 Jan 2024 07:42:17 -0800 (PST) Received: from e127643.lan (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 6DB033F738; Mon, 29 Jan 2024 07:41:31 -0800 (PST) From: James Clark To: coresight@lists.linaro.org, suzuki.poulose@arm.com Cc: James Clark , Mike Leach , Alexander Shishkin , Maxime Coquelin , Alexandre Torgue , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com Subject: [PATCH v2 03/12] coresight: Remove ops callback checks Date: Mon, 29 Jan 2024 15:40:34 +0000 Message-Id: <20240129154050.569566-4-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240129154050.569566-1-james.clark@arm.com> References: <20240129154050.569566-1-james.clark@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The check for the existence of callbacks before using them implies that this happens and is supported. There are no devices without enable/disable callbacks, and it wouldn't be possible to add a new working device without adding them either, so just remove them. Furthermore, there are more callbacks than just enable and disable that are already used unguarded in other places. The comment about new session compatibility doesn't seem to match up to the line of code that it's on so remove it. I think it's alluding to the fact that sinks will check if they were already enabled via sysfs or Perf and fail the enable. But there are more detailed comments at those places, and this one isn't very useful. Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-core.c | 51 +++++--------------- 1 file changed, 12 insertions(+), 39 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtraci= ng/coresight/coresight-core.c index 2bb74ad8f68b..37767656bf9d 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -279,16 +279,8 @@ EXPORT_SYMBOL_GPL(coresight_add_helper); static int coresight_enable_sink(struct coresight_device *csdev, enum cs_mode mode, void *data) { - int ret; - - /* - * We need to make sure the "new" session is compatible with the - * existing "mode" of operation. - */ - if (!sink_ops(csdev)->enable) - return -EINVAL; + int ret =3D sink_ops(csdev)->enable(csdev, mode, data); =20 - ret =3D sink_ops(csdev)->enable(csdev, mode, data); if (ret) return ret; =20 @@ -299,12 +291,7 @@ static int coresight_enable_sink(struct coresight_devi= ce *csdev, =20 static void coresight_disable_sink(struct coresight_device *csdev) { - int ret; - - if (!sink_ops(csdev)->disable) - return; - - ret =3D sink_ops(csdev)->disable(csdev); + int ret =3D sink_ops(csdev)->disable(csdev); if (ret) return; csdev->enable =3D false; @@ -330,11 +317,9 @@ static int coresight_enable_link(struct coresight_devi= ce *csdev, if (link_subtype =3D=3D CORESIGHT_DEV_SUBTYPE_LINK_SPLIT && IS_ERR(outcon= n)) return PTR_ERR(outconn); =20 - if (link_ops(csdev)->enable) { - ret =3D link_ops(csdev)->enable(csdev, inconn, outconn); - if (!ret) - csdev->enable =3D true; - } + ret =3D link_ops(csdev)->enable(csdev, inconn, outconn); + if (!ret) + csdev->enable =3D true; =20 return ret; } @@ -354,9 +339,7 @@ static void coresight_disable_link(struct coresight_dev= ice *csdev, outconn =3D coresight_find_out_connection(csdev, child); link_subtype =3D csdev->subtype.link_subtype; =20 - if (link_ops(csdev)->disable) { - link_ops(csdev)->disable(csdev, inconn, outconn); - } + link_ops(csdev)->disable(csdev, inconn, outconn); =20 if (link_subtype =3D=3D CORESIGHT_DEV_SUBTYPE_LINK_MERG) { for (i =3D 0; i < csdev->pdata->nr_inconns; i++) @@ -382,11 +365,9 @@ int coresight_enable_source(struct coresight_device *c= sdev, enum cs_mode mode, int ret; =20 if (!csdev->enable) { - if (source_ops(csdev)->enable) { - ret =3D source_ops(csdev)->enable(csdev, data, mode); - if (ret) - return ret; - } + ret =3D source_ops(csdev)->enable(csdev, data, mode); + if (ret) + return ret; csdev->enable =3D true; } =20 @@ -404,11 +385,8 @@ static bool coresight_is_helper(struct coresight_devic= e *csdev) static int coresight_enable_helper(struct coresight_device *csdev, enum cs_mode mode, void *data) { - int ret; + int ret =3D helper_ops(csdev)->enable(csdev, mode, data); =20 - if (!helper_ops(csdev)->enable) - return 0; - ret =3D helper_ops(csdev)->enable(csdev, mode, data); if (ret) return ret; =20 @@ -418,12 +396,8 @@ static int coresight_enable_helper(struct coresight_de= vice *csdev, =20 static void coresight_disable_helper(struct coresight_device *csdev) { - int ret; - - if (!helper_ops(csdev)->disable) - return; + int ret =3D helper_ops(csdev)->disable(csdev, NULL); =20 - ret =3D helper_ops(csdev)->disable(csdev, NULL); if (ret) return; csdev->enable =3D false; @@ -453,8 +427,7 @@ static void coresight_disable_helpers(struct coresight_= device *csdev) */ void coresight_disable_source(struct coresight_device *csdev, void *data) { - if (source_ops(csdev)->disable) - source_ops(csdev)->disable(csdev, data); + source_ops(csdev)->disable(csdev, data); coresight_disable_helpers(csdev); } EXPORT_SYMBOL_GPL(coresight_disable_source); --=20 2.34.1