Skip to content

Commit 803e3f4

Browse files
author
Jyri Sarha
committed
probe: logging: Return the bytes writen in probe_logging_hook()
Write only the amount of bytes that fits to DMA buffer and return the amount written. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent 166126a commit 803e3f4

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

src/include/sof/probe/probe.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/**
1414
* A buffer of logging data is available for processing.
1515
*/
16-
typedef void(*probe_logging_hook_t)(uint8_t *buffer, size_t length);
16+
typedef int(*probe_logging_hook_t)(uint8_t *buffer, size_t length);
1717

1818
#if CONFIG_LOG_BACKEND_SOF_PROBE
1919
const struct log_backend *log_backend_probe_get(void);

src/probe/probe.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -842,27 +842,32 @@ static void kick_probe_task(struct probe_pdata *_probe)
842842
}
843843

844844
#if CONFIG_LOG_BACKEND_SOF_PROBE
845-
static void probe_logging_hook(uint8_t *buffer, size_t length)
845+
static int probe_logging_hook(uint8_t *buffer, size_t length)
846846
{
847847
struct probe_pdata *_probe = probe_get();
848+
uint32_t max_len;
848849
uint64_t checksum;
849850
int ret;
850851

852+
max_len = _probe->ext_dma.dmapb.avail - sizeof(struct probe_data_packet) - sizeof(checksum);
853+
length = MIN(max_len, (uint32_t) length);
854+
851855
ret = probe_gen_header(PROBE_LOGGING_BUFFER_ID, length, 0, &checksum);
852856
if (ret < 0)
853-
return;
857+
return ret;
854858

855859
ret = copy_to_pbuffer(&_probe->ext_dma.dmapb,
856860
buffer, length);
857861
if (ret < 0)
858-
return;
862+
return ret;
859863

860864
ret = copy_to_pbuffer(&_probe->ext_dma.dmapb,
861865
&checksum, sizeof(checksum));
862866
if (ret < 0)
863-
return;
867+
return ret;
864868

865869
kick_probe_task(_probe);
870+
return length;
866871
}
867872
#endif
868873

0 commit comments

Comments
 (0)