platform/loongarch: laptop: fix some issues
cover platform/loongarch: laptop: fix some issues
This patchset fixes some issues in error path and remove unnecessary BUG_ON() in generic_subdriver_init().
Yang Yingliang (3):
platform/loongarch: laptop: add missing platform_driver_unregister()
in generic_subdriver_exit()
platform/loongarch: laptop: add missing generic_subdriver_exit() in
generic_acpi_laptop_init()
platform/loongarch: laptop: remove unnecessary BUG_ON in
generic_subdriver_init()
drivers/platform/loongarch/loongson-laptop.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/3 platform/loongarch: laptop: add missing platform_driver_unregister() in generic_subdriver_exit()
If setup_acpi_notify() fails in generic_subdriver_init(), platform_driver_unregister() need be called. Call it in generic_subdriver_exit().
--- drivers/platform/loongarch/loongson-laptop.c | 1 + 1 file changed, 1 insertion(+)
drivers/platform/loongarch/loongson-laptop.c +1 -0
@@ -535,6 +535,7 @@ static void generic_subdriver_exit(struct generic_sub_driver *sub_driver) sub_driver->type, dispatch_acpi_notify); sub_driver->acpi_notify_installed =0 ; } +platform_driver_unregister (sub_driver->driver); }static struct generic_sub_driver generic_sub_drivers[]__refdata = {
Signature · 1 line
2.25.1
PATCH 2/3 platform/loongarch: laptop: add missing generic_subdriver_exit() in generic_acpi_laptop_init()
In reply to Yang YingliangAdd missing generic_subdriver_exit() in generic_acpi_laptop_init() in error path.
--- drivers/platform/loongarch/loongson-laptop.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/platform/loongarch/loongson-laptop.c +4 -0
@@ -582,6 +582,8 @@ static int __init generic_acpi_laptop_init(void)for (i =0 ; i <ARRAY_SIZE (generic_sub_drivers); i++) { ret =generic_subdriver_init (&generic_sub_drivers[i]);if (ret <0 ) { +while (--i >=0 ) +generic_subdriver_exit (&generic_sub_drivers[i]);input_free_device (generic_inputdev);return ret; }
@@ -589,6 +591,8 @@ static int __init generic_acpi_laptop_init(void) ret =input_register_device (generic_inputdev);if (ret <0 ) { +while (--i >=0 ) +generic_subdriver_exit (&generic_sub_drivers[i]);input_free_device (generic_inputdev);pr_err ("Unable to register input device\n" );return ret;
Signature · 1 line
2.25.1
PATCH 3/3 platform/loongarch: laptop: remove unnecessary BUG_ON in generic_subdriver_init()
In reply to Yang YingliangThe 'sub_driver' has already be check, remove BUG_ON() to handle the fault more gracefully.
--- drivers/platform/loongarch/loongson-laptop.c | 2 -- 1 file changed, 2 deletions(-)
drivers/platform/loongarch/loongson-laptop.c +0 -2
@@ -498,8 +498,6 @@ static int __init generic_subdriver_init(struct generic_sub_driver *sub_driver) {int ret; -BUG_ON (!sub_driver); -if (!sub_driver || !sub_driver->driver)return -EINVAL ;
Signature · 1 line
2.25.1
Hi, Yingliang,
Thank you for your patch. But since the original patch is not upstream, this series will be squashed to the original one, thanks.
Huacai
Quoted 18 lines · Yang Yingliang
This patchset fixes some issues in error path and remove unnecessary
BUG_ON()ingeneric_subdriver_init().Yang Yingliang (3):
platform/loongarch: laptop: add missingplatform_driver_unregister()
ingeneric_subdriver_exit()
platform/loongarch: laptop: add missinggeneric_subdriver_exit()in
generic_acpi_laptop_init()
platform/loongarch: laptop: remove unnecessaryBUG_ONin
generic_subdriver_init()drivers/platform/loongarch/loongson-laptop.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)--
2.25.1