Skip to content

Commit 613e390

Browse files
soyersoyerij-intel
authored andcommitted
platform/x86: ideapad-laptop: introduce a generic notification chain
There are several cases where a notification chain can simplify Lenovo WMI drivers. Add a generic notification chain into ideapad-laptop. Signed-off-by: Gergo Koteles <[email protected]> Link: https://lore.kernel.org/r/c5a43efae8a32bd034c3d19c0a686941347575a7.1721898747.git.soyer@irl.hu Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent 7829642 commit 613e390

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

drivers/platform/x86/ideapad-laptop.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,6 +1592,39 @@ static void ideapad_sync_touchpad_state(struct ideapad_private *priv, bool send_
15921592
priv->r_touchpad_val = value;
15931593
}
15941594

1595+
static int ideapad_laptop_nb_notify(struct notifier_block *nb,
1596+
unsigned long action, void *data)
1597+
{
1598+
switch (action) {
1599+
}
1600+
1601+
return 0;
1602+
}
1603+
1604+
static struct notifier_block ideapad_laptop_notifier = {
1605+
.notifier_call = ideapad_laptop_nb_notify,
1606+
};
1607+
1608+
static BLOCKING_NOTIFIER_HEAD(ideapad_laptop_chain_head);
1609+
1610+
int ideapad_laptop_register_notifier(struct notifier_block *nb)
1611+
{
1612+
return blocking_notifier_chain_register(&ideapad_laptop_chain_head, nb);
1613+
}
1614+
EXPORT_SYMBOL_NS_GPL(ideapad_laptop_register_notifier, IDEAPAD_LAPTOP);
1615+
1616+
int ideapad_laptop_unregister_notifier(struct notifier_block *nb)
1617+
{
1618+
return blocking_notifier_chain_unregister(&ideapad_laptop_chain_head, nb);
1619+
}
1620+
EXPORT_SYMBOL_NS_GPL(ideapad_laptop_unregister_notifier, IDEAPAD_LAPTOP);
1621+
1622+
void ideapad_laptop_call_notifier(unsigned long action, void *data)
1623+
{
1624+
blocking_notifier_call_chain(&ideapad_laptop_chain_head, action, data);
1625+
}
1626+
EXPORT_SYMBOL_NS_GPL(ideapad_laptop_call_notifier, IDEAPAD_LAPTOP);
1627+
15951628
static void ideapad_acpi_notify(acpi_handle handle, u32 event, void *data)
15961629
{
15971630
struct ideapad_private *priv = data;
@@ -1974,6 +2007,8 @@ static int ideapad_acpi_add(struct platform_device *pdev)
19742007
if (err)
19752008
goto shared_init_failed;
19762009

2010+
ideapad_laptop_register_notifier(&ideapad_laptop_notifier);
2011+
19772012
return 0;
19782013

19792014
shared_init_failed:
@@ -2006,6 +2041,8 @@ static void ideapad_acpi_remove(struct platform_device *pdev)
20062041
struct ideapad_private *priv = dev_get_drvdata(&pdev->dev);
20072042
int i;
20082043

2044+
ideapad_laptop_unregister_notifier(&ideapad_laptop_notifier);
2045+
20092046
ideapad_shared_exit(priv);
20102047

20112048
acpi_remove_notify_handler(priv->adev->handle,

drivers/platform/x86/ideapad-laptop.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
#include <linux/acpi.h>
1313
#include <linux/jiffies.h>
1414
#include <linux/errno.h>
15+
#include <linux/notifier.h>
16+
17+
int ideapad_laptop_register_notifier(struct notifier_block *nb);
18+
int ideapad_laptop_unregister_notifier(struct notifier_block *nb);
19+
void ideapad_laptop_call_notifier(unsigned long action, void *data);
1520

1621
enum {
1722
VPCCMD_R_VPC1 = 0x10,

0 commit comments

Comments
 (0)