From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.19 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796122664; b=Scf/IX7jOAOKlEQOWrQ+wuysrDc6prNoto2ksX5iuGcG0muTo2krU8vgJ4UzAnzWsVVM 69fnMnRx78V6DRc62OLJSZs2fH2iwW4T4gZPAxYt0kYzo+s5YE1aBlTuv+jN2Lalc9qrV VaxgUajB+K/lMjKvS/q9Qsxw9o4XkmY0OX1ilUABDeZyQc3AtgetuZnS9kOP2MuXReXU5 vzGyT0QDuhTEl2JnOnuv6DEgf+xn6kM2xQiFsD9c/5OeA1aDaixyRh8hf2UExcgTtdKDA 2bjZNaVLhg4o5/qsfKypzQ9baF5IUuWNQqTekuO4efIPi1rX69ONzNYpXghauaybEnQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796122664; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:Date:To:cc: Subject:In-Reply-To:Message-ID:References:MIME-Version:Content-Type; bh=Csxem1Vw0Augd6v1vDbSBRu5WVLroD064yRHv+vjC9g=; b=1bLdkrOBTYG4yvhPuzHArfs0paYscXu3ec0szR6PKHTUyt/YJlzPGNufmWsHcj/A7xvq cPgsghetB4HyaCSYlQkV04FGanxKuLzlp4ky2L+Fil7MDDrcs0KGj2eAKJayihV3cJOqV XHdz4qUbrbMw5MRb+xQMdUd21mS8dIU/vZivYESFDDaHMZjsmvy1/m+EwGrtkOyDlv89Y rsUrLoyZkoQK25bQYIrcn8Lahtp5CqTOp+aFNOvXbR4abzvOuliSf61mysVpxblFPRkWm Fpa3YowE4WAJ4Uime5x5ydewJcqO0Ew7Qulrr5JXHvJRRj9ciQ0YKZ2WcO93rTj5DkQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Ayzngc5F; arc=none smtp.remote-ip=198.175.65.19 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C4AD606A32D; Tue, 1 Dec 2026 10:57:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0C4AD606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Ayzngc5F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796122664; x=1827658664; h=from:date:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=Csxem1Vw0Augd6v1vDbSBRu5WVLroD064yRHv+vjC9g=; b=Ayzngc5FaOaNmyRwfdLQBjxAb/kJJs2dARQGgcwWKasazJtf1MT17Xqg WBX3rRGp/VL8iXrEKkfgelTElXI/AsvalPp6NhcEgce3jNfTUVfdPRef6 jeunZY34AL5DxsXVbQSGjgNkezZlRgz1JDeysHWxziAB4LjZQZbpVUPFM auhguCLiozoNTmSQkR7vNWnBoAj3BGz/asz86DgrHMI20BWctvzAGyTg9 pcZVl0zud55OWFeitNsFBAZNwoo3W9T/c1hscvIJOnPNtZS97dJYnhvjG QIfkFc3AqzbuNT+E9+EwSOSYxd0XF74xbrgTI19uxrDBF2lzpCSUPruRh g==; X-CSE-ConnectionGUID: ngz+cExMT9COX9gCBw/U1Q== X-CSE-MsgGUID: IA+fa1OeToO6Ag1IIpiuZw== X-IronPort-AV: E=McAfee;i="6800,10657,11982"; a="5060374" X-IronPort-AV: E=Sophos;i="6.27,244,1787036400"; d="scan'208";a="5060374" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 02:57:43 -0800 X-CSE-ConnectionGUID: rgNiQ9fXTU+NmOgKHgVAZQ== X-CSE-MsgGUID: s4hZhDLXTKST8IhL5KdE0w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,244,1787036400"; d="scan'208";a="13184678" Received: from pgcooper-mobl3.ger.corp.intel.com (HELO localhost) ([10.245.245.21]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 02:57:41 -0800 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Date: Tue, 1 Dec 2026 12:57:37 +0200 (EET) To: Fuwei Xie <12313607@mail.sustech.edu.cn> cc: Hans de Goede , platform-driver-x86@vger.kernel.org, LKML , =?ISO-8859-15?Q?Eren_=D6zen?= , Zheng Shuyang Subject: Re: [PATCH v4 2/5] platform/x86: huawei-wmi: bind the Huawei method device In-Reply-To: Message-ID: <1a1e7f60-2bdd-3423-787c-6c6fa601b157@linux.intel.com> References: <20261130101218.243426-1-12313607@mail.sustech.edu.cn> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII On Mon, 30 Nov 2026, Fuwei Xie wrote: > Bind the method GUID on the WMI bus and give its platform device the > bound wdev for method calls. Unregister the platform device before the > method driver releases the binding. Keep the platform sysfs location > and the input-only path on machines without the method GUID. > > Allocate platform state on probe and unwind previously registered > input handlers if a later input device fails to register. > > Signed-off-by: Fuwei Xie <12313607@mail.sustech.edu.cn> > --- > drivers/platform/x86/huawei-wmi.c | 109 ++++++++++++++++++++---------- > 1 file changed, 75 insertions(+), 34 deletions(-) > > diff --git a/drivers/platform/x86/huawei-wmi.c b/drivers/platform/x86/huawei-wmi.c > index 559731d15..690bd0abc 100644 > --- a/drivers/platform/x86/huawei-wmi.c > +++ b/drivers/platform/x86/huawei-wmi.c > @@ -60,6 +60,7 @@ struct huawei_wmi_debug { > }; > > struct huawei_wmi { > + struct wmi_device *wdev; > bool battery_available; > bool fn_lock_available; > > @@ -156,7 +157,7 @@ static int huawei_wmi_call(struct huawei_wmi *huawei, > acpi_status status; > > mutex_lock(&huawei->wmi_lock); > - status = wmi_evaluate_method(HWMI_METHOD_GUID, 0, 1, in, out); > + status = wmidev_evaluate_method(huawei->wdev, 0, 1, in, out); > mutex_unlock(&huawei->wmi_lock); > if (ACPI_FAILURE(status)) { > dev_err(huawei->dev, "Failed to evaluate wmi method\n"); > @@ -880,25 +881,36 @@ static const struct wmi_device_id huawei_wmi_events_id_table[] = { > > static int huawei_wmi_probe(struct platform_device *pdev) > { > - const struct wmi_device_id *guid = huawei_wmi_events_id_table; > + const struct wmi_device_id *guid; > + struct wmi_device **method = dev_get_platdata(&pdev->dev); > int err; > > + huawei_wmi = devm_kzalloc(&pdev->dev, sizeof(*huawei_wmi), GFP_KERNEL); > + if (!huawei_wmi) > + return -ENOMEM; > + > + huawei_wmi->wdev = method ? *method : NULL; > platform_set_drvdata(pdev, huawei_wmi); > huawei_wmi->dev = &pdev->dev; > > - while (*guid->guid_string) { > - if (wmi_has_guid(guid->guid_string)) { > - err = huawei_wmi_input_setup(&pdev->dev, guid->guid_string); > - if (err) { > - dev_err(&pdev->dev, "Failed to setup input on %s\n", guid->guid_string); > - return err; > - } > - } > + for (guid = huawei_wmi_events_id_table; *guid->guid_string; guid++) { > + if (!wmi_has_guid(guid->guid_string)) > + continue; > > - guid++; > + err = huawei_wmi_input_setup(&pdev->dev, guid->guid_string); > + if (!err) > + continue; > + > + dev_err(&pdev->dev, "Failed to setup input on %s\n", guid->guid_string); > + while (guid != huawei_wmi_events_id_table) { > + guid--; > + if (wmi_has_guid(guid->guid_string)) > + huawei_wmi_input_exit(&pdev->dev, guid->guid_string); > + } > + return err; > } > > - if (wmi_has_guid(HWMI_METHOD_GUID)) { > + if (huawei_wmi->wdev) { > mutex_init(&huawei_wmi->wmi_lock); > > huawei_wmi_leds_setup(&pdev->dev); > @@ -921,7 +933,7 @@ static void huawei_wmi_remove(struct platform_device *pdev) > guid++; > } > > - if (wmi_has_guid(HWMI_METHOD_GUID)) { > + if (huawei_wmi->wdev) { > huawei_wmi_debugfs_exit(&pdev->dev); > huawei_wmi_battery_exit(&pdev->dev); > huawei_wmi_fn_lock_exit(&pdev->dev); > @@ -936,14 +948,46 @@ static struct platform_driver huawei_wmi_driver = { > .remove = huawei_wmi_remove, > }; > > -static __init int huawei_wmi_init(void) > +/* > + * Keep the platform device and its existing userspace paths on both > + * method-capable and older event-only machines. > + */ > +static struct platform_device *legacy_pdev; > + > +static int huawei_wmi_method_probe(struct wmi_device *wdev, const void *context) > { > struct platform_device *pdev; > - int err; > > - huawei_wmi = kzalloc_obj(struct huawei_wmi); > - if (!huawei_wmi) > - return -ENOMEM; > + pdev = platform_device_register_data(NULL, "huawei-wmi", PLATFORM_DEVID_NONE, > + &wdev, sizeof(wdev)); > + if (IS_ERR(pdev)) > + return PTR_ERR(pdev); > + > + dev_set_drvdata(&wdev->dev, pdev); > + return 0; > +} > + > +static void huawei_wmi_method_remove(struct wmi_device *wdev) > +{ > + platform_device_unregister(dev_get_drvdata(&wdev->dev)); > +} > + > +static const struct wmi_device_id huawei_wmi_method_ids[] = { > + { HWMI_METHOD_GUID }, > + { } > +}; > +MODULE_DEVICE_TABLE(wmi, huawei_wmi_method_ids); > + > +static struct wmi_driver huawei_wmi_method_driver = { > + .driver.name = "huawei-wmi-method", > + .id_table = huawei_wmi_method_ids, > + .probe = huawei_wmi_method_probe, > + .remove = huawei_wmi_method_remove, > +}; > + > +static __init int huawei_wmi_init(void) > +{ > + int err; > > quirks = &quirk_unknown; > dmi_check_system(huawei_quirks); > @@ -954,37 +998,34 @@ static __init int huawei_wmi_init(void) > > err = platform_driver_register(&huawei_wmi_driver); > if (err) > - goto pdrv_err; > + return err; > > - pdev = platform_device_register_simple("huawei-wmi", PLATFORM_DEVID_NONE, NULL, 0); > - if (IS_ERR(pdev)) { > - err = PTR_ERR(pdev); > - goto pdev_err; > + if (wmi_has_guid(HWMI_METHOD_GUID)) { > + err = wmi_driver_register(&huawei_wmi_method_driver); > + } else { > + legacy_pdev = platform_device_register_simple("huawei-wmi", PLATFORM_DEVID_NONE, > + NULL, 0); > + err = PTR_ERR_OR_ZERO(legacy_pdev); > } > + if (err) > + platform_driver_unregister(&huawei_wmi_driver); The old rollback path was better than this. Armin, is this legacy_pdev approach what is supposed to be used? > - return 0; > - > -pdev_err: > - platform_driver_unregister(&huawei_wmi_driver); > -pdrv_err: > - kfree(huawei_wmi); > return err; > } > > static __exit void huawei_wmi_exit(void) > { > - struct platform_device *pdev = to_platform_device(huawei_wmi->dev); > + if (legacy_pdev) > + platform_device_unregister(legacy_pdev); > + else > + wmi_driver_unregister(&huawei_wmi_method_driver); > > - platform_device_unregister(pdev); > platform_driver_unregister(&huawei_wmi_driver); > - > - kfree(huawei_wmi); > } > > module_init(huawei_wmi_init); > module_exit(huawei_wmi_exit); > > -MODULE_ALIAS("wmi:"HWMI_METHOD_GUID); > MODULE_DEVICE_TABLE(wmi, huawei_wmi_events_id_table); > MODULE_AUTHOR("Ayman Bagabas "); > MODULE_DESCRIPTION("Huawei WMI laptop extras driver"); > -- i.