Loading drivers/misc/wigig_sensing.c +39 −5 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ /* * Copyright (c) 2019, The Linux foundation. All rights reserved. */ #include <linux/cdev.h> #include <linux/circ_buf.h> #include <linux/clk.h> Loading @@ -15,6 +14,7 @@ #include <linux/io.h> #include <linux/ioctl.h> #include <linux/kernel.h> #include <linux/kfifo.h> #include <linux/list.h> #include <linux/module.h> #include <linux/of.h> Loading Loading @@ -639,9 +639,19 @@ static int wigig_sensing_ioc_get_num_avail_bursts( return 0; } static int wigig_sensing_ioc_get_event(struct wigig_sensing_ctx *ctx) static int wigig_sensing_ioc_get_event(struct wigig_sensing_ctx *ctx, enum wigig_sensing_event *event) { return 0; u32 copied; if (!ctx->event_pending) return -EINVAL; if (kfifo_len(&ctx->events_fifo) == 1) ctx->event_pending = false; return kfifo_to_user(&ctx->events_fifo, event, sizeof(enum wigig_sensing_event), &copied); } static int wigig_sensing_open(struct inode *inode, struct file *filp) Loading Loading @@ -769,7 +779,7 @@ static int wigig_sensing_release(struct inode *inode, struct file *filp) } static long wigig_sensing_ioctl(struct file *file, unsigned int cmd, unsigned long arg) __user unsigned long arg) { int rc; struct wigig_sensing_ctx *ctx = file->private_data; Loading Loading @@ -822,7 +832,8 @@ static long wigig_sensing_ioctl(struct file *file, unsigned int cmd, break; case WIGIG_SENSING_IOCTL_GET_EVENT: pr_info("Received WIGIG_SENSING_IOCTL_GET_EVENT command\n"); rc = wigig_sensing_ioc_get_event(ctx); rc = wigig_sensing_ioc_get_event(ctx, (enum wigig_sensing_event *)arg); break; case WIGIG_SENSING_IOCTL_GET_NUM_AVAIL_BURSTS: pr_info("Received WIGIG_SENSING_IOCTL_GET_NUM_AVAIL_BURSTS command\n"); Loading Loading @@ -1138,6 +1149,22 @@ static int wigig_sensing_spi_init(struct wigig_sensing_ctx *ctx) return rc; } static int wigig_sensing_send_event(struct wigig_sensing_ctx *ctx, enum wigig_sensing_event event) { if (kfifo_is_full(&ctx->events_fifo)) { pr_err("events fifo is full, unable to send event\n"); return -EFAULT; } kfifo_in(&ctx->events_fifo, &event, 1); ctx->event_pending = true; wake_up_interruptible(&ctx->cmd_wait_q); return 0; } static irqreturn_t wigig_sensing_dri_isr_thread(int irq, void *cookie) { struct wigig_sensing_ctx *ctx = cookie; Loading Loading @@ -1225,6 +1252,9 @@ static irqreturn_t wigig_sensing_dri_isr_thread(int irq, void *cookie) wigig_sensing_change_state(ctx, &ctx->stm, WIGIG_SENSING_STATE_READY_STOPPED); /* Send asynchronous FW_READY event to application */ wigig_sensing_send_event(ctx, WIGIG_SENSING_EVENT_FW_READY); spi_status.v &= ~INT_FW_READY; } if (spi_status.b.int_data_ready) { Loading @@ -1247,6 +1277,9 @@ static irqreturn_t wigig_sensing_dri_isr_thread(int irq, void *cookie) ctx->stm.state != WIGIG_SENSING_STATE_SYS_ASSERT) pr_err("State change to WIGIG_SENSING_SYS_ASSERT failed\n"); /* Send asynchronous RESET event to application */ wigig_sensing_send_event(ctx, WIGIG_SENSING_EVENT_RESET); ctx->stm.spi_malfunction = true; spi_status.v &= ~INT_SYSASSERT; } Loading Loading @@ -1319,6 +1352,7 @@ static int wigig_sensing_probe(struct spi_device *spi) init_waitqueue_head(&ctx->cmd_wait_q); init_waitqueue_head(&ctx->data_wait_q); ctx->stm.state = WIGIG_SENSING_STATE_INITIALIZED; INIT_KFIFO(ctx->events_fifo); /* Allocate memory for the CIRs */ /* Allocate a 2MB == 2^21 buffer for CIR data */ Loading drivers/misc/wigig_sensing.h +2 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ #define __WIGIG_SENSING_H__ #include <linux/cdev.h> #include <linux/circ_buf.h> #include <linux/kfifo.h> #include <linux/slab.h> #include <uapi/misc/wigig_sensing_uapi.h> Loading Loading @@ -193,6 +194,7 @@ struct wigig_sensing_ctx { struct cir_data cir_data; u8 *temp_buffer; bool event_pending; DECLARE_KFIFO(events_fifo, enum wigig_sensing_event, 8); u32 dropped_bursts; }; Loading include/uapi/misc/wigig_sensing_uapi.h +3 −1 Original line number Diff line number Diff line Loading @@ -27,8 +27,10 @@ struct wigig_sensing_change_mode { }; enum wigig_sensing_event { WIGIG_SENSING_EVENT_MIN, WIGIG_SENSING_EVENT_FW_READY, WIGIG_SENSING_EVENT_RESET, WIGIG_SENSING_EVENT_MAX, }; #define WIGIG_SENSING_IOC_MAGIC 'r' Loading Loading @@ -84,7 +86,7 @@ enum wigig_sensing_event { WIGIG_SENSING_IOCTL_GET_NUM_DROPPED_BURSTS, sizeof(uint32_t)) /** * Get number of bursts that where dropped due to data buffer overflow * Get asynchronous event (FW_READY, RESET) */ #define WIGIG_SENSING_IOC_GET_EVENT \ _IOR(WIGIG_SENSING_IOC_MAGIC, WIGIG_SENSING_IOCTL_GET_EVENT, \ Loading Loading
drivers/misc/wigig_sensing.c +39 −5 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ /* * Copyright (c) 2019, The Linux foundation. All rights reserved. */ #include <linux/cdev.h> #include <linux/circ_buf.h> #include <linux/clk.h> Loading @@ -15,6 +14,7 @@ #include <linux/io.h> #include <linux/ioctl.h> #include <linux/kernel.h> #include <linux/kfifo.h> #include <linux/list.h> #include <linux/module.h> #include <linux/of.h> Loading Loading @@ -639,9 +639,19 @@ static int wigig_sensing_ioc_get_num_avail_bursts( return 0; } static int wigig_sensing_ioc_get_event(struct wigig_sensing_ctx *ctx) static int wigig_sensing_ioc_get_event(struct wigig_sensing_ctx *ctx, enum wigig_sensing_event *event) { return 0; u32 copied; if (!ctx->event_pending) return -EINVAL; if (kfifo_len(&ctx->events_fifo) == 1) ctx->event_pending = false; return kfifo_to_user(&ctx->events_fifo, event, sizeof(enum wigig_sensing_event), &copied); } static int wigig_sensing_open(struct inode *inode, struct file *filp) Loading Loading @@ -769,7 +779,7 @@ static int wigig_sensing_release(struct inode *inode, struct file *filp) } static long wigig_sensing_ioctl(struct file *file, unsigned int cmd, unsigned long arg) __user unsigned long arg) { int rc; struct wigig_sensing_ctx *ctx = file->private_data; Loading Loading @@ -822,7 +832,8 @@ static long wigig_sensing_ioctl(struct file *file, unsigned int cmd, break; case WIGIG_SENSING_IOCTL_GET_EVENT: pr_info("Received WIGIG_SENSING_IOCTL_GET_EVENT command\n"); rc = wigig_sensing_ioc_get_event(ctx); rc = wigig_sensing_ioc_get_event(ctx, (enum wigig_sensing_event *)arg); break; case WIGIG_SENSING_IOCTL_GET_NUM_AVAIL_BURSTS: pr_info("Received WIGIG_SENSING_IOCTL_GET_NUM_AVAIL_BURSTS command\n"); Loading Loading @@ -1138,6 +1149,22 @@ static int wigig_sensing_spi_init(struct wigig_sensing_ctx *ctx) return rc; } static int wigig_sensing_send_event(struct wigig_sensing_ctx *ctx, enum wigig_sensing_event event) { if (kfifo_is_full(&ctx->events_fifo)) { pr_err("events fifo is full, unable to send event\n"); return -EFAULT; } kfifo_in(&ctx->events_fifo, &event, 1); ctx->event_pending = true; wake_up_interruptible(&ctx->cmd_wait_q); return 0; } static irqreturn_t wigig_sensing_dri_isr_thread(int irq, void *cookie) { struct wigig_sensing_ctx *ctx = cookie; Loading Loading @@ -1225,6 +1252,9 @@ static irqreturn_t wigig_sensing_dri_isr_thread(int irq, void *cookie) wigig_sensing_change_state(ctx, &ctx->stm, WIGIG_SENSING_STATE_READY_STOPPED); /* Send asynchronous FW_READY event to application */ wigig_sensing_send_event(ctx, WIGIG_SENSING_EVENT_FW_READY); spi_status.v &= ~INT_FW_READY; } if (spi_status.b.int_data_ready) { Loading @@ -1247,6 +1277,9 @@ static irqreturn_t wigig_sensing_dri_isr_thread(int irq, void *cookie) ctx->stm.state != WIGIG_SENSING_STATE_SYS_ASSERT) pr_err("State change to WIGIG_SENSING_SYS_ASSERT failed\n"); /* Send asynchronous RESET event to application */ wigig_sensing_send_event(ctx, WIGIG_SENSING_EVENT_RESET); ctx->stm.spi_malfunction = true; spi_status.v &= ~INT_SYSASSERT; } Loading Loading @@ -1319,6 +1352,7 @@ static int wigig_sensing_probe(struct spi_device *spi) init_waitqueue_head(&ctx->cmd_wait_q); init_waitqueue_head(&ctx->data_wait_q); ctx->stm.state = WIGIG_SENSING_STATE_INITIALIZED; INIT_KFIFO(ctx->events_fifo); /* Allocate memory for the CIRs */ /* Allocate a 2MB == 2^21 buffer for CIR data */ Loading
drivers/misc/wigig_sensing.h +2 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ #define __WIGIG_SENSING_H__ #include <linux/cdev.h> #include <linux/circ_buf.h> #include <linux/kfifo.h> #include <linux/slab.h> #include <uapi/misc/wigig_sensing_uapi.h> Loading Loading @@ -193,6 +194,7 @@ struct wigig_sensing_ctx { struct cir_data cir_data; u8 *temp_buffer; bool event_pending; DECLARE_KFIFO(events_fifo, enum wigig_sensing_event, 8); u32 dropped_bursts; }; Loading
include/uapi/misc/wigig_sensing_uapi.h +3 −1 Original line number Diff line number Diff line Loading @@ -27,8 +27,10 @@ struct wigig_sensing_change_mode { }; enum wigig_sensing_event { WIGIG_SENSING_EVENT_MIN, WIGIG_SENSING_EVENT_FW_READY, WIGIG_SENSING_EVENT_RESET, WIGIG_SENSING_EVENT_MAX, }; #define WIGIG_SENSING_IOC_MAGIC 'r' Loading Loading @@ -84,7 +86,7 @@ enum wigig_sensing_event { WIGIG_SENSING_IOCTL_GET_NUM_DROPPED_BURSTS, sizeof(uint32_t)) /** * Get number of bursts that where dropped due to data buffer overflow * Get asynchronous event (FW_READY, RESET) */ #define WIGIG_SENSING_IOC_GET_EVENT \ _IOR(WIGIG_SENSING_IOC_MAGIC, WIGIG_SENSING_IOCTL_GET_EVENT, \ Loading