Skip to content

Commit 6cb9441

Browse files
sudeep-hollarafaeljw
authored andcommitted
ACPI: APEI: EINJ: Transition to the faux device interface
The APEI error injection driver does not require the creation of a platform device. Originally, this approach was chosen for simplicity when the driver was first implemented. With the introduction of the lightweight faux device interface, we now have a more appropriate alternative. Migrate the driver to utilize the faux bus, given that the platform device it previously created was not a real one anyway. This will simplify the code, reducing its footprint while maintaining functionality. Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> Link: https://patch.msgid.link/20250317-plat2faux_dev-v1-8-5fe67c085ad5@arm.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 0af2f6b commit 6cb9441

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

drivers/acpi/apei/einj-core.c

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include <linux/nmi.h>
2222
#include <linux/delay.h>
2323
#include <linux/mm.h>
24-
#include <linux/platform_device.h>
24+
#include <linux/device/faux.h>
2525
#include <linux/unaligned.h>
2626

2727
#include "apei-internal.h"
@@ -749,7 +749,7 @@ static int einj_check_table(struct acpi_table_einj *einj_tab)
749749
return 0;
750750
}
751751

752-
static int __init einj_probe(struct platform_device *pdev)
752+
static int __init einj_probe(struct faux_device *fdev)
753753
{
754754
int rc;
755755
acpi_status status;
@@ -851,7 +851,7 @@ static int __init einj_probe(struct platform_device *pdev)
851851
return rc;
852852
}
853853

854-
static void __exit einj_remove(struct platform_device *pdev)
854+
static void __exit einj_remove(struct faux_device *fdev)
855855
{
856856
struct apei_exec_context ctx;
857857

@@ -872,44 +872,34 @@ static void __exit einj_remove(struct platform_device *pdev)
872872
acpi_put_table((struct acpi_table_header *)einj_tab);
873873
}
874874

875-
static struct platform_device *einj_dev;
875+
static struct faux_device *einj_dev;
876876
/*
877877
* einj_remove() lives in .exit.text. For drivers registered via
878878
* platform_driver_probe() this is ok because they cannot get unbound at
879879
* runtime. So mark the driver struct with __refdata to prevent modpost
880880
* triggering a section mismatch warning.
881881
*/
882-
static struct platform_driver einj_driver __refdata = {
882+
static struct faux_device_ops einj_device_ops __refdata = {
883+
.probe = einj_probe,
883884
.remove = __exit_p(einj_remove),
884-
.driver = {
885-
.name = "acpi-einj",
886-
},
887885
};
888886

889887
static int __init einj_init(void)
890888
{
891-
struct platform_device_info einj_dev_info = {
892-
.name = "acpi-einj",
893-
.id = -1,
894-
};
895-
int rc;
896-
897-
einj_dev = platform_device_register_full(&einj_dev_info);
898-
if (IS_ERR(einj_dev))
899-
return PTR_ERR(einj_dev);
889+
einj_dev = faux_device_create("acpi-einj", NULL, &einj_device_ops);
890+
if (!einj_dev)
891+
return -ENODEV;
900892

901-
rc = platform_driver_probe(&einj_driver, einj_probe);
902-
einj_initialized = rc == 0;
893+
einj_initialized = true;
903894

904895
return 0;
905896
}
906897

907898
static void __exit einj_exit(void)
908899
{
909900
if (einj_initialized)
910-
platform_driver_unregister(&einj_driver);
901+
faux_device_destroy(einj_dev);
911902

912-
platform_device_unregister(einj_dev);
913903
}
914904

915905
module_init(einj_init);

0 commit comments

Comments
 (0)