Skip to content

Commit

Permalink
platform/x86: toshiba_acpi: Fix quickstart quirk handling
Browse files Browse the repository at this point in the history
The global hci_hotkey_quickstart quirk flag is tested in
toshiba_acpi_enable_hotkeys() before the quirk flag is properly
initialized based on SMBIOS data. This causes the quirk to be
applied to all models, some of which behave erratically as a
result.

Fix this by initializing the global quirk flags during module
initialization before registering the ACPI driver. This also
allows us to mark toshiba_dmi_quirks[] as __initconst.

Fixes: 23f1d8b ("platform/x86: toshiba_acpi: Add quirk for buttons on Z830")
Reported-by: kemal <kmal@cock.li>
Closes: https://lore.kernel.org/platform-driver-x86/R4CYFS.TWB8QUU2SHWI1@cock.li/
Tested-by: kemal <kmal@cock.li>
Cc: stable@vger.kernel.org
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20240701194539.348937-1-W_Armin@gmx.de
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  • Loading branch information
Wer-Wolf authored and jwrdegoede committed Jul 2, 2024
1 parent 7add1ee commit e527a61
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions drivers/platform/x86/toshiba_acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -3271,7 +3271,7 @@ static const char *find_hci_method(acpi_handle handle)
*/
#define QUIRK_HCI_HOTKEY_QUICKSTART BIT(1)

static const struct dmi_system_id toshiba_dmi_quirks[] = {
static const struct dmi_system_id toshiba_dmi_quirks[] __initconst = {
{
/* Toshiba Portégé R700 */
/* https://bugzilla.kernel.org/show_bug.cgi?id=21012 */
Expand Down Expand Up @@ -3306,8 +3306,6 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
struct toshiba_acpi_dev *dev;
const char *hci_method;
u32 dummy;
const struct dmi_system_id *dmi_id;
long quirks = 0;
int ret = 0;

if (toshiba_acpi)
Expand Down Expand Up @@ -3460,16 +3458,6 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
}
#endif

dmi_id = dmi_first_match(toshiba_dmi_quirks);
if (dmi_id)
quirks = (long)dmi_id->driver_data;

if (turn_on_panel_on_resume == -1)
turn_on_panel_on_resume = !!(quirks & QUIRK_TURN_ON_PANEL_ON_RESUME);

if (hci_hotkey_quickstart == -1)
hci_hotkey_quickstart = !!(quirks & QUIRK_HCI_HOTKEY_QUICKSTART);

toshiba_wwan_available(dev);
if (dev->wwan_supported)
toshiba_acpi_setup_wwan_rfkill(dev);
Expand Down Expand Up @@ -3618,10 +3606,27 @@ static struct acpi_driver toshiba_acpi_driver = {
.drv.pm = &toshiba_acpi_pm,
};

static void __init toshiba_dmi_init(void)
{
const struct dmi_system_id *dmi_id;
long quirks = 0;

dmi_id = dmi_first_match(toshiba_dmi_quirks);
if (dmi_id)
quirks = (long)dmi_id->driver_data;

if (turn_on_panel_on_resume == -1)
turn_on_panel_on_resume = !!(quirks & QUIRK_TURN_ON_PANEL_ON_RESUME);

if (hci_hotkey_quickstart == -1)
hci_hotkey_quickstart = !!(quirks & QUIRK_HCI_HOTKEY_QUICKSTART);
}

static int __init toshiba_acpi_init(void)
{
int ret;

toshiba_dmi_init();
toshiba_proc_dir = proc_mkdir(PROC_TOSHIBA, acpi_root_dir);
if (!toshiba_proc_dir) {
pr_err("Unable to create proc dir " PROC_TOSHIBA "\n");
Expand Down

0 comments on commit e527a61

Please sign in to comment.