Skip to content

Commit c43b577

Browse files
author
Jyri Sarha
committed
probe: logging: Return the bytes written 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 2ddfe2f commit c43b577

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

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
@@ -865,27 +865,32 @@ static void kick_probe_task(struct probe_pdata *_probe)
865865
}
866866

867867
#if CONFIG_LOG_BACKEND_SOF_PROBE
868-
static void probe_logging_hook(uint8_t *buffer, size_t length)
868+
static int probe_logging_hook(uint8_t *buffer, size_t length)
869869
{
870870
struct probe_pdata *_probe = probe_get();
871+
uint32_t max_len;
871872
uint64_t checksum;
872873
int ret;
873874

875+
max_len = _probe->ext_dma.dmapb.avail - sizeof(struct probe_data_packet) - sizeof(checksum);
876+
length = MIN(max_len, (uint32_t)length);
877+
874878
ret = probe_gen_header(PROBE_LOGGING_BUFFER_ID, length, 0, &checksum);
875879
if (ret < 0)
876-
return;
880+
return ret;
877881

878882
ret = copy_to_pbuffer(&_probe->ext_dma.dmapb,
879883
buffer, length);
880884
if (ret < 0)
881-
return;
885+
return ret;
882886

883887
ret = copy_to_pbuffer(&_probe->ext_dma.dmapb,
884888
&checksum, sizeof(checksum));
885889
if (ret < 0)
886-
return;
890+
return ret;
887891

888892
kick_probe_task(_probe);
893+
return length;
889894
}
890895
#endif
891896

0 commit comments

Comments
 (0)