diff mbox series

Input: wm97xx: only unregister wm97xx_driver if it has been registered

Message ID 20180904183505.10693-1-colin.king@canonical.com (mailing list archive)
State New, archived
Headers show
Series Input: wm97xx: only unregister wm97xx_driver if it has been registered | expand

Commit Message

Colin King Sept. 4, 2018, 6:35 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

In the case where IS_BUILTIN(CONFIG_AC97_BUS)) is not true, the
wm97xx_driver driver is being unregistered even it has not been
previously registered.  Fix this by only unregistering it if
IS_BUILTIN(CONFIG_AC97_BUS)) is true.  This fixes the warning
message:

[  834.111248] ------------[ cut here ]------------
[  834.111248] Unexpected driver unregister!
[  834.111319] WARNING: CPU: 2 PID: 11749 at drivers/base/driver.c:193 driver_unregister+0x3b/0x40
[  834.111319] Modules linked in: wm97xx_ts(-) ....

..and a stack trace.

To easily reproduce this, load and unload the module on a system where
the hardware is not supported.

Fixes: ae9d1b5fbd7b ("Input: wm97xx: add new AC97 bus support")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/input/touchscreen/wm97xx-core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Charles Keepax Sept. 5, 2018, 9:16 a.m. UTC | #1
On Tue, Sep 04, 2018 at 07:35:05PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> In the case where IS_BUILTIN(CONFIG_AC97_BUS)) is not true, the
> wm97xx_driver driver is being unregistered even it has not been
> previously registered.  Fix this by only unregistering it if
> IS_BUILTIN(CONFIG_AC97_BUS)) is true.  This fixes the warning
> message:
> 
> [  834.111248] ------------[ cut here ]------------
> [  834.111248] Unexpected driver unregister!
> [  834.111319] WARNING: CPU: 2 PID: 11749 at drivers/base/driver.c:193 driver_unregister+0x3b/0x40
> [  834.111319] Modules linked in: wm97xx_ts(-) ....
> 
> ..and a stack trace.
> 
> To easily reproduce this, load and unload the module on a system where
> the hardware is not supported.
> 
> Fixes: ae9d1b5fbd7b ("Input: wm97xx: add new AC97 bus support")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---

Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>

Thanks,
Charles
Robert Jarzmik Sept. 9, 2018, 7:08 p.m. UTC | #2
Charles Keepax <ckeepax@opensource.cirrus.com> writes:

> On Tue, Sep 04, 2018 at 07:35:05PM +0100, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>> 
>> In the case where IS_BUILTIN(CONFIG_AC97_BUS)) is not true, the
>> wm97xx_driver driver is being unregistered even it has not been
>> previously registered.  Fix this by only unregistering it if
>> IS_BUILTIN(CONFIG_AC97_BUS)) is true.  This fixes the warning
>> message:
>> 
>> [  834.111248] ------------[ cut here ]------------
>> [  834.111248] Unexpected driver unregister!
>> [  834.111319] WARNING: CPU: 2 PID: 11749 at drivers/base/driver.c:193 driver_unregister+0x3b/0x40
>> [  834.111319] Modules linked in: wm97xx_ts(-) ....
>> 
>> ..and a stack trace.
>> 
>> To easily reproduce this, load and unload the module on a system where
>> the hardware is not supported.
>> 
>> Fixes: ae9d1b5fbd7b ("Input: wm97xx: add new AC97 bus support")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>
> Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>

Cheers.
diff mbox series

Patch

diff --git a/drivers/input/touchscreen/wm97xx-core.c b/drivers/input/touchscreen/wm97xx-core.c
index 2566b4d8b342..73856c2a8ac0 100644
--- a/drivers/input/touchscreen/wm97xx-core.c
+++ b/drivers/input/touchscreen/wm97xx-core.c
@@ -929,7 +929,8 @@  static int __init wm97xx_init(void)
 
 static void __exit wm97xx_exit(void)
 {
-	driver_unregister(&wm97xx_driver);
+	if (IS_BUILTIN(CONFIG_AC97_BUS))
+		driver_unregister(&wm97xx_driver);
 	platform_driver_unregister(&wm97xx_mfd_driver);
 }