Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tpm_crb: Convert ACPI driver to a platform one

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 <rafael.j.wysocki@intel.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>

authored by

Rafael J. Wysocki and committed by
Jarkko Sakkinen
48fe2cdd e6ffe094

+16 -19
+16 -19
drivers/char/tpm/tpm_crb.c
··· 15 15 #include <linux/highmem.h> 16 16 #include <linux/rculist.h> 17 17 #include <linux/module.h> 18 + #include <linux/platform_device.h> 18 19 #include <linux/pm_runtime.h> 19 20 #ifdef CONFIG_ARM64 20 21 #include <linux/arm-smccc.h> ··· 603 602 return io_res->end - start + 1; 604 603 } 605 604 606 - static int crb_map_io(struct acpi_device *device, struct crb_priv *priv, 605 + static int crb_map_io(struct device *dev, struct crb_priv *priv, 607 606 struct acpi_table_tpm2 *buf) 608 607 { 608 + struct acpi_device *device = ACPI_COMPANION(dev); 609 609 struct list_head acpi_resource_list; 610 610 struct resource iores_array[TPM_CRB_MAX_RESOURCES + 1] = { {0} }; 611 611 void __iomem *iobase_array[TPM_CRB_MAX_RESOURCES] = {NULL}; 612 - struct device *dev = &device->dev; 613 612 struct resource *iores; 614 613 void __iomem **iobase_ptr; 615 614 int i; ··· 783 782 return 0; 784 783 } 785 784 786 - static int crb_acpi_add(struct acpi_device *device) 785 + static int crb_acpi_probe(struct platform_device *pdev) 787 786 { 787 + struct device *dev = &pdev->dev; 788 + struct acpi_device *device = ACPI_COMPANION(dev); 788 789 struct acpi_table_tpm2 *buf; 789 790 struct crb_priv *priv; 790 791 struct tpm_chip *chip; 791 - struct device *dev = &device->dev; 792 792 struct tpm2_crb_smc *crb_smc; 793 793 struct tpm2_crb_ffa *crb_ffa; 794 794 struct tpm2_crb_pluton *crb_pluton; ··· 869 867 priv->sm = sm; 870 868 priv->hid = acpi_device_hid(device); 871 869 872 - rc = crb_map_io(device, priv, buf); 870 + rc = crb_map_io(dev, priv, buf); 873 871 if (rc) 874 872 goto out; 875 873 ··· 903 901 return rc; 904 902 } 905 903 906 - static void crb_acpi_remove(struct acpi_device *device) 904 + static void crb_acpi_remove(struct platform_device *pdev) 907 905 { 908 - struct device *dev = &device->dev; 909 - struct tpm_chip *chip = dev_get_drvdata(dev); 910 - 911 - tpm_chip_unregister(chip); 906 + tpm_chip_unregister(platform_get_drvdata(pdev)); 912 907 } 913 908 914 909 static const struct dev_pm_ops crb_pm = { ··· 918 919 }; 919 920 MODULE_DEVICE_TABLE(acpi, crb_device_ids); 920 921 921 - static struct acpi_driver crb_acpi_driver = { 922 - .name = "tpm_crb", 923 - .ids = crb_device_ids, 924 - .ops = { 925 - .add = crb_acpi_add, 926 - .remove = crb_acpi_remove, 927 - }, 928 - .drv = { 922 + static struct platform_driver crb_acpi_driver = { 923 + .probe = crb_acpi_probe, 924 + .remove = crb_acpi_remove, 925 + .driver = { 926 + .name = "tpm_crb_acpi", 927 + .acpi_match_table = crb_device_ids, 929 928 .pm = &crb_pm, 930 929 }, 931 930 }; 932 931 933 - module_acpi_driver(crb_acpi_driver); 932 + module_platform_driver(crb_acpi_driver); 934 933 MODULE_AUTHOR("Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>"); 935 934 MODULE_DESCRIPTION("TPM2 Driver"); 936 935 MODULE_VERSION("0.1");