From nobody Mon Feb 9 08:56:20 2026 Received: from mail-io1-f73.google.com (mail-io1-f73.google.com [209.85.166.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5316124A047 for ; Thu, 30 Oct 2025 14:10:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761833444; cv=none; b=OwvxpQekd4wcw38RkRzL7AgX4IC1t8OeO1zSiMcrqGSY4iJwP2o9nU6NlQgc9SgIOMqXw/zH0cnRIfIcSt0zkHOqXg/ZvuTM/KEr1D9lx+XcKaC0nURVZJ7ll867IQfRQVPk8FmaHhcxIo7J0LC/WHlHZSMpaOwTudMJBXtpQgg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761833444; c=relaxed/simple; bh=1Rv+cNZUnHqjrlP4AuPv1UvjdUJGPgsu2fReIcVoAss=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=n2eI0txAugpG7HgtxuPcWKQwN90KuMc6oWP/KT9SZeYttV3xY5ebOE5qjH9X516osES/9SyZ+iTu6s5/2E7i57CZn37JLfCnWYOLbCz3Elwl6HVQRIQqQL3pwip23gAIk/LUAFbZYK+1YzCItNzaoCd2p1rI54+A4rJx3/ajZEM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jdenose.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=JB67kJya; arc=none smtp.client-ip=209.85.166.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jdenose.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="JB67kJya" Received: by mail-io1-f73.google.com with SMTP id ca18e2360f4ac-945a4849260so305368939f.3 for ; Thu, 30 Oct 2025 07:10:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1761833442; x=1762438242; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=uzx+TIGAHeWAdlRbvKzxCvCV+3aa2fiQ4ymntya7+7o=; b=JB67kJyaAPmlahBeN0yC/NaYZyjgzoCJo5z6MKZdBgiMKJIsU6KGWIdK6zpb/qxkbj F4mOtsNZTCtu8ZV9seE7+kpClrMSb4Y3OX+QL3RLvsw3gG/HPpNs1kggur4dXyMlv5G5 6NySnIVj+LC35ANVHc4uaO0Ii23KJNscZ/5Lw0sVjv3DsQ8j+Wbdxhb4oFbGXoHL7jfv mZGjgwH5nsbtnCzYt31QCNXm59DDyOZXe2Ywf6g/tLuOZrQAov13X3fd46LLmCg/x0l7 BvFgsM6dUHFUJNEOFMlhRxuaUpwqoXVz7zs49/3a8wFbtBFZbRDfVkRfwhZCnzepURC7 N9SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761833442; x=1762438242; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uzx+TIGAHeWAdlRbvKzxCvCV+3aa2fiQ4ymntya7+7o=; b=FVVyqXQe0Ai1grJEcRP9blAvlAcj7jVXwOVR0WbU9Kd8Cc+XY2QihlYsdX0zyTa7L0 mJQbevMKNmz8MMPd/NOKbbGdLKFSOBayG0N7mIYFloOIDPiF1Q39JtKTDyaAQb+iBIur n96Pn1lPy3E3Al66AwxZXkThtolA9fndc2LMKH3brEZZo8mCAS5j01hEpZALn56X5T90 fB0JSvjZMFuV4EvFT5Yl4f8ATCihUFVnn6OhscVyeAtR0cKbXM6i2TUXKUxj0yUyeiVc 8SD6j2f14RbPwDEva15n3EgBPnenHrEGvCSLkZJVxmVf6hgOrEYHtS/sLJMXUR77oorG hVeg== X-Forwarded-Encrypted: i=1; AJvYcCVNmJ5ARMgVZ8pyEu6DWMxin3fwz2NsSkngPUMqIxrQJAFR9/gz51hNqr+ecRSdC3GrPfRTbteX3f4fXBk=@vger.kernel.org X-Gm-Message-State: AOJu0YwHxenLGgGP08VfFkxjj9aBt9wpBVB1kOAY++nz9TicbnyLW0ML ZNYULaQCvRXGcnfd87tp+rTrmWJ6ck/3Vx4ou+j/FQXLKHZ91yYe90MoFq1yaT7qqg7gFIeOCgB zqFEtldhevA== X-Google-Smtp-Source: AGHT+IEwb0t0Qlisa1OGs7apQisuIV8c9QvZ3+m4D0xseH90T0W4voKqMOYGDhGhJCAdffYKjr4Z1nUlCfXn X-Received: from iobbe6.prod.google.com ([2002:a05:6602:3786:b0:943:5a50:ad49]) (user=jdenose job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6e02:1609:b0:42d:b5d0:1930 with SMTP id e9e14a558f8ab-4330154fb44mr46377195ab.23.1761833442501; Thu, 30 Oct 2025 07:10:42 -0700 (PDT) Date: Thu, 30 Oct 2025 14:10:40 +0000 In-Reply-To: <20251030-lid-switch-notifier-v1-0-c58dc9b1439d@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251030-lid-switch-notifier-v1-0-c58dc9b1439d@google.com> X-Mailer: b4 0.14.2 Message-ID: <20251030-lid-switch-notifier-v1-1-c58dc9b1439d@google.com> Subject: [PATCH 1/2] Input: Create input notifier chain in input.c From: Jonathan Denose To: Dmitry Torokhov , Jiri Kosina , Benjamin Tissoires Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Denose Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable To expose input events to other kernel modules, add a blocking notifier chain. Publish LID_SWITCH_OPEN/LID_SWITCH_CLOSE events through this notifier chain when input_handle_event detects events signaling the lid switch has opened or closed. Additionally, export a function which allows other kernel modules to register notifier_block structs against this notifier chain. Signed-off-by: Jonathan Denose --- drivers/input/input.c | 13 +++++++++++++ include/linux/input.h | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/drivers/input/input.c b/drivers/input/input.c index a500e1e276c211d1146dbfea421a3402084007f8..b342b1ff138ccc58d4623edcf11= 52bd85d7054bf 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "input-compat.h" #include "input-core-private.h" #include "input-poller.h" @@ -62,6 +63,8 @@ static const unsigned int input_max_code[EV_CNT] =3D { [EV_FF] =3D FF_MAX, }; =20 +static struct blocking_notifier_head input_notifier_head; + static inline int is_event_supported(unsigned int code, unsigned long *bm, unsigned int max) { @@ -367,10 +370,20 @@ void input_handle_event(struct input_dev *dev, if (type !=3D EV_SYN) add_input_randomness(type, code, value); =20 + if (type =3D=3D EV_SW && code =3D=3D SW_LID && !value) + blocking_notifier_call_chain(&input_notifier_head, value ? + LID_SWITCH_CLOSE : LID_SWITCH_OPEN, dev); + input_event_dispose(dev, disposition, type, code, value); } } =20 +int register_input_notifier(struct notifier_block *notifier) +{ + return blocking_notifier_chain_register(&input_notifier_head, notifier); +} +EXPORT_SYMBOL(register_input_notifier); + /** * input_event() - report new input event * @dev: device that generated the event diff --git a/include/linux/input.h b/include/linux/input.h index 7d7cb0593a63e93c4906c49cde430188db2d1ab5..e940aff8843a0afc693c60a252d= 6b0dbcb3476c4 100644 --- a/include/linux/input.h +++ b/include/linux/input.h @@ -42,6 +42,11 @@ enum input_clock_type { INPUT_CLK_MAX }; =20 +enum input_notify_event_type { + LID_SWITCH_OPEN, + LID_SWITCH_CLOSE +}; + /** * struct input_dev - represents an input device * @name: name of the device @@ -431,6 +436,8 @@ int input_flush_device(struct input_handle *handle, str= uct file *file); void input_set_timestamp(struct input_dev *dev, ktime_t timestamp); ktime_t *input_get_timestamp(struct input_dev *dev); =20 +int register_input_notifier(struct notifier_block *notifier); + void input_event(struct input_dev *dev, unsigned int type, unsigned int co= de, int value); void input_inject_event(struct input_handle *handle, unsigned int type, un= signed int code, int value); =20 --=20 2.51.1.851.g4ebd6896fd-goog