linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next 0/3] platform/loongarch: laptop: fix some issues
@ 2022-10-09  3:40 Yang Yingliang
  2022-10-09  3:40 ` [PATCH -next 1/3] platform/loongarch: laptop: add missing platform_driver_unregister() in generic_subdriver_exit() Yang Yingliang
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Yang Yingliang @ 2022-10-09  3:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: chenhuacai, lvjianmin, chenhuacai

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(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH -next 1/3] platform/loongarch: laptop: add missing platform_driver_unregister() in generic_subdriver_exit()
  2022-10-09  3:40 [PATCH -next 0/3] platform/loongarch: laptop: fix some issues Yang Yingliang
@ 2022-10-09  3:40 ` Yang Yingliang
  2022-10-09  3:40 ` [PATCH -next 2/3] platform/loongarch: laptop: add missing generic_subdriver_exit() in generic_acpi_laptop_init() Yang Yingliang
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Yang Yingliang @ 2022-10-09  3:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: chenhuacai, lvjianmin, chenhuacai

If setup_acpi_notify() fails in generic_subdriver_init(),
platform_driver_unregister() need be called. Call it in
generic_subdriver_exit().

Fixes: ee7fa5029de8 ("LoongArch: Add ACPI-based generic laptop driver")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/platform/loongarch/loongson-laptop.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/platform/loongarch/loongson-laptop.c b/drivers/platform/loongarch/loongson-laptop.c
index e61fe7c305e0..d9f82c3991c0 100644
--- a/drivers/platform/loongarch/loongson-laptop.c
+++ b/drivers/platform/loongarch/loongson-laptop.c
@@ -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 = {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH -next 2/3] platform/loongarch: laptop: add missing generic_subdriver_exit() in generic_acpi_laptop_init()
  2022-10-09  3:40 [PATCH -next 0/3] platform/loongarch: laptop: fix some issues Yang Yingliang
  2022-10-09  3:40 ` [PATCH -next 1/3] platform/loongarch: laptop: add missing platform_driver_unregister() in generic_subdriver_exit() Yang Yingliang
@ 2022-10-09  3:40 ` Yang Yingliang
  2022-10-09  3:40 ` [PATCH -next 3/3] platform/loongarch: laptop: remove unnecessary BUG_ON in generic_subdriver_init() Yang Yingliang
  2022-10-09  6:15 ` [PATCH -next 0/3] platform/loongarch: laptop: fix some issues Huacai Chen
  3 siblings, 0 replies; 5+ messages in thread
From: Yang Yingliang @ 2022-10-09  3:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: chenhuacai, lvjianmin, chenhuacai

Add missing generic_subdriver_exit() in generic_acpi_laptop_init()
in error path.

Fixes: ee7fa5029de8 ("LoongArch: Add ACPI-based generic laptop driver")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/platform/loongarch/loongson-laptop.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/platform/loongarch/loongson-laptop.c b/drivers/platform/loongarch/loongson-laptop.c
index d9f82c3991c0..a9fdfac50f35 100644
--- a/drivers/platform/loongarch/loongson-laptop.c
+++ b/drivers/platform/loongarch/loongson-laptop.c
@@ -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;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH -next 3/3] platform/loongarch: laptop: remove unnecessary BUG_ON in generic_subdriver_init()
  2022-10-09  3:40 [PATCH -next 0/3] platform/loongarch: laptop: fix some issues Yang Yingliang
  2022-10-09  3:40 ` [PATCH -next 1/3] platform/loongarch: laptop: add missing platform_driver_unregister() in generic_subdriver_exit() Yang Yingliang
  2022-10-09  3:40 ` [PATCH -next 2/3] platform/loongarch: laptop: add missing generic_subdriver_exit() in generic_acpi_laptop_init() Yang Yingliang
@ 2022-10-09  3:40 ` Yang Yingliang
  2022-10-09  6:15 ` [PATCH -next 0/3] platform/loongarch: laptop: fix some issues Huacai Chen
  3 siblings, 0 replies; 5+ messages in thread
From: Yang Yingliang @ 2022-10-09  3:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: chenhuacai, lvjianmin, chenhuacai

The 'sub_driver' has already be check, remove BUG_ON() to handle the fault
more gracefully.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/platform/loongarch/loongson-laptop.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/platform/loongarch/loongson-laptop.c b/drivers/platform/loongarch/loongson-laptop.c
index a9fdfac50f35..8299195a7116 100644
--- a/drivers/platform/loongarch/loongson-laptop.c
+++ b/drivers/platform/loongarch/loongson-laptop.c
@@ -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;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH -next 0/3] platform/loongarch: laptop: fix some issues
  2022-10-09  3:40 [PATCH -next 0/3] platform/loongarch: laptop: fix some issues Yang Yingliang
                   ` (2 preceding siblings ...)
  2022-10-09  3:40 ` [PATCH -next 3/3] platform/loongarch: laptop: remove unnecessary BUG_ON in generic_subdriver_init() Yang Yingliang
@ 2022-10-09  6:15 ` Huacai Chen
  3 siblings, 0 replies; 5+ messages in thread
From: Huacai Chen @ 2022-10-09  6:15 UTC (permalink / raw)
  To: Yang Yingliang; +Cc: linux-kernel, lvjianmin, chenhuacai

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

On Sun, Oct 9, 2022 at 11:40 AM Yang Yingliang <yangyingliang@huawei.com> wrote:
>
> 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(-)
>
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-10-09  6:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-09  3:40 [PATCH -next 0/3] platform/loongarch: laptop: fix some issues Yang Yingliang
2022-10-09  3:40 ` [PATCH -next 1/3] platform/loongarch: laptop: add missing platform_driver_unregister() in generic_subdriver_exit() Yang Yingliang
2022-10-09  3:40 ` [PATCH -next 2/3] platform/loongarch: laptop: add missing generic_subdriver_exit() in generic_acpi_laptop_init() Yang Yingliang
2022-10-09  3:40 ` [PATCH -next 3/3] platform/loongarch: laptop: remove unnecessary BUG_ON in generic_subdriver_init() Yang Yingliang
2022-10-09  6:15 ` [PATCH -next 0/3] platform/loongarch: laptop: fix some issues Huacai Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).