From 78705a40c4284170c5e37612b1e027a8aec388fe Mon Sep 17 00:00:00 2001 From: Gidon Studinski Date: Thu, 7 Nov 2019 16:58:20 +0200 Subject: [PATCH 1/2] wigig_sensing: add GET_NUM_AVAIL_BURSTS ioctl WIGIG_SENSING_IOCTL_GET_NUM_AVAIL_BURSTS returns the number of available bursts in the drivers buffer. Change-Id: I474770a817393e1b64831886803d65a3f76d92e0 Signed-off-by: Gidon Studinski --- drivers/misc/wigig_sensing.c | 14 ++++++++++++++ include/uapi/misc/wigig_sensing_uapi.h | 10 +++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/misc/wigig_sensing.c b/drivers/misc/wigig_sensing.c index fe366cf32c73..f2d09d62caad 100644 --- a/drivers/misc/wigig_sensing.c +++ b/drivers/misc/wigig_sensing.c @@ -629,6 +629,16 @@ static int wigig_sensing_ioc_get_num_dropped_bursts( return ctx->dropped_bursts; } +static int wigig_sensing_ioc_get_num_avail_bursts( + struct wigig_sensing_ctx *ctx) +{ + if (ctx->stm.burst_size) + return circ_cnt(&ctx->cir_data.b, ctx->cir_data.size_bytes) / + ctx->stm.burst_size; + else + return 0; +} + static int wigig_sensing_ioc_get_event(struct wigig_sensing_ctx *ctx) { return 0; @@ -814,6 +824,10 @@ static long wigig_sensing_ioctl(struct file *file, unsigned int cmd, pr_info("Received WIGIG_SENSING_IOCTL_GET_EVENT command\n"); rc = wigig_sensing_ioc_get_event(ctx); break; + case WIGIG_SENSING_IOCTL_GET_NUM_AVAIL_BURSTS: + pr_info("Received WIGIG_SENSING_IOCTL_GET_NUM_AVAIL_BURSTS command\n"); + rc = wigig_sensing_ioc_get_num_avail_bursts(ctx); + break; default: rc = -EINVAL; break; diff --git a/include/uapi/misc/wigig_sensing_uapi.h b/include/uapi/misc/wigig_sensing_uapi.h index 4fb82213e807..f6fdf8930643 100644 --- a/include/uapi/misc/wigig_sensing_uapi.h +++ b/include/uapi/misc/wigig_sensing_uapi.h @@ -39,6 +39,7 @@ enum wigig_sensing_event { #define WIGIG_SENSING_IOCTL_CLEAR_DATA (3) #define WIGIG_SENSING_IOCTL_GET_NUM_DROPPED_BURSTS (4) #define WIGIG_SENSING_IOCTL_GET_EVENT (5) +#define WIGIG_SENSING_IOCTL_GET_NUM_AVAIL_BURSTS (6) /** * Set auto recovery, which means that the system will go back to search mode @@ -89,4 +90,11 @@ enum wigig_sensing_event { _IOR(WIGIG_SENSING_IOC_MAGIC, WIGIG_SENSING_IOCTL_GET_EVENT, \ sizeof(enum wigig_sensing_event)) -#endif /* ____WIGIG_SENSING_UAPI_H__ */ +/** + * Get number of available bursts in the data buffer + */ +#define WIGIG_SENSING_IOC_GET_NUM_AVAIL_BURSTS \ + _IOR(WIGIG_SENSING_IOC_MAGIC, WIGIG_SENSING_IOCTL_GET_NUM_AVAIL_BURSTS,\ + sizeof(uint32_t)) + +#endif /* __WIGIG_SENSING_UAPI_H__ */ From 5653e13854c9c392b56ba26639e94a8ae1a3f095 Mon Sep 17 00:00:00 2001 From: Gidon Studinski Date: Thu, 14 Nov 2019 14:06:54 +0200 Subject: [PATCH 2/2] wigig_sensing: change DROPPED_BURSTS ioctl definition Change the ioctl definition so it matches the expected signature. Change-Id: Idd7db40545ae5831bc1b81c84826a98c7bf2d2d1 Signed-off-by: Gidon Studinski --- include/uapi/misc/wigig_sensing_uapi.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/uapi/misc/wigig_sensing_uapi.h b/include/uapi/misc/wigig_sensing_uapi.h index f6fdf8930643..e2f8e0f9b79a 100644 --- a/include/uapi/misc/wigig_sensing_uapi.h +++ b/include/uapi/misc/wigig_sensing_uapi.h @@ -77,11 +77,11 @@ enum wigig_sensing_event { _IO(WIGIG_SENSING_IOC_MAGIC, WIGIG_SENSING_IOCTL_CLEAR_DATA) /** - * Get number of bursts that where dropped due to data buffer overflow + * Get number of bursts that were dropped due to data buffer overflow */ #define WIGIG_SENSING_IOC_GET_NUM_DROPPED_BURSTS \ _IOR(WIGIG_SENSING_IOC_MAGIC, \ - WIGIG_SENSING_IOCTL_GET_NUM_DROPPED_BURSTS, uint32_t) + WIGIG_SENSING_IOCTL_GET_NUM_DROPPED_BURSTS, sizeof(uint32_t)) /** * Get number of bursts that where dropped due to data buffer overflow