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

Commit 80c8b0a4 authored by Satyajit Desai's avatar Satyajit Desai
Browse files

coresight-tmc-etr: Remove irrelevant conditional logic



As part of the change to add scatter gather support  memory
assignment is being handled by mem alloc function. This change
gets rid of the old conditional logic which became irrelevant
since memory assignment has changed. The code being removed does not
have any effect on execution path.

Change-Id: Ib0628a9b024e911e4400a03af1f98fd1c12c92a7
Signed-off-by: default avatarSatyajit Desai <sadesai@codeaurora.org>
parent 8fccfa63
Loading
Loading
Loading
Loading
+20 −55
Original line number Diff line number Diff line
@@ -563,30 +563,14 @@ static void tmc_etr_free_mem(struct tmc_drvdata *drvdata)
static int tmc_enable_etr_sink_sysfs(struct coresight_device *csdev, u32 mode)
{
	int ret = 0;
	bool used = false;
	long val;
	unsigned long flags;
	void __iomem *vaddr = NULL;
	dma_addr_t paddr;
	struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);

	 /* This shouldn't be happening */
	if (WARN_ON(mode != CS_MODE_SYSFS))
		return -EINVAL;

	/*
	 * If we don't have a buffer release the lock and allocate memory.
	 * Otherwise keep the lock and move along.
	 */
	spin_lock_irqsave(&drvdata->spinlock, flags);
	if (!drvdata->vaddr) {
		spin_unlock_irqrestore(&drvdata->spinlock, flags);

		/*
		 * Contiguous  memory can't be allocated while a spinlock is
		 * held.  As such allocate memory here and free it if a buffer
		 * has already been allocated (from a previous session).
		 */
	mutex_lock(&drvdata->mem_lock);

	/*
@@ -611,10 +595,7 @@ static int tmc_enable_etr_sink_sysfs(struct coresight_device *csdev, u32 mode)
	}
	mutex_unlock(&drvdata->mem_lock);

		/* Let's try again */
	spin_lock_irqsave(&drvdata->spinlock, flags);
	}

	if (drvdata->reading) {
		ret = -EBUSY;
		goto out;
@@ -629,26 +610,10 @@ static int tmc_enable_etr_sink_sysfs(struct coresight_device *csdev, u32 mode)
	if (val == CS_MODE_SYSFS)
		goto out;

	/*
	 * If drvdata::buf == NULL, use the memory allocated above.
	 * Otherwise a buffer still exists from a previous session, so
	 * simply use that.
	 */
	if (drvdata->buf == NULL) {
		used = true;
		drvdata->vaddr = vaddr;
		drvdata->paddr = paddr;
		drvdata->buf = drvdata->vaddr;
	}

	tmc_etr_enable_hw(drvdata);
out:
	spin_unlock_irqrestore(&drvdata->spinlock, flags);

	/* Free memory outside the spinlock if need be */
	if (!used && vaddr)
		dma_free_coherent(drvdata->dev, drvdata->size, vaddr, paddr);

	if (!ret)
		dev_info(drvdata->dev, "TMC-ETR enabled\n");