iichid(4): Do not power down opened device in attach handler

Some iichid(4) child devices, currently hkbd(4) only, opens parent
device in their attach handlers. That breaks internal iichid(4) state
leading to rejecting any incoming data on software and hardware levels.

Fix it with adding of extra state check in iichid(4) attach handler.

Approved by:	re (cperciva)
Reported by:	many
Submitted by:	trasz (initial version)
PR:		280290
MFC after:	3 days

(cherry picked from commit 018cb11cb7d412b031e1be681a6a19e734473f99)
(cherry picked from commit c53ec86f0e)
This commit is contained in:
Vladimir Kondratyev 2024-11-08 22:23:38 +03:00
parent d86dcfc648
commit b8276743e4

View file

@ -1205,8 +1205,12 @@ iichid_attach(device_t dev)
iichid_detach(dev);
}
done:
(void)iichid_set_power(sc, I2C_HID_POWER_OFF);
sc->power_on = false;
iicbus_request_bus(device_get_parent(dev), dev, IIC_WAIT);
if (!sc->open) {
(void)iichid_set_power(sc, I2C_HID_POWER_OFF);
sc->power_on = false;
}
iicbus_release_bus(device_get_parent(dev), dev);
return (error);
}