Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1118752lqt; Fri, 7 Jun 2024 08:29:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW0C51MS1GXC8r3sD1ngOTQ2dtr2SG9GbkBzJv4lQeXWAWMJl6WsuoX2zrO0PqqH1vjWxxfRVpcCWVIcuvpetEv/VeAsMivKhtHUyVcSg== X-Google-Smtp-Source: AGHT+IFbvjrtEmMPkguCuBcWc27Eq6+SUjc7mH33R5PoGeS96IsohIDdnDJk9FlVcb4ZRM6geVaI X-Received: by 2002:a05:620a:470c:b0:792:bb6c:a0f1 with SMTP id af79cd13be357-7953c49e214mr314238985a.61.1717774147327; Fri, 07 Jun 2024 08:29:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717774147; cv=pass; d=google.com; s=arc-20160816; b=p6rdWvovRvIiGbZjv3tV54t8oT6aG93543/lIQzsYd2Qto3x+CWT5zr10IiXcdpYbh yrg9b5BfOZ1rFYWYHq8ZWDTNwp7+CaWkBzFQ3O5a1hKxyJSWFZXVk58ofiCGq5OlGrBZ j14rvlU4VVepBLTW2JXBQkXxuTgz/fD3rWS5hslstxbStW0JQQwpi8H2D1HQYceQwjQ5 bym7LvE2O87xcU8n920CNWoMjGPWbiqvPB2qjhuVnmPHxI+I3Z0wc6DJU0YK3ngV/oOo QQ1XE2DdHl8vx+tjIZP/7YkKJDMoO8YpZIX2P/nhG0izqHfeLALksqVBgRaG7+xR8TJQ Cb+Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=vMfP+9TpUdf+z6Plt3LxyK4rlYRmwCbRaELJz1fj69g=; fh=YpHnV/6uyiPbG6kMterX8knOBa279otQWiSdSsr99Bc=; b=vQ43qeWA8UHgan/Uh5s4IJWQKRYz5/AAkESr7m6XYHvCg4aFXiLucwVBanx26TjGBa X9KFQCuEdfFL/5xT0v1YzS6Qo6VaDB2WrXEQtgsDVcOsMcGZjl5Pdi/cW1BjfBlzFUjQ ujp6lBjo1U43GaRHczRCONRkciK/ifUwi5bgYvr2loyiWYvSgfOHT6vYqWTnGGWkPwpQ izLuSpBbzDHrx3v/kDrC4hk+3RixPYDTmonUUot496rrwclwQYHxBKvhhdGFQpXzTxr/ QbMfVbkm8dC87nB9WX1vPlgVN3eVd8roJF1Kq64sHb9br85wN2ruujk9jYDGhmCv62jz /MlQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XWnNZ7+J; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-206392-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206392-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-7954c3cc7a5si81772485a.425.2024.06.07.08.29.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 08:29:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-206392-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XWnNZ7+J; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-206392-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206392-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id EF4471C22186 for ; Fri, 7 Jun 2024 15:29:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 96A1419939C; Fri, 7 Jun 2024 15:28:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XWnNZ7+J" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E9CF1991A4; Fri, 7 Jun 2024 15:28:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717774114; cv=none; b=XK/jmTyLWU96r17v38ta/4eDfyoIzP89eViKqXs+a79pXfji/Vx6Nurh9bLlVxm8SFmsDtW1Octrh2q/cyFpY2qY9b9R/nCuJ1ChMFXUW89WgBUCgysx6BR5z5kfXfgoODMp4lkc8PuXnk7rfF/Ft5eVR5bWNmdC633DvnZynrE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717774114; c=relaxed/simple; bh=sk+4EpfD1zH+CucdvjuuJelZ5EX03PW7OO3NJXTmWuE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cYH8AhlYFywF4/Y5g+sBVdSMmBGRe2oAFPZ32MPHe3DwKkQwlBz/DLu+lJlKj1HpdkSEdJt5F5gEhcdWImxDTGqO4G12jTkez8G+ndNTdUlnwTURT8g4dt+xBXjD3RtMf1EHdaPNrC5fewQyGQuGTaQon/kjE2xCj1R8G8PdjY0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XWnNZ7+J; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96C39C4AF07; Fri, 7 Jun 2024 15:28:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717774114; bh=sk+4EpfD1zH+CucdvjuuJelZ5EX03PW7OO3NJXTmWuE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=XWnNZ7+JK5H//hCfzpJV/+TyKAxoZI0XkNV9d2qvdKkoTa7S18YLzBmNnMh8RFqys +/xy9LEZQ9aAKkPDtE8VMm1wF84gErzqmID/ZwalKPmPFfyqJDsL6dde7NPVGGCV4A Guhx2LCiulrvEtk09kFde5FEC2mc5rEWKfoG0FOzlorwIY+WXb4yK8G+sBswCpKQ1R GZCEaLxFq5+s7YwcimhWxe1uR2qJkVHN9XgkZWpYUooOi6K9PGNTr9GgziSRQZl7z/ oBuyn/AWpUCu+tdxoH51J1XWjbZlAQaymlhiim6kpG1F65mbBu6r6hNzrsIWt8ra23 3f3fcI8p96UJA== From: Benjamin Tissoires Date: Fri, 07 Jun 2024 17:28:21 +0200 Subject: [PATCH HID v2 01/16] HID: rename struct hid_bpf_ops into hid_ops Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240607-hid_bpf_struct_ops-v2-1-3f95f4d02292@kernel.org> References: <20240607-hid_bpf_struct_ops-v2-0-3f95f4d02292@kernel.org> In-Reply-To: <20240607-hid_bpf_struct_ops-v2-0-3f95f4d02292@kernel.org> To: Shuah Khan , Jiri Kosina , Jonathan Corbet , Alexei Starovoitov Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-input@vger.kernel.org, linux-doc@vger.kernel.org, Benjamin Tissoires X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1717774109; l=4932; i=bentiss@kernel.org; s=20230215; h=from:subject:message-id; bh=sk+4EpfD1zH+CucdvjuuJelZ5EX03PW7OO3NJXTmWuE=; b=seLSmRWKHKzKnXXcwBTE2IGAGej4pnPtN0tEJs0VS4uDdie7rXBzzC4ZBxz3Fs2LNtFNslE92 AA0zeODix0XBRKVA61OyIwOPlFXlXwSNvqDvCjRvW7XbCQTIAXlJSgM X-Developer-Key: i=bentiss@kernel.org; a=ed25519; pk=7D1DyAVh6ajCkuUTudt/chMuXWIJHlv2qCsRkIizvFw= Those operations are the ones from HID, not HID-BPF, and I'd like to reuse hid_bpf_ops as the user facing struct_ops API. Signed-off-by: Benjamin Tissoires --- no changes in v2 --- drivers/hid/bpf/hid_bpf_dispatch.c | 22 +++++++++++----------- drivers/hid/hid-core.c | 6 +++--- include/linux/hid_bpf.h | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/hid/bpf/hid_bpf_dispatch.c b/drivers/hid/bpf/hid_bpf_dispatch.c index 10289f44d0cc..55c9f82fdef0 100644 --- a/drivers/hid/bpf/hid_bpf_dispatch.c +++ b/drivers/hid/bpf/hid_bpf_dispatch.c @@ -21,8 +21,8 @@ #include "hid_bpf_dispatch.h" #include "entrypoints/entrypoints.lskel.h" -struct hid_bpf_ops *hid_bpf_ops; -EXPORT_SYMBOL(hid_bpf_ops); +struct hid_ops *hid_ops; +EXPORT_SYMBOL(hid_ops); /** * hid_bpf_device_event - Called whenever an event is coming in from the device @@ -284,13 +284,13 @@ hid_bpf_attach_prog(unsigned int hid_id, int prog_fd, __u32 flags) struct device *dev; int err, fd; - if (!hid_bpf_ops) + if (!hid_ops) return -EINVAL; if ((flags & ~HID_BPF_FLAG_MASK)) return -EINVAL; - dev = bus_find_device(hid_bpf_ops->bus_type, NULL, &hid_id, device_match_id); + dev = bus_find_device(hid_ops->bus_type, NULL, &hid_id, device_match_id); if (!dev) return -EINVAL; @@ -335,10 +335,10 @@ hid_bpf_allocate_context(unsigned int hid_id) struct hid_bpf_ctx_kern *ctx_kern = NULL; struct device *dev; - if (!hid_bpf_ops) + if (!hid_ops) return NULL; - dev = bus_find_device(hid_bpf_ops->bus_type, NULL, &hid_id, device_match_id); + dev = bus_find_device(hid_ops->bus_type, NULL, &hid_id, device_match_id); if (!dev) return NULL; @@ -386,7 +386,7 @@ __hid_bpf_hw_check_params(struct hid_bpf_ctx *ctx, __u8 *buf, size_t *buf__sz, u32 report_len; /* check arguments */ - if (!ctx || !hid_bpf_ops || !buf) + if (!ctx || !hid_ops || !buf) return -EINVAL; switch (rtype) { @@ -404,7 +404,7 @@ __hid_bpf_hw_check_params(struct hid_bpf_ctx *ctx, __u8 *buf, size_t *buf__sz, hdev = (struct hid_device *)ctx->hid; /* discard const */ report_enum = hdev->report_enum + rtype; - report = hid_bpf_ops->hid_get_report(report_enum, buf); + report = hid_ops->hid_get_report(report_enum, buf); if (!report) return -EINVAL; @@ -459,7 +459,7 @@ hid_bpf_hw_request(struct hid_bpf_ctx *ctx, __u8 *buf, size_t buf__sz, if (!dma_data) return -ENOMEM; - ret = hid_bpf_ops->hid_hw_raw_request(hdev, + ret = hid_ops->hid_hw_raw_request(hdev, dma_data[0], dma_data, size, @@ -501,7 +501,7 @@ hid_bpf_hw_output_report(struct hid_bpf_ctx *ctx, __u8 *buf, size_t buf__sz) if (!dma_data) return -ENOMEM; - ret = hid_bpf_ops->hid_hw_output_report(hdev, + ret = hid_ops->hid_hw_output_report(hdev, dma_data, size); @@ -534,7 +534,7 @@ hid_bpf_input_report(struct hid_bpf_ctx *ctx, enum hid_report_type type, u8 *buf hdev = (struct hid_device *)ctx->hid; /* discard const */ - return hid_bpf_ops->hid_input_report(hdev, type, buf, size, 0); + return hid_ops->hid_input_report(hdev, type, buf, size, 0); } __bpf_kfunc_end_defs(); diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index b1fa0378e8f4..14bbac432de5 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -2971,7 +2971,7 @@ int hid_check_keys_pressed(struct hid_device *hid) EXPORT_SYMBOL_GPL(hid_check_keys_pressed); #ifdef CONFIG_HID_BPF -static struct hid_bpf_ops hid_ops = { +static struct hid_ops __hid_ops = { .hid_get_report = hid_get_report, .hid_hw_raw_request = hid_hw_raw_request, .hid_hw_output_report = hid_hw_output_report, @@ -2992,7 +2992,7 @@ static int __init hid_init(void) } #ifdef CONFIG_HID_BPF - hid_bpf_ops = &hid_ops; + hid_ops = &__hid_ops; #endif ret = hidraw_init(); @@ -3011,7 +3011,7 @@ static int __init hid_init(void) static void __exit hid_exit(void) { #ifdef CONFIG_HID_BPF - hid_bpf_ops = NULL; + hid_ops = NULL; #endif hid_debug_exit(); hidraw_exit(); diff --git a/include/linux/hid_bpf.h b/include/linux/hid_bpf.h index eec2592dec12..a66103618e6e 100644 --- a/include/linux/hid_bpf.h +++ b/include/linux/hid_bpf.h @@ -97,7 +97,7 @@ enum hid_bpf_prog_type { struct hid_report_enum; -struct hid_bpf_ops { +struct hid_ops { struct hid_report *(*hid_get_report)(struct hid_report_enum *report_enum, const u8 *data); int (*hid_hw_raw_request)(struct hid_device *hdev, unsigned char reportnum, __u8 *buf, @@ -110,7 +110,7 @@ struct hid_bpf_ops { const struct bus_type *bus_type; }; -extern struct hid_bpf_ops *hid_bpf_ops; +extern struct hid_ops *hid_ops; struct hid_bpf_prog_list { u16 prog_idx[HID_BPF_MAX_PROGS_PER_DEV]; -- 2.44.0