From nobody Sun Apr 5 18:20:01 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 78ED32F363F; Mon, 23 Feb 2026 15:55:26 +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=1771862126; cv=none; b=qddIxgQrUEkoelAcmnz1JzKYo3UhpyWzvCdpDG63OWE2/dlL6yITb9c/0epz1GlWJJfeIjdfkBiqJYcHEPfWlfUtrzNgs+q4YX+7WGqtSqpNvLGlXcstZsDWP0E+lavLcSthQtxHsuwIsFX4ZkJPv9fyrC3bXgcGp8XgegWwiy4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771862126; c=relaxed/simple; bh=Ma/3uqBCY/oUPUsGcZ/PXNd8NktwdM+w2Ph3AWGp1Ls=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=W1mzM/vEe+DuiajCqbAipBiKKYMzGeFQFJyUp5octf81ZybZNWvklqKQlg8DeY9DDbqoWHmLA9Mts2qluELJjY08Lc++TPIaPpre9wKY7O/sYnpnqsUTpexTQZ8cnM15A2FPtzWUjFR+yS3qrB/pyMaCOuM/llWK8alvzFI8FGI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JN3t+APY; 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="JN3t+APY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F312C116C6; Mon, 23 Feb 2026 15:55:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771862126; bh=Ma/3uqBCY/oUPUsGcZ/PXNd8NktwdM+w2Ph3AWGp1Ls=; h=From:To:Cc:Subject:Date:From; b=JN3t+APYYN1dJ7kEXNH1Qu1AB2XL5ZPUNPEj28cqzrOnwVArreAdUJYhXoCZUqsQW fP9Ta4gw21Shsp2DrRr8090B4bUstkKE2+AdZX+MBSd0f74+cOeUGBfPY8cHWyIArG 6wfJHXyJsclJuqhHuq8eAVHHzejdaT5WPQCixQisAtSv4bRpcp5Gna7vzLR98+wv9t 48U9obonP4vIowjistMzT/OM+XXRJ86WCrG1yPJhfEV10FefzO2DVlqCEx0r8wsqrR 7ARmP3iGlXhi1wMzff+ouzAcRaoCh3PZJdP3bsZJRwek4CVJHoiDrCVFOlawFxBaTL f4Xh+3oIrW4GQ== From: "Rafael J. Wysocki" To: Jarkko Sakkinen Cc: Peter Huewe , Jason Gunthorpe , linux-integrity@vger.kernel.org, LKML , Linux ACPI Subject: [PATCH v1] tpm_crb: Convert ACPI driver to a platform one Date: Mon, 23 Feb 2026 16:55:21 +0100 Message-ID: <2706178.Lt9SDvczpP@rafael.j.wysocki> Organization: Linux Kernel Development 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 tpm_crb ACPI driver to a platform one. 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 Reviewed-by: Jarkko Sakkinen --- drivers/char/tpm/tpm_crb.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c index 6c25305c256e..7d1377e8e616 100644 --- a/drivers/char/tpm/tpm_crb.c +++ b/drivers/char/tpm/tpm_crb.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #ifdef CONFIG_ARM64 #include @@ -602,13 +603,13 @@ static u64 crb_fixup_cmd_size(struct device *dev, str= uct resource *io_res, return io_res->end - start + 1; } =20 -static int crb_map_io(struct acpi_device *device, struct crb_priv *priv, +static int crb_map_io(struct device *dev, struct crb_priv *priv, struct acpi_table_tpm2 *buf) { + struct acpi_device *device =3D ACPI_COMPANION(dev); struct list_head acpi_resource_list; struct resource iores_array[TPM_CRB_MAX_RESOURCES + 1] =3D { {0} }; void __iomem *iobase_array[TPM_CRB_MAX_RESOURCES] =3D {NULL}; - struct device *dev =3D &device->dev; struct resource *iores; void __iomem **iobase_ptr; int i; @@ -782,12 +783,13 @@ static int crb_map_pluton(struct device *dev, struct = crb_priv *priv, return 0; } =20 -static int crb_acpi_add(struct acpi_device *device) +static int crb_acpi_probe(struct platform_device *pdev) { + struct device *dev =3D &pdev->dev; + struct acpi_device *device =3D ACPI_COMPANION(dev); struct acpi_table_tpm2 *buf; struct crb_priv *priv; struct tpm_chip *chip; - struct device *dev =3D &device->dev; struct tpm2_crb_smc *crb_smc; struct tpm2_crb_ffa *crb_ffa; struct tpm2_crb_pluton *crb_pluton; @@ -867,7 +869,7 @@ static int crb_acpi_add(struct acpi_device *device) priv->sm =3D sm; priv->hid =3D acpi_device_hid(device); =20 - rc =3D crb_map_io(device, priv, buf); + rc =3D crb_map_io(dev, priv, buf); if (rc) goto out; =20 @@ -901,12 +903,9 @@ static int crb_acpi_add(struct acpi_device *device) return rc; } =20 -static void crb_acpi_remove(struct acpi_device *device) +static void crb_acpi_remove(struct platform_device *pdev) { - struct device *dev =3D &device->dev; - struct tpm_chip *chip =3D dev_get_drvdata(dev); - - tpm_chip_unregister(chip); + tpm_chip_unregister(platform_get_drvdata(pdev)); } =20 static const struct dev_pm_ops crb_pm =3D { @@ -919,19 +918,17 @@ static const struct acpi_device_id crb_device_ids[] = =3D { }; MODULE_DEVICE_TABLE(acpi, crb_device_ids); =20 -static struct acpi_driver crb_acpi_driver =3D { - .name =3D "tpm_crb", - .ids =3D crb_device_ids, - .ops =3D { - .add =3D crb_acpi_add, - .remove =3D crb_acpi_remove, - }, - .drv =3D { +static struct platform_driver crb_acpi_driver =3D { + .probe =3D crb_acpi_probe, + .remove =3D crb_acpi_remove, + .driver =3D { + .name =3D "tpm_crb_acpi", + .acpi_match_table =3D crb_device_ids, .pm =3D &crb_pm, }, }; =20 -module_acpi_driver(crb_acpi_driver); +module_platform_driver(crb_acpi_driver); MODULE_AUTHOR("Jarkko Sakkinen "); MODULE_DESCRIPTION("TPM2 Driver"); MODULE_VERSION("0.1"); --=20 2.51.0