Setting the initial state of input-device switches must be done before
registering the input-device.
Otherwise the initial state will get send out as an event as soon
as input_sync() gets called.
E.g. when undocking a tablet using intel-vbtn to report SW_TABLET_MODE
and SW_DOCK before this commit we would get (evemu-record output):
E: 0.000001 0005 0005 0001 # EV_SW / SW_DOCK 1
E: 0.000001 0000 0000 0000 # ------------ SYN_REPORT (0) ---------- +0ms
E: 0.000109 0005 0005 0000 # EV_SW / SW_DOCK 0
E: 0.000109 0000 0000 0000 # ------------ SYN_REPORT (0) ---------- +0ms
E: 0.000133 0005 0001 0001 # EV_SW / SW_TABLET_MODE 1
E: 0.000133 0000 0000 0000 # ------------ SYN_REPORT (0) ---------- +0ms
The first SW_DOCK=1 report is spurious, setting the initial switch
state before registering the input-device fixes this.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
priv->input_dev->name = "Intel Virtual Button driver";
priv->input_dev->id.bustype = BUS_HOST;
+ if (priv->has_switches)
+ detect_tablet_mode(device);
+
return input_register_device(priv->input_dev);
}
return err;
}
- if (priv->has_switches)
- detect_tablet_mode(device);
-
status = acpi_install_notify_handler(handle,
ACPI_DEVICE_NOTIFY,
notify_handler,