Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 857ed7bf authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Rest replicator registers when enabling it first time"

parents b3a442af 04dbc4c3
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
 * Copyright (c) 2011-2015, 2020 The Linux Foundation. All rights reserved.
 */

#include <linux/amba/bus.h>
@@ -84,6 +84,18 @@ static int dynamic_replicator_enable(struct replicator_state *drvdata,
	return rc;
}

static bool is_replicator_disabled(struct coresight_device *csdev)
{
	int i;

	for (i = 0; i < csdev->nr_outport; i++) {
		if (atomic_read(&csdev->refcnt[i]) > 0)
			return false;
	}

	return true;
}

static int replicator_enable(struct coresight_device *csdev, int inport,
			     int outport)
{
@@ -93,6 +105,10 @@ static int replicator_enable(struct coresight_device *csdev, int inport,
	bool first_enable = false;

	spin_lock_irqsave(&drvdata->spinlock, flags);

	if (is_replicator_disabled(csdev))
		replicator_reset(drvdata);

	if (atomic_read(&csdev->refcnt[outport]) == 0) {
		rc = dynamic_replicator_enable(drvdata, inport, outport);
		if (!rc)