From nobody Thu Apr 9 20:27:23 2026 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 EBE443A7F4F; Thu, 5 Mar 2026 19:48:15 +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=1772740096; cv=none; b=QYywvdLovRcnZ9T2N77i8QhW96yTY9Um81AHg9K8dTXxn21DqXDX5bC0onwLDJbiUYx1xO98Hx7gzIh8DVwz4FurzhZGfc/hSoyE1PxSizoQnc+w+aninFwG23yRF3ga8GnJhDLspZYjkO4/PuBCeJyJWUYNzaXXdWjIHb0O8jU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772740096; c=relaxed/simple; bh=9yJer96MzJXuZvdxv6mJybxoA3s/Seq/8IaWNJOiWZY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZYOt4c59mL5P9YDCjfEjL54Hjt+C629VdwX28ifWDe6pdA96F7BK9x185Bmedo+rsmMtIeGBXbMHeScrG94uflKn2L3UZ6G41zz0GrLFzWj42DDxJGA+YA2J3IpwNPRErimK5UGDkMk+E6aqXZjlLh3SDjHYt7nwCOYdR2WSr7E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NbelGDBp; 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="NbelGDBp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0F6BC2BC9E; Thu, 5 Mar 2026 19:48:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772740095; bh=9yJer96MzJXuZvdxv6mJybxoA3s/Seq/8IaWNJOiWZY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NbelGDBp3wkzHB3rzx8aJe4OKMR54PPB267ejld2fr6/Hq9mD2OSCq9qFOsthSjzF lrdaJ1yV4XPDOc9W/bHIZdcc03l9l2ArfgsEFVbe9xTnKObXi574LdkmI1pcJAJRc1 HTKfBgAaJwONrGDBNpQvPDVgQ0+Dq0LfEJGUWe9VC3rW0RZ3hkujVwN6G65qnlzTZx FjzLA9miFdGIo6FchoVOOgsUui3Q2SgVOVfLcMfel5Ecgt3SkQhqJpXDaFRdUcPMVp E4E25/di3sSMHBGX6/52wpC0gC02QG277qytx7izDDE99kq4FX+0qY+feyVodh7lEI W2oZENK/UfRCA== From: "Rafael J. Wysocki" To: Tzung-Bi Shih Cc: chrome-platform@lists.linux.dev, LKML , Linux ACPI , Benson Leung , Enric Balletbo i Serra , Ravi Chandra Sadineni Subject: [PATCH v2 4/6] platform/chrome: chromeos_tbmc: Convert to a platform driver Date: Thu, 05 Mar 2026 20:42:25 +0100 Message-ID: <10827297.nUPlyArG6x@rafael.j.wysocki> Organization: Linux Kernel Development In-Reply-To: <6259948.lOV4Wx5bFT@rafael.j.wysocki> References: <6259948.lOV4Wx5bFT@rafael.j.wysocki> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Rafael J. Wysocki" In all cases in which a struct acpi_driver is used for binding a driver to an ACPI device object, a corresponding platform device is created by the ACPI core and that device is regarded as a proper representation of underlying hardware. Accordingly, a struct platform_driver should be used by driver code to bind to that device. There are multiple reasons why drivers should not bind directly to ACPI device objects [1]. Overall, it is better to bind drivers to platform devices than to their ACPI companions, so convert the ChromeOS tablet mode change (TBMC) ACPI driver to a platform one. After this change, the subordinate input device and wakeup source class device will be registered under the platform device used for driver binding instead of its ACPI companion. While this is not expected to alter functionality, it changes sysfs layout and so it will be visible to user space. Link: https://lore.kernel.org/all/2396510.ElGaqSPkdT@rafael.j.wysocki/ [1] Signed-off-by: Rafael J. Wysocki --- v1 -> v2: * Pass dev to acpi_pm_wakeup_event() in chromeos_tbmc_notify() (Tzung-Bi= Shih) * Pass ACPI_COMPANION(dev) directly to chromeos_tbmc_query_switch in chromeos_tbmc_notify() --- drivers/platform/chrome/chromeos_tbmc.c | 47 ++++++++++++------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/drivers/platform/chrome/chromeos_tbmc.c b/drivers/platform/chr= ome/chromeos_tbmc.c index 9c988e697d09..5133806b2d95 100644 --- a/drivers/platform/chrome/chromeos_tbmc.c +++ b/drivers/platform/chrome/chromeos_tbmc.c @@ -16,6 +16,7 @@ #include #include #include +#include #include =20 #define DRV_NAME "chromeos_tbmc" @@ -40,22 +41,20 @@ static int chromeos_tbmc_query_switch(struct acpi_devic= e *adev, =20 static __maybe_unused int chromeos_tbmc_resume(struct device *dev) { - struct acpi_device *adev =3D to_acpi_device(dev); - - return chromeos_tbmc_query_switch(adev, adev->driver_data); + return chromeos_tbmc_query_switch(ACPI_COMPANION(dev), dev_get_drvdata(de= v)); } =20 static void chromeos_tbmc_notify(acpi_handle handle, u32 event, void *data) { - struct acpi_device *adev =3D data; + struct device *dev =3D data; =20 - acpi_pm_wakeup_event(&adev->dev); + acpi_pm_wakeup_event(dev); switch (event) { case 0x80: - chromeos_tbmc_query_switch(adev, adev->driver_data); + chromeos_tbmc_query_switch(ACPI_COMPANION(dev), dev_get_drvdata(dev)); break; default: - dev_err(&adev->dev, "Unexpected event: 0x%08X\n", event); + dev_err(dev, "Unexpected event: 0x%08X\n", event); } } =20 @@ -66,10 +65,11 @@ static int chromeos_tbmc_open(struct input_dev *idev) return chromeos_tbmc_query_switch(adev, idev); } =20 -static int chromeos_tbmc_add(struct acpi_device *adev) +static int chromeos_tbmc_probe(struct platform_device *pdev) { struct input_dev *idev; - struct device *dev =3D &adev->dev; + struct device *dev =3D &pdev->dev; + struct acpi_device *adev =3D ACPI_COMPANION(dev); int ret; =20 idev =3D devm_input_allocate_device(dev); @@ -85,7 +85,7 @@ static int chromeos_tbmc_add(struct acpi_device *adev) idev->open =3D chromeos_tbmc_open; =20 input_set_drvdata(idev, adev); - adev->driver_data =3D idev; + platform_set_drvdata(pdev, idev); =20 input_set_capability(idev, EV_SW, SW_TABLET_MODE); ret =3D input_register_device(idev); @@ -96,7 +96,7 @@ static int chromeos_tbmc_add(struct acpi_device *adev) device_init_wakeup(dev, true); =20 ret =3D acpi_dev_install_notify_handler(adev, ACPI_DEVICE_NOTIFY, - chromeos_tbmc_notify, adev); + chromeos_tbmc_notify, dev); if (ret) { dev_err(dev, "cannot install ACPI notify handler\n"); device_init_wakeup(dev, false); @@ -106,11 +106,11 @@ static int chromeos_tbmc_add(struct acpi_device *adev) return 0; } =20 -static void chromeos_tbmc_remove(struct acpi_device *adev) +static void chromeos_tbmc_remove(struct platform_device *pdev) { - acpi_dev_remove_notify_handler(adev, ACPI_DEVICE_NOTIFY, - chromeos_tbmc_notify); - device_init_wakeup(&adev->dev, false); + acpi_dev_remove_notify_handler(ACPI_COMPANION(&pdev->dev), + ACPI_DEVICE_NOTIFY, chromeos_tbmc_notify); + device_init_wakeup(&pdev->dev, false); } =20 static const struct acpi_device_id chromeos_tbmc_acpi_device_ids[] =3D { @@ -122,18 +122,17 @@ MODULE_DEVICE_TABLE(acpi, chromeos_tbmc_acpi_device_i= ds); static SIMPLE_DEV_PM_OPS(chromeos_tbmc_pm_ops, NULL, chromeos_tbmc_resume); =20 -static struct acpi_driver chromeos_tbmc_driver =3D { - .name =3D DRV_NAME, - .class =3D DRV_NAME, - .ids =3D chromeos_tbmc_acpi_device_ids, - .ops =3D { - .add =3D chromeos_tbmc_add, - .remove =3D chromeos_tbmc_remove, +static struct platform_driver chromeos_tbmc_driver =3D { + .probe =3D chromeos_tbmc_probe, + .remove =3D chromeos_tbmc_remove, + .driver =3D { + .name =3D DRV_NAME, + .acpi_match_table =3D chromeos_tbmc_acpi_device_ids, + .pm =3D &chromeos_tbmc_pm_ops, }, - .drv.pm =3D &chromeos_tbmc_pm_ops, }; =20 -module_acpi_driver(chromeos_tbmc_driver); +module_platform_driver(chromeos_tbmc_driver); =20 MODULE_LICENSE("GPL v2"); MODULE_DESCRIPTION("ChromeOS ACPI tablet switch driver"); --=20 2.51.0