From patchwork Thu Jan 26 19:40:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 48875 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp452451wrn; Thu, 26 Jan 2023 11:42:35 -0800 (PST) X-Google-Smtp-Source: AK7set9Q9eb+lyGPSL8HntqtKJt93+Nk5bGqCEguXk/ib5bDgFAL93NBAdDqVAY79PAJ67SNbS70 X-Received: by 2002:a05:6a21:3a8d:b0:bb:baa9:ad88 with SMTP id zv13-20020a056a213a8d00b000bbbaa9ad88mr8120864pzb.44.1674762154828; Thu, 26 Jan 2023 11:42:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674762154; cv=none; d=google.com; s=arc-20160816; b=Y37n8HaGgg0RZuapG0TLHYU9m9amMu687udEp9RyNFhG053x0PkDIl+qEMqJfRwgIj G76yK9QlpwCh3liI/w8ZsB3FNkrdYAi8Y5ocDPZT1a0Hj31/hdN0Pk1o74Z7OWntz1Dl yGVoRb1+4zjJiPu1fw4d1HwkOpc5w9TC4GrVZp5xKCddCxP/swkIMYGtXOD30S8FHJb2 b3Tm88jPIs6oLq29EwLEo2xaMcbO9xPOyVgCHkuCak5e++e3R8WTawM2LjybxXOAR+Rn ZISToCkK0wtCWPpcPz2XDq/TzlbRrD8rWaGZcoltVE0lPY/RioTa0n/LPsBaPMhRvT1X mLdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xkozjD46LDhevsQ3LKkvtfA8TOfGLn1ChQiqgMIt/0k=; b=zuHt4MMuUeatqFYmoDU/Do1rFRZiY5/fUxDd6s9hoCPUF8YvUykBG1GmQheVVnWd0j J+bjKTXYRLNgJCNDvX4xlkAUfWcgvXtLxyM30Hc61/VZCW6uSDqE2RxPyTO/a+3YQEBa +HvY7ngiP7iNY15q9thp6ZafzM8P6yepuiZCA1CKQjL1n/QI9kQuwzNv8bfTxUhsFwUA iT3q5CJvVs3XPzxHDfp8lFGT7FEsFvXNhHHI4s9sR46CrrW46m3vRVAZaflDLfJU94RC oZBjcQpl/7B03H38itoHazlg1rQQAwpgeaJdGHfJirxeLH6xuqeANnQCXvoaLTA90kQg g70w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=sUV2O9si; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m23-20020a637117000000b004c7883728c4si1999943pgc.324.2023.01.26.11.42.22; Thu, 26 Jan 2023 11:42:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=sUV2O9si; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232511AbjAZTky (ORCPT + 99 others); Thu, 26 Jan 2023 14:40:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232186AbjAZTkw (ORCPT ); Thu, 26 Jan 2023 14:40:52 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35B982D51; Thu, 26 Jan 2023 11:40:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1674762030; bh=2TL7aTm8N/AzcTDSZC7SmNVqKjGX/jFf0Ms82bCmlQ4=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=sUV2O9sisppQ5XXA8g+mZZ+Cx2PgWPgOWrxSu2SQI4nWrDhc0ydAmK76YZWWKYRXb RDS5bvpH+5QIT6/KNzsqFUyYvlNNLufUbRI9rJoOORmrDHZW1fe7Kg8agFe878wEs8 m7ERRrPSYYzysTJlG4Zy2G9TOZyE6LtLWD5rqUVSzArbkJGf7aK/QvWfji+VY3OfEw ZKEY9GXTlVWEWieVpPNxB8Bs2+4ux/MjyEhbuwurEZfRwtJeQKSFrcsbpXA/oRt7o1 Q1bckiTyEXAjyDDzCaDscKwkUkT2vMZXGXf5qK63bJzrtaJFHK2pNFuwnbhZdYV2rP HeCp51hkYs8DQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from esprimo-mx.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M42nY-1pL86o0Wpc-0001Gb; Thu, 26 Jan 2023 20:40:30 +0100 From: Armin Wolf To: hdegoede@redhat.com, markgross@kernel.org Cc: jdelvare@suse.com, linux@roeck-us.net, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/5] platform/x86: dell-ddv: Add support for interface version 3 Date: Thu, 26 Jan 2023 20:40:17 +0100 Message-Id: <20230126194021.381092-2-W_Armin@gmx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230126194021.381092-1-W_Armin@gmx.de> References: <20230126194021.381092-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:Cv+dN4fSwbR9l2vEKOEDAENRLMdwkFzHQ4eIoeDdE5p0oZttKYX zjHWDE/v7mxpFRiDAyZjH4Hu3vOAx1z7As5mwDb28OPwcDJPsAjFN8bT8CM8dSQstoOMoBK 1EOLXaeSJ+QugAdSaEG7D6OONTe37PQWMMBGyLc3um26bmKtTlY0CsMir7oNJyA8ngOAeUk H1uoRiDzJj+M3xIyWq7LQ== UI-OutboundReport: notjunk:1;M01:P0:ib7GGmWQ2PA=;Y+R1eYyO3J9NR2Pv0sNfv78K44V 1o0JfBV03CeIIJYNO7AVjqEe1YMrjDRrz7M4VI8EUw0MKqiXFcM5rdcY7UeNlHkwb5ErTQMkI JVHfbzsrKe0XGrf2+GnfgBBkk15MqoYS/K460lQVj6Oj9G8UnHNE6Qe2Hx6WqFC2QtrPs5wgS mDdAyM2XkDgARmh4yV4tS2pkpYyMGeSE2dNKazK8xWVhku1ABFzALb1I7BRgVhBQKcRQW6AHr O0Ccgh5L7cLGacO1eYSdr6HOmOtqZZf3dldrmrbKI9w7u+JgCAjTuj+q4DBgCu2fI70/CR60q FBByw8mhC6ObSTu8KYlhouWJ5+XD4w87aUtgGM7EJpP+W0iuqnncZwa448j6BIcwkD+C74WwP XEteXx7S/7PQQWTUgBL6JmjQc1f8LXJ0csFBaT5qW/jOyM3H2ZUJZ64fKEU9cXnpeI5bu7+Wp 4E2o95KasC26kChfVTQljYZEIrcjHxoakESDH9LIE5Ap7Zxg6LIK2ckoIvCUhTWY0NuBuyFTj i+soZXSrJn6H7FiYfZJooYCLmdEIBe+oDqF/DhIL0CCRNDwzWy0fvjsmUb6srN1B7gQ8JCekG cFD0XjEL1IP3ExEzVQIE0R5/uCdoCLpVeU530xc+a/9EqHiDKFxWiSsLbyn8ok53uLf2wPhsv 7XTMTIl71Mmf6paL9pbV80s/Kuo+epijeIk3U64UWuQ7SI4fa8ZcNadNKHRwENj3lr07oK70C UOmKkRVBmw/x2KSrphv3I+cfr52I1n7mQ/q8ZzRMOpnTjklnY9gdw3l3vVsUT+HquTByA//rE oSMXnNd8nLrp3wIC42RXw74nZSvyAY2Jip4WPkkfgHjCFRRLXCjcf2f6wGq5RG25JYctznq0b eNVYv73KPCoaX9lVbhds3jQzkiekoetviqWOMasHLgjmarCXxSVMxPCM8QtTtSFujBcmi/7nt ZHwmOKT4dF4Cs8gWE5Va1DrjosA= X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756115401127707697?= X-GMAIL-MSGID: =?utf-8?q?1756115401127707697?= While trying to solve a bugreport on bugzilla, i learned that some devices (for example the Dell XPS 17 9710) provide a more recent DDV WMI interface (version 3). Since the new interface version just adds an additional method, no code changes are necessary apart from whitelisting the version. Signed-off-by: Armin Wolf --- drivers/platform/x86/dell/dell-wmi-ddv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.30.2 diff --git a/drivers/platform/x86/dell/dell-wmi-ddv.c b/drivers/platform/x86/dell/dell-wmi-ddv.c index 2bb449845d14..9cb6ae42dbdc 100644 --- a/drivers/platform/x86/dell/dell-wmi-ddv.c +++ b/drivers/platform/x86/dell/dell-wmi-ddv.c @@ -26,7 +26,8 @@ #define DRIVER_NAME "dell-wmi-ddv" -#define DELL_DDV_SUPPORTED_INTERFACE 2 +#define DELL_DDV_SUPPORTED_VERSION_MIN 2 +#define DELL_DDV_SUPPORTED_VERSION_MAX 3 #define DELL_DDV_GUID "8A42EA14-4F2A-FD45-6422-0087F7A7E608" #define DELL_EPPID_LENGTH 20 @@ -49,6 +50,7 @@ enum dell_ddv_method { DELL_DDV_BATTERY_RAW_ANALYTICS_START = 0x0E, DELL_DDV_BATTERY_RAW_ANALYTICS = 0x0F, DELL_DDV_BATTERY_DESIGN_VOLTAGE = 0x10, + DELL_DDV_BATTERY_RAW_ANALYTICS_A_BLOCK = 0x11, /* version 3 */ DELL_DDV_INTERFACE_VERSION = 0x12, @@ -340,7 +342,7 @@ static int dell_wmi_ddv_probe(struct wmi_device *wdev, const void *context) return ret; dev_dbg(&wdev->dev, "WMI interface version: %d\n", version); - if (version != DELL_DDV_SUPPORTED_INTERFACE) + if (version < DELL_DDV_SUPPORTED_VERSION_MIN || version > DELL_DDV_SUPPORTED_VERSION_MAX) return -ENODEV; data = devm_kzalloc(&wdev->dev, sizeof(*data), GFP_KERNEL); From patchwork Thu Jan 26 19:40:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 48872 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp452346wrn; Thu, 26 Jan 2023 11:42:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXvVEku7Fm3p7KkDAvzaf4F7F8MR+CVi2KwUIoGnd3X2VIRVATAGOrrHiJCATEyYDnoYUaeD X-Received: by 2002:a17:903:2349:b0:195:e373:4c60 with SMTP id c9-20020a170903234900b00195e3734c60mr31943998plh.40.1674762135119; Thu, 26 Jan 2023 11:42:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674762135; cv=none; d=google.com; s=arc-20160816; b=xrSgObDPFnBm7J4GuxCLFvzUKIswbunVafT4M7mwTKauXiTrSD4NoLxj7lp0Ye+zXE QV6Tamc7cBp/uOzTr8CoBTqsxl+Jrmkf6lC85RjRIWh00axTR6MZJj9y7F6Bv25k8hUV dMAQr9Vana8mADv5xYwiHb9OogjfZeNxuaMCCYIlS/2cce2Xvts55VRRNwgcIm1z4AXs u7DlpX71MnLPYtgRi9mYttrQDxus3uyPQpGvJULmIJwAtNgPB+KeaOjbXHKh5S0MAh8d dfnc+BD06J7ykvmz5lJTVN9pyI8xJkHDan1Urg06GIZgacvjoqvDMgvNuYB3RY/8Nl3e rqtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+z1XNMUUUjdhrVPcxwTpObnHQqrCUwQCqsaZnKf+4QA=; b=YgmWMJAb4/emRyGqXZOZG+xYqjFl0skDDnNpCpoINzx9ubAcuSonXtsPQ2J4XChuxc C3Ra9sqsTy/ztm5OlRO4+TYk2GW0B0MWW3gA3J/C12tv5eJ18547U2NwMueDeVT1mSva B5Gin4hp/zaek5FpFVf6GsZ3LVdrAUYreC0UjvLqvolX8Zuaag5853YRqw+0bg0g3eZ1 Dds8goO6cO2XAWbNyMOtboKhnNCpA91+9vJpEViQ8Tb0izdgsUFYCezCa0ctQr4kHC49 W/jktBl6RBuvk77A1egV/HuPMnQLcziL7ApFDn3ZxGKLyJBvLzBVS8nx54Y/qZd6cBQt Pnmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=c8THx++8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m2-20020a170902bb8200b0019608f59f8bsi2246165pls.64.2023.01.26.11.42.03; Thu, 26 Jan 2023 11:42:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=c8THx++8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232563AbjAZTk4 (ORCPT + 99 others); Thu, 26 Jan 2023 14:40:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229781AbjAZTky (ORCPT ); Thu, 26 Jan 2023 14:40:54 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFE6B10C3; Thu, 26 Jan 2023 11:40:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1674762031; bh=35rCENsPcijyAOhim7K4l+Ky2PzYKCOaBYl4vL3So08=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=c8THx++88u0z3Li2dPWLmiUJh3tQYk+5k5AWe9kgtAZawNap337YUDeEm69M8y6F7 Cq2ZeKfRlSRNw7EwlYSx9eEEZBFih2v+pZe5xxE8hY9VQ/oqV24uv1/7BgbxY+Wmyx Zvoz5NUo8v4yRrwiE5MCSXYFLqDHeKTKusoYbsm9IHu/sSAz5Jh5wYWrKuWbTTOTsQ K1Pmpru0qCnMeyNw8googOpxFOL4SODHDHm8gcM5CTZlihaX2KsiNbyiCUnZ/Fz1GT HalvDJ1lGRlmPLwCN9jXw87hPtQNt4pLlAhZTFwKkHgsrbQMwsEIVSeEdsKl/JC3cN GzCs1G11apZcQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from esprimo-mx.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MOzSu-1p2Ljv2IwO-00PNjg; Thu, 26 Jan 2023 20:40:31 +0100 From: Armin Wolf To: hdegoede@redhat.com, markgross@kernel.org Cc: jdelvare@suse.com, linux@roeck-us.net, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/5] platform/x86: dell-ddv: Return error if buffer is empty Date: Thu, 26 Jan 2023 20:40:18 +0100 Message-Id: <20230126194021.381092-3-W_Armin@gmx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230126194021.381092-1-W_Armin@gmx.de> References: <20230126194021.381092-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:FMTSH4+GCt1tIQzTjFcLnT66ULXWluDg6AME49SW9RJN1ESjvgZ VlzlLuMrNKVyBIgofZwYDWFS4KsSB1uSrr8AblshAKjrk1wf4GwjlT+raPTNc0TrdUVCPPF 6JjwVwtk+RHuggQOGvLXVRbpCq1VlrSa43K01HL6YW2RstdBBA1h4DIJQ7G8uEWrcAjezAm BCtgrnuYnpSEUzkwVABXQ== UI-OutboundReport: notjunk:1;M01:P0:4icOODEvEbI=;ZMKE8wju+QfVcIYhCsHMOJcrICL hQOd58nd4xh9P9bhNSOJT5DpwQ3JAGkOaka8lIpE/bFZm44YDhkfJCnOOwL8OQMV0xeyjcULW gt16zlY+xc8URMUhQ+rYrTYYsgqvhgWx831voblF0jNZCgjY5Lov+xhzQX8DaIG78LXKTeEMt vdMy0YoL4FP5OFtNeAdRjRvcUZ90I9U3bWMgqFA1qCLVDilECHLJdBBXI2uHphSCUn3WsD8UK Aw7hxZJmVwJjIjUquzE1W6wTutsQy7vnnf773dONHmW5kpD+7goI6rao39Jp7QNktJhk6P1EZ LrTjX6NTv/G+AlK0SOfuPdYlYo8MAx5u7Ej3MibCFQGH4kD28J4b13KZCGmNaujDpNJ8s+eQ1 V8+UOm/kSsNgGZnH/u4XQ1ZNgnBAzn11Uy6hAiSPH8924r9S/Ur0alrh9ovHpSXWYpykN+tAb kN+rpzUaLWyBQArw80Fyh7MdOEEH5L+nXXT15OkKv9WNEJ8zXfmr1ZB0d2wOnGiqKaKsvN2qV ICQEhRVqIMlo4MjTzMlD8hL2TC67MzuKXtGFiET+VviRXTzJjmDMDHV9lB8q2aYn8LIHdkFJi FJp+srLE/qCUZZJxBzZVk5JCSBIXIZ5Ohzh5oIAtGPZ+R8mW1d7i/4x6zkLDNb/VOiHDXaeXY znDwpYIMqq7hE/grPPFWq36phLTxFx3Vx2bQqacP+x8NJDRzFmJRGXvlDtRjgIHcZMgbrTYZq VZJerh3goSQ5PsHY9JTWYGXTUOaKLbUvyGPVyWOxK1RBjxpWoCP2PQaoESHmGt1kZM0/+txmv pcqhJDVFSxfiiOnuezA/kqSnhyRNqokHE4id0n0eX56hhZr4oeCLrkjeESO2PzS2zb3gDGW1z Q1vk9seCktKdR3uFJFhxXeFI/pcjM+uRjr7LS5vsWkUIVONCF5uTOdYPGZhZJT2/BPjDkmEZS /qAEFy7TyJ6VtIZ+hddwYYLgTAk= X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756115380801854323?= X-GMAIL-MSGID: =?utf-8?q?1756115380801854323?= In several cases, the DDV WMI interface can return buffers with a length of zero. Return -ENODATA in such a case for proper error handling. Also replace some -EIO errors with more specialized ones. Signed-off-by: Armin Wolf --- drivers/platform/x86/dell/dell-wmi-ddv.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) -- 2.30.2 diff --git a/drivers/platform/x86/dell/dell-wmi-ddv.c b/drivers/platform/x86/dell/dell-wmi-ddv.c index 9cb6ae42dbdc..f99c4cb686fd 100644 --- a/drivers/platform/x86/dell/dell-wmi-ddv.c +++ b/drivers/platform/x86/dell/dell-wmi-ddv.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -125,21 +126,27 @@ static int dell_wmi_ddv_query_buffer(struct wmi_device *wdev, enum dell_ddv_meth if (ret < 0) return ret; - if (obj->package.count != 2) - goto err_free; + if (obj->package.count != 2 || + obj->package.elements[0].type != ACPI_TYPE_INTEGER || + obj->package.elements[1].type != ACPI_TYPE_BUFFER) { + ret = -ENOMSG; - if (obj->package.elements[0].type != ACPI_TYPE_INTEGER) goto err_free; + } buffer_size = obj->package.elements[0].integer.value; - if (obj->package.elements[1].type != ACPI_TYPE_BUFFER) + if (!buffer_size) { + ret = -ENODATA; + goto err_free; + } if (buffer_size > obj->package.elements[1].buffer.length) { dev_warn(&wdev->dev, FW_WARN "WMI buffer size (%llu) exceeds ACPI buffer size (%d)\n", buffer_size, obj->package.elements[1].buffer.length); + ret = -EMSGSIZE; goto err_free; } @@ -151,7 +158,7 @@ static int dell_wmi_ddv_query_buffer(struct wmi_device *wdev, enum dell_ddv_meth err_free: kfree(obj); - return -EIO; + return ret; } static int dell_wmi_ddv_query_string(struct wmi_device *wdev, enum dell_ddv_method method, From patchwork Thu Jan 26 19:40:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 48873 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp452417wrn; Thu, 26 Jan 2023 11:42:31 -0800 (PST) X-Google-Smtp-Source: AMrXdXv0axStD7r0JNIqHRzlgMoqXg9hFNSywEx+c1bpFfsXxtxiWT69nH/hqPID1s/xyf1klYJY X-Received: by 2002:a05:6a20:1a9d:b0:b6:3708:7be7 with SMTP id ci29-20020a056a201a9d00b000b637087be7mr30515573pzb.34.1674762151328; Thu, 26 Jan 2023 11:42:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674762151; cv=none; d=google.com; s=arc-20160816; b=Hc+pJA1HoBOVrtrI6icbYLlol5+22FZtFjxpzmkakZFUOwooOcKs8VUQeDeP27AlQo ChcyRZgRfG5X4BFy0GDjMf0T0tKM4PizDh2S+u1ulzsgu+zjiB1qKduz5l4vqaBRt6uo +x8ptzJHu7ltQce+r2P6CEMn1wbr6viNAAA9X8+DC/w8gT+IIqfKaU36IR/WuO14vEiL dKfuQCUD+Hkv84SHq26D7dzopHBKxw6y9Uya0R1tB6tjBcz6ZFTISfq0LdNvGET8H7In 6c9Z31zMmxoXS1Pilt71FGKD9RyitwainXr0uvBae3ESB3m/0kAVNQmT6wMOZGEKvxzQ xCgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oV+Y9fErEf4XtP60I3tQ1n07WYtDgzidBkYZsvgLiTE=; b=IuJtRs1ZvbRvgaOlC7m1Y7zM978O6TVzoqOzbvKu2EM1K/IFXLw/Wl1xWGshhEQ1mM Ds9dj5vcc5K7lfDVST3DZf8P3Ho4iw6CMbzxkEQLcF6yFpAoZlwMg0KzsYQj+OEidRVT Wdvlhp8y68hwfy49t6oXoWIAwgJs337YHaXG+QsrhiUUraNxSbGZy0K6pKFCUG3NpZZ6 mcX+68TG93apdynxokQXJz6kZhqN7i630DZaO11SG+bW+CsMpBS8S07QA8v4eiUba+Yk VA9wwDFBm+OiYNBYCZXQ8HszgxFBWNSa+popv7xkvVE3DCae+WuaNqgvaCZv9rAjg95P PTDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=LgPh1JBT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s15-20020a632c0f000000b004de8f355affsi2054694pgs.541.2023.01.26.11.42.19; Thu, 26 Jan 2023 11:42:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=LgPh1JBT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232571AbjAZTlD (ORCPT + 99 others); Thu, 26 Jan 2023 14:41:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232509AbjAZTky (ORCPT ); Thu, 26 Jan 2023 14:40:54 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CA44DBDF; Thu, 26 Jan 2023 11:40:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1674762033; bh=2z2q3D58SxI2OajPK6DnDMenUSp1L1IQAUjbGhv12o4=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=LgPh1JBTURosMdr/JcNu4u2YBVQx8SlXuAhnlEgm9HPgmh7uqQJ76dlr4N2NS6bBV KyPQLvrmXbdag6F6isDoGtAjcS/j2/F+83nv1dTBy0BdcNuhdWu7yUK1pdaV0pyQMl 7X1Ma/y2kPtlLCg40lQKLB9JKfgtv8oa87G2J9ta4IThYrmy0GRx3CuZQmDQCpR87s BYWycuh4Omcm9nhdsSEADutBsBLfgtB4n8t+upfMwcFn/NfOihsJ1cPcQUvmQoBFJe XDst35WpPwqEIUGi/GbAPXDke/EiilyXDaxASYwLVfENLAdDocmIAE04obrRPvyElX 2vTdMXfEnF6WQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from esprimo-mx.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MBDnC-1pWiQI3u9u-00CiQy; Thu, 26 Jan 2023 20:40:33 +0100 From: Armin Wolf To: hdegoede@redhat.com, markgross@kernel.org Cc: jdelvare@suse.com, linux@roeck-us.net, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/5] platform/x86: dell-ddv: Replace EIO with ENOMSG Date: Thu, 26 Jan 2023 20:40:19 +0100 Message-Id: <20230126194021.381092-4-W_Armin@gmx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230126194021.381092-1-W_Armin@gmx.de> References: <20230126194021.381092-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:NLVVbpI0BmlKNg26OrmolKtnlDOYVheuTHtAOKwORDofmSKfbcM bjnky+2Lh3flELgms70KofKOudqX/n6r+g+p6ddyRdtCXqzs/DjHN0KROyOy/AoP4902TXN I9GWkowT/hIG9SAKRl+7dgGlS55SZyWMwLJmEdE8Rkl6xSEz7++RLdS7gcv/TyAuuf5KJhu Cv7hUVLjOExBaUnNcbKpA== UI-OutboundReport: notjunk:1;M01:P0:y6MTc6yr1t4=;XLSNSA9rwoNDlSx+yXsyXK1OrpS iy8pSN6DIVpjGkMlMcnVCqg4e8ZudOoWyVszsq2zBGalc4Q9q3H1EV1LrGpvp2ADjHVc11cir HGQUE10h3IqfoKjBygkb7j77ljewKikXU4wg48fqAw1C4ZnL+kkuVR5zqord7gG4ENkNMgMex 4b0zmGf4U6dOIhAXkArNa13Wk8+MDYQQ7dgzKWVo3TSBRKxXgj7UjiEuwKJ0SlaqJqy82rWuH Mwq+2w2vLk7ycVcBAwIKa5eia5sDFw7y2gJzLUIfCoqfo0VeISwWfbkxN6DIkT8OsG+MAKiuT 4csbpXDkr1XpkK9MCdbm5BKjSxBffMc5dsVwjBXj3ecEaMFspX8t/GP7NpvnXKTousDb4ZrZV huFyt5prhDifJSs6wBVnBkfWVLpraKFstoxljMXt8ifyGxQBWA0QXyerrlJwJoBKrCqM6CrdP kf9QoZhdckWR1suwx1w0agwIPzghmlden9LwVNcEmrcGwdiImUewa8n3ZvWxTbjj0COJRgjbC kY/ThdeJ1x4NM8huWP4/qwy77zEH3SWKnC4+8gRLO0Cz+dyrw4eZQ7sfclqjrGr9fmr0DuOHv hNFDsLh/lWzAnHlyX1SETMlmIAtPDV75EX6zP03BoPARW7LJLWQxBRC8EaVvsc6w8Ci823eHl CaBirN1Bqthm/QRpz5Jmiv6YO9oVG06WXds80TEi+xhrtUU/Eh2DV4no4EXF/8BHwC9DnbiJu CjZY2BiaqYZcOPZGq092IHsGM/VO5Qt2DrGJcfa4g8us4NOhy93d8Na9Lg8uPTW+HdlG/k0WG /bv/rqK/Bs1hf8k+xYhHr8LYQ6Qp2X5JeuINMA8bUHtPNUDkTwGOYVdfO7E3Tm+nVm9vCoOQc 4yBUH9t7CA77OYVAAAc7PS0hxLcP0oZBRCikpUK6rwKRhJFSviey4SS2XKsETXlqG2bIYE/bR SwbqOQfsUJdSR5jOBr0dNPTqyaY= X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756115397654236255?= X-GMAIL-MSGID: =?utf-8?q?1756115397654236255?= When the ACPI WMI interface returns a valid ACPI object which has the wrong type, then ENOMSG instead of EIO should be returned, since the WMI method was still successfully evaluated. Signed-off-by: Armin Wolf --- drivers/platform/x86/dell/dell-wmi-ddv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.30.2 diff --git a/drivers/platform/x86/dell/dell-wmi-ddv.c b/drivers/platform/x86/dell/dell-wmi-ddv.c index f99c4cb686fd..58fadb74e86a 100644 --- a/drivers/platform/x86/dell/dell-wmi-ddv.c +++ b/drivers/platform/x86/dell/dell-wmi-ddv.c @@ -87,7 +87,7 @@ static int dell_wmi_ddv_query_type(struct wmi_device *wdev, enum dell_ddv_method if (obj->type != type) { kfree(obj); - return -EIO; + return -ENOMSG; } *result = obj; From patchwork Thu Jan 26 19:40:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 48874 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp452425wrn; Thu, 26 Jan 2023 11:42:33 -0800 (PST) X-Google-Smtp-Source: AMrXdXsIbx2EWnLjbVvUSbFAYHo1jiTg4E96s1CExqm69krLEnZElpT59FDDpPfhQzh/jjruVGTD X-Received: by 2002:a17:902:f705:b0:191:1e89:35de with SMTP id h5-20020a170902f70500b001911e8935demr38847409plo.9.1674762152621; Thu, 26 Jan 2023 11:42:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674762152; cv=none; d=google.com; s=arc-20160816; b=OBAQ3t+x1tUo03r5gtuLvHo2qJph/0lc0DDzBz+DiNoz4OoIZbxQZ8BU75h4tAjRZW 9ZHdqam5WhhW0iQpNlsPVFntG2poRo1SgITcTEJUbedJp7rmgMuHaZeHTcc4oowejZpY JjjygMSlN2b+8Hu36AkoQgkrSdgmdPyDUwnKNPk1OO5eAG0f8tO2YQld/eRPZjN7bNAO 1mfYuqksZ/qiw1BamaD0wkufJfkHP9V1bVtiPR2gdDy2lwr9pAHaSB52bimlGI4rjiCF 8xrY/6FFYbJZG66NWBh+GPiUyzvypmUDEjv+D1HAiam5vfS2QGXKcCD0sZ9aC5fZRjlv S3SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5Qw4dlWo0kFGdfZl/6cmK5KDYkbtUAwvb18ARv8Bppc=; b=k41QUG2nG0w/aLYfkhlw0F1l+sInmdhdhKERNshdwXSyhqsv+ZEvYIgnS+lpq/qQdj MfHouwWoXSE2PSkYQ+y/iFGkQTTRChPdn1HKJD0m1nNPdhp6yWy/IrkTaDMy3m+BiFII qqb+qCSxRTczFN9fi+RABmMuXbUumQezSd7jQB41/Z0ErKMXEsvBEkF9V7Jool7lP94t mF8d/3Ra5p43FuqzB4SAsMyqallXK9M4Phu0Wkd4Jzvr1O8HN2y+YHaOCo1+IEOzccQ+ l6JPm2h5yPwX86wRpTQ1KlU92psYDYVV0Zj59RUY+bRFtfECfoZvm+Q4Oc8wD5Ofyo7b phJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=T+IFB2Ff; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w22-20020a170902a71600b00194b1c44205si2151998plq.523.2023.01.26.11.42.21; Thu, 26 Jan 2023 11:42:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=T+IFB2Ff; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232576AbjAZTlG (ORCPT + 99 others); Thu, 26 Jan 2023 14:41:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232558AbjAZTk4 (ORCPT ); Thu, 26 Jan 2023 14:40:56 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B1E919F1E; Thu, 26 Jan 2023 11:40:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1674762035; bh=YdjYt1hNkKObM0Ir4G1v9+RZ9f+OGA4OgCN1VC6gvV4=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=T+IFB2FfvYzRv1fKEdc+2ZsV0LecOaCxwY9keMu6+w7IIVXVGx9FooWbHWVSdJI5h we2PK8ssigdZFlaAHx7Q4+co1UK/jtGZ3ieMPVRVH/crbjreAIUscuuHnlX3mYvBvO b+8RcQ4p6dBKxwCO+BJUJI71oU/DocJ4y3ys5T8Rxu3CXUdUNOkFLxPhSuqPJUmTBi OnepSDmGXFzm2wnHjOwKHNm+tjsVXDpgpLZiTbd9CfW5T/Q02ERYT+1O+b1FAPnDwv uIehPxxlYb/cS/zsxk4maeUlbkk8zFNpcFg1kpOcgERJdrvu+5+isXh216+kMxZkfc w+U0Hvuo0fKSA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from esprimo-mx.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MC34X-1pXXdX3JOf-00CRnZ; Thu, 26 Jan 2023 20:40:34 +0100 From: Armin Wolf To: hdegoede@redhat.com, markgross@kernel.org Cc: jdelvare@suse.com, linux@roeck-us.net, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/5] platform/x86: dell-ddv: Add "force" module param Date: Thu, 26 Jan 2023 20:40:20 +0100 Message-Id: <20230126194021.381092-5-W_Armin@gmx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230126194021.381092-1-W_Armin@gmx.de> References: <20230126194021.381092-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:eTK8nJcBuZ63uhcSzfBS3cLU0NjgY3Wzp9l/NVLM+qvDcz6m6cy hAlUJtWguiDTODwnm8chbdA/U/C6LjGjo43zVjIRJgZqYb7Lltq33+WkK6cdomutWm+B8xO kieIGn/fM8ifOptJ6hj7GigmqpCv0UOMhw2l0dVnLIYlbaN/kklNE0YzjeqvDbutm/f96EN P2cRoGD121AUyZzLgSsfw== UI-OutboundReport: notjunk:1;M01:P0:CcRpqVwyz7k=;85JdvKVLhlzdNJsKc8PI5Nx6fu6 eOz9QjCbZ07+cAx67ZtpHq5M+givHKU1mMeo/DoBIC9v94QFvgJrs+5tuuyvlSGlBm+G5ax5b J/Rvq1EYOcD/j1S/Xdsm95htf+4vTetPv1eJnwbAzWvD4WT469JGXA7HRTlYC6Of/ylDOAXEa cDKt2RVVOpmC9QsmF3+oKnOUm+g2sYHtDE+BEWM8uzVstSu7bY/qxcZjfhNAIlHz8gbSXS0IW kTO0hVA+0LUzYcDz3QMbfF+nIX+NxC5Y2v3TVgIMeOYrpITmAt2t0VDeuBGP6GjSv5cNQUHrV 8ebL0oIRoNhnw4cwkLCBJtXjv5vpbmtCMBhMB4MRQ3zXrLETu8qHTC4EvwOPt5841iSNhsOqD bT66RYXtsmsH9XhCRp+hDQ5sJ+3KLaBUotfpOVg2Q4t62wlZQMAFwr33EO+sOHM8LCPKPS8uB AQ9MfcU8E1BKeHeM9t0oyW9pCW+KD5Zrkfmk9cghu9EPI2nSEqohx2MX/E+vBmX6P/vS/Ajse Z1jI0K6aMlP3g6l176uBowwkOH2T0HSooUYs9Nd/KcdnQXZw/v1ZWLh+zDu48SZ06Mqx+sPDq 4B7jNOKaQgyO7L5oTS/R5SNVtVD2mL94w5a6bkzTxOA6LROXUmhhPy2jCCFSup7oJBJLbuF5q G4bbQF77LfB7IR+yL/oFNrAjnbjPlKtZ/Iez0oPHEUwmsNf44LEl8NNaYjX9NzTvq1sYH6lyo sY+o75JkrHGblZeu3IqLrhKdt0cEgdy6ybnCvcuF1Y4Bbt1gZ03fp96BuNW27vL10FAEM03lo TP+BXJE4sZJfhex5J/Iu0kqScrrPxdfd3Buo4pDI9lNGzbckCwk8cXcSBuaWhTJn0E7Q7oJa+ d8P5jZTCnas7kjjMH2dmwFOogkAlwJV+bpAOCuEVWbIESPIVKNQyYB5lwvaH7NVmAcblrg5DK D5JYR4lXNjZuNAoD8udJcR3U6kk= X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756115399282764020?= X-GMAIL-MSGID: =?utf-8?q?1756115399282764020?= Until now, the dell-wmi-ddv driver needs to be manually patched and compiled to test compatibility with unknown DDV WMI interface versions. Add a module param to allow users to force loading even when a unknown interface version was detected. Since this might cause various unwanted side effects, the module param is marked as unsafe. Also update kernel-parameters.txt. Signed-off-by: Armin Wolf --- Documentation/admin-guide/kernel-parameters.txt | 3 +++ drivers/platform/x86/dell/dell-wmi-ddv.c | 13 +++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) -- 2.30.2 diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 6cfa6e3996cf..9bbff5113427 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -1024,6 +1024,9 @@ dell_smm_hwmon.fan_max= [HW] Maximum configurable fan speed. + dell_wmi_ddv.force= + [HW] Do not check for supported WMI interface versions. + dfltcc= [HW,S390] Format: { on | off | def_only | inf_only | always } on: s390 zlib hardware support for compression on diff --git a/drivers/platform/x86/dell/dell-wmi-ddv.c b/drivers/platform/x86/dell/dell-wmi-ddv.c index 58fadb74e86a..9695bf493ea6 100644 --- a/drivers/platform/x86/dell/dell-wmi-ddv.c +++ b/drivers/platform/x86/dell/dell-wmi-ddv.c @@ -34,6 +34,10 @@ #define DELL_EPPID_LENGTH 20 #define DELL_EPPID_EXT_LENGTH 23 +static bool force; +module_param_unsafe(force, bool, 0); +MODULE_PARM_DESC(force, "Force loading without checking for supported WMI interface versions"); + enum dell_ddv_method { DELL_DDV_BATTERY_DESIGN_CAPACITY = 0x01, DELL_DDV_BATTERY_FULL_CHARGE_CAPACITY = 0x02, @@ -349,8 +353,13 @@ static int dell_wmi_ddv_probe(struct wmi_device *wdev, const void *context) return ret; dev_dbg(&wdev->dev, "WMI interface version: %d\n", version); - if (version < DELL_DDV_SUPPORTED_VERSION_MIN || version > DELL_DDV_SUPPORTED_VERSION_MAX) - return -ENODEV; + if (version < DELL_DDV_SUPPORTED_VERSION_MIN || version > DELL_DDV_SUPPORTED_VERSION_MAX) { + if (!force) + return -ENODEV; + + dev_warn(&wdev->dev, "Loading despite unsupported WMI interface version (%u)\n", + version); + } data = devm_kzalloc(&wdev->dev, sizeof(*data), GFP_KERNEL); if (!data) From patchwork Thu Jan 26 19:40:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 48876 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp453567wrn; Thu, 26 Jan 2023 11:45:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXvkCYKgKhF1nWrRk8g1zZ+6tSdWg7ydIOXWDPNBmE0FRqLvHmL3mlkW3JuCB6gOoZUJm+Xp X-Received: by 2002:a17:902:f546:b0:194:d9d7:88c4 with SMTP id h6-20020a170902f54600b00194d9d788c4mr34077307plf.49.1674762335363; Thu, 26 Jan 2023 11:45:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674762335; cv=none; d=google.com; s=arc-20160816; b=fbf/goYwHl2GiDJ1j74amo5+dBREqP3VUS1GFlJ3qd+QED7ScG51BA75P0XF9V4IfQ YJwqsGIQ3M8Cry0mXnchb9gvV6aEhqMl27Hj/5Jv0p1HwZ7WWiUfjkRNWf2KKrUTZ9GY C54J9bQ0mmUscMg4BRa9NTxA5c9Ia4OPyqfduFagUsXDdSlta7Na4qnPSKWS4Piu8Jfy tXtUCa4D/Ff0tXMDVsIf758G833y15BhAC5orh/g1C/XWGJwvOy8Fqkgw/+2SlPTghZi QLDLvGRcEZPydAdyV7rxBlm5wvqMe7vVN2X/C66NNIu6qSDvqAIi4CwTCcWml8+EGoaF VCAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qpPhI6wz/gu31ePGlqejz9yWDwnuaN9TJe5/SJiCYZc=; b=ZbErpZ83ZD09MLfD2R0BSfxFjbnfeZ4hDiC8IBHVZ1XP9bZkWzICjkyTsknOlnSSz8 u4p2QxoZDSA3BseWfv3a3WYP8wPaTWlkSlH73FNKGGvWCQe3fp2103VEiR6VBxRwgwOx CWoeU1qR8fUC5dIaRilBvCYKm8wdJ7caguVvNu/YYUvmK8qfPxQVinDzzlegWHdafEtb bZ21TNM7ASlZwRt1HO93H8cj/GdVAgUCM4vaLTXbmCPpXuGa4aaFXXDZcpQnhZ9SgW1q 66WEOLSe2DCZRy4EnFyY20A5Kqa88+APYPPcRXWLrso5MRIyALyuKMxBTnZAb6dg6SS+ BT0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b="qOp7HRU/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z21-20020a63b915000000b004a587b86b62si1946661pge.786.2023.01.26.11.45.15; Thu, 26 Jan 2023 11:45:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b="qOp7HRU/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232682AbjAZTlQ (ORCPT + 99 others); Thu, 26 Jan 2023 14:41:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232608AbjAZTlD (ORCPT ); Thu, 26 Jan 2023 14:41:03 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2ACFE19F14; Thu, 26 Jan 2023 11:40:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1674762036; bh=QdrZXwtINisoF2jUYT+sA8JZU9N6BJ1lzZkFgrjz8cY=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=qOp7HRU/vAqhLkrLsmJoaDwWHxmbbRqY1/+CHXl2RxHuPA89rDePQYvSK+6Le6NgY yN0fa52HegC1B/ubGxkMM+7A8uagUZ4npPObbqfL7mbayTqXpTzf4BAGTt4zigiWI/ Yhq9VqaSzxEdrKdqcjucXW+o5YZf8CybOjrXwvv0qr3HcdwjckRUTr/oMDzPjrkXA6 UWTogorIsx5iVdvC3DzKwEtMslOy6ajzF4Cfkna+mxVDkucsQHTWYz75N+sqopRlZK 2eP9Yi+NL27YC2iIYxSmGWLnPjPN1nsF5YTLhVkmp5+dq8Y0G2zMtHXd1FoyHr0eUS TC3iHn9DDf+cw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from esprimo-mx.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mz9Ux-1oPQsp0pCV-00wEI0; Thu, 26 Jan 2023 20:40:36 +0100 From: Armin Wolf To: hdegoede@redhat.com, markgross@kernel.org Cc: jdelvare@suse.com, linux@roeck-us.net, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/5] platform/x86: dell-ddv: Add hwmon support Date: Thu, 26 Jan 2023 20:40:21 +0100 Message-Id: <20230126194021.381092-6-W_Armin@gmx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230126194021.381092-1-W_Armin@gmx.de> References: <20230126194021.381092-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:XjjZNtVzX+dAeBXDZMsentlZWpFivTubs9rDFG1eKW6EHqIEYF5 0gAubAgTWWzv2fgKCqXy6n2KvPjCYkv/jGClWguDwAhhfPBmayo28ma5vFyUB1cttB3Agl8 fcrStXujlRpnAm1fw3pJGR1PBoU8uW7G0db74VOBU0UbVsKQXDGU/wHuIPeVBmgqHITZumq R2PmkG2CZfkIn+9ByqxCA== UI-OutboundReport: notjunk:1;M01:P0:VI7xKuTrcvw=;FFeZkxKuFjnaF5Z0nToY0v5yMb7 q8jRm9pXERPeTh09eI2Ci+8FiIQKTKF0HvOsTiG9PWlt5Eye6LL/J5gvVdNxrV1jZNKLM0h/C hF5udUsczr80b7LFUu8L94Yd8cchI9hOf8wi/SEYUWr3Fz/gpSSMYJ0a+b7tH8mxzGGUuLYPc V1Yv8S/L3wwA2heeaErcCb0Qt9KV0TSKG5+4bfX5ZzoIRTChuf9GVlfhL8/a7H2ynskZS+jD8 I+e5i1PlIlK7oxKzFC0JIHtX2wr4a6bAVHNKIDomkbJS476VDAK20LcuOdU8BwzVVUASoujUF JiiQNOMiEXJpJla+9pIe5V4WFo+Yn43wk4AKp0SkYrZR3AqTM/xcQWuwEf3o9wNrPAnVmlflg qL0R/dAkVIe4SQYoW3JrX8TGtao2fJyM6FnT1gda4w6JCwFbcSQjRjkVimj8yxdkWbzgcMSeo 5I8mS8dx3y3Uo3H2UWV8jvd/TM60U0ciZGp+RlffCSDP7mWxcXXykARnZbc7tSRZr7m4zE6o3 vo8WnxfQiMyUKXmpi+KmTPzHsEbnvBToL5pULObWwhpEEDTdDF214z6JOR8SjvgWR+xtCX7ZE Hv4tFb2uiACC1gB8jPNGikJWs3B0rA8eLu+vpCBmkwxyuwmmbZBwpaiz9KBuR4CYZopigZ58R VnXxAxRBE6axDRalXdoUl+FklnOUC2azzPjNBKLikcb7dyJ6aKaDjNVPkA0LGDWtiKL387TBe 97OuFlNvoc73UbYGshxioXBJ6d1ULgmdWiJExq60kL23YeJKm0U7Jz9kBOPyIlYcWvJ0jIj3U EqSx4OS91eSjpSuGflpAe47+w52/1Gf4MIYodGRNbRA+RV2psy7x1gedgwNQxe9YaofEXbAfD ZWxa2p5w4woW3OMZ4tQS0vhiSa8kMNs+wjd8UESrc4Js/VH6OaaEaZNE3R7HH3msi2O+j82/r qfrgJSZaOVU7zTRI6P0Px0ewGSY= X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756115590727092282?= X-GMAIL-MSGID: =?utf-8?q?1756115590727092282?= Thanks to bugreport 216655 on bugzilla triggered by the dell-smm-hwmon driver, the contents of the sensor buffers could be almost completely decoded. Add an hwmon interface for exposing the fan and thermal sensor values. The debugfs interface remains in place to aid in reverse-engineering of unknown sensor types and the thermal buffer. Tested-by: AntonĂ­n Skala Tested-by: Gustavo Walbon Signed-off-by: Armin Wolf --- drivers/platform/x86/dell/Kconfig | 1 + drivers/platform/x86/dell/dell-wmi-ddv.c | 435 ++++++++++++++++++++++- 2 files changed, 435 insertions(+), 1 deletion(-) -- 2.30.2 diff --git a/drivers/platform/x86/dell/Kconfig b/drivers/platform/x86/dell/Kconfig index d319de8f2132..21a74b63d9b1 100644 --- a/drivers/platform/x86/dell/Kconfig +++ b/drivers/platform/x86/dell/Kconfig @@ -194,6 +194,7 @@ config DELL_WMI_DDV default m depends on ACPI_BATTERY depends on ACPI_WMI + depends on HWMON help This option adds support for WMI-based sensors like battery temperature sensors found on some Dell notebooks. diff --git a/drivers/platform/x86/dell/dell-wmi-ddv.c b/drivers/platform/x86/dell/dell-wmi-ddv.c index 9695bf493ea6..5b30bb85199e 100644 --- a/drivers/platform/x86/dell/dell-wmi-ddv.c +++ b/drivers/platform/x86/dell/dell-wmi-ddv.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -21,10 +22,13 @@ #include #include #include +#include #include #include +#include + #define DRIVER_NAME "dell-wmi-ddv" #define DELL_DDV_SUPPORTED_VERSION_MIN 2 @@ -63,6 +67,29 @@ enum dell_ddv_method { DELL_DDV_THERMAL_SENSOR_INFORMATION = 0x22, }; +struct fan_sensor_entry { + u8 type; + __le16 rpm; +} __packed; + +struct thermal_sensor_entry { + u8 type; + s8 now; + s8 min; + s8 max; + u8 unknown; +} __packed; + +struct combined_channel_info { + struct hwmon_channel_info info; + u32 config[]; +}; + +struct combined_chip_info { + struct hwmon_chip_info chip; + const struct hwmon_channel_info *info[]; +}; + struct dell_wmi_ddv_data { struct acpi_battery_hook hook; struct device_attribute temp_attr; @@ -70,6 +97,24 @@ struct dell_wmi_ddv_data { struct wmi_device *wdev; }; +static const char * const fan_labels[] = { + "CPU Fan", + "Chassis Motherboard Fan", + "Video Fan", + "Power Supply Fan", + "Chipset Fan", + "Memory Fan", + "PCI Fan", + "HDD Fan", +}; + +static const char * const fan_dock_labels[] = { + "Docking Chassis/Motherboard Fan", + "Docking Video Fan", + "Docking Power Supply Fan", + "Docking Chipset Fan", +}; + static int dell_wmi_ddv_query_type(struct wmi_device *wdev, enum dell_ddv_method method, u32 arg, union acpi_object **result, acpi_object_type type) { @@ -171,6 +216,386 @@ static int dell_wmi_ddv_query_string(struct wmi_device *wdev, enum dell_ddv_meth return dell_wmi_ddv_query_type(wdev, method, arg, result, ACPI_TYPE_STRING); } +static int dell_wmi_ddv_query_sensors(struct wmi_device *wdev, enum dell_ddv_method method, + size_t entry_size, union acpi_object **result, u64 *count) +{ + union acpi_object *obj; + u64 buffer_size; + u8 *buffer; + int ret; + + ret = dell_wmi_ddv_query_buffer(wdev, method, 0, &obj); + if (ret < 0) + return ret; + + buffer_size = obj->package.elements[0].integer.value; + buffer = obj->package.elements[1].buffer.pointer; + if (buffer_size % entry_size != 1 || buffer[buffer_size - 1] != 0xff) { + kfree(obj); + + return -ENOMSG; + } + + *count = (buffer_size - 1) / entry_size; + *result = obj; + + return 0; +} + +static umode_t dell_wmi_ddv_is_visible(const void *drvdata, enum hwmon_sensor_types type, u32 attr, + int channel) +{ + return 0444; +} + +static int dell_wmi_ddv_fan_read_channel(struct dell_wmi_ddv_data *data, u32 attr, int channel, + long *val) +{ + struct fan_sensor_entry *entry; + union acpi_object *obj; + u64 count; + int ret; + + ret = dell_wmi_ddv_query_sensors(data->wdev, DELL_DDV_FAN_SENSOR_INFORMATION, + sizeof(*entry), &obj, &count); + if (ret < 0) + return ret; + + entry = (struct fan_sensor_entry *)obj->package.elements[1].buffer.pointer; + if (count > channel) { + switch (attr) { + case hwmon_fan_input: + *val = get_unaligned_le16(&entry[channel].rpm); + + break; + default: + ret = -EOPNOTSUPP; + } + } else { + ret = -ENXIO; + } + + kfree(obj); + + return ret; +} + +static int dell_wmi_ddv_temp_read_channel(struct dell_wmi_ddv_data *data, u32 attr, int channel, + long *val) +{ + struct thermal_sensor_entry *entry; + union acpi_object *obj; + u64 count; + int ret; + + ret = dell_wmi_ddv_query_sensors(data->wdev, DELL_DDV_THERMAL_SENSOR_INFORMATION, + sizeof(*entry), &obj, &count); + if (ret < 0) + return ret; + + entry = (struct thermal_sensor_entry *)obj->package.elements[1].buffer.pointer; + if (count > channel) { + switch (attr) { + case hwmon_temp_input: + *val = entry[channel].now * 1000; + + break; + case hwmon_temp_min: + *val = entry[channel].min * 1000; + + break; + case hwmon_temp_max: + *val = entry[channel].max * 1000; + + break; + default: + ret = -EOPNOTSUPP; + } + } else { + ret = -ENXIO; + } + + kfree(obj); + + return ret; +} + +static int dell_wmi_ddv_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, + int channel, long *val) +{ + struct dell_wmi_ddv_data *data = dev_get_drvdata(dev); + + switch (type) { + case hwmon_fan: + return dell_wmi_ddv_fan_read_channel(data, attr, channel, val); + case hwmon_temp: + return dell_wmi_ddv_temp_read_channel(data, attr, channel, val); + default: + break; + } + + return -EOPNOTSUPP; +} + +static int dell_wmi_ddv_fan_read_string(struct dell_wmi_ddv_data *data, int channel, + const char **str) +{ + struct fan_sensor_entry *entry; + union acpi_object *obj; + u64 count; + u8 type; + int ret; + + ret = dell_wmi_ddv_query_sensors(data->wdev, DELL_DDV_FAN_SENSOR_INFORMATION, + sizeof(*entry), &obj, &count); + if (ret < 0) + return ret; + + entry = (struct fan_sensor_entry *)obj->package.elements[1].buffer.pointer; + if (count > channel) { + type = entry[channel].type; + + switch (type) { + case 0x00 ... 0x07: + *str = fan_labels[type]; + + break; + case 0x11 ... 0x14: + *str = fan_dock_labels[type - 0x11]; + + break; + default: + *str = "Unknown Fan"; + } + } else { + ret = -ENXIO; + } + + kfree(obj); + + return ret; +} + +static int dell_wmi_ddv_temp_read_string(struct dell_wmi_ddv_data *data, int channel, + const char **str) +{ + struct thermal_sensor_entry *entry; + union acpi_object *obj; + u64 count; + int ret; + + ret = dell_wmi_ddv_query_sensors(data->wdev, DELL_DDV_THERMAL_SENSOR_INFORMATION, + sizeof(*entry), &obj, &count); + if (ret < 0) + return ret; + + entry = (struct thermal_sensor_entry *)obj->package.elements[1].buffer.pointer; + if (count > channel) { + switch (entry[channel].type) { + case 0x00: + *str = "CPU"; + + break; + case 0x11: + *str = "Video"; + + break; + case 0x22: + *str = "Memory"; // sometimes called DIMM + + break; + case 0x33: + *str = "Other"; + + break; + case 0x44: + *str = "Ambient"; // sometimes called SKIN + + break; + case 0x52: + *str = "SODIMM"; + + break; + case 0x55: + *str = "HDD"; + + break; + case 0x62: + *str = "SODIMM 2"; + + break; + case 0x73: + *str = "NB"; + + break; + case 0x83: + *str = "Charger"; + + break; + case 0xbb: + *str = "Memory 3"; + + break; + default: + *str = "Unknown"; + } + } else { + ret = -ENXIO; + } + + kfree(obj); + + return ret; +} + +static int dell_wmi_ddv_read_string(struct device *dev, enum hwmon_sensor_types type, u32 attr, + int channel, const char **str) +{ + struct dell_wmi_ddv_data *data = dev_get_drvdata(dev); + + switch (type) { + case hwmon_fan: + switch (attr) { + case hwmon_fan_label: + return dell_wmi_ddv_fan_read_string(data, channel, str); + default: + break; + } + break; + case hwmon_temp: + switch (attr) { + case hwmon_temp_label: + return dell_wmi_ddv_temp_read_string(data, channel, str); + default: + break; + } + break; + default: + break; + } + + return -EOPNOTSUPP; +} + +static const struct hwmon_ops dell_wmi_ddv_ops = { + .is_visible = dell_wmi_ddv_is_visible, + .read = dell_wmi_ddv_read, + .read_string = dell_wmi_ddv_read_string, +}; + +static struct hwmon_channel_info *dell_wmi_ddv_channel_create(struct device *dev, u64 count, + enum hwmon_sensor_types type, + u32 config) +{ + struct combined_channel_info *cinfo; + int i; + + cinfo = devm_kzalloc(dev, struct_size(cinfo, config, count + 1), GFP_KERNEL); + if (!cinfo) + return ERR_PTR(-ENOMEM); + + cinfo->info.type = type; + cinfo->info.config = cinfo->config; + + for (i = 0; i < count; i++) + cinfo->config[i] = config; + + return &cinfo->info; +} + +static struct hwmon_channel_info *dell_wmi_ddv_channel_init(struct wmi_device *wdev, + enum dell_ddv_method method, + size_t entry_size, + enum hwmon_sensor_types type, + u32 config) +{ + union acpi_object *obj; + u64 count; + int ret; + + ret = dell_wmi_ddv_query_sensors(wdev, method, entry_size, &obj, &count); + if (ret < 0) + return ERR_PTR(ret); + + kfree(obj); + + if (!count) + return ERR_PTR(-ENODEV); + + return dell_wmi_ddv_channel_create(&wdev->dev, count, type, config); +} + +static int dell_wmi_ddv_hwmon_add(struct dell_wmi_ddv_data *data) +{ + struct wmi_device *wdev = data->wdev; + struct combined_chip_info *cinfo; + struct device *hdev; + int index = 0; + int ret; + + if (!devres_open_group(&wdev->dev, dell_wmi_ddv_hwmon_add, GFP_KERNEL)) + return -ENOMEM; + + cinfo = devm_kzalloc(&wdev->dev, struct_size(cinfo, info, 4), GFP_KERNEL); + if (!cinfo) { + ret = -ENOMEM; + + goto err_release; + } + + cinfo->chip.ops = &dell_wmi_ddv_ops; + cinfo->chip.info = cinfo->info; + + cinfo->info[index] = dell_wmi_ddv_channel_create(&wdev->dev, 1, hwmon_chip, + HWMON_C_REGISTER_TZ); + + if (IS_ERR(cinfo->info[index])) { + ret = PTR_ERR(cinfo->info[index]); + + goto err_release; + } + + index++; + + cinfo->info[index] = dell_wmi_ddv_channel_init(wdev, DELL_DDV_FAN_SENSOR_INFORMATION, + sizeof(struct fan_sensor_entry), hwmon_fan, + (HWMON_F_INPUT | HWMON_F_LABEL)); + if (!IS_ERR(cinfo->info[index])) + index++; + + cinfo->info[index] = dell_wmi_ddv_channel_init(wdev, DELL_DDV_THERMAL_SENSOR_INFORMATION, + sizeof(struct thermal_sensor_entry), + hwmon_temp, (HWMON_T_INPUT | HWMON_T_MIN | + HWMON_T_MAX | HWMON_T_LABEL)); + if (!IS_ERR(cinfo->info[index])) + index++; + + if (!index) { + ret = -ENODEV; + + goto err_release; + } + + cinfo->info[index] = NULL; + + hdev = devm_hwmon_device_register_with_info(&wdev->dev, "dell_ddv", data, &cinfo->chip, + NULL); + if (IS_ERR(hdev)) { + ret = PTR_ERR(hdev); + + goto err_release; + } + + devres_close_group(&wdev->dev, dell_wmi_ddv_hwmon_add); + + return 0; + +err_release: + devres_release_group(&wdev->dev, dell_wmi_ddv_hwmon_add); + + return ret; +} + static int dell_wmi_ddv_battery_index(struct acpi_device *acpi_dev, u32 *index) { const char *uid_str; @@ -370,7 +795,15 @@ static int dell_wmi_ddv_probe(struct wmi_device *wdev, const void *context) dell_wmi_ddv_debugfs_init(wdev); - return dell_wmi_ddv_battery_add(data); + ret = dell_wmi_ddv_hwmon_add(data); + if (ret < 0) + dev_dbg(&wdev->dev, "Unable to register hwmon interface: %d\n", ret); + + ret = dell_wmi_ddv_battery_add(data); + if (ret < 0) + dev_dbg(&wdev->dev, "Unable to register acpi battery hook: %d\n", ret); + + return 0; } static const struct wmi_device_id dell_wmi_ddv_id_table[] = {