ASoC: SOF: trace: Simplify count adjustment in trace_read
authorPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Fri, 28 Jan 2022 12:06:27 +0000 (14:06 +0200)
committerMark Brown <broonie@kernel.org>
Fri, 28 Jan 2022 13:06:48 +0000 (13:06 +0000)
The first count check and fixup against "buffer - lpos" can be removed as
we will do the adjustment later against the "avail" in
sof_dfsentry_trace_read()

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20220128120627.18443-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/trace.c

index f13024c8ebf2fbf6ea23b1f26c9a10234c8a2d0c..9b505c4fe79459c0acb7a35d47d804acc2f05fd1 100644 (file)
@@ -308,9 +308,6 @@ static ssize_t sof_dfsentry_trace_read(struct file *file, char __user *buffer,
        lpos_64 = lpos;
        lpos = do_div(lpos_64, buffer_size);
 
-       if (count > buffer_size - lpos) /* min() not used to avoid sparse warnings */
-               count = buffer_size - lpos;
-
        /* get available count based on current host offset */
        avail = sof_wait_trace_avail(sdev, lpos, buffer_size);
        if (sdev->dtrace_error) {
@@ -319,7 +316,8 @@ static ssize_t sof_dfsentry_trace_read(struct file *file, char __user *buffer,
        }
 
        /* make sure count is <= avail */
-       count = avail > count ? count : avail;
+       if (count > avail)
+               count = avail;
 
        /* copy available trace data to debugfs */
        rem = copy_to_user(buffer, ((u8 *)(dfse->buf) + lpos), count);