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"
@@ -83,6 +83,8 @@ static struct debugfs_blob_wrapper vendor_blob;
8383static struct debugfs_blob_wrapper vendor_errors ;
8484static char vendor_dev [64 ];
8585
86+ static u32 available_error_type ;
87+
8688/*
8789 * Some BIOSes allow parameters to the SET_ERROR_TYPE entries in the
8890 * EINJ table through an unpublished extension. Use with caution as
@@ -648,14 +650,9 @@ static struct { u32 mask; const char *str; } const einj_error_type_string[] = {
648650
649651static int available_error_type_show (struct seq_file * m , void * v )
650652{
651- int rc ;
652- u32 error_type = 0 ;
653653
654- rc = einj_get_available_error_type (& error_type );
655- if (rc )
656- return rc ;
657654 for (int pos = 0 ; pos < ARRAY_SIZE (einj_error_type_string ); pos ++ )
658- if (error_type & einj_error_type_string [pos ].mask )
655+ if (available_error_type & einj_error_type_string [pos ].mask )
659656 seq_printf (m , "0x%08x\t%s\n" , einj_error_type_string [pos ].mask ,
660657 einj_error_type_string [pos ].str );
661658
@@ -678,8 +675,7 @@ bool einj_is_cxl_error_type(u64 type)
678675
679676int einj_validate_error_type (u64 type )
680677{
681- u32 tval , vendor , available_error_type = 0 ;
682- int rc ;
678+ u32 tval , vendor ;
683679
684680 /* Only low 32 bits for error type are valid */
685681 if (type & GENMASK_ULL (63 , 32 ))
@@ -695,13 +691,9 @@ int einj_validate_error_type(u64 type)
695691 /* Only one error type can be specified */
696692 if (tval & (tval - 1 ))
697693 return - EINVAL ;
698- if (!vendor ) {
699- rc = einj_get_available_error_type (& available_error_type );
700- if (rc )
701- return rc ;
694+ if (!vendor )
702695 if (!(type & available_error_type ))
703696 return - EINVAL ;
704- }
705697
706698 return 0 ;
707699}
@@ -749,17 +741,12 @@ static int einj_check_table(struct acpi_table_einj *einj_tab)
749741 return 0 ;
750742}
751743
752- static int __init einj_probe (struct platform_device * pdev )
744+ static int __init einj_probe (struct faux_device * fdev )
753745{
754746 int rc ;
755747 acpi_status status ;
756748 struct apei_exec_context ctx ;
757749
758- if (acpi_disabled ) {
759- pr_debug ("ACPI disabled.\n" );
760- return - ENODEV ;
761- }
762-
763750 status = acpi_get_table (ACPI_SIG_EINJ , 0 ,
764751 (struct acpi_table_header * * )& einj_tab );
765752 if (status == AE_NOT_FOUND ) {
@@ -777,6 +764,10 @@ static int __init einj_probe(struct platform_device *pdev)
777764 goto err_put_table ;
778765 }
779766
767+ rc = einj_get_available_error_type (& available_error_type );
768+ if (rc )
769+ return rc ;
770+
780771 rc = - ENOMEM ;
781772 einj_debug_dir = debugfs_create_dir ("einj" , apei_get_debugfs_dir ());
782773
@@ -851,7 +842,7 @@ static int __init einj_probe(struct platform_device *pdev)
851842 return rc ;
852843}
853844
854- static void __exit einj_remove (struct platform_device * pdev )
845+ static void __exit einj_remove (struct faux_device * fdev )
855846{
856847 struct apei_exec_context ctx ;
857848
@@ -872,44 +863,39 @@ static void __exit einj_remove(struct platform_device *pdev)
872863 acpi_put_table ((struct acpi_table_header * )einj_tab );
873864}
874865
875- static struct platform_device * einj_dev ;
866+ static struct faux_device * einj_dev ;
876867/*
877868 * einj_remove() lives in .exit.text. For drivers registered via
878869 * platform_driver_probe() this is ok because they cannot get unbound at
879870 * runtime. So mark the driver struct with __refdata to prevent modpost
880871 * triggering a section mismatch warning.
881872 */
882- static struct platform_driver einj_driver __refdata = {
873+ static struct faux_device_ops einj_device_ops __refdata = {
874+ .probe = einj_probe ,
883875 .remove = __exit_p (einj_remove ),
884- .driver = {
885- .name = "acpi-einj" ,
886- },
887876};
888877
889878static int __init einj_init (void )
890879{
891- struct platform_device_info einj_dev_info = {
892- .name = "acpi-einj" ,
893- .id = -1 ,
894- };
895- int rc ;
880+ if (acpi_disabled ) {
881+ pr_debug ("ACPI disabled.\n" );
882+ return - ENODEV ;
883+ }
896884
897- einj_dev = platform_device_register_full ( & einj_dev_info );
898- if (IS_ERR ( einj_dev ) )
899- return PTR_ERR ( einj_dev ) ;
885+ einj_dev = faux_device_create ( "acpi-einj" , NULL , & einj_device_ops );
886+ if (! einj_dev )
887+ return - ENODEV ;
900888
901- rc = platform_driver_probe (& einj_driver , einj_probe );
902- einj_initialized = rc == 0 ;
889+ einj_initialized = true;
903890
904891 return 0 ;
905892}
906893
907894static void __exit einj_exit (void )
908895{
909896 if (einj_initialized )
910- platform_driver_unregister ( & einj_driver );
897+ faux_device_destroy ( einj_dev );
911898
912- platform_device_unregister (einj_dev );
913899}
914900
915901module_init (einj_init );
0 commit comments