From patchwork Thu Oct 21 17:54:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 12575981 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 287ACC433F5 for ; Thu, 21 Oct 2021 17:55:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F2C2B61929 for ; Thu, 21 Oct 2021 17:55:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232169AbhJUR5f (ORCPT ); Thu, 21 Oct 2021 13:57:35 -0400 Received: from mout.gmx.net ([212.227.15.18]:49797 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231727AbhJUR5f (ORCPT ); Thu, 21 Oct 2021 13:57:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1634838902; bh=xdsP6gml0dd2Q0fEMW1hNJf983q2tKghr0Vd2QYvf6A=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=LTUvX6IpaxFHJclfYyrZK3JsMoh+Jx0o1WHWZDp4/MVBloXMj++YtFE1ISqs3tC4x 9O33HiU516rgcHtrrLujCOsuEMNZOX6FjdQMfl8QnjCtuQPOa2XkfH0lDvR8qyo1rR RE/1I+zJdhJXBPOSLLV0gQ9OOxV4Ax/TXRZD4COQ= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from esprimo-mx.fritz.box ([91.137.126.34]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MJE2D-1mOYN31BoB-00KeYA; Thu, 21 Oct 2021 19:55:02 +0200 From: W_Armin@gmx.de To: pali@kernel.org Cc: linux@roeck-us.net, jdelvare@suse.com, linux-hwmon@vger.kernel.org Subject: [PATCH 1/5] hwmon: (dell-smm) Sort includes in alphabetical order Date: Thu, 21 Oct 2021 19:54:43 +0200 Message-Id: <20211021175447.5380-2-W_Armin@gmx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211021175447.5380-1-W_Armin@gmx.de> References: <20211021175447.5380-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:47SVpheqy166JFYkXJjZPNc61/pGhjvoSFuyoCqox2UkOm/5xOL RgFK8KDSqb3j2SrIBKsF+Nkw6GSmZBnsnKh7FuRJfs9uGL4G8RHXlaEnjXWgbUlgvol5FjB RRUsSkQCV7wRS/Hy6LXkZVOaWi4r7pCgD68CHvDuL7yl0flHghG0QC4nn2ijjr5pYmtl7oh Zj8CTf2bFQSWvCnIqCLrg== X-UI-Out-Filterresults: notjunk:1;V03:K0:cC6Wx2g7khI=:B6FPxVUg6LPpn0L4p5dtkw 1pf3G3RZnzeD09N+wVcIVIkYydwUcZwm+1Cynq2N2aKWhi4EHv/SMpBmjr9K1twf45y8Kk/NZ 0Y8SZuuEgc27D8STkjeTDONEPc44iBsIhveyk8oj+BRjrEJF4p/arggSR6UWk7DQgEXqGYteY UXSxme7QyMeoYjVWAiE2hOP1i1I2Ca+uVmvA4NqLzDWarqmUVeAqRgiFS1LtGOVS5BCoQj5dN XizCEu1xdCb+TVkpNNDXOR0gcdclLtz4ut7i898mRZX6q5hLzGy2gcRh6KuzLPfdf+MB2ce7U +VuqNVbJgijT8e5/Ru1mi5VShbbZn9Lb3FhEU6LTXi/nE+GPj1Cjd+Tol+dyzqYFzfqX8wM5j 6pKUhGvTS4XVnBQLdKg8VHyvaQuDm4AGix1Zl1S4QeULOrZzgebMAl/GEP5uO0pggyNb2TezF uFTGO0CFMisIj1MUJkumKY6H93VbNjxn3IqpfGeTJeqMbrAszrjGT2OI3S4jSGfy9oxempUVv 3RWElpbdeUQ66+FSvv0bNB/t6UAQfhycOSt1JYxXmPClOD8pQoE414HkZu20TyzhilOKpMlxh pvJ7hCTW4Pt+2EyiqkmM1zcEdS0oEW+KKfr+0yKHA/RUSUQ7KXg0M32cIL3KUfCHr+RLwZUhG Gr7Up8hFT4vBl6ckqUQdjrdSFqUt4XFvJOgcFl/7O4YHrC99X+U3tQUOYkZUZxMGxNfe4SdvG SCvZUe7LsZNdh0AIe+7G07JKdsC/M64zTA7cHRnHGHaphDdtW1uAwbI6uXzsRedodi5ViwcjK m7MTFZFzQ4Tk4ZGkv+4lu+8rW7bOBf6A44jnnMmLoalKDccF0rTv7V3/g9c2Q50bAoiVPWFYY Eob6WC0gAkX8jUUq2fVMrJtYsn8Tyau5w82z42hT+umKwIvi+3BwbBKH1XJywoawN4LJhSw3D xbbKLigFbetCmRLo6vj5RV3DBmJx8sEotUWfrePo5Py1S8NHZ/H+qJLOiSU2l403gpzIPhqS6 x3n9Lc5Q/y2/iDUuxUGIWoMdgDVU0QKE4cMjrfLE2rdDiQHl3+4AJWpSHEX+2fXzUOot4Z32O afhaJ3fVbEE7FQ= Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Armin Wolf Sort includes for better overview. Signed-off-by: Armin Wolf Acked-by: Pali Rohár --- drivers/hwmon/dell-smm-hwmon.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) -- 2.20.1 diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c index af0d0d2b6e99..9773d6c0477a 100644 --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -12,22 +12,22 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include +#include #include +#include #include +#include +#include #include +#include #include -#include -#include #include #include -#include -#include -#include -#include -#include -#include #include +#include +#include #include From patchwork Thu Oct 21 17:54:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 12575987 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AAFBC433FE for ; Thu, 21 Oct 2021 17:55:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 09C2861390 for ; Thu, 21 Oct 2021 17:55:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231873AbhJUR5h (ORCPT ); Thu, 21 Oct 2021 13:57:37 -0400 Received: from mout.gmx.net ([212.227.15.15]:43707 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231842AbhJUR5g (ORCPT ); Thu, 21 Oct 2021 13:57:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1634838903; bh=6FuQuYj16NdgIbX/lw2K6OzlybkRPbtSc2HFQNbFz6M=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=AxKbJV2Ed0Bz/f+pFv/zG74OcYBGR8h73FocKzvXlT2C8sSjPgQfCgjYm134h43eG zFC8aMqNwJoRtLmU1scWPQTZSKccId8zAd2GVmdMvRnVZrOhdsPSrZaW+tUkWETiRg cpLPRuphyh2tCJKYagLos9q5jcJZ5yL2vwTHcRI0= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from esprimo-mx.fritz.box ([91.137.126.34]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M8QS2-1mZEYh2PNg-004PTx; Thu, 21 Oct 2021 19:55:03 +0200 From: W_Armin@gmx.de To: pali@kernel.org Cc: linux@roeck-us.net, jdelvare@suse.com, linux-hwmon@vger.kernel.org Subject: [PATCH 2/5] hwmon: (dell-smm) Use strscpy_pad() Date: Thu, 21 Oct 2021 19:54:44 +0200 Message-Id: <20211021175447.5380-3-W_Armin@gmx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211021175447.5380-1-W_Armin@gmx.de> References: <20211021175447.5380-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:uxCblOLguGhSrsohqK3mjt+phttuXFW9nkTtaMisNHpEqE+6Ucr BDTjvYQ7qN2e3xppWvFvm4J5APioVEsROa6f0nTAGBajkM+Hy638tfmTfPbSNQ/LCuDYxEj Zi5n8nIbZNRtfhW5NbBs0AZ/rqduM8gZv4XPyBfntavpPvHYL+I1PJoOzTpiPzmGC/R5klU tkX8YgdIiYhmCMQfWm+Xg== X-UI-Out-Filterresults: notjunk:1;V03:K0:L0I1iPCmAqg=:+In+6yB9ZLAhykORSQNsYl 3osJQkhBV0uMWskZNxMYdTr1RMVhqar9mireQH71bDhr3by6p8/TXP61zDmDrA7hb5PlQ0YZw TjciXjUe9+b6Z4kSLBc44OOut19WR3y0qeNshz5o/z/4G57zabjCrB9o8jzH2jNtFK9FMdQyF VigzarlHxVYlFAs7LjCZwggCbs3dhMkjQquTuR5pf8+jNLS8Qz6IHfbOOqSWt16U86cSynWRV ghMqhkXq9KuLe/W1S7dWm0AZmDorKPrYHOovQwnn7SHCNUzsb4w4OgW9LMxCi87R3YHf0KDiC DCh1gPhLgh2z3E8vXpmUGlaYffAyBl73jqZiHsZi1Y7W25AwIgywBNtrioWDRcYuYTSAyvvO2 ER6tffCIAGDIXfoitJ/E7b+3L8FXRTz0w4l2Ft26950B78Q6XcX5urk38aA4QPzrLApJQ5G8K x8cKrSjE2yNjphK2ZSfXKW8z9urYSeg2G/jGBTlwMVUYO5Pit/Ur95QjAb6VTGaQhbtECT0AR P0/Sl8P2j3bUJgZVhW9WPlnMHevNaA2C6T8v6EIajUV/IEoLGdXlrbuXvqltceCaRh5XKebX1 cGS2W18VIeOj6hIF7mImbyZKpTRfRwfC8RWwjIL4cT+s3qvfwUkatyWdVbJQrD6gH95ETjOys sBpumE4iZTBTPM/Rs97cNyr0H4/MyTYt0Q3MGmCl3qC70vFGIMxYiPuEqkxYXsTQNDgZflRyl CczDvi+p6GP+R8IjKmr0Jb2PJu/TOLCKoY9GsDpbGgDQ3OJ7gxSGatpUvlDU/ymcScR/8PT33 AY/a1dIamoihG/iL0WrBxLTe5BwwiT8lJucVQEI2tUfyKBWMBV4yeFwPPTfghjGo+AaL1nIi6 RN6fV9pyJNdx/C5PYy3iB/Ub6kCP8SWetA5kRcEy0pRdmWDUwdlJj/sjwTAP9ZJI/XsjGAmgG Sr+dIGWTjV8SY8BQHksF0gnzgiFWRb+lt5/u8KXFGH2nPZFu5xazcQ+9h9cVZpYdmEh25yGQI rEl47osL5Py6/6FClax/p/8mlUKpTBainBWi7TdtcaCkgKuVywAB+rHjf2LRMoPaW9yceVW7e xFrv0GcsHIrXNQ= Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Armin Wolf Using strscpy_pad() allows for fewer memory accesses since memset() will not unconditionally zero-out the whole buffer. Signed-off-by: Armin Wolf Acked-by: Pali Rohár --- drivers/hwmon/dell-smm-hwmon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c index 9773d6c0477a..b0c591bb761a 100644 --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -472,8 +473,7 @@ i8k_ioctl_unlocked(struct file *fp, struct dell_smm_data *data, unsigned int cmd if (restricted && !capable(CAP_SYS_ADMIN)) return -EPERM; - memset(buff, 0, sizeof(buff)); - strscpy(buff, data->bios_machineid, sizeof(buff)); + strscpy_pad(buff, data->bios_machineid, sizeof(buff)); break; case I8K_FN_STATUS: From patchwork Thu Oct 21 17:54:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 12575985 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA613C4332F for ; Thu, 21 Oct 2021 17:55:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D3B1861929 for ; Thu, 21 Oct 2021 17:55:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232180AbhJUR5i (ORCPT ); Thu, 21 Oct 2021 13:57:38 -0400 Received: from mout.gmx.net ([212.227.15.18]:54961 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231396AbhJUR5h (ORCPT ); Thu, 21 Oct 2021 13:57:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1634838905; bh=P5BZx8ckD0FBJeT759FTzHUfCFpqVzUVIc8iCkJsyDQ=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=XfuwQQ5uLixDScplv7ElAgR29HurDS3wHsXvXeVP2SYxHcURl5CZ6apo4wB27+1bt BHlPKS2F2FMdtm2OY98XQpr6rdvuTxHVkMM4/3E5ZwhhE/q6orPpM6KbchJ3V3qst+ CFoXljnnUy+os6acM6gHRhwpuJ/6NRDb61WWb76o= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from esprimo-mx.fritz.box ([91.137.126.34]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MDhlV-1mWA9e06P1-00Am8X; Thu, 21 Oct 2021 19:55:05 +0200 From: W_Armin@gmx.de To: pali@kernel.org Cc: linux@roeck-us.net, jdelvare@suse.com, linux-hwmon@vger.kernel.org Subject: [PATCH 3/5] hwmon: (dell-smm) Return -ENOIOCTLCMD instead of -EINVAL Date: Thu, 21 Oct 2021 19:54:45 +0200 Message-Id: <20211021175447.5380-4-W_Armin@gmx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211021175447.5380-1-W_Armin@gmx.de> References: <20211021175447.5380-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:bR3yyN/vMo5SH7ua0/jsm29b0ThcjizrSGeeF7n0J5fz1wJxjP4 N9uGO9VjbhXQCZkOxp+3pNNjnfpIuqiXoEjZ9h8RT9wtrcqimUY9oSwRSZLlUUw+/6aDyRu uClpLUY3uoHZNIWXURP/KEt5kknpQGI6inFU9Ke+ubovta2tmldZ/qB7C6IKm3HqfSz2bmY 88V01RCMn1HjLpdQjEbRg== X-UI-Out-Filterresults: notjunk:1;V03:K0:ju+sBgrS718=:uAYx12wbftYBBWGeEUZRy2 1zbIwYHsX4jjVZPsEwqGvdwWvfi2P61N4oijoOjpH56esHJm78HooI2nQPGEayFRZdrNtLNS4 2VsVfjxyo1GoyQoTRZebGgDDAV+V8cftXFpqsYxIUIAHHkIf0h6mU/lZRkvA3AROMry2+eHOr ts1Zx0kMSGKdb5wJJW6tP4Hk/Q9OGrTmdEwKRvGLTn7mxsXJHK+m1oOGLenVhN7KTH7xLmDBJ tQHU5c+Yk2zDwVtoNc3ORCliuwx2tnp0FlaXzXaiUz+DuIkoF252JLjbo+zsEhkc8C5u4XGGw +/UwZvlv72RCoGNOMcHTzn6mvIXi5CxkwgMhnNOxLnZAzRLEYjZ5USQyl7H9ZqsAB7wNrTf3V Oj4749uCrX92DhBbrwcrI1D2J3KMGqvlBHLgGhfYaNJ11izoJciqUO0AlI9lEOAKrWP2vcvEn NWgUArDOBmFsdC2LS6PDX+sphlp9QSODZtYXjgpdyDol4R6Xo+X18JgJKEJf+jgRX5QLJKEf+ N1lyxbumQQFw95VG28GrmSG87+AzUNL5Ir5XJYZ4Zu7rCOT/Ys1ijPJe+TIVQ8pflLEfc83Ti R1OSINs8U1uIuq/g448Z5Pdn5SPJMuuW0JB5nL1tC7lSnduQ4XTTlTMvh551m6jd3vM/i0gdx ZDru4bY7zhAn/aDsXLOjoJMPF6htcOO8lgQRtL3UKp1nmFXr04jFrXh0dJFOyTz3bulo3R0ai S77jfyx/Rh1plADhWFR3HrdCscr541GvWMk7O9FSs+VvVBAKHFc7umo/gwzNuVDNydAJELEeC 8w+FIwpFVaNO+qI4edfdW6EZWZxSWqxvePYEi7tZ3A6JXQGMB3DCWbcXPfTzNi7b2p/iBcJd3 6iwqYUTTdB6b9do/uqkNxGbJSoHevVq8AFie+RurumSUfjbnLaD2sDaNTacrfC25/n1ERFejA 9rEeq2LVS4io9H08DR16jdNlUWkUB3IbGxhfuFHi/h0ogl96k/bwgRBcfWENKmIFx3hcItVEK OKiCDwCPijhIiA6uJ/rLh8aNM2c9JvTwwRFfmGN0e3tkAQUe1yLB/UoUE9HphB7JaANtfaGRF gbKFaNpeKpOxwo= Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Armin Wolf Returning -ENOIOCTLCMD gives the callers a better hint of what went wrong and is the recommended behavior. Signed-off-by: Armin Wolf Acked-by: Pali Rohár --- drivers/hwmon/dell-smm-hwmon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c index b0c591bb761a..5f0338b4a717 100644 --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -516,7 +517,7 @@ i8k_ioctl_unlocked(struct file *fp, struct dell_smm_data *data, unsigned int cmd break; default: - return -EINVAL; + return -ENOIOCTLCMD; } if (val < 0) From patchwork Thu Oct 21 17:54:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 12575989 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D939C433EF for ; Thu, 21 Oct 2021 17:55:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2F57D61390 for ; Thu, 21 Oct 2021 17:55:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231842AbhJUR5j (ORCPT ); Thu, 21 Oct 2021 13:57:39 -0400 Received: from mout.gmx.net ([212.227.15.19]:48951 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231396AbhJUR5j (ORCPT ); Thu, 21 Oct 2021 13:57:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1634838906; bh=jac/CaH1YH563dghuUKBKgU49JQgYUdW3AaiDKqB3BE=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=YC8Md/+Cmf7JeZwdUmaFAuu6prMfTZPStzsuKnplmeHUTh+sVO8pZZn0dl3JxreF+ QVRN1OGm8M1o7CmBgBNxmPi1jG+v+iu0ZE7jonhayMn6C/9+zo9sl/8yItRURHN3w4 Z2Ydo6/zT6YSWcPw/+Fqi4tDbwSLAoLCD31P+UcY= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from esprimo-mx.fritz.box ([91.137.126.34]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mdeb5-1nCOvz1jWL-00Zhck; Thu, 21 Oct 2021 19:55:06 +0200 From: W_Armin@gmx.de To: pali@kernel.org Cc: linux@roeck-us.net, jdelvare@suse.com, linux-hwmon@vger.kernel.org Subject: [PATCH 4/5] hwmon: (dell-smm) Add Dell Inspiron 3505 config data Date: Thu, 21 Oct 2021 19:54:46 +0200 Message-Id: <20211021175447.5380-5-W_Armin@gmx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211021175447.5380-1-W_Armin@gmx.de> References: <20211021175447.5380-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:grIJCnfaEAPW6x6yE/+29DOLbdSau35UmyT35FVqv7XxI6UfMAh NwwI+uV1lCPn1dqQm0Jubj7HK1r3vxnl328MFbNNPyhhsDfpw+Nb4WGLqVK7zNNVg3NXSG8 prdL8iGfoqmhDHOEVHWUl9qeKSAtl9YKWbys53VYpJU4Fn00qswVlNLUkmPFF7skLCcMdiM GUngCKPcezJqxkXaWhnag== X-UI-Out-Filterresults: notjunk:1;V03:K0:+0/z56191hY=:SfcFrXGNWa7drJ6qpuGG80 tYmTDq2oJM2JwtgjJjxD45+bU77lkENrD25Fju3mSUIitbkID0AFaimHEFwdTjsNRCscgpgxP /X0Vv6ykrgCsTa6Kc+T6A/SQx8Kj0DJTqMGdcycXfAgORZ+ro8bLjAXJ0yTbnVKzhVZSv8sIN Sgsy/B4ZJjqHGrJ1g16bfjK0E1sII7/InF8dM/pU6JdeAjfVvNSSLlttOI+gSfafiSHoYw/r0 F/2xmrx8cWXnAGg7tQ8zuZTVuxvrSLdKKWi5/3AXO+MmH+ESlRRiqAOuNsVUtQr/dvRyfhbRZ H00SdmKD2mFioNVjyj1MQ1UOckxODAZZ4OHiob82bUqqzw7daprOXNmwwrzAP35baY+7BLS45 zpGx7Khwuihwp8wkjR0QHIIAJOq/Ll4B+79bh443ehwQnLYRweS9zLPrtsD/oqw2wbYc9iqdw m8y4qpkblLIGkASsJZeeKCvbnfaqBYQN3d7PSJRd/XgWuPXPNYlYabqBf3UztB0qgBXMnCBjZ iizQ+YxsHQoSn0nGpAWXeGGNiE3AvOlUu4kxJjN6g2lksSuZHiz5yH9FGg1RvQoGmN6lg+TK4 RtObfAtW4ROPe03GkHPQv6bKcSk8f3tBQdUjKw0cmzGjqcqRtGsp0BIMM89ioH8yKMyN4pWHT efbyfdgET9Gse6T2zGQXSGZgBM32mGeoWNeibqQet+YflDyyAzdvhGvmVs/nqbZlOQ9iDtcjT XQrsgTxEmMRUpuOOJS/mxxRTBigCIoQpey4RU9JwBdDJ1ssKjgkfealDreae6rLbuzhzb+wBK +D+kOwU/Rc9kdsMXyRQKouPhUiI+ZNLChlJoWso2Uco4/1EkNuzBeJOOZR7vcxsNk9dFd/VEv SIrHOO+4dePplMMon991twUQIvvqUZzmcY5u/4kO1XePF1B/IB+bPWJ/48MmTO39JckUuNKpk 8pFxZRtG9ldQeNdv66D/ExQ5X9upBTqEZwMHYE8NyGRwz1U6jFyLR0QCwAPZh0SMDXwfU8v3D PnxZQssgDpF8Yp+fcSlkjG26ilI1oPcVfPVUxJaDhPytkfiJP9RhyNrpMPEY07vgBsMdRTrs4 Peyh4hGM2P3T/0= Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Armin Wolf After checking the fan speeds reported with the Dell Diag UEFI ROM, its safe to permanently set fan_max to I8K_FAN_HIGH and fan_mult to 1 for the Dell Inspiron 3505. Tested on a Dell Inspiron 3505. Signed-off-by: Armin Wolf --- drivers/hwmon/dell-smm-hwmon.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) -- 2.20.1 diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c index 5f0338b4a717..2579dd646b20 100644 --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -990,6 +990,7 @@ struct i8k_config_data { }; enum i8k_configs { + DELL_INSPIRON_3505, DELL_LATITUDE_D520, DELL_PRECISION_490, DELL_STUDIO, @@ -997,6 +998,10 @@ enum i8k_configs { }; static const struct i8k_config_data i8k_config_data[] __initconst = { + [DELL_INSPIRON_3505] = { + .fan_mult = 1, + .fan_max = I8K_FAN_HIGH, + }, [DELL_LATITUDE_D520] = { .fan_mult = 1, .fan_max = I8K_FAN_TURBO, @@ -1030,6 +1035,14 @@ static const struct dmi_system_id i8k_dmi_table[] __initconst = { DMI_MATCH(DMI_PRODUCT_NAME, "Latitude"), }, }, + { + .ident = "Dell Inspiron 3505", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 3505"), + }, + .driver_data = (void *)&i8k_config_data[DELL_INSPIRON_3505], + }, { .ident = "Dell Inspiron 2", .matches = { From patchwork Thu Oct 21 17:54:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 12575991 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAFDBC433F5 for ; Thu, 21 Oct 2021 17:55:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B44326162E for ; Thu, 21 Oct 2021 17:55:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232233AbhJUR5l (ORCPT ); Thu, 21 Oct 2021 13:57:41 -0400 Received: from mout.gmx.net ([212.227.15.19]:37651 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231396AbhJUR5k (ORCPT ); Thu, 21 Oct 2021 13:57:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1634838908; bh=bQMi+iQQSOVtfNjpKLoDLJ8+wtqyYr+u8eOCiOUw4aY=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=BGM6ByIlx5shm1ECumrSNZGESmpgQ9hEEHiZ25xolZpe3GVmQtj6wcg1Qqeuu55Ws d3iUhTtSlSrvVlwkAeL217bRsBYQ8NAD3FRa+kXhs1uZgATMcHcfmrgaBRgl0xsTIR GgWgFnvE9CNfvMzC5oTBtDfVeBSouea0XaL0nLA0= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from esprimo-mx.fritz.box ([91.137.126.34]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N79uI-1mlE3c0gcW-017Xxv; Thu, 21 Oct 2021 19:55:08 +0200 From: W_Armin@gmx.de To: pali@kernel.org Cc: linux@roeck-us.net, jdelvare@suse.com, linux-hwmon@vger.kernel.org Subject: [PATCH 5/5] hwmon: (dell-smm) Speed up setting of fan speed Date: Thu, 21 Oct 2021 19:54:47 +0200 Message-Id: <20211021175447.5380-6-W_Armin@gmx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211021175447.5380-1-W_Armin@gmx.de> References: <20211021175447.5380-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:UpFGIFkgSRWhufFW5C71gxkqyDTwtsTKkv9C4Tlen1z2UsshucX 7gon8Wkf6tQnm5POJDR2E/tWQGHgvQ/ttfMjekuhDjMs8gr8bF344MvD9K7T2O4n4RSzcDZ mm7TaQ4YeOVTWN4vzmllrXcKjawPhZyS2/c+uPCt1FD2FC3KSmqgXUsDekFZQNxQiam/D9q 5JS61NT83P8FDPKTpkR2g== X-UI-Out-Filterresults: notjunk:1;V03:K0:udeRE6jYRFs=:/Ooct4w3i2g0FWjmngCmTd 72dy4RSy2Yu46z8Xv4EZs0d4imLLDLJL4UohRUDqmKjoAc5vu23OmnZlkJHhvsfNhthFTB/4X r/qDP2lpoDvyT5CO3D+qJ8iullUCvXzuIXmc8cbzBeip6ncP4z9JBknqC6dH9kyqK2ix0PTVZ 2qWNMGixhQsw4/e7NA/B0Y41AFySIXf0rVfxf9Q4/u/KIhub+urXQ93jhSoOkzA/iDkwciX/a Zz3zPZ7m5YMfmlRAMd0dSaxwQL7DAxv0Z5olDvYBvZyAK8kSqDcGeSMGR5xsgyPLU03xIAy4l BdPhX9OxDqryyOed0l8IOAwAL6KCjc2HR8lK1t8u1HSZtgBPbPpqageoKHZspwCXoJ2Uh5NrN KwU5dH54OLpKbsnPGgxy2aAG7MpKQQemF36u/Dc/adgj9MVuDzhFJrU9YyHzxCtZ7RzYwVUgV ye8EMes9rpvlahaexztV4pGL6KTxUjwf6oZ844zKquK2PowjYTloIyzWTaPllNAXoDBQl0+d8 VVg+DjQEAxYkR/RpoQ+YQeLd3xDoj+PLsJFYG26MpiM/fSiU3Pd3k4b4atdFifUY+WwU5NmvR lq0vY1qcnYblivaRpFIA53v+uvw6R3/9HSP5qdPEcJrt6oTwzgRB1xsB5MuYIyNwT6MioUuS0 CupSW8QZ85PIiR2VYW2fI8UtvGYKimdwFtLcT88iFi7k1NRvk/EOzEs3QOP7yjInbtqJAv1xJ P1GAGdc2BGQDUCi35bM5ioFKQ7t1fZCRXMP59tA3NLLltMQPHZ1K2fKTDg79IodTEnkWxhV5+ a/y38ylhUsnxVCDq5yBESaMbv9XDzae3hZeiFKqIba+wHHxTyCPtRWj9tk2g1XvdZfkP80s4j ZSjlHo5x/HaZsqQfEkxaDPsL0QMYyJOYxNHJd3vt4RQBftXbbd0z3DyPx9oIMWCMQHJXT57xF +Qa9EAmQpCsi27gCCKkSmYREr45TVVraBfu24JqgbEG++bA6yENJKnFaaGd8UrL1Nn2tI5JDE LDFB6yoPFswUQDotOljnvwxhQ/I581zFtgd+SF5goTIrzhZRUUJiibmabTMvHo/YtaCm0FC2g PSv0acOBLcvdC4= Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Armin Wolf When setting the fan speed, i8k_set_fan() calls i8k_get_fan_status(), causing an unnecessary smm call which can be very slow while also making error handling difficult. Fix that by removing the function call from i8k_set_fan() and call it separately when needed. Tested on a Dell Inspiron 3505. Signed-off-by: Armin Wolf Reviewed-by: Pali Rohár --- drivers/hwmon/dell-smm-hwmon.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) -- 2.20.1 diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c index 2579dd646b20..62f087f67925 100644 --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -327,7 +327,7 @@ static int i8k_enable_fan_auto_mode(const struct dell_smm_data *data, bool enabl } /* - * Set the fan speed (off, low, high). Returns the new fan status. + * Set the fan speed (off, low, high, ...). */ static int i8k_set_fan(const struct dell_smm_data *data, int fan, int speed) { @@ -339,7 +339,7 @@ static int i8k_set_fan(const struct dell_smm_data *data, int fan, int speed) speed = (speed < 0) ? 0 : ((speed > data->i8k_fan_max) ? data->i8k_fan_max : speed); regs.ebx = (fan & 0xff) | (speed << 8); - return i8k_smm(®s) ? : i8k_get_fan_status(data, fan); + return i8k_smm(®s); } static int __init i8k_get_temp_type(int sensor) @@ -453,7 +453,7 @@ static int i8k_ioctl_unlocked(struct file *fp, struct dell_smm_data *data, unsigned int cmd, unsigned long arg) { int val = 0; - int speed; + int speed, err; unsigned char buff[16]; int __user *argp = (int __user *)arg; @@ -513,7 +513,11 @@ i8k_ioctl_unlocked(struct file *fp, struct dell_smm_data *data, unsigned int cmd if (copy_from_user(&speed, argp + 1, sizeof(int))) return -EFAULT; - val = i8k_set_fan(data, val, speed); + err = i8k_set_fan(data, val, speed); + if (err < 0) + return err; + + val = i8k_get_fan_status(data, val); break; default: