Skip to content

Commit 6bbddb8

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 a750a05 commit 6bbddb8

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
@@ -867,27 +867,32 @@ static void kick_probe_task(struct probe_pdata *_probe)
867867
}
868868

869869
#if CONFIG_LOG_BACKEND_SOF_PROBE
870-
static void probe_logging_hook(uint8_t *buffer, size_t length)
870+
static int probe_logging_hook(uint8_t *buffer, size_t length)
871871
{
872872
struct probe_pdata *_probe = probe_get();
873+
uint32_t max_len;
873874
uint64_t checksum;
874875
int ret;
875876

877+
max_len = _probe->ext_dma.dmapb.avail - sizeof(struct probe_data_packet) - sizeof(checksum);
878+
length = MIN(max_len, (uint32_t)length);
879+
876880
ret = probe_gen_header(PROBE_LOGGING_BUFFER_ID, length, 0, &checksum);
877881
if (ret < 0)
878-
return;
882+
return ret;
879883

880884
ret = copy_to_pbuffer(&_probe->ext_dma.dmapb,
881885
buffer, length);
882886
if (ret < 0)
883-
return;
887+
return ret;
884888

885889
ret = copy_to_pbuffer(&_probe->ext_dma.dmapb,
886890
&checksum, sizeof(checksum));
887891
if (ret < 0)
888-
return;
892+
return ret;
889893

890894
kick_probe_task(_probe);
895+
return length;
891896
}
892897
#endif
893898

0 commit comments

Comments
 (0)