Skip to content

Commit 7b1f781

Browse files
committed
Input: psmouse - set up dependency between PS/2 and SMBus companions
When we switch from emulated PS/2 to native (RMI4 or Elan) protocols, we create SMBus companion devices that are attached to I2C/SMBus controllers. However, when suspending and resuming, we also need to make sure that we take into account the PS/2 device they are associated with, so that PS/2 device is suspended after the companion and resumed before it, otherwise companions will not work properly. Before I2C devices were marked for asynchronous suspend/resume, this ordering happened naturally, but now we need to enforce it by establishing device links, with PS/2 devices being suppliers and SMBus companions being consumers. Fixes: 172d931 ("i2c: enable async suspend/resume on i2c client devices") Reported-and-tested-by: Hugh Dickins <[email protected]> Tested-by: Jarkko Nikula <[email protected]> Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent de8aa31 commit 7b1f781

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/input/mouse/psmouse-smbus.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ static void psmouse_smbus_detach_i2c_client(struct i2c_client *client)
7575
"Marking SMBus companion %s as gone\n",
7676
dev_name(&smbdev->client->dev));
7777
smbdev->dead = true;
78+
device_link_remove(&smbdev->client->dev,
79+
&smbdev->psmouse->ps2dev.serio->dev);
7880
serio_rescan(smbdev->psmouse->ps2dev.serio);
7981
} else {
8082
list_del(&smbdev->node);
@@ -174,6 +176,8 @@ static void psmouse_smbus_disconnect(struct psmouse *psmouse)
174176
kfree(smbdev);
175177
} else {
176178
smbdev->dead = true;
179+
device_link_remove(&smbdev->client->dev,
180+
&psmouse->ps2dev.serio->dev);
177181
psmouse_dbg(smbdev->psmouse,
178182
"posting removal request for SMBus companion %s\n",
179183
dev_name(&smbdev->client->dev));
@@ -270,6 +274,12 @@ int psmouse_smbus_init(struct psmouse *psmouse,
270274

271275
if (smbdev->client) {
272276
/* We have our companion device */
277+
if (!device_link_add(&smbdev->client->dev,
278+
&psmouse->ps2dev.serio->dev,
279+
DL_FLAG_STATELESS))
280+
psmouse_warn(psmouse,
281+
"failed to set up link with iSMBus companion %s\n",
282+
dev_name(&smbdev->client->dev));
273283
return 0;
274284
}
275285

0 commit comments

Comments
 (0)