From patchwork Tue Oct 1 14:30:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 832582 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 ED3591CB50A; Tue, 1 Oct 2024 14:30:50 +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=1727793051; cv=none; b=gD9sXh8lN+05A+Oom+mXwfnsRnmmw2UpbSUEfaDK/74NOYUXFMtQvSEUEIGffw9kYgbjw10V3BQdb4CN5kmxlnvg5rMLldaF5bgaZjtttMENQEcfLHuMrUThcgN/Y3TGNYYnoaGkowtay5w7eBnjotHyEk1GbSKHWIVKIpkFOkc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727793051; c=relaxed/simple; bh=DRRfheB9mdrcUWe1w3swekqPJusrinGNe3sPZf+1eEg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eyzWPHn/v/xsGfwCcUZCxVID1TldOFWrVZLFPKgC6uCCKyBVoH8Q938Qi3QGdseYlZlSqTGKJZQQld4fXLTYCED3kc8fRV+lGgYU4ZniowtUL2lx/da6MFOT6s0GOuCzoOq0yEYv9Erv8+27J2kNzhBcM0ktBLYwZjiVIYCdsrg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YgBYwi3v; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YgBYwi3v" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD2DAC4CED2; Tue, 1 Oct 2024 14:30:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727793050; bh=DRRfheB9mdrcUWe1w3swekqPJusrinGNe3sPZf+1eEg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=YgBYwi3vvdRd3vAH0VmHpG5S5b2qbg8k3rYxHhfrzabDAebeyd8Ipcapyw9eliveP 6JRHGpmt/4utyuaR/EOCr89gzgpkaxMqdpbVIuZu6aCZvuVl6I/qc6mP5THACRvgmn rAtzdF3Yca8mWA4IQ6FaPOCbBNCpJhScE8ftYf3aN2Tf3YetXeuzaQIg4HF4j+RTS4 CNzSP5bpurBPiTtRYnehtGQGGVwJnufGuiwJdGW94IyHcD7ztbz4RrCjJDrlnHGDYe hDTphp7Spjz8xa9MJv3heJyY6nkNuilra7r5IpQKlYJUn79x64Ct3ngIXfYr8uM9Bf bsEvDgUjpRrgg== From: Benjamin Tissoires Date: Tue, 01 Oct 2024 16:30:12 +0200 Subject: [PATCH HID v3 8/9] HID: add per device quirk to force bind to hid-generic Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241001-hid-bpf-hid-generic-v3-8-2ef1019468df@kernel.org> References: <20241001-hid-bpf-hid-generic-v3-0-2ef1019468df@kernel.org> In-Reply-To: <20241001-hid-bpf-hid-generic-v3-0-2ef1019468df@kernel.org> To: Jiri Kosina , Peter Hutterer , Vicki Pfau , Shuah Khan Cc: linux-input@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, Benjamin Tissoires X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1727793031; l=2784; i=bentiss@kernel.org; s=20230215; h=from:subject:message-id; bh=DRRfheB9mdrcUWe1w3swekqPJusrinGNe3sPZf+1eEg=; b=zc7qGrFJZPV8iY+dFZC1So+CsgImJ4yBf4MfFymlT1MpL4v5gVOkFM8qPlKN/2cJvfUpopmT2 uRq6gCl4j7ECbTB4TddXZ3QyhrNiGS1kGk6iQZOi/2AXnc9GaFS8Pfu X-Developer-Key: i=bentiss@kernel.org; a=ed25519; pk=7D1DyAVh6ajCkuUTudt/chMuXWIJHlv2qCsRkIizvFw= We already have the possibility to force not binding to hid-generic and rely on a dedicated driver, but we couldn't do the other way around. This is useful for BPF programs where we are fixing the report descriptor and the events, but want to avoid a specialized driver to come after BPF which would unwind everything that is done there. Reviewed-by: Peter Hutterer Signed-off-by: Benjamin Tissoires --- no changes in v3 changes in v2: - rely on hdev->quirks for that instead of a new struct for hid_driver --- drivers/hid/hid-core.c | 5 +++-- drivers/hid/hid-generic.c | 3 +++ include/linux/hid.h | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 8e879937e956..f1c23b21e96a 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -2698,9 +2698,10 @@ static bool hid_check_device_match(struct hid_device *hdev, /* * hid-generic implements .match(), so we must be dealing with a * different HID driver here, and can simply check if - * hid_ignore_special_drivers is set or not. + * hid_ignore_special_drivers or HID_QUIRK_IGNORE_SPECIAL_DRIVER + * are set or not. */ - return !hid_ignore_special_drivers; + return !hid_ignore_special_drivers && !(hdev->quirks & HID_QUIRK_IGNORE_SPECIAL_DRIVER); } static int __hid_device_probe(struct hid_device *hdev, struct hid_driver *hdrv) diff --git a/drivers/hid/hid-generic.c b/drivers/hid/hid-generic.c index f9db991d3c5a..88882c1bfffe 100644 --- a/drivers/hid/hid-generic.c +++ b/drivers/hid/hid-generic.c @@ -40,6 +40,9 @@ static bool hid_generic_match(struct hid_device *hdev, if (ignore_special_driver) return true; + if (hdev->quirks & HID_QUIRK_IGNORE_SPECIAL_DRIVER) + return true; + if (hdev->quirks & HID_QUIRK_HAVE_SPECIAL_DRIVER) return false; diff --git a/include/linux/hid.h b/include/linux/hid.h index ff58b5ceb62e..63330d623335 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -359,6 +359,7 @@ struct hid_item { * | @HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP: * | @HID_QUIRK_HAVE_SPECIAL_DRIVER: * | @HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE: + * | @HID_QUIRK_IGNORE_SPECIAL_DRIVER * | @HID_QUIRK_FULLSPEED_INTERVAL: * | @HID_QUIRK_NO_INIT_REPORTS: * | @HID_QUIRK_NO_IGNORE: @@ -384,6 +385,7 @@ struct hid_item { #define HID_QUIRK_HAVE_SPECIAL_DRIVER BIT(19) #define HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE BIT(20) #define HID_QUIRK_NOINVERT BIT(21) +#define HID_QUIRK_IGNORE_SPECIAL_DRIVER BIT(22) #define HID_QUIRK_FULLSPEED_INTERVAL BIT(28) #define HID_QUIRK_NO_INIT_REPORTS BIT(29) #define HID_QUIRK_NO_IGNORE BIT(30)