From patchwork Thu Oct 21 19:05:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 12576281 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 995F3C433FE for ; Thu, 21 Oct 2021 19:05:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 789FD60FE8 for ; Thu, 21 Oct 2021 19:05:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230103AbhJUTIL (ORCPT ); Thu, 21 Oct 2021 15:08:11 -0400 Received: from mout.gmx.net ([212.227.15.15]:52123 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230441AbhJUTIK (ORCPT ); Thu, 21 Oct 2021 15:08:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1634843137; bh=xh+0y61AKC9kcs7CHjSiGAI/3dEEHsF36lazThS7Ybw=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=Mgw4Ew1oeet2nsZl7t7nwylVQaSl3eKr8zj5MpyOd5JMrP9KXEdKsH93SulAPpDYe 5q95zTOCTQ77SxcX14qBNawwWQQZcRm1XtaJFE6O8F0Umo8wBsFJIFM8x0FU2XuaqE z290KbGYqt5zVHV4A3WsEOHFYRJffNyV1B8z9ZS4= 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 1MxUs7-1msfKi0ioD-00xsYE; Thu, 21 Oct 2021 21:05:37 +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 v2 1/5] hwmon: (dell-smm) Sort includes in alphabetical order Date: Thu, 21 Oct 2021 21:05:27 +0200 Message-Id: <20211021190531.17379-2-W_Armin@gmx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211021190531.17379-1-W_Armin@gmx.de> References: <20211021190531.17379-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:UsOdVn3T3TPbLPwlVDk0HFtlC5Xh11gujslhrInQZzM3ALWTwB1 ZDCbOjDkWgPDpmsJj/OQP0YqO+t+/yO8cagThKw9+nO4quI7hR84xUhMyrBdTSviBAMigpj MQy/QOERm1bkQZYmV2w17EeqxdLpWR8aIees+vd4jHI4vLS5gcUcPULfC67ylsl+OsT+lw2 srbXNwcU4VE5mpbK/pJPQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:uo9HmMpKil0=:0qG1iugsn5t9QsLgouKzTg 3wyeJevkSNHwxmvqBY0JSI85zEKYvzRBr/brB7w9Sxomd+0CLQrvja7pvt0/GEV1/MvdBbjO4 mZPVIhl+NPe7DbdY1pB13EiaqadGeFA+pM6LY+oBC+sMqKdmZxAaeV2Hrmp2lO/8OpVM1tptP pDaPTflB89MPWyrGsnFWffI67NtVzUG/Vjuu2T4yr3/kTLQ9/SLTfkbHBAxOhlswJKwtAyUXC tCq1zys+Y2MIr5kTrSZbfF+CPfpnZSQvALExpfNNjUe3Fm75izjK8NL4bBUJ2Y9B+9coDZgKI +yZ/BoFIPDsWNZ06v4YA1FiXJX65GOTj0iaGjqubkbRKe49uNCdUysKDxM5RP+ZS7v8JtfP3+ uEodti0RptkBbUUfcNQF1w5YiBYdmpkpMyxpxONHojc841tp11k5qUvIu7Tgv51spPqUeC+/T xv+pjYq+RduBn2QmhqSmrBz09P9u8ULlodZpTFJ80uwbWo8o+Rxf80QSme9+FC0Y3E5rwU7gk GP1lZQbO7My4/hg9TINCoMvVdPUYC2QnRN8ZRirh1VkhSECGfMrD0kisBiXIdWv/eCKBwDMNE /ZPiArvwVMxFutlogHGT05+sMkiuElTPPAGYyty+mfIXcTmw9cwxdriPKlU1Cu8Ouc5uyPEcm d1dr7XAmy4GqbBRead0EETE4uD7qqMJnzVGl71hih3UVtQbwVc11GzrJiJcHs3FpW0UkST9lW egb9ZFOtD2uonM8MKrZMGlM4Pp6WhRmii6AqP2WNx9vX0PDfsVWtpsQOKWNtlTtEQ7CiHmIfL 9Ou4OSqlEV6zXu3ecK4H0vvhNJ7NSVq5p93bV2N/xZ/H5lI/AqxLb6qOwUqNuxEWfCWnE7K41 MPKH4IWupTp0B9PLEAcGeg1jauVJooa0ziCQsDWOTbyI6vmK9h4z5jjHCdalgwh6eAlXQ7so4 QoCi/lP/JcaGUUf3WveWKsmQETJ4/e8KnO7VQZxiyfTNYWTOvcr4YK4ApT2dHtembREq5uW6K a7T+NWwlgY39cn+NGeLfBB70MNStOWHUd97T4ajsH2LLcjR0BeZLTJO1PvUYOgxk27PKm4vBA D9wsUbPfJN4m/w= 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 19:05:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 12576283 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 6F89EC433F5 for ; Thu, 21 Oct 2021 19:05:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5215560FE8 for ; Thu, 21 Oct 2021 19:05:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230441AbhJUTIL (ORCPT ); Thu, 21 Oct 2021 15:08:11 -0400 Received: from mout.gmx.net ([212.227.15.18]:47895 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230267AbhJUTIL (ORCPT ); Thu, 21 Oct 2021 15:08:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1634843138; bh=i1FCDvf0fe36+3EFlTapIEjo0Psx4IWGt4yQRHZqTtE=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=l1LqKjc4SxpIMqskjt9A7TlGCoz1hpUM187rTPDJNySvL0oEkRGFheo9ZvnS+x0Sz aD7XhZBt4qD+kGWtzn9L9O6PXNesvgOmTyBDuVXZ5bd62/GIexGR+G7C5VAqey8xLf B/p7RTCzYm4mh/L7m3TyvqwRoMGIUNqvtxZ1bQ24= 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 1M6llE-1md3pE1AGU-008FtF; Thu, 21 Oct 2021 21:05:38 +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 v2 2/5] hwmon: (dell-smm) Use strscpy_pad() Date: Thu, 21 Oct 2021 21:05:28 +0200 Message-Id: <20211021190531.17379-3-W_Armin@gmx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211021190531.17379-1-W_Armin@gmx.de> References: <20211021190531.17379-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:gHwMulcEyDqyJAklZHX6FevazPDs/H3cYzRMYb+1ssN1V81cVpt 37alIFdoR5or0paHc9U5Zh3R6c+3GEI8v7NkJaXtcMa7Kcpmoa1GLjSjk9uxzZqZ1vlUwl2 pxDtMrG5mY/Hp3OeETH1+cStTzEeqdlXR1nhh/UlW6nGUOYL4XSOHYv7Myxhk2D6/hOqcPM DSQekjQMJCgJ9K7tLePXg== X-UI-Out-Filterresults: notjunk:1;V03:K0:x6uJs92nP3I=:5FdFISdoyGVtnqpqshfw+8 wPJhGyzoDbWusdtuAshxhAosvI3ieTxRJIxB2i1DXBF3LUnoOyYadJELVRlLeLL56/Y6wBHM/ QC0vjwyQm/Lf6QpWaSqZkol76K1w8rq1Ad+iPQdGe9bE0zYfEGA9guxVxeBCTzF3mG6qFELiE ZfJByaXId36TpQ1mgtpIkqLm9H98UiCSX4IqAR0EsxdQjbxU/Cpv+CVcPzVeQZySMibkNlqCs zeA/BhgjKhVpbjdoAcWAd+Gg1UhalO3oEtwWMk9ZKUoVr7gk25gFa5+6yEjr9v5rxz9py2TLo dAmTI9iZRK/1wVMmNBwm0Qygt1moWmDuwSIyU9RRXXWB5qpveiFWpcVoCqw+fAW7cQoWL5M6H gixy0aizV1WaYSSnIECLx0CsC7LlvnOTnY85i2GBlXn6y04eKmbpn+zMWJgHtPh2jhCWyMOZw zCP0mICHDa1DdY4ET+xT+kRp+z2d5s4LrXZ5Y83mistGhFoflY4AEmH4qAt5N7BbXbWhxjrDh I6esKarUcPLQiltzloJOKaErSz5ew7H4GJTC/bXe0iMP70l3RXFTIfkDLemT3cO3JFBLKWbSf aPgm7gfJPbAZOC/OuuVz0Whc0BmxRf7jsrZfbEOEFU1ZCpRjr0KaMi5wtbOJtEmEOQhS+VMdl 0ymQ6vvRRhD1WjaCgPkJWn+aTelU+gdiox42Bz5VpLIsSIJKAjnAR6/NCj5eQiyayNvJLN2l6 hpSRpNQeSBQZUWAhjb7VI8JzPz5McUzuK6J0AB3YixIDvOUQftIjBnmSq63GdjpxBuI4RTGQE eHFU1eo2kzK3N8wMvjsQFzIfzZxj24nWbBSPrEk7JeRRHQbVioG4gNoscE9oxpf4OE93VCKQ0 cASLAafdj7twnyXqR29MksQB77UTfdX19dlfCxI+STdx5MJN0QoahmQ7KVqXhrv0t5ZyyUsyq vfWXO8mywX84zVXGATDuZLd1G+SJm8JqjDZvPaELJ27Yg5XBzEkVtidhaTUOMe5SvgyFt8dsp X9n499u1IVM0wwSXYlYm5Kq/+teEM/NEiMm6otDmrjchbjZg1a20Gug1nY9QrAW3gP+Ro6G6t 5N2khn31F4j1I4= 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 19:05:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 12576285 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 0FE6BC433EF for ; Thu, 21 Oct 2021 19:05:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ED8A060FE8 for ; Thu, 21 Oct 2021 19:05:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230267AbhJUTIM (ORCPT ); Thu, 21 Oct 2021 15:08:12 -0400 Received: from mout.gmx.net ([212.227.15.18]:57711 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230434AbhJUTIL (ORCPT ); Thu, 21 Oct 2021 15:08:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1634843139; bh=15joEZi4zx54NaKUF79r6g74phLxBhOZUBAyv6HLWEY=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=a4v3DVt5/eNiu8M3+GjxGgicIxYACgS9xmVdrZsfKrzuv8CicoWwhQeBSaKwxmWye +qLVgzYi6j6FHuv7HMluc2CfmhbNbW8XK/1CM+to7UB0mgTTJjvZD5II90G/vT0eGK eIJozgB7PydZzVskIVRnmaDdogLnMG/oBM4j2nBA= 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 1MyKDe-1mu2mN1RQi-00yiG3; Thu, 21 Oct 2021 21:05:39 +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 v2 3/5] hwmon: (dell-smm) Return -ENOIOCTLCMD instead of -EINVAL Date: Thu, 21 Oct 2021 21:05:29 +0200 Message-Id: <20211021190531.17379-4-W_Armin@gmx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211021190531.17379-1-W_Armin@gmx.de> References: <20211021190531.17379-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:SN85eiwjMPxvU4fczpagxkaa8OhCMURHu0NmRPekpxdlOuT4kFU kVOegNxxLsC3X3GoF87ARz/QpIjTfEwA9JzoDyhHsbClvL/P3xoAXeelIuJvXA/uD3wElUb gWyFGwzDBrA4AZSIF87U1xJLIf5MhGBiZLF51feGXzXSu0LkC0A5RblOqVcfrvpUhEAsS7l wQvriE8/E4IuanDybbkUA== X-UI-Out-Filterresults: notjunk:1;V03:K0:WLZ/GOwTdEI=:uK9Y6rwDDPc8NuP8uTRzKn kzfvwiz9j0O3CIJb/0dv937hT0J9+bCq6zme828FE5bhY+nNsPvlS/+osUB9ZSC86inemrp29 Q5JH/gkoyj+CiY+x0pmGxZakQipEJ50Hu8wf+VJeVtzjoDdr3XEku/4KfFJYDh0/c4X6Erh8p mGcIJqVxk1djz5fpsRstj5aOlUJ09hVo2U1ZiE+Ej7b6KoR2LMToa1JY4Grhf+mHLnwWkbELR EE2q2Ey6avSAqMVRu6E6Y+7lbc6zdjwaGv1+MLXdnTXaNAWSMxy16YokB28VHyebTOdu+eHjf jTTkHpZNKs4drkiiLPmdMEmzXe52QEx50j/FwYw94Rmd+KX/XA2LRc/hFmXNMp5MGH0ZqrXY6 M5u3J58TEOei89bkBwy/26yf/ybPEKVVrNbeQ2VSznqT6S7QIIMkCBHm3j9SabIY6Kx1ogjvO jdWgZSM55PLIc2ZDtHG34I3+vkr5L49sSkQ5+pl3t9ENTJf3XE6c/EuhBelC4od+fGw/TrvMh txJvt30X8VFTMTX5lzIiTZANnQ801QSbKEz2V6QIoqfA19QX4qwiNQ7RGk/fMUW/RaylHH/56 CqeJ+FoJm9ZUPffDJ/Py2ZA59tVr1RTQAoF2CsKauzF5felbRmLRsKDwYSOGWwzhb6fsY3w3K XDZzjbt7x1NwqKxEyFFCIFTqZLAxqX0spi/Ds0s+RJ8I8YzAsfzMyt8zN6eiCtAf8kX1Jl5tF sY2jRB3aSsHjOVm8iNwDHtIrDcHnhoOhIsMhqz5Ef9NfyEGaXPO3ZC5yBldDL+UjC7kiAxG/g 6ClytLwhpTpv6O3CdCmYLtv+tCXxS77F5W4h7iLquSj9oBD7QuoxhWFCLeqGY5pnHgf98kFo2 Z7TAL/UoE+V/n/T4W1ihoSUkSLpJ+k/N1Etjsbocq3Dwe8fqSJlDYGnBzRqhaJy5X5U8/Nujj VTlHUI0DGMY91y6qun+hsrWCI7895rXds19X+pL5HJ0xSABaYjaLk5bKgnoZkcS7x0zaL5MKl 654HCknZQXtKGP4y552z6htksGsNfw3HtTTN21Jc0yx5N91QM/0qQ0hWySWYHd6IdGI/K5hna oGtxf7DAUHllLQ= 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 19:05:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 12576287 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 68FF0C433F5 for ; Thu, 21 Oct 2021 19:05:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5450B60FE8 for ; Thu, 21 Oct 2021 19:05:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231336AbhJUTIP (ORCPT ); Thu, 21 Oct 2021 15:08:15 -0400 Received: from mout.gmx.net ([212.227.15.18]:41815 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230434AbhJUTIO (ORCPT ); Thu, 21 Oct 2021 15:08:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1634843142; bh=X2Z7JBMRebfJyZk9XZ+QOd/fBckyw9ZXpHUlRUiLvCg=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=UFDnTHapNrMTp3IgU41eU0tunhF//OU2igPuZY5M9jOihKHiEPy4sjoyClShTT2U4 fuAohnOz/lOzRokCHs2JKSIaHBQnqtA1Rb/KAaZVZ7oeTJW31Ylib36+nClYEolgPn OqN+y44ApWdpwAFKCmW/rqGnmiOPowqV0y3lnKvM= 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 1MxUnz-1msfKm3g1B-00xowb; Thu, 21 Oct 2021 21:05:41 +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 v2 4/5] hwmon: (dell-smm) Add comment explaining usage of i8k_config_data[] Date: Thu, 21 Oct 2021 21:05:30 +0200 Message-Id: <20211021190531.17379-5-W_Armin@gmx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211021190531.17379-1-W_Armin@gmx.de> References: <20211021190531.17379-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:ficeM1naa/9cH27nSjykQEVJeLf75Nu96jIy1MX0ZusD0wEp2Xz e0yBm6ZLS+52QVArBGD+fh1dHcdgRXA9ZykS5UYwHHDnUHxvkTyCxC36/QU/+0Tc3tp/rlm r5iMpx+EqUfrKW0tEoM09Epa9mSWm6McxQ351zyibr2A/oIEQeCxetlXepyB86hzt6FR+Tj w0nQgk/mkAHlVWq2g/P5A== X-UI-Out-Filterresults: notjunk:1;V03:K0:E8DeV3m7p1Y=:y8kAXYHOyQUeGESWciDJdi NrXjSdjAnz8DkmHA2LfcaNR8o2DRkvPNBeganF0zq7+7ybeeAMlEQuzMH8OFCNFjQ2qWBwI/A 0sWOPfmym7cZfOvI3KiaW5ldBqOuLSj66oc7GWTyBroqxE4bzikQltZHzjomDlv2W/I60UaU6 3ymrTwJA/VkAxIo54lCjAFGqpWZNEYf1JX1mTqR1gb6ICsxq00aMx6WC/SAaSt45YclB2/wz4 hJSmzkfu3U8afudWulPtXIzq5bKBgs2PNlhY4I891q6sgF5qSmNFCJWCJxYVzlb2wyWoN8YOL 610rfB5UbPrDrb/hREklvbDL1b4Do9XbWTJYy6n9sZPCPVRmV5bo5MhYog8QdYHOp496WMckp yZk3yP1YX53VgZ1MLDuRdovI/wBtCPHAFeMV0FfZMbH/iam4p77JLO8JUxjEddAY5+kF2ixP4 kQ8vnfB6P5XAiEfatbkRyGecXw+pRNWtBnKT5syxVGZJtgG39sk4bGkZ0yls5lN/Sckz1w0em dxyVtFopzkUGEcqKd7wx5JRUsOeQ5tTKjQHEAQJPahzvJZpSIlYNLlP0Stcen49bLaJROXhTK l6XMfkVI3zdxtI6QOWySrxWNu+0rHqWMcqO/9gndpldrUboKE25cQsbjs3unB5rIYSfdiTO+T IbWNtk8Kd3dwExGiq1kRxPBbi5EiYKvLUgexc+EqfaMnVqhW+0Pe4PPMjY+/eW0KZGWictlZ4 Pwmqza/wGC3YAXCv+2QFJ9F/t5+wLUTEYOLZlDaIJ2bMmyXQFidxMss6WkFGmZXR1tHbg9/Rp PWWInT8Oy+Uvzca8ZQDJL8vYj1TKSe4BwupyYdjoApgi5MsHxt8TB7Jc06XB48vbg1VMb1Lli +CNzGl5k7XacBaWoycgREbFZBkrwFzEdSFowSyKiAWLlOERRlcMs0k5c+fSu4TeCCaXgQNafF O60m5xA8LXlw2jU35VrxLGJwBi0clEK3c/mFC6Getxdr5CThFqz0+1/RIdMCUXwmjQoLlcKAF gsqqjmAxftyv9b6mYr01N39gD3gwHBPUp9As2kpNxJ1is3uz/fhW5RrL8xVaRj0sdrReYsVsH hJZM4A8/WN1fvY= Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Armin Wolf i8k_config_data[] should only be used for applying device specific quirks in case autoconfig does not work properly on certain devices. Signed-off-by: Armin Wolf Reviewed-by: Pali Rohár --- drivers/hwmon/dell-smm-hwmon.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.20.1 diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c index 5f0338b4a717..0e1bc3a2dd12 100644 --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -996,6 +996,11 @@ enum i8k_configs { DELL_XPS, }; +/* + * Only use for machines which need some special configuration + * in order to work correctly (e.g. if autoconfig fails on this machines). + */ + static const struct i8k_config_data i8k_config_data[] __initconst = { [DELL_LATITUDE_D520] = { .fan_mult = 1, From patchwork Thu Oct 21 19:05:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 12576289 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 B2EC8C433EF for ; Thu, 21 Oct 2021 19:06:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9603660F46 for ; Thu, 21 Oct 2021 19:06:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231443AbhJUTIQ (ORCPT ); Thu, 21 Oct 2021 15:08:16 -0400 Received: from mout.gmx.net ([212.227.15.19]:59137 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230434AbhJUTIP (ORCPT ); Thu, 21 Oct 2021 15:08:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1634843143; bh=sJgIsGCg68NznbWZGkvDnYMEcCSo6xcAKIRHglZPoOE=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=EUotikqfZ9FPTjE7VHUBholKEbKNiC0Nx7UZ9YnGIIa07AC1P+iX77NQfOe3dmjNK NPpA5nWkJWSonEou132cQUSE0CLZZdg+yMeGDICWL/FSTD8WPZK9c7odEv+HHyGqRh admoweifiIFd2ti1moqA5tdc/sPqipZ25qFfd9s0= 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 1M42jK-1mddNn0VdI-0001MV; Thu, 21 Oct 2021 21:05:43 +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 v2 5/5] hwmon: (dell-smm) Speed up setting of fan speed Date: Thu, 21 Oct 2021 21:05:31 +0200 Message-Id: <20211021190531.17379-6-W_Armin@gmx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211021190531.17379-1-W_Armin@gmx.de> References: <20211021190531.17379-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:PzAkWWd6AC/fbiCi7/aXLYn+7ujC0uhqrUZY6cZAf5t6NEcpSZN VJ9PEcUDGn/JvTivBbZ1fg+s8397Ghh21l67bp0fUwE5x0A+f2+ffEb8ZZrYRJy2QkWFxYq EqzRbiTSAaKwAZlbV3KVewO/G9ImMNH6HBZr4LwoRhZG137BYSuEZnpMJvUmu8qLX6Up5ju wb6ONKB6fKfgwvK5vbX4w== X-UI-Out-Filterresults: notjunk:1;V03:K0:hVLMMlLvI6Y=:+FvDvqvmYS/6bvJUxBeRY3 SyLBDlteksJDDfHaLipaTmTWfA1P27Y+iltfQPNUFWCC54hXZNdhE0HdSD+NWdBOplu9xTZvG kaDHkwD9cneuhNcr2fU0wAkoreHmpB/aPZzDlSAtZ58xUC9QT2VPimLyc7k6YS+JTUS9Pi0oy V40iet/nH7+xwiYSUBbqSYEJrsfpywFmfUxBgwyJGou6HkCylvWOVNB45AIs97pvo9RS/gpfO PdUjBkpVVIt9unDULY2K7Tt1CuU1f7WPY24+dXym1jtEjhiNwUkVS2nvlcF/czAcNoqt3l1O+ YfKZTTtR1kaiX4g8JNluCKwmjLIkA6Zd8eWKmdJd0vUuoX6KqD6ML1f15KBunY0pBtLYiDVnK Sg+tl7k65ETRqkXu3uZqotNylt5X8SpLVqWBjI9s8Xf8VXeAXGVwtUQ9aOhmC480BqH4keR7f Y5MwtgbssOSH90NnJvlzhy8Zvln2+5KK83h2Y5llST6ctCq/3KlWM8l+rkAk3110QayPfXOK3 CVgQ2m82NMkcTAqd4Ecm3tey19oYFCzFjNT5mx5zTpFLL/HczERWxwkdSi5MnUHfYEouLNejm UVHXl4uNLcsWfjQ3/dx47pgVvwCdycLw6IlmLhv2aE6Wk2PDE2vDbFq+c6Rw+DSSCdbbCrg+J UQkc89bY+ryl2izP9fQDa6r6Kzr4eurCCwTzVG1U7M4l49/9RU/q2NRDNiW7n85uLHcVimxaG jPIPUjkF67SuEKd2pPMRiXoiHz8by7rk32my7J1vhPNAG6lu2hqz6KduBnRe0exzlpCRRNdoX bKf00eHfQXepiVAIhVMG9iihUxUsQ96GerSj62HpDxURSMaFfXDm1drqY6bK+WafO7YQV6KmP aQV1w0Aa9cVnU0jLRJDIS06gVY0kT1G9gLykW6IqVEx29Ny8iaPvd5RPOsJrnH8LBNARybgEv rysmtlCVixd/FI82ibGw+q4wXwLC3xeef4t7yQharYtZ0PK5nQn6h8lDAqY6wPw/Oh9E35Zau fgzj1dK7Sf/535hwmJ0hKlN7rgFobsM/e8lIn6MWx9gGVCCeIdFEoQ2cO8SnuQoYJz24KDFfC FVwIumtaAPqolA= 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 since from the two users of this function, only i8k_ioctl_unlocked() needs to know the new fan status while dell_smm_write() ignores the new fan status. Since SMM calls can be very slow while also making error reporting difficult for dell_smm_write(), remove the function call from i8k_set_fan() and call it separately in i8k_ioctl_unlocked(). 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 0e1bc3a2dd12..eaace478f508 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: