mirror of
https://github.com/torvalds/linux.git
synced 2026-09-26 18:12:03 +02:00
platform/surface: gpe: use platform_device_register_full()
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. Acked-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> Link: https://patch.msgid.link/20260716-swnode-remove-on-dev-unreg-v8-2-5c2b8cc38c28@oss.qualcomm.com Signed-off-by: Danilo Krummrich <dakr@kernel.org>
This commit is contained in:
parent
e6054f410c
commit
1e0bd438b8
|
|
@ -290,9 +290,9 @@ static struct platform_device *surface_gpe_device;
|
||||||
|
|
||||||
static int __init surface_gpe_init(void)
|
static int __init surface_gpe_init(void)
|
||||||
{
|
{
|
||||||
|
struct platform_device_info pdevinfo;
|
||||||
const struct dmi_system_id *match;
|
const struct dmi_system_id *match;
|
||||||
struct platform_device *pdev;
|
struct platform_device *pdev;
|
||||||
struct fwnode_handle *fwnode;
|
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
match = dmi_first_match(dmi_lid_device_table);
|
match = dmi_first_match(dmi_lid_device_table);
|
||||||
|
|
@ -305,44 +305,27 @@ static int __init surface_gpe_init(void)
|
||||||
if (status)
|
if (status)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
fwnode = fwnode_create_software_node(match->driver_data, NULL);
|
pdevinfo = (struct platform_device_info){
|
||||||
if (IS_ERR(fwnode)) {
|
.name = "surface_gpe",
|
||||||
status = PTR_ERR(fwnode);
|
.id = PLATFORM_DEVID_NONE,
|
||||||
goto err_node;
|
.properties = match->driver_data,
|
||||||
|
};
|
||||||
|
|
||||||
|
pdev = platform_device_register_full(&pdevinfo);
|
||||||
|
if (IS_ERR(pdev)) {
|
||||||
|
platform_driver_unregister(&surface_gpe_driver);
|
||||||
|
return PTR_ERR(pdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
pdev = platform_device_alloc("surface_gpe", PLATFORM_DEVID_NONE);
|
|
||||||
if (!pdev) {
|
|
||||||
status = -ENOMEM;
|
|
||||||
goto err_alloc;
|
|
||||||
}
|
|
||||||
|
|
||||||
platform_device_set_fwnode(pdev, fwnode);
|
|
||||||
|
|
||||||
status = platform_device_add(pdev);
|
|
||||||
if (status)
|
|
||||||
goto err_add;
|
|
||||||
|
|
||||||
surface_gpe_device = pdev;
|
surface_gpe_device = pdev;
|
||||||
return 0;
|
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);
|
module_init(surface_gpe_init);
|
||||||
|
|
||||||
static void __exit surface_gpe_exit(void)
|
static void __exit surface_gpe_exit(void)
|
||||||
{
|
{
|
||||||
struct fwnode_handle *fwnode = surface_gpe_device->dev.fwnode;
|
|
||||||
|
|
||||||
platform_device_unregister(surface_gpe_device);
|
platform_device_unregister(surface_gpe_device);
|
||||||
platform_driver_unregister(&surface_gpe_driver);
|
platform_driver_unregister(&surface_gpe_driver);
|
||||||
fwnode_remove_software_node(fwnode);
|
|
||||||
}
|
}
|
||||||
module_exit(surface_gpe_exit);
|
module_exit(surface_gpe_exit);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user