Re: [PATCH v4 5/7] HID: bpf: allow to inject HID event from BPF

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 3/15/24 07:44, Benjamin Tissoires wrote:
> It can be interesting to inject events from BPF as if the event were
> to come from the device.
> For example, some multitouch devices do not all the time send a proximity
> out event, and we might want to send it for the physical device.
> 
> Compared to uhid, we can now inject events on any physical device, not
> just uhid virtual ones.
> 
> Signed-off-by: Benjamin Tissoires <bentiss@xxxxxxxxxx>
> 
> ---
> 
> no changes in v4
> 
> no changes in v3
> 
> no changes in v2
> ---
>  Documentation/hid/hid-bpf.rst      |  2 +-
>  drivers/hid/bpf/hid_bpf_dispatch.c | 29 +++++++++++++++++++++++++++++
>  drivers/hid/hid-core.c             |  1 +
>  include/linux/hid_bpf.h            |  2 ++
>  4 files changed, 33 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/hid/hid-bpf.rst b/Documentation/hid/hid-bpf.rst
> index a575004d9025..0765b3298ecf 100644
> --- a/Documentation/hid/hid-bpf.rst
> +++ b/Documentation/hid/hid-bpf.rst
> @@ -179,7 +179,7 @@ Available API that can be used in syscall HID-BPF programs:
>  -----------------------------------------------------------
>  
>  .. kernel-doc:: drivers/hid/bpf/hid_bpf_dispatch.c
> -   :functions: hid_bpf_attach_prog hid_bpf_hw_request hid_bpf_hw_output_report hid_bpf_allocate_context hid_bpf_release_context
> +   :functions: hid_bpf_attach_prog hid_bpf_hw_request hid_bpf_hw_output_report hid_bpf_input_report hid_bpf_allocate_context hid_bpf_release_context
>  
>  General overview of a HID-BPF program
>  =====================================
> diff --git a/drivers/hid/bpf/hid_bpf_dispatch.c b/drivers/hid/bpf/hid_bpf_dispatch.c
> index a5b88b491b80..e1a650f4a626 100644
> --- a/drivers/hid/bpf/hid_bpf_dispatch.c
> +++ b/drivers/hid/bpf/hid_bpf_dispatch.c
> @@ -508,6 +508,34 @@ hid_bpf_hw_output_report(struct hid_bpf_ctx *ctx, __u8 *buf, size_t buf__sz)
>  	kfree(dma_data);
>  	return ret;
>  }
> +
> +/**
> + * hid_bpf_input_report - Inject a HID report in the kernel from a HID device
> + *
> + * @ctx: the HID-BPF context previously allocated in hid_bpf_allocate_context()
> + * @type: the type of the report (%HID_INPUT_REPORT, %HID_FEATURE_REPORT, %HID_OUTPUT_REPORT)
> + * @buf: a %PTR_TO_MEM buffer
> + * @buf__sz: the size of the data to transfer
> + *
> + * @returns %0 on success, a negative error code otherwise.

Minimum change:

      @returns:

Preferred change:

      Returns:

"@returns" is not documented.

> + */
> +__bpf_kfunc int
> +hid_bpf_input_report(struct hid_bpf_ctx *ctx, enum hid_report_type type, u8 *buf,
> +		     const size_t buf__sz)
> +{


-- 
#Randy




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux