Commit f021801c authored by Tao Zhang's avatar Tao Zhang Committed by Suzuki K Poulose
Browse files

coresight-tpdm: Optimize the useage of tpdm_has_dsb_dataset



Since the function tpdm_has_dsb_dataset will be called by TPDA
driver in subsequent patches, it is moved to the header file.
And move this judgement form the function __tpdm_{enable/disable}
to the beginning of the function tpdm_{enable/disable}_dsb.

Signed-off-by: default avatarTao Zhang <quic_taozha@quicinc.com>
Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/1707024641-22460-3-git-send-email-quic_taozha@quicinc.com
parent 9f0ea8e8
Loading
Loading
Loading
Loading
+14 −16
Original line number Diff line number Diff line
@@ -125,11 +125,6 @@ static ssize_t tpdm_simple_dataset_store(struct device *dev,
	return ret;
}

static bool tpdm_has_dsb_dataset(struct tpdm_drvdata *drvdata)
{
	return (drvdata->datasets & TPDM_PIDR0_DS_DSB);
}

static umode_t tpdm_dsb_is_visible(struct kobject *kobj,
				   struct attribute *attr, int n)
{
@@ -232,6 +227,9 @@ static void tpdm_enable_dsb(struct tpdm_drvdata *drvdata)
{
	u32 val, i;

	if (!tpdm_has_dsb_dataset(drvdata))
		return;

	for (i = 0; i < TPDM_DSB_MAX_EDCR; i++)
		writel_relaxed(drvdata->dsb->edge_ctrl[i],
			       drvdata->base + TPDM_DSB_EDCR(i));
@@ -250,7 +248,6 @@ static void tpdm_enable_dsb(struct tpdm_drvdata *drvdata)
	}

	set_dsb_tier(drvdata);

	set_dsb_msr(drvdata);

	val = readl_relaxed(drvdata->base + TPDM_DSB_CR);
@@ -278,7 +275,6 @@ static void __tpdm_enable(struct tpdm_drvdata *drvdata)
{
	CS_UNLOCK(drvdata->base);

	if (tpdm_has_dsb_dataset(drvdata))
	tpdm_enable_dsb(drvdata);

	CS_LOCK(drvdata->base);
@@ -307,6 +303,9 @@ static void tpdm_disable_dsb(struct tpdm_drvdata *drvdata)
{
	u32 val;

	if (!tpdm_has_dsb_dataset(drvdata))
		return;

	/* Set the enable bit of DSB control register to 0 */
	val = readl_relaxed(drvdata->base + TPDM_DSB_CR);
	val &= ~TPDM_DSB_CR_ENA;
@@ -318,7 +317,6 @@ static void __tpdm_disable(struct tpdm_drvdata *drvdata)
{
	CS_UNLOCK(drvdata->base);

	if (tpdm_has_dsb_dataset(drvdata))
	tpdm_disable_dsb(drvdata);

	CS_LOCK(drvdata->base);
+4 −0
Original line number Diff line number Diff line
@@ -220,4 +220,8 @@ struct tpdm_dataset_attribute {
	u32 idx;
};

static bool tpdm_has_dsb_dataset(struct tpdm_drvdata *drvdata)
{
	return (drvdata->datasets & TPDM_PIDR0_DS_DSB);
}
#endif  /* _CORESIGHT_CORESIGHT_TPDM_H */