On Mon, 13 Jul 2026, Bartosz Golaszewski wrote: > Creating a software node for a given set of properties and adding it to > a platform device can be achieved with a single call to > platform_device_register_full(). There's nothing in this driver that > suggests using the more fine-grained interfaces was intentional so > switch to using the high-level helper. > > Signed-off-by: Bartosz Golaszewski <[email protected]> > --- > drivers/platform/surface/surface_gpe.c | 39 > ++++++++++------------------------ > 1 file changed, 11 insertions(+), 28 deletions(-) > > diff --git a/drivers/platform/surface/surface_gpe.c > b/drivers/platform/surface/surface_gpe.c > index > 40896a8544b0a4da4261ea881b1eaed62d93b32b..4ca7ad76f3b9d2b6c455a5d5b37f23a85eb69c69 > 100644 > --- a/drivers/platform/surface/surface_gpe.c > +++ b/drivers/platform/surface/surface_gpe.c > @@ -290,9 +290,9 @@ static struct platform_device *surface_gpe_device; > > static int __init surface_gpe_init(void) > { > + struct platform_device_info pdevinfo; > const struct dmi_system_id *match; > struct platform_device *pdev; > - struct fwnode_handle *fwnode; > int status; > > match = dmi_first_match(dmi_lid_device_table); > @@ -305,44 +305,27 @@ static int __init surface_gpe_init(void) > if (status) > return status; > > - fwnode = fwnode_create_software_node(match->driver_data, NULL); > - if (IS_ERR(fwnode)) { > - status = PTR_ERR(fwnode); > - goto err_node; > - } > - > - pdev = platform_device_alloc("surface_gpe", PLATFORM_DEVID_NONE); > - if (!pdev) { > - status = -ENOMEM; > - goto err_alloc; > + pdevinfo = (struct platform_device_info){ > + .name = "surface_gpe", > + .id = PLATFORM_DEVID_NONE, > + .properties = match->driver_data, > + }; > + > + pdev = platform_device_register_full(&pdevinfo); > + if (IS_ERR(pdev)) {
Hi, Please add an include for this and PTR_ERR(). With the missing include fixed, Acked-by: Ilpo Järvinen <[email protected]> Thanks for doing these. > + platform_driver_unregister(&surface_gpe_driver); > + return PTR_ERR(pdev); > } -- i. > > - platform_device_set_fwnode(pdev, fwnode); > - > - status = platform_device_add(pdev); > - if (status) > - goto err_add; > - > surface_gpe_device = pdev; > return 0; > - > -err_add: > - platform_device_put(pdev); > -err_alloc: > - fwnode_remove_software_node(fwnode); > -err_node: > - platform_driver_unregister(&surface_gpe_driver); > - return status; > } > module_init(surface_gpe_init); > > static void __exit surface_gpe_exit(void) > { > - struct fwnode_handle *fwnode = surface_gpe_device->dev.fwnode; > - > platform_device_unregister(surface_gpe_device); > platform_driver_unregister(&surface_gpe_driver); > - fwnode_remove_software_node(fwnode); > } > module_exit(surface_gpe_exit);
