Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2635461lqb; Tue, 28 May 2024 06:15:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXynf/sgOKNxCZvlF8q27LeoQtuygSP5QVgqeE+MV34P9yOLmYEcMeg1KZGT2RXQ3FCtIFSxOLDzkNXmlMkLfb0qY7DKlV1bTRySRmekQ== X-Google-Smtp-Source: AGHT+IHmSnlUzwOskFnFv1GNwF8ItTT00Dd6d5W2m47xIdUPmgk3axNcNqNVMFiAe2OtBEw0TofQ X-Received: by 2002:a17:906:c0d3:b0:a59:c2c3:bb45 with SMTP id a640c23a62f3a-a6265112b00mr852478966b.56.1716902146790; Tue, 28 May 2024 06:15:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716902146; cv=pass; d=google.com; s=arc-20160816; b=isyIJtl8w/h5nSxMhGEoQNslh8cFm/LUPRU7KlIdnhafiSZ5l5wf53UJz2epn1ZyGT Tv4tf7iHYY3PeaEWxzewsqL28IkesYZVe2BvWTzf/rWiCKyN4R/T9DSiJYITGaEFfwVI Dy3qGmvxCUmitr9X3on3zKmhYgc1mDjoW6llk15ECDye4N6ZQFbD6F9UTQ9reX35owD/ ikh4JKHmOiybavwH9n10V+vMxmq+gxQCXXlJ7Kv/Z0BmQ7rOwguzie6CKkgunllIVrbt gGpveO5OF1RLritD86VES7lxKAzGuMoGhM8/OqDtI884s75SFgZUxf6iixzrOwZ5uaX8 a/FA== 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=5oYVRVyXaJ8daCiiLLS9BgqgMtoCMQ8YZbuiDkcKOpI=; fh=YpHnV/6uyiPbG6kMterX8knOBa279otQWiSdSsr99Bc=; b=fIAdm9x4e3+aOxtAiDnIjCtP/dmZ6vORzw/Ym7aQ3u4AXdHgP1DmlcGh77Qvd8WSuY jsi5GZHNi3Pcitvg3eYQ2OyC6meUfxv73I6hI+3y/DwnwB4Bc6/kr8hccKpxYv0YXZ0n o3/Ju9HuPBXjQv4fD4z1E7s+NXOdhQbe18xef56zwNbIVhNJxagQO+4preBvGfe4mgRy 5bgEq4e3XYAUWG0qv7PpUCHtbFVFaucteK1x4xReSCXshgz8OuaDKMjMHnYQ4qRVSEUK /4jAs9CdbdGj2SPKG9yx5+KKz7iqJyvBR7CnjDwL4IsG2LHCw/ib7xvT+babmqYLRc2A YR0A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pQpQptQv; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-192377-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192377-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a626cc691ffsi522713566b.676.2024.05.28.06.15.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 06:15:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-192377-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pQpQptQv; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-192377-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192377-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 60B8F1F23020 for ; Tue, 28 May 2024 13:15:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B63C316F292; Tue, 28 May 2024 13:15:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pQpQptQv" 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 A657A16F26D; Tue, 28 May 2024 13:15:18 +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=1716902118; cv=none; b=RenYQa4+hsoBP2yNSD8yF1rJbG3e1op744DuiHeezQO/IYkn0F+IH2EFaDQCFooaQdhIoy0+7jq1RBFwWfM1EiSZx50uRpJf397pSdvDM34PUbWsySaoZ0thnBgAB2AdXiLYQnhLu9ngwb6hh1aH3wFsNn8ntOwuo0D+af7qIQ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716902118; c=relaxed/simple; bh=qjh548Ed99ribfGzmhee9KtCOpFpgKgwNHDsKsVMZ2E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oBeoZzDaA5wwdnXGAQSE475q8MGd1zwurC5ZIzurh450IP873O7tPgr0a6azVsXEOJvTu32JR3RAGXW3c2fCRt9Y2E88H+CEqTyciz7zV0gn3dLwciRHPgbjnJGOkmdsqtr2ugSfAoEB5E/7YMNehKSL5AXbNBQtI4J8xJOq6O4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pQpQptQv; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DE53C32782; Tue, 28 May 2024 13:15:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716902118; bh=qjh548Ed99ribfGzmhee9KtCOpFpgKgwNHDsKsVMZ2E=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=pQpQptQv9MrWTl3Z8WwqNILsEgxJXmuPYP7wvRCN0nx8QKRJ+nbkZfrkOFjM3fsuL WkAlzU/pHAKBNCUNLzr7XBqVPckrpg/+gd4mEyhTfRxgrto1ArhxRCBJSMbad1wRSH TaTE0fR5dI82DDvJzhBkCtWaSxLfhbmjeWucEBG0uQmNROBCbqeP29bgOI8YyjOBZn hpTlZ21X91/l9N/GXHNpfxbqBqB8R69bkEVrzMQBskMB3Q0ztg84vnaol33Fl7BWnA 7FWTD5/XuRGX8Fln/SJoR1eA9N7sOV++yMR+QIsS7gh24y9Li6GparAGlyCJOHNtB4 lyispOTTlhSyg== From: Benjamin Tissoires Date: Tue, 28 May 2024 15:14:39 +0200 Subject: [PATCH HID 01/13] 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: <20240528-hid_bpf_struct_ops-v1-1-8c6663df27d8@kernel.org> References: <20240528-hid_bpf_struct_ops-v1-0-8c6663df27d8@kernel.org> In-Reply-To: <20240528-hid_bpf_struct_ops-v1-0-8c6663df27d8@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=1716902113; l=4905; i=bentiss@kernel.org; s=20230215; h=from:subject:message-id; bh=qjh548Ed99ribfGzmhee9KtCOpFpgKgwNHDsKsVMZ2E=; b=Oo/12hPcmAyPOG2YIYuV5Ne6Mk1J/N4KezsSZ9g/H1gkEepx7MOydLSfCa4Q1RWBuj7FZuluM VcaoejiYtzjAqiwDT1RPPYaou5X5eQP4UApnDYpnjNdP0DClXkUH5jI 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 --- 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