From patchwork Fri May 28 17:37:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 12287315 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B437DC47087 for ; Fri, 28 May 2021 17:37:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 91D59613F0 for ; Fri, 28 May 2021 17:37:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229450AbhE1RjS (ORCPT ); Fri, 28 May 2021 13:39:18 -0400 Received: from mout.gmx.net ([212.227.17.21]:48527 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbhE1RjR (ORCPT ); Fri, 28 May 2021 13:39:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1622223446; bh=9ioOuZHrB615DINpZx/84r2gsWltQRh6q331stYqAwI=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=JwjAjrdE5TbgGJHZQk2LQYFEljmUnNH85C7kNxgqvEJM45YwwpTcadzO12Ud8t4KS nNL7z6xNDgbiuipxEDFdeDYxJf++J58DHrRYDuVXMRo0RtoluDlg1zZ3P1WShywaPr /m2RIyTDOB39LF7DGIqlQ5x9F7NR7pvpzsZEIQwk= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from esprimo-mx.fritz.box ([79.242.180.99]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MnJlc-1l5tUg2RLo-00jIBh; Fri, 28 May 2021 19:37:26 +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/6] hwmon: (dell-smm-hwmon) Use platform device Date: Fri, 28 May 2021 19:37:11 +0200 Message-Id: <20210528173716.10975-2-W_Armin@gmx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210528173716.10975-1-W_Armin@gmx.de> References: <20210528173716.10975-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:O/40oL73SdctKgwtTTXJ5N4p+v9Bv4nAB0yd+fj2N+597308Gu8 ym/8xfE0vR0nAU2DfO+mWAUgHLH9AngxxIqFu4Kw8YM9PoJjaNshUHSVNV1JxttdKZ8KDD0 Fi4yu3MuMfkq3D9OlSdtBiUPtEexwe4iQd/NB2miKUZajVSsp4Xn6hXo1ClPSkCtPgE609A ZkWTU5aHIvrRhK1sEw85w== X-UI-Out-Filterresults: notjunk:1;V03:K0:978+MGNXm7E=:q4N0BpKY91/5SgZh+iyVkA GMyfnUpsK29vtabx17wUn9MSOA8SW9ItQFbJYrdQwcS2ngSwGbd4frkOaWqOgbMBg64l7KDNa bP3ZTVz3J1RFw9pmazGWzJfW2oY+tg9+Sxe76KXcaXLmCnape4T9zQ8GdBGVE2VY3F1JFtgw4 ruRjxHtdoZfMoEsB4gTGvEEYwz7eI0kxvZ3+eNnxoFRLGWalXq08Y1kd6iFKByZGiTrynsXRB DFkDKCxJ29DxNZ6Wr4t98TPRKWebYUGF7wiXQ8RcQMHjKrxqTRTyKgqVF19Ly4xhdFWgK2rql 22n1Cv03ys4tM9DZf37QEwkj9UdB9/lHj9BKzehjCrA+oRbc0r5/ppn3do22FPVUueXF5G1HR 28SHsWr12wFVCthSFJdgMW4HprkCaSxRdQe5suPD7WAZBe9w9J7LHcfi3MB2Cbld35fEroZOy lG9DBX1iOk80TZv+GSyLo0D3axq9fpwalkICzNesJ+YubUdGzervxPueJ032mwRhcby1JiQe5 INacKCxPa8A152+YLNouHlH8hMJHTJlkit7yxAPQqP59VN5IW5laV02pV4ngh2BE53z1muoq8 Lf6mUfKXMhMD3rRUJKM3U2/M+ugdIOnIB05wis/YBInLjw6eseL1+bQ+9WsQFT4gIusWY0b7p MpPuWkzGSSmqv/ZPt7wfpvXmb+GMKhonTflaAG7ud60x73gL3dQpxCGhuc+JdD/go4YUaEo5O IwnUFmPotOSqkTuLDshsw+VMjW70IjhPm9rJ1HB7qSJopkKaXJXO8ousyEkjYpkbF3H/+eCfF HFp3iElrzjdxkkrnlbnTLMURv6Ud/9+j/4g8lPUhUGwB1CdEPtXrO602vbSs6iDSSvAqHiJF5 2ITtG8Wse9Z8TDuIt1YOiZOE92mL8QISUpIjxsl32IMi5pzMi7tBJJju/KvUQITOiZXOvCpp8 92FfiSmEv4dt0+odvhUkI461e2b5Kct4uKdgwGDngvU6K0QNbkr/k5NwrqsYicCQyye+to4xW EmVzHhwDonDIwk1h05Hcn0Vs1FX3eTSrsud8RstHkYE251KsXFVMTgRJ9nvk0YLaUfw/8iLom ma294I9xVZY2oZQKCH0Rn3NyL+i1+ajYhhAGnYKdN4n60HgIkSngrbLPcXthdv1kxkfk+PGaa ka2YSOpj+f1vUjnNo593rJTdm5RhfOHnmypFw6A9pJu4KY0/zK4onjTwCTJWxfKat7qGs= Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Armin Wolf Register a platform device for usage with devm_hwmon_device_register_with_groups. Also the platform device is necessary for future changes. Signed-off-by: Armin Wolf --- drivers/hwmon/dell-smm-hwmon.c | 115 ++++++++++++++++++--------------- 1 file changed, 63 insertions(+), 52 deletions(-) -- 2.20.1 diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c index f2221ca0aa7b..2038f2a50e11 100644 --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -14,7 +14,9 @@ #include #include +#include #include +#include #include #include #include @@ -896,7 +898,7 @@ static const struct attribute_group i8k_group = { }; __ATTRIBUTE_GROUPS(i8k); -static int __init i8k_init_hwmon(void) +static int __init dell_smm_init_hwmon(struct device *dev) { int err; @@ -956,15 +958,9 @@ static int __init i8k_init_hwmon(void) if (err >= 0) i8k_hwmon_flags |= I8K_HWMON_HAVE_FAN3; - i8k_hwmon_dev = hwmon_device_register_with_groups(NULL, "dell_smm", - NULL, i8k_groups); - if (IS_ERR(i8k_hwmon_dev)) { - err = PTR_ERR(i8k_hwmon_dev); - i8k_hwmon_dev = NULL; - pr_err("hwmon registration failed (%d)\n", err); - return err; - } - return 0; + i8k_hwmon_dev = devm_hwmon_device_register_with_groups(dev, "dell_smm", NULL, i8k_groups); + + return PTR_ERR_OR_ZERO(i8k_hwmon_dev); } struct i8k_config_data { @@ -1221,28 +1217,11 @@ static struct dmi_system_id i8k_whitelist_fan_control[] __initdata = { { } }; -/* - * Probe for the presence of a supported laptop. - */ -static int __init i8k_probe(void) +static int __init dell_smm_probe(struct platform_device *pdev) { const struct dmi_system_id *id, *fan_control; int fan, ret; - /* - * Get DMI information - */ - if (!dmi_check_system(i8k_dmi_table)) { - if (!ignore_dmi && !force) - return -ENODEV; - - pr_info("not running on a supported Dell system.\n"); - pr_info("vendor=%s, model=%s, version=%s\n", - i8k_get_dmi_data(DMI_SYS_VENDOR), - i8k_get_dmi_data(DMI_PRODUCT_NAME), - i8k_get_dmi_data(DMI_BIOS_VERSION)); - } - if (dmi_check_system(i8k_blacklist_fan_support_dmi_table)) { pr_warn("broken Dell BIOS detected, disallow fan support\n"); if (!force) @@ -1255,21 +1234,11 @@ static int __init i8k_probe(void) disallow_fan_type_call = true; } - strlcpy(bios_version, i8k_get_dmi_data(DMI_BIOS_VERSION), + strscpy(bios_version, i8k_get_dmi_data(DMI_BIOS_VERSION), sizeof(bios_version)); - strlcpy(bios_machineid, i8k_get_dmi_data(DMI_PRODUCT_SERIAL), + strscpy(bios_machineid, i8k_get_dmi_data(DMI_PRODUCT_SERIAL), sizeof(bios_machineid)); - /* - * Get SMM Dell signature - */ - if (i8k_get_dell_signature(I8K_SMM_GET_DELL_SIG1) && - i8k_get_dell_signature(I8K_SMM_GET_DELL_SIG2)) { - pr_err("unable to get SMM Dell signature\n"); - if (!force) - return -ENODEV; - } - /* * Set fan multiplier and maximal fan speed from dmi config * Values specified in module parameters override values from dmi @@ -1277,13 +1246,14 @@ static int __init i8k_probe(void) id = dmi_first_match(i8k_dmi_table); if (id && id->driver_data) { const struct i8k_config_data *conf = id->driver_data; + if (!fan_mult && conf->fan_mult) fan_mult = conf->fan_mult; if (!fan_max && conf->fan_max) fan_max = conf->fan_max; } - i8k_fan_max = fan_max ? : I8K_FAN_HIGH; /* Must not be 0 */ + i8k_fan_max = fan_max ? : I8K_FAN_HIGH; /* Must not be 0 */ i8k_pwm_mult = DIV_ROUND_UP(255, i8k_fan_max); fan_control = dmi_first_match(i8k_whitelist_fan_control); @@ -1313,29 +1283,70 @@ static int __init i8k_probe(void) i8k_fan_mult = fan_mult; } + ret = dell_smm_init_hwmon(&pdev->dev); + if (ret) + return ret; + + i8k_init_procfs(); + return 0; } +static int dell_smm_remove(struct platform_device *pdev) +{ + i8k_exit_procfs(); + + return 0; +} + +static struct platform_driver dell_smm_driver = { + .driver = { + .name = KBUILD_MODNAME, + }, + .remove = dell_smm_remove, +}; + +static struct platform_device *dell_smm_device; + +/* + * Probe for the presence of a supported laptop. + */ static int __init i8k_init(void) { - int err; + /* + * Get DMI information + */ + if (!dmi_check_system(i8k_dmi_table)) { + if (!ignore_dmi && !force) + return -ENODEV; - /* Are we running on an supported laptop? */ - if (i8k_probe()) - return -ENODEV; + pr_info("not running on a supported Dell system.\n"); + pr_info("vendor=%s, model=%s, version=%s\n", + i8k_get_dmi_data(DMI_SYS_VENDOR), + i8k_get_dmi_data(DMI_PRODUCT_NAME), + i8k_get_dmi_data(DMI_BIOS_VERSION)); + } - err = i8k_init_hwmon(); - if (err) - return err; + /* + * Get SMM Dell signature + */ + if (i8k_get_dell_signature(I8K_SMM_GET_DELL_SIG1) && + i8k_get_dell_signature(I8K_SMM_GET_DELL_SIG2)) { + pr_err("unable to get SMM Dell signature\n"); + if (!force) + return -ENODEV; + } - i8k_init_procfs(); - return 0; + dell_smm_device = platform_create_bundle(&dell_smm_driver, dell_smm_probe, NULL, 0, NULL, + 0); + + return PTR_ERR_OR_ZERO(dell_smm_device); } static void __exit i8k_exit(void) { - hwmon_device_unregister(i8k_hwmon_dev); - i8k_exit_procfs(); + platform_device_unregister(dell_smm_device); + platform_driver_unregister(&dell_smm_driver); } module_init(i8k_init); From patchwork Fri May 28 17:37:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 12287317 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E15E0C2B9F7 for ; Fri, 28 May 2021 17:37:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C54A6613DA for ; Fri, 28 May 2021 17:37:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229476AbhE1RjU (ORCPT ); Fri, 28 May 2021 13:39:20 -0400 Received: from mout.gmx.net ([212.227.17.21]:56121 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbhE1RjT (ORCPT ); Fri, 28 May 2021 13:39:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1622223448; bh=JoDvYIsMHtx6gueKLKKW45Zj/pND9+2ajlZZg/tERBE=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=Yjkjxkc2V3ND31BIsHkYJhMCyu9hmoUUUoM48mvD0wbBX2us0tg2PEtJBZm5rT+Qx LQ7rXHwORoBb5m2gwxpq039yTaqrWT+1TT+0AUpQAAo6NqFd/bSRtjwLRyGIG+ocKm tf0mbz/XtIpXDR5pLrPSFLMPim6gnggBOCwQ94Ds= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from esprimo-mx.fritz.box ([79.242.180.99]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MmULx-1l4W3F1ziD-00iTrO; Fri, 28 May 2021 19:37:28 +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/6] hwmon: (dell-smm-hwmon) Mark functions as __init Date: Fri, 28 May 2021 19:37:12 +0200 Message-Id: <20210528173716.10975-3-W_Armin@gmx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210528173716.10975-1-W_Armin@gmx.de> References: <20210528173716.10975-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:ZWIH3eTbeY6ob3CkC66F0Ha2gENifmsLQxrf0xceHkJNJkcTLjF ohpXnwu8wpqto2bwbBygNIfECZipK74EbZkxS9M2f/j9yhpfymfb79XyBIKIWgA7fxcd8PU d3LtZsLCXZxp2VmGl/CKwsZdnVs5DwefadbinQcFmkoTwG2x3Bz3DtPL0Gz0VGOuLPniyJO zBjftbLgwssb+JAnGPhAQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:kFvwH581IJs=:Udelijg/Xmuu4KwRq1cZlN FrwAZWLUuMqulh2Injwagnoyv9c5z7xSZ7nALAOIVflVyN3mLo++KIJukAEWo/4OSWMdb66AN L8WWDWIX6NUOwz67XVHjen+e7gma3g3emHTbVf5IJOIUrWAFjSWA1VpMqavpXXM8P1O730bsv K3G6g1bW/bk73KUyPsvDHN8yTvv81zvACIVnKl1n6uQuKiswXq+N1fvX6hHhex7M0YMREZ5ui NNE3RQG98CEGLCK0hwWiBnTZd4Q3H+zOkZ8ekMf2KxDEwLmMhROCBrHDc477iyvts0Y9Bvgln vzGHy5Ag2lfsKUuqkcA+f7mbdFpvz/gVRB/o0QdfLtCQF3W0Q1GEFvll7rzPImBSxYojnGUFk BtYTkWAgvoK5HxQsnI4rQeFZAhfHbeK4zZnII9zY7lNHyMlz+moz8e3T3/Wv7HaOS0gt+rU78 YsruXUSxnY8/9Ma4lzrmcomJg0GR5Sm+kO13dzHxjz0xF0OtmbAUG8cXeiQIeut3VxUPXtWzT pZaWvtbL4PGROpo5pI2TSmZG3ml4hLEoORyTb0A4f+iNIbEsXrznMOqTGOei/FqGFmgbQqMwx uwxzU6hacdVDbj7V1Z1oyf1KBHAOeSgroFDQ0a61UrrflOCuxdxYdCBlq2eb0bwIlpYxZbHEu ejHs1BXh+4HgD1hyzt2jmgh5gvN0UimoUXJALgj3HGp0nQ4gtwgWe+e8/5LZKzBxMRfTxZACi Kn/gMMDYVbYQLa19Wy+SNZuVSTo/G9oLZ4u7+kV800bGQvn8NB2uIpQr2C8wnlCLI5AXUCDQH FDsg3iHNnMAEWO4emhkBqt7YCcj82U8amj2mGhYW53hwBvFYVS5oCMMyqvngsstANuG5Ee6Da uxix3Zk9KlaydP3OvueuUKoCWxzkZXuO5fg0fjH2Qued+kcIZrgojF49Dual5aQX9OuWie/rl G2wm7Vs1Fqj3dqweaunS5W5YC0xzSugYqsRmT8beUzP3HvH9bDY7M0x2bFy1YwIoLPR4uCrqi RasBi4trs8vC0BzH8uZA7cSmFQg55eXyVs7k3Co67b4jTgG4upV3FszfZ9YmUj0Niwsa3ioM6 /ahbsqEa+2CHQFBLuJb9aSniSgKw9sNqtKnZIGGieFpNMS9StkU0AaWo+w8QhL2m/MD7ny3pk Kzttjt6gxfv4KfDt8cUhgeFEb7Xs7b0W4OsFdpNVZQH12sJu90skCdjR5Jmw2yLFLeZwM= Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Armin Wolf i8k_get_dmi_data() and i8k_get_dell_signature() are only called during module init and probe, which both are marked as __init. Also mark these function as __init to lower the runtime memory footprint. Signed-off-by: Armin Wolf Reviewed-by: Pali Rohár Tested-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 2038f2a50e11..deba8819164d 100644 --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -128,7 +128,7 @@ struct smm_regs { unsigned int edi __packed; }; -static inline const char *i8k_get_dmi_data(int field) +static inline const char __init *i8k_get_dmi_data(int field) { const char *dmi_data = dmi_get_system_info(field); @@ -384,7 +384,7 @@ static int i8k_get_temp(int sensor) return temp; } -static int i8k_get_dell_signature(int req_fn) +static int __init i8k_get_dell_signature(int req_fn) { struct smm_regs regs = { .eax = req_fn, }; int rc; From patchwork Fri May 28 17:37:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 12287319 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C66F0C2B9F7 for ; Fri, 28 May 2021 17:37:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A892F613F1 for ; Fri, 28 May 2021 17:37:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229481AbhE1RjW (ORCPT ); Fri, 28 May 2021 13:39:22 -0400 Received: from mout.gmx.net ([212.227.17.21]:40159 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbhE1RjV (ORCPT ); Fri, 28 May 2021 13:39:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1622223450; bh=4/ljCOdE+I1VICQb1TLHMJkok/Dqbw0P8Sqj81hRNDg=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=NzOx+GAcQjlOu69drMWRCbNagtKuJwnDc74IOCjEHXS3rtrZVIE7FPs9/sDkAMhS7 QZjjCmhIja7ecX+wNh3WDncVhsvjy0M6NcltwWtk50VrducYpk/Hi3Lj1kG8MN9NPO M+MsPCDV9pLWE8cnReOfZBOSLd6xjRYf1rM5uFvM= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from esprimo-mx.fritz.box ([79.242.180.99]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MQv8x-1m1LWY45p9-00NzsR; Fri, 28 May 2021 19:37:30 +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/6] hwmon: (dell-smm-hwmon) Use devm_add_action_or_reset() Date: Fri, 28 May 2021 19:37:13 +0200 Message-Id: <20210528173716.10975-4-W_Armin@gmx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210528173716.10975-1-W_Armin@gmx.de> References: <20210528173716.10975-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:izCOAJ5h1vsdQIgVM/GdEngdOCFENq/IdTzldPAt08xvbSaeQV4 vnGrFMf9f4vBDrU7kgxZIIs349le+0/ToGiZomhsJmZo9GnOaOYZ8fTBEzZEwtZISvUEABh W2CpLLr/xmyFxsUrBmS8UWranYi6YiJ78Zv4kE6uRCMdOypLLi96JSB2ckslDSlQPIBh77k 73iybRmHA7WOOLSvGwxWg== X-UI-Out-Filterresults: notjunk:1;V03:K0:lQTgS1wVgqo=:V9AvRzqzYrX6yQ4pVHbZxu 9eHkkP53HQdbCjYk01gSTFE3mzy3PwHyTpXxxgYEzp6E6dPeogtr/dVvndOAOApV3THXS1iyv /wWYs12qm8SdggJKclRawf5Qdx/BrKx6k1sdWS1O9jkA3SDB/+oO9L1+fvzzeFJqPji3kL7tQ ZfWdmReB0tYpo1jbSIr96Yztxw25POa0Z4yEAY+meP4mJ/k5FH8DQbXl5dgF4o6A3vWQ2dgjM J8gpajA5buIM4j3N20UnhXXKT9clxsx52of2euaD6GRGYae4e7IoStK6gf13qphkg7ekpPHtq +BhW5NLUR42cRwT4gikOrIBcgg1atsj50AuY4F8YcfM413o5heG8ncJ3FFWSDVz9JAPicFNh1 hsfJIJNYMDqUf7iD9WHG2pgvh/GMlTVspWuVWh6npMD8j2ATbII3h/syJIDu5UFH3UFKrzmLY DjfR8/zoLrUGO0bAc+s2t+vAI5x4Q7KSMpCZ9k1dpQsFLqkisFx1HbHKlF4sCsyNiugaLqJG6 cWAxXR/KbVW0en3vbGMDJWA8uJr///OaS28A08AXzbzIQFhb8MWXOWSpkh2syehSfL2OhyXuD BfWMXq0WU7hfMPmfW8no5LE+w0RfVsad54bEjYiAnKOIDoJUujddnZTjNeuufbBf0lOY4wvFG F6wkBMu7c8oU44ScqE4mjourhwH5YUzJFopsnGjTTDufBG5y31dM7qTYNs1J1rsk0g9F+moxq s1UC2S1Lc1SCqzjaCO+a+G2JEQknJp70csDnaN0IrKeh5xeqimX3KGfg7SWM600XUsm8P+XEs uJM0EF/+3gaAEG5QCxB1fHDvgPR8ePdnD02gZZVckkHxjL8gnsxHBtXqQoPDfNGN95Nc6xYgq TZhcOFpnlH2kOi7M8ZvO+2pcww411RsDRfm2fSLxu9C9G7y+sMHk6of16aib7LqMuH3DFILet Iz2pgTKVMtL9dg6+YtdLkAdqH2Pqjf4u7+drnD2OWDc93MmGrB+aLLgXZ5otxwS4OjTpOKhmm wTJpuzBIvc+eqByRNwJdAKIpsIhVLCv0hs/OHnCD2bcT2CjrS4JBHPbHiCEHcz+OELN5pV4dP 8KSxvq0bmawlgvZ/PHxWUjZ0Z62CUfxMfgLxxauX52aXV8ih/R9MtYMB6A8sVsWBeeg/j2Ku/ LNz7XJC/iEh9o39k4wJPBkkCkHPzmgMktuwzfksv+aKhAxm3ptX3kZzSBmnt40joaGSG8= Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Armin Wolf Use devm_add_action_or_reset() for calling i8k_exit_procfs() so the remove() function in dell_smm_driver can be omitted. Signed-off-by: Armin Wolf Reviewed-by: Pali Rohár Tested-by: Pali Rohár --- drivers/hwmon/dell-smm-hwmon.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) -- 2.20.1 diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c index deba8819164d..ed2c42badf1a 100644 --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -605,24 +605,22 @@ static const struct proc_ops i8k_proc_ops = { .proc_ioctl = i8k_ioctl, }; -static void __init i8k_init_procfs(void) +static void i8k_exit_procfs(void *param) { - /* Register the proc entry */ - proc_create("i8k", 0, NULL, &i8k_proc_ops); + remove_proc_entry("i8k", NULL); } -static void __exit i8k_exit_procfs(void) +static void __init i8k_init_procfs(struct device *dev) { - remove_proc_entry("i8k", NULL); + /* Register the proc entry */ + proc_create("i8k", 0, NULL, &i8k_proc_ops); + + devm_add_action_or_reset(dev, i8k_exit_procfs, NULL); } #else -static inline void __init i8k_init_procfs(void) -{ -} - -static inline void __exit i8k_exit_procfs(void) +static void __init i8k_init_procfs(struct device *dev) { } @@ -1287,14 +1285,7 @@ static int __init dell_smm_probe(struct platform_device *pdev) if (ret) return ret; - i8k_init_procfs(); - - return 0; -} - -static int dell_smm_remove(struct platform_device *pdev) -{ - i8k_exit_procfs(); + i8k_init_procfs(&pdev->dev); return 0; } @@ -1303,7 +1294,6 @@ static struct platform_driver dell_smm_driver = { .driver = { .name = KBUILD_MODNAME, }, - .remove = dell_smm_remove, }; static struct platform_device *dell_smm_device; From patchwork Fri May 28 17:37:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 12287321 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B72DC4708C for ; Fri, 28 May 2021 17:37:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 12DEB61008 for ; Fri, 28 May 2021 17:37:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229482AbhE1RjX (ORCPT ); Fri, 28 May 2021 13:39:23 -0400 Received: from mout.gmx.net ([212.227.17.21]:53415 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbhE1RjX (ORCPT ); Fri, 28 May 2021 13:39:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1622223451; bh=GXqomoZSdBjRB0oq6Z2cHzh/ASxySPbR36fTfHmt1+Q=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=bW507i56OVHavuCTMxMkfovwEqM4tjS67QlEFWTg44vAX6Qx8IrT6mAaPSMymWh4S vK1OOJS1StiMHyFRMKDnNphkLgYFdURsIALOFKjGcZq9gyq12FyF7MvuEqexqkR7Zb JHD/B7x1NBe1T+RJtEI5AWzBd86T69C91KZveYJk= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from esprimo-mx.fritz.box ([79.242.180.99]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MXp9Y-1luQi71d3k-00YDOS; Fri, 28 May 2021 19:37:31 +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/6] hwmon: (dell-smm-hwmon) Move variables into a driver private data structure Date: Fri, 28 May 2021 19:37:14 +0200 Message-Id: <20210528173716.10975-5-W_Armin@gmx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210528173716.10975-1-W_Armin@gmx.de> References: <20210528173716.10975-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:smvB5CAvPalBmwTdpTG/ZQLQgApJZ51DqF97l9peGhgtsh+iblv ouA73qNI5LXbbRIXKgTgfCBuLSb4zp/pVwlXFoJnhJqGnFXJs7TOuMKfVUDoDKNK+aQKdjo +XWRY9qfT8zJF2L5i5npRhTtWN0MARa54bnHn1zQdmCcclzrzpqW7y4t3zmimHEntj1a+so 8+uXFCpHfDl+Xzdck7iIg== X-UI-Out-Filterresults: notjunk:1;V03:K0:eKnrNJQyuOA=:0Aryh9bZdRVxekAca2Zyyc e8d0b/BJINKtxcklVmWWTcdWQbxTjNZZAxjlDgHPdtgN5efonzYM7ZFsZl1TjrS+DJVsS9R5o ZCm2D8meF8OTI1fpno6+bZFY3UN40ACbzgtZ0/T/TC+rT5uRT7ZSvskVkOU3CZaHBIzvDvLaG AQDFCtoUoHofWTlrK7WuUhdd70j/qiE7wjeb3r54syp0UjJQijBQI7z9CB4ITIVZTzPSAwYB9 9Xlvv68IhWJTcZPbyBZ+DZPukit0drm1RIkgLmNnnbhCoIYFUvzPaxQl7GorTKnnBiAfVYXQI db3OFM1sh9Sgvs80p59AGXUryJLlp41didJkZI6O9LWzNvzggudLCM6NuB4RLHRmDkIN28bA4 agJL2KMBpQerAlug686pj6O0LP+zpwHmxV1/tcsjtto9QKUa4Mn0hm8nUX4fDMeSinwP++cpD A0ze+sEd4+QrOrRa5ump7Ty/hqeRNuoMqWyeQ/oTjfrSRvzsPrQLnr9zS1AsqpdjI2+j1v9Av 5v5Ao8cVZEDKWkwcDcgFGaEOgsxWOywmYMVerJJVDtXKpuYH+Dw/VvS5P1fgVu5NLeRPR41DR E5duXJ/gojyczMuMW4+nkhIjRIA9cqxLvmVtEnw05dZ3QPe+BsUVz2VAJ8hbZUmn0RiKOCbf9 gRa2Q64U9pbXNWG8dNGT8ooIZS9NteLsGdgj80x6uHWbJaYobhDvKLFgWoXyt2Eu+Lx2wbTuU myw52o1qLeaX2j7wp0siit5JvwE0iUE5fKY5zMefXwxX71l/H7avfJ4tZhqBbvajY/UX/4/qn mHtamsmTJ9xf6AeHeH+Ji0yB2Bq+qciR1VGvN3/52Mc/Rzfblz/zpPcHsbfGu/GX3TUNT/Qk4 fXstTdDEfhsQaZ7rd2odkzEZ+/Cw8lKZ7MaOZTlIcmP6v9Ovs9zuxVdURVBviqPTAKU41Fje9 vH3BlS/RU6+nxAfdTyXj82hNmpcLkW0TELRjpfs4KHVi7+QvrKiceiXrs6Y+5YzVdc9LkDLYI h/jELN84pl00ffBrjfuuoCimsiLk9zR/tKJ2qmiRwstG2my5/ZEjTVq8u3CLG22BmlKy5/YG6 56TJzwwTd19l4pxBeRRtCLkAaJK619Ee39iJP0vDeH0ltpMgpruNf6w0wgMNhFl3Yca2MMLgf 3+ypCZmfkDIZI/PGs9+DjZg9HaMJzmGS+DWwfaXXHdvxLVlTbUSgfeY9GmBuxCjPhpMdM= Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Armin Wolf Move Variables into a driver private data structure. Signed-off-by: Armin Wolf --- drivers/hwmon/dell-smm-hwmon.c | 277 ++++++++++++++++++--------------- 1 file changed, 152 insertions(+), 125 deletions(-) -- 2.20.1 diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c index ed2c42badf1a..420fdd2de2fb 100644 --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -60,18 +60,20 @@ #define I8K_POWER_AC 0x05 #define I8K_POWER_BATTERY 0x01 -static DEFINE_MUTEX(i8k_mutex); -static char bios_version[4]; -static char bios_machineid[16]; -static struct device *i8k_hwmon_dev; -static u32 i8k_hwmon_flags; -static uint i8k_fan_mult = I8K_FAN_MULT; -static uint i8k_pwm_mult; -static uint i8k_fan_max = I8K_FAN_HIGH; -static bool disallow_fan_type_call; -static bool disallow_fan_support; -static unsigned int manual_fan; -static unsigned int auto_fan; +struct dell_smm_data { + struct mutex i8k_mutex; /* lock for sensors writes */ + char bios_version[4]; + char bios_machineid[16]; + u32 i8k_hwmon_flags; + uint i8k_fan_mult; + uint i8k_pwm_mult; + uint i8k_fan_max; + bool disallow_fan_type_call; + bool disallow_fan_support; + unsigned int manual_fan; + unsigned int auto_fan; + int types[3]; +}; #define I8K_HWMON_HAVE_TEMP1 (1 << 0) #define I8K_HWMON_HAVE_TEMP2 (1 << 1) @@ -240,11 +242,11 @@ static int i8k_smm(struct smm_regs *regs) /* * Read the fan status. */ -static int i8k_get_fan_status(int fan) +static int i8k_get_fan_status(const struct dell_smm_data *data, int fan) { struct smm_regs regs = { .eax = I8K_SMM_GET_FAN, }; - if (disallow_fan_support) + if (data->disallow_fan_support) return -EINVAL; regs.ebx = fan & 0xff; @@ -254,84 +256,82 @@ static int i8k_get_fan_status(int fan) /* * Read the fan speed in RPM. */ -static int i8k_get_fan_speed(int fan) +static int i8k_get_fan_speed(const struct dell_smm_data *data, int fan) { struct smm_regs regs = { .eax = I8K_SMM_GET_SPEED, }; - if (disallow_fan_support) + if (data->disallow_fan_support) return -EINVAL; regs.ebx = fan & 0xff; - return i8k_smm(®s) ? : (regs.eax & 0xffff) * i8k_fan_mult; + return i8k_smm(®s) ? : (regs.eax & 0xffff) * data->i8k_fan_mult; } /* * Read the fan type. */ -static int _i8k_get_fan_type(int fan) +static int _i8k_get_fan_type(struct dell_smm_data *data, int fan) { struct smm_regs regs = { .eax = I8K_SMM_GET_FAN_TYPE, }; - if (disallow_fan_support || disallow_fan_type_call) + if (data->disallow_fan_support || data->disallow_fan_type_call) return -EINVAL; regs.ebx = fan & 0xff; return i8k_smm(®s) ? : regs.eax & 0xff; } -static int i8k_get_fan_type(int fan) +static int i8k_get_fan_type(struct dell_smm_data *data, int fan) { /* I8K_SMM_GET_FAN_TYPE SMM call is expensive, so cache values */ - static int types[3] = { INT_MIN, INT_MIN, INT_MIN }; + if (data->types[fan] == INT_MIN) + data->types[fan] = _i8k_get_fan_type(data, fan); - if (types[fan] == INT_MIN) - types[fan] = _i8k_get_fan_type(fan); - - return types[fan]; + return data->types[fan]; } /* * Read the fan nominal rpm for specific fan speed. */ -static int i8k_get_fan_nominal_speed(int fan, int speed) +static int i8k_get_fan_nominal_speed(const struct dell_smm_data *data, int fan, int speed) { struct smm_regs regs = { .eax = I8K_SMM_GET_NOM_SPEED, }; - if (disallow_fan_support) + if (data->disallow_fan_support) return -EINVAL; regs.ebx = (fan & 0xff) | (speed << 8); - return i8k_smm(®s) ? : (regs.eax & 0xffff) * i8k_fan_mult; + return i8k_smm(®s) ? : (regs.eax & 0xffff) * data->i8k_fan_mult; } /* * Enable or disable automatic BIOS fan control support */ -static int i8k_enable_fan_auto_mode(bool enable) +static int i8k_enable_fan_auto_mode(const struct dell_smm_data *data, bool enable) { struct smm_regs regs = { }; - if (disallow_fan_support) + if (data->disallow_fan_support) return -EINVAL; - regs.eax = enable ? auto_fan : manual_fan; + regs.eax = enable ? data->auto_fan : data->manual_fan; return i8k_smm(®s); } /* * Set the fan speed (off, low, high). Returns the new fan status. */ -static int i8k_set_fan(int fan, int speed) +static int i8k_set_fan(const struct dell_smm_data *data, int fan, int speed) { struct smm_regs regs = { .eax = I8K_SMM_SET_FAN, }; - if (disallow_fan_support) + if (data->disallow_fan_support) return -EINVAL; - speed = (speed < 0) ? 0 : ((speed > i8k_fan_max) ? i8k_fan_max : 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(fan); + return i8k_smm(®s) ? : i8k_get_fan_status(data, fan); } static int i8k_get_temp_type(int sensor) @@ -442,7 +442,7 @@ static int i8k_get_power_status(void) */ static int -i8k_ioctl_unlocked(struct file *fp, unsigned int cmd, unsigned long arg) +i8k_ioctl_unlocked(struct file *fp, struct dell_smm_data *data, unsigned int cmd, unsigned long arg) { int val = 0; int speed; @@ -454,12 +454,12 @@ i8k_ioctl_unlocked(struct file *fp, unsigned int cmd, unsigned long arg) switch (cmd) { case I8K_BIOS_VERSION: - if (!isdigit(bios_version[0]) || !isdigit(bios_version[1]) || - !isdigit(bios_version[2])) + if (!isdigit(data->bios_version[0]) || !isdigit(data->bios_version[1]) || + !isdigit(data->bios_version[2])) return -EINVAL; - val = (bios_version[0] << 16) | - (bios_version[1] << 8) | bios_version[2]; + val = (data->bios_version[0] << 16) | + (data->bios_version[1] << 8) | data->bios_version[2]; break; case I8K_MACHINE_ID: @@ -467,7 +467,7 @@ i8k_ioctl_unlocked(struct file *fp, unsigned int cmd, unsigned long arg) return -EPERM; memset(buff, 0, sizeof(buff)); - strlcpy(buff, bios_machineid, sizeof(buff)); + strscpy(buff, data->bios_machineid, sizeof(buff)); break; case I8K_FN_STATUS: @@ -486,14 +486,14 @@ i8k_ioctl_unlocked(struct file *fp, unsigned int cmd, unsigned long arg) if (copy_from_user(&val, argp, sizeof(int))) return -EFAULT; - val = i8k_get_fan_speed(val); + val = i8k_get_fan_speed(data, val); break; case I8K_GET_FAN: if (copy_from_user(&val, argp, sizeof(int))) return -EFAULT; - val = i8k_get_fan_status(val); + val = i8k_get_fan_status(data, val); break; case I8K_SET_FAN: @@ -506,7 +506,7 @@ i8k_ioctl_unlocked(struct file *fp, unsigned int cmd, unsigned long arg) if (copy_from_user(&speed, argp + 1, sizeof(int))) return -EFAULT; - val = i8k_set_fan(val, speed); + val = i8k_set_fan(data, val, speed); break; default: @@ -539,11 +539,12 @@ i8k_ioctl_unlocked(struct file *fp, unsigned int cmd, unsigned long arg) static long i8k_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) { + struct dell_smm_data *data = PDE_DATA(file_inode(fp)); long ret; - mutex_lock(&i8k_mutex); - ret = i8k_ioctl_unlocked(fp, cmd, arg); - mutex_unlock(&i8k_mutex); + mutex_lock(&data->i8k_mutex); + ret = i8k_ioctl_unlocked(fp, data, cmd, arg); + mutex_unlock(&data->i8k_mutex); return ret; } @@ -553,17 +554,18 @@ static long i8k_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) */ static int i8k_proc_show(struct seq_file *seq, void *offset) { + struct dell_smm_data *data = seq->private; int fn_key, cpu_temp, ac_power; int left_fan, right_fan, left_speed, right_speed; - cpu_temp = i8k_get_temp(0); /* 11100 µs */ - left_fan = i8k_get_fan_status(I8K_FAN_LEFT); /* 580 µs */ - right_fan = i8k_get_fan_status(I8K_FAN_RIGHT); /* 580 µs */ - left_speed = i8k_get_fan_speed(I8K_FAN_LEFT); /* 580 µs */ - right_speed = i8k_get_fan_speed(I8K_FAN_RIGHT); /* 580 µs */ - fn_key = i8k_get_fn_status(); /* 750 µs */ + cpu_temp = i8k_get_temp(0); /* 11100 µs */ + left_fan = i8k_get_fan_status(data, I8K_FAN_LEFT); /* 580 µs */ + right_fan = i8k_get_fan_status(data, I8K_FAN_RIGHT); /* 580 µs */ + left_speed = i8k_get_fan_speed(data, I8K_FAN_LEFT); /* 580 µs */ + right_speed = i8k_get_fan_speed(data, I8K_FAN_RIGHT); /* 580 µs */ + fn_key = i8k_get_fn_status(); /* 750 µs */ if (power_status) - ac_power = i8k_get_power_status(); /* 14700 µs */ + ac_power = i8k_get_power_status(); /* 14700 µs */ else ac_power = -1; @@ -583,8 +585,8 @@ static int i8k_proc_show(struct seq_file *seq, void *offset) */ seq_printf(seq, "%s %s %s %d %d %d %d %d %d %d\n", I8K_PROC_FMT, - bios_version, - (restricted && !capable(CAP_SYS_ADMIN)) ? "-1" : bios_machineid, + data->bios_version, + (restricted && !capable(CAP_SYS_ADMIN)) ? "-1" : data->bios_machineid, cpu_temp, left_fan, right_fan, left_speed, right_speed, ac_power, fn_key); @@ -594,7 +596,7 @@ static int i8k_proc_show(struct seq_file *seq, void *offset) static int i8k_open_fs(struct inode *inode, struct file *file) { - return single_open(file, i8k_proc_show, NULL); + return single_open(file, i8k_proc_show, PDE_DATA(inode)); } static const struct proc_ops i8k_proc_ops = { @@ -612,8 +614,10 @@ static void i8k_exit_procfs(void *param) static void __init i8k_init_procfs(struct device *dev) { + struct dell_smm_data *data = dev_get_drvdata(dev); + /* Register the proc entry */ - proc_create("i8k", 0, NULL, &i8k_proc_ops); + proc_create_data("i8k", 0, NULL, &i8k_proc_ops, data); devm_add_action_or_reset(dev, i8k_exit_procfs, NULL); } @@ -670,6 +674,7 @@ static ssize_t i8k_hwmon_fan_label_show(struct device *dev, struct device_attribute *devattr, char *buf) { + struct dell_smm_data *data = dev_get_drvdata(dev); static const char * const labels[] = { "Processor Fan", "Motherboard Fan", @@ -682,7 +687,7 @@ static ssize_t i8k_hwmon_fan_label_show(struct device *dev, bool dock = false; int type; - type = i8k_get_fan_type(index); + type = i8k_get_fan_type(data, index); if (type < 0) return type; @@ -700,10 +705,11 @@ static ssize_t i8k_hwmon_fan_label_show(struct device *dev, static ssize_t i8k_hwmon_fan_show(struct device *dev, struct device_attribute *devattr, char *buf) { + struct dell_smm_data *data = dev_get_drvdata(dev); int index = to_sensor_dev_attr(devattr)->index; int fan_speed; - fan_speed = i8k_get_fan_speed(index); + fan_speed = i8k_get_fan_speed(data, index); if (fan_speed < 0) return fan_speed; return sprintf(buf, "%d\n", fan_speed); @@ -712,19 +718,21 @@ static ssize_t i8k_hwmon_fan_show(struct device *dev, static ssize_t i8k_hwmon_pwm_show(struct device *dev, struct device_attribute *devattr, char *buf) { + struct dell_smm_data *data = dev_get_drvdata(dev); int index = to_sensor_dev_attr(devattr)->index; int status; - status = i8k_get_fan_status(index); + status = i8k_get_fan_status(data, index); if (status < 0) return -EIO; - return sprintf(buf, "%d\n", clamp_val(status * i8k_pwm_mult, 0, 255)); + return sprintf(buf, "%d\n", clamp_val(status * data->i8k_pwm_mult, 0, 255)); } static ssize_t i8k_hwmon_pwm_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { + struct dell_smm_data *data = dev_get_drvdata(dev); int index = to_sensor_dev_attr(attr)->index; unsigned long val; int err; @@ -732,11 +740,11 @@ static ssize_t i8k_hwmon_pwm_store(struct device *dev, err = kstrtoul(buf, 10, &val); if (err) return err; - val = clamp_val(DIV_ROUND_CLOSEST(val, i8k_pwm_mult), 0, i8k_fan_max); + val = clamp_val(DIV_ROUND_CLOSEST(val, data->i8k_pwm_mult), 0, data->i8k_fan_max); - mutex_lock(&i8k_mutex); - err = i8k_set_fan(index, val); - mutex_unlock(&i8k_mutex); + mutex_lock(&data->i8k_mutex); + err = i8k_set_fan(data, index, val); + mutex_unlock(&data->i8k_mutex); return err < 0 ? -EIO : count; } @@ -745,11 +753,12 @@ static ssize_t i8k_hwmon_pwm_enable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { + struct dell_smm_data *data = dev_get_drvdata(dev); int err; bool enable; unsigned long val; - if (!auto_fan) + if (!data->auto_fan) return -ENODEV; err = kstrtoul(buf, 10, &val); @@ -763,9 +772,9 @@ static ssize_t i8k_hwmon_pwm_enable_store(struct device *dev, else return -EINVAL; - mutex_lock(&i8k_mutex); - err = i8k_enable_fan_auto_mode(enable); - mutex_unlock(&i8k_mutex); + mutex_lock(&data->i8k_mutex); + err = i8k_enable_fan_auto_mode(data, enable); + mutex_unlock(&data->i8k_mutex); return err ? err : count; } @@ -838,53 +847,56 @@ static struct attribute *i8k_attrs[] = { static umode_t i8k_is_visible(struct kobject *kobj, struct attribute *attr, int index) { - if (disallow_fan_support && index >= 20) + struct device *dev = kobj_to_dev(kobj); + struct dell_smm_data *data = dev_get_drvdata(dev); + + if (data->disallow_fan_support && index >= 20) return 0; - if (disallow_fan_type_call && + if (data->disallow_fan_type_call && (index == 21 || index == 25 || index == 28)) return 0; if (index >= 0 && index <= 1 && - !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP1)) + !(data->i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP1)) return 0; if (index >= 2 && index <= 3 && - !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP2)) + !(data->i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP2)) return 0; if (index >= 4 && index <= 5 && - !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP3)) + !(data->i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP3)) return 0; if (index >= 6 && index <= 7 && - !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP4)) + !(data->i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP4)) return 0; if (index >= 8 && index <= 9 && - !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP5)) + !(data->i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP5)) return 0; if (index >= 10 && index <= 11 && - !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP6)) + !(data->i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP6)) return 0; if (index >= 12 && index <= 13 && - !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP7)) + !(data->i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP7)) return 0; if (index >= 14 && index <= 15 && - !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP8)) + !(data->i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP8)) return 0; if (index >= 16 && index <= 17 && - !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP9)) + !(data->i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP9)) return 0; if (index >= 18 && index <= 19 && - !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP10)) + !(data->i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP10)) return 0; if (index >= 20 && index <= 23 && - !(i8k_hwmon_flags & I8K_HWMON_HAVE_FAN1)) + !(data->i8k_hwmon_flags & I8K_HWMON_HAVE_FAN1)) return 0; if (index >= 24 && index <= 26 && - !(i8k_hwmon_flags & I8K_HWMON_HAVE_FAN2)) + !(data->i8k_hwmon_flags & I8K_HWMON_HAVE_FAN2)) return 0; if (index >= 27 && index <= 29 && - !(i8k_hwmon_flags & I8K_HWMON_HAVE_FAN3)) + !(data->i8k_hwmon_flags & I8K_HWMON_HAVE_FAN3)) return 0; - if (index == 23 && !auto_fan) + if (index == 23 && !data->auto_fan) return 0; return attr->mode; @@ -898,65 +910,65 @@ __ATTRIBUTE_GROUPS(i8k); static int __init dell_smm_init_hwmon(struct device *dev) { + struct dell_smm_data *data = dev_get_drvdata(dev); + struct device *i8k_hwmon_dev; int err; - i8k_hwmon_flags = 0; - /* CPU temperature attributes, if temperature type is OK */ err = i8k_get_temp_type(0); if (err >= 0) - i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP1; + data->i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP1; /* check for additional temperature sensors */ err = i8k_get_temp_type(1); if (err >= 0) - i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP2; + data->i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP2; err = i8k_get_temp_type(2); if (err >= 0) - i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP3; + data->i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP3; err = i8k_get_temp_type(3); if (err >= 0) - i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP4; + data->i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP4; err = i8k_get_temp_type(4); if (err >= 0) - i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP5; + data->i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP5; err = i8k_get_temp_type(5); if (err >= 0) - i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP6; + data->i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP6; err = i8k_get_temp_type(6); if (err >= 0) - i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP7; + data->i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP7; err = i8k_get_temp_type(7); if (err >= 0) - i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP8; + data->i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP8; err = i8k_get_temp_type(8); if (err >= 0) - i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP9; + data->i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP9; err = i8k_get_temp_type(9); if (err >= 0) - i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP10; + data->i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP10; /* First fan attributes, if fan status or type is OK */ - err = i8k_get_fan_status(0); + err = i8k_get_fan_status(data, 0); if (err < 0) - err = i8k_get_fan_type(0); + err = i8k_get_fan_type(data, 0); if (err >= 0) - i8k_hwmon_flags |= I8K_HWMON_HAVE_FAN1; + data->i8k_hwmon_flags |= I8K_HWMON_HAVE_FAN1; /* Second fan attributes, if fan status or type is OK */ - err = i8k_get_fan_status(1); + err = i8k_get_fan_status(data, 1); if (err < 0) - err = i8k_get_fan_type(1); + err = i8k_get_fan_type(data, 1); if (err >= 0) - i8k_hwmon_flags |= I8K_HWMON_HAVE_FAN2; + data->i8k_hwmon_flags |= I8K_HWMON_HAVE_FAN2; /* Third fan attributes, if fan status or type is OK */ - err = i8k_get_fan_status(2); + err = i8k_get_fan_status(data, 2); if (err < 0) - err = i8k_get_fan_type(2); + err = i8k_get_fan_type(data, 2); if (err >= 0) - i8k_hwmon_flags |= I8K_HWMON_HAVE_FAN3; + data->i8k_hwmon_flags |= I8K_HWMON_HAVE_FAN3; - i8k_hwmon_dev = devm_hwmon_device_register_with_groups(dev, "dell_smm", NULL, i8k_groups); + i8k_hwmon_dev = devm_hwmon_device_register_with_groups(dev, "dell_smm", data, i8k_groups); return PTR_ERR_OR_ZERO(i8k_hwmon_dev); } @@ -1217,25 +1229,38 @@ static struct dmi_system_id i8k_whitelist_fan_control[] __initdata = { static int __init dell_smm_probe(struct platform_device *pdev) { + struct dell_smm_data *data; const struct dmi_system_id *id, *fan_control; int fan, ret; + data = devm_kzalloc(&pdev->dev, sizeof(struct dell_smm_data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + mutex_init(&data->i8k_mutex); + data->i8k_fan_mult = I8K_FAN_MULT; + data->i8k_fan_max = I8K_FAN_HIGH; + data->types[0] = INT_MIN; + data->types[1] = INT_MIN; + data->types[2] = INT_MIN; + platform_set_drvdata(pdev, data); + if (dmi_check_system(i8k_blacklist_fan_support_dmi_table)) { - pr_warn("broken Dell BIOS detected, disallow fan support\n"); + dev_warn(&pdev->dev, "broken Dell BIOS detected, disallow fan support\n"); if (!force) - disallow_fan_support = true; + data->disallow_fan_support = true; } if (dmi_check_system(i8k_blacklist_fan_type_dmi_table)) { - pr_warn("broken Dell BIOS detected, disallow fan type call\n"); + dev_warn(&pdev->dev, "broken Dell BIOS detected, disallow fan type call\n"); if (!force) - disallow_fan_type_call = true; + data->disallow_fan_type_call = true; } - strscpy(bios_version, i8k_get_dmi_data(DMI_BIOS_VERSION), - sizeof(bios_version)); - strscpy(bios_machineid, i8k_get_dmi_data(DMI_PRODUCT_SERIAL), - sizeof(bios_machineid)); + strscpy(data->bios_version, i8k_get_dmi_data(DMI_BIOS_VERSION), + sizeof(data->bios_version)); + strscpy(data->bios_machineid, i8k_get_dmi_data(DMI_PRODUCT_SERIAL), + sizeof(data->bios_machineid)); /* * Set fan multiplier and maximal fan speed from dmi config @@ -1247,20 +1272,21 @@ static int __init dell_smm_probe(struct platform_device *pdev) if (!fan_mult && conf->fan_mult) fan_mult = conf->fan_mult; + if (!fan_max && conf->fan_max) fan_max = conf->fan_max; } - i8k_fan_max = fan_max ? : I8K_FAN_HIGH; /* Must not be 0 */ - i8k_pwm_mult = DIV_ROUND_UP(255, i8k_fan_max); + data->i8k_fan_max = fan_max ? : I8K_FAN_HIGH; /* Must not be 0 */ + data->i8k_pwm_mult = DIV_ROUND_UP(255, data->i8k_fan_max); fan_control = dmi_first_match(i8k_whitelist_fan_control); if (fan_control && fan_control->driver_data) { - const struct i8k_fan_control_data *data = fan_control->driver_data; + const struct i8k_fan_control_data *control = fan_control->driver_data; - manual_fan = data->manual_fan; - auto_fan = data->auto_fan; - pr_info("enabling support for setting automatic/manual fan control\n"); + data->manual_fan = control->manual_fan; + data->auto_fan = control->auto_fan; + dev_info(&pdev->dev, "enabling support for setting automatic/manual fan control\n"); } if (!fan_mult) { @@ -1269,16 +1295,17 @@ static int __init dell_smm_probe(struct platform_device *pdev) * If fan reports rpm value too high then set multiplier to 1 */ for (fan = 0; fan < 2; ++fan) { - ret = i8k_get_fan_nominal_speed(fan, i8k_fan_max); + ret = i8k_get_fan_nominal_speed(data, fan, data->i8k_fan_max); if (ret < 0) continue; + if (ret > I8K_FAN_MAX_RPM) - i8k_fan_mult = 1; + data->i8k_fan_mult = 1; break; } } else { /* Fan multiplier was specified in module param or in dmi */ - i8k_fan_mult = fan_mult; + data->i8k_fan_mult = fan_mult; } ret = dell_smm_init_hwmon(&pdev->dev); From patchwork Fri May 28 17:37:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 12287325 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6C78C2B9F7 for ; Fri, 28 May 2021 17:37:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A1087613F0 for ; Fri, 28 May 2021 17:37:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229522AbhE1Rj0 (ORCPT ); Fri, 28 May 2021 13:39:26 -0400 Received: from mout.gmx.net ([212.227.17.22]:53103 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbhE1RjZ (ORCPT ); Fri, 28 May 2021 13:39:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1622223453; bh=Es0Et/WjfefCemrJFp9Q6R97s+nioEiM1TtUj01wmwA=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=ZWHSV1X+QgV9S6yaWLrYFplKmoUGNOsYfXIMYy+1OZLAo+NIeE82UvZM/kmQlwrta d6yUWDqJ5mkGkkTHKlaVBZ5+vdf9nkpGaaYIeOzClW855VdfG8Txm0hZCS/g5VOjn6 +vXhDxVVY7+0K4EoHuJ6IUdrBoXGRuEK242w1MVg= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from esprimo-mx.fritz.box ([79.242.180.99]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M6DWi-1lkUYm3i6C-006jLD; Fri, 28 May 2021 19:37:33 +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/6] hwmon: (dell-smm-hwmon) Convert to devm_hwmon_device_register_with_info() Date: Fri, 28 May 2021 19:37:15 +0200 Message-Id: <20210528173716.10975-6-W_Armin@gmx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210528173716.10975-1-W_Armin@gmx.de> References: <20210528173716.10975-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:u6Y+Uj4mQkbxlA4QrfzZEzprKQm4XplV5Ulw8g8Rr7Iy4IxprN+ 1BBY9WWOX6Ueu/d+n13FGiWYY7azJDac6FSM1/2nlCXNfr0Tz+pV+5Aq5xt88QYfJOnSQW0 NaWWa7jAyIJ2SERcidbvY3Z0HZbMYsbLm3drxM8kj0/vB+jsSKIGwC7Aplrsnv5wb9JLhxq sazEahv9P6vMWOXwd7cMA== X-UI-Out-Filterresults: notjunk:1;V03:K0:qGuYoabJVCg=:ClaLmXyxxhUxjDvLJcg8dR ivpBY6JuuzJvtEUd8MZdwdEBx+RYB0TQvGneyjEqjgeFO71Hda+cT6RrfP7Bvysl4kkslu061 KqoMWrfDbwRWzCMbFq/rsyE1gRqnBH1qEKe7HG4dEPgaMryaTJkOEdp4as9WfU99xEwd0gcaq CLWufCQPSX1bwSx47oi1WNFOTfeB9h9vdzrN/Xid+oZHKSWK1NYy5y+SKiwpBPpmlYGat6Fdk w4vq/gG7mOTuLRGwWPH+qFybqfeMUwQV3KOHjPlLD9XwHLoZuhaP6QJv86Vf9DCkIBD63FZ8w 51nAGvSCM+8WTfFmjPUu1NbnCA/Qs1aCgocaCb4DM5rcX4dap3B5eaZvGNLLSXGquI0mxsX6I 2K9J5tPNZoLlvAxFblNYmiYTq6+Fb53rSSAAUej/iLdaAdCGb3JxmpYuDdleTjYkTL4mJcCYs +WndbHpiC0SU0MUnQijr7nq/jTrVYIqU+hWaFmqBU2mu+DUrvinG6H96VC+Kcrgl3hU5JdlB4 0aFK26YUFU8hF8IJXs9gTmw/3e+zMOWLb4HtralUByYicPwlfDjsmzS1JtWBzCW6u4syCO3mv 3gDqysv1E7qI6qJvSHcAFBBrgjjptZeYKmtH5zQxv1vJQGaqyiPvwlYfUuNH43P7vYC+bsnWO H4WHxYf6G7Ft/dbJ9IXZpjdlFiTs4VG06G64K5yuDfU7WuP93IHriC8PTABXGrIlqfn2NM/Oy 608ACnFzzvGFjCKXvw2u0O3YnpEOr9WvFuQEdZ5fyJ5cQdlq6QpngSus0N3+LDEdiwt1OYCfY S+OeJ5KaNfDWT9gUZf2uE0sJIt+ugL+ApIFxnAp/ftJnE8d1s315KUAKduse47ofYAL7cfyVJ EEj9t+P2Pbw8QcbTsRThGWx75ACJTBx1cU/cVq/IxEmRT0VA0hyGF9rP9ATqUkRh3o1bQj6/i zTtYQlqO+7FeSA/4rlePD6dr/Z9wOpgm+xdCKWN3Z66cFuYLMvULDOEdJ0KH8YaadP3JfWfXP 4Y1Th3vS42ufo8Uk8/mXUjELWq2TXK509CugkwWOOJHs/nY6Vs54Z79iHEAeDjR4mZVaA8Fcb EBwGtqKBOlB8lmjluoqYVaBZlBGZciOWpRR8p/veEmJLsihaShTNVVlWLZaRede1oInbQszb+ a4Zr/XMz9zjLwyRFbqvBhZ6A1/x+pbANQa7j9IpEY5CopPMsaKDZOq+I5AQ9XUGszfnLo= Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Armin Wolf Convert to new registration API to get rid of attribute magic numbers and reduce module size. Signed-off-by: Armin Wolf --- drivers/hwmon/dell-smm-hwmon.c | 600 +++++++++++++++------------------ 1 file changed, 281 insertions(+), 319 deletions(-) -- 2.20.1 diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c index 420fdd2de2fb..504ade34833e 100644 --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -60,11 +59,13 @@ #define I8K_POWER_AC 0x05 #define I8K_POWER_BATTERY 0x01 +#define DELL_SMM_NO_TEMP 10 +#define DELL_SMM_NO_FANS 3 + struct dell_smm_data { struct mutex i8k_mutex; /* lock for sensors writes */ char bios_version[4]; char bios_machineid[16]; - u32 i8k_hwmon_flags; uint i8k_fan_mult; uint i8k_pwm_mult; uint i8k_fan_max; @@ -72,23 +73,11 @@ struct dell_smm_data { bool disallow_fan_support; unsigned int manual_fan; unsigned int auto_fan; - int types[3]; + long auto_fan_enable; + const char *temp_label[DELL_SMM_NO_TEMP]; + const char *fan_label[DELL_SMM_NO_FANS]; }; -#define I8K_HWMON_HAVE_TEMP1 (1 << 0) -#define I8K_HWMON_HAVE_TEMP2 (1 << 1) -#define I8K_HWMON_HAVE_TEMP3 (1 << 2) -#define I8K_HWMON_HAVE_TEMP4 (1 << 3) -#define I8K_HWMON_HAVE_TEMP5 (1 << 4) -#define I8K_HWMON_HAVE_TEMP6 (1 << 5) -#define I8K_HWMON_HAVE_TEMP7 (1 << 6) -#define I8K_HWMON_HAVE_TEMP8 (1 << 7) -#define I8K_HWMON_HAVE_TEMP9 (1 << 8) -#define I8K_HWMON_HAVE_TEMP10 (1 << 9) -#define I8K_HWMON_HAVE_FAN1 (1 << 10) -#define I8K_HWMON_HAVE_FAN2 (1 << 11) -#define I8K_HWMON_HAVE_FAN3 (1 << 12) - MODULE_AUTHOR("Massimo Dal Zotto (dz@debian.org)"); MODULE_AUTHOR("Pali Rohár "); MODULE_DESCRIPTION("Dell laptop SMM BIOS hwmon driver"); @@ -130,6 +119,33 @@ struct smm_regs { unsigned int edi __packed; }; +static const char * const temp_labels[] = { + "CPU", + "GPU", + "SODIMM", + "Other", + "Ambient", + "Other", +}; + +static const char * const fan_labels[] = { + "Processor Fan", + "Motherboard Fan", + "Video Fan", + "Power Supply Fan", + "Chipset Fan", + "Other Fan", +}; + +static const char * const docking_labels[] = { + "Docking Processor Fan", + "Docking Motherboard Fan", + "Docking Video Fan", + "Docking Power Supply Fan", + "Docking Chipset Fan", + "Docking Other Fan", +}; + static inline const char __init *i8k_get_dmi_data(int field) { const char *dmi_data = dmi_get_system_info(field); @@ -270,7 +286,7 @@ static int i8k_get_fan_speed(const struct dell_smm_data *data, int fan) /* * Read the fan type. */ -static int _i8k_get_fan_type(struct dell_smm_data *data, int fan) +static int __init i8k_get_fan_type(const struct dell_smm_data *data, int fan) { struct smm_regs regs = { .eax = I8K_SMM_GET_FAN_TYPE, }; @@ -281,15 +297,6 @@ static int _i8k_get_fan_type(struct dell_smm_data *data, int fan) return i8k_smm(®s) ? : regs.eax & 0xff; } -static int i8k_get_fan_type(struct dell_smm_data *data, int fan) -{ - /* I8K_SMM_GET_FAN_TYPE SMM call is expensive, so cache values */ - if (data->types[fan] == INT_MIN) - data->types[fan] = _i8k_get_fan_type(data, fan); - - return data->types[fan]; -} - /* * Read the fan nominal rpm for specific fan speed. */ @@ -334,7 +341,7 @@ static int i8k_set_fan(const struct dell_smm_data *data, int fan, int speed) return i8k_smm(®s) ? : i8k_get_fan_status(data, fan); } -static int i8k_get_temp_type(int sensor) +static int __init i8k_get_temp_type(int sensor) { struct smm_regs regs = { .eax = I8K_SMM_GET_TEMP_TYPE, }; @@ -634,343 +641,300 @@ static void __init i8k_init_procfs(struct device *dev) * Hwmon interface */ -static ssize_t i8k_hwmon_temp_label_show(struct device *dev, - struct device_attribute *devattr, - char *buf) +static umode_t dell_smm_is_visible(const void *drvdata, enum hwmon_sensor_types type, u32 attr, + int channel) { - static const char * const labels[] = { - "CPU", - "GPU", - "SODIMM", - "Other", - "Ambient", - "Other", - }; - int index = to_sensor_dev_attr(devattr)->index; - int type; + const struct dell_smm_data *data = drvdata; - type = i8k_get_temp_type(index); - if (type < 0) - return type; - if (type >= ARRAY_SIZE(labels)) - type = ARRAY_SIZE(labels) - 1; - return sprintf(buf, "%s\n", labels[type]); -} + switch (type) { + case hwmon_temp: + switch (attr) { + case hwmon_temp_input: + case hwmon_temp_label: + if (!IS_ERR(data->temp_label[channel])) + return 0444; -static ssize_t i8k_hwmon_temp_show(struct device *dev, - struct device_attribute *devattr, - char *buf) -{ - int index = to_sensor_dev_attr(devattr)->index; - int temp; + break; + default: + break; + } + break; + case hwmon_fan: + if (data->disallow_fan_support) + break; - temp = i8k_get_temp(index); - if (temp < 0) - return temp; - return sprintf(buf, "%d\n", temp * 1000); -} + switch (attr) { + case hwmon_fan_input: + if (i8k_get_fan_speed(data, channel) >= 0) + return 0444; -static ssize_t i8k_hwmon_fan_label_show(struct device *dev, - struct device_attribute *devattr, - char *buf) -{ - struct dell_smm_data *data = dev_get_drvdata(dev); - static const char * const labels[] = { - "Processor Fan", - "Motherboard Fan", - "Video Fan", - "Power Supply Fan", - "Chipset Fan", - "Other Fan", - }; - int index = to_sensor_dev_attr(devattr)->index; - bool dock = false; - int type; + break; + case hwmon_fan_label: + if (!IS_ERR(data->fan_label[channel])) + return 0444; - type = i8k_get_fan_type(data, index); - if (type < 0) - return type; + break; + default: + break; + } + break; + case hwmon_pwm: + if (data->disallow_fan_support) + break; - if (type & 0x10) { - dock = true; - type &= 0x0F; - } + switch (attr) { + case hwmon_pwm_input: + if (i8k_get_fan_status(data, channel) >= 0) + return 0644; - if (type >= ARRAY_SIZE(labels)) - type = (ARRAY_SIZE(labels) - 1); + break; + case hwmon_pwm_enable: + if (data->auto_fan) + return 0644; + + break; + default: + break; + } + break; + default: + break; + } - return sprintf(buf, "%s%s\n", (dock ? "Docking " : ""), labels[type]); + return 0; } -static ssize_t i8k_hwmon_fan_show(struct device *dev, - struct device_attribute *devattr, char *buf) +static int dell_smm_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, int channel, + long *val) { struct dell_smm_data *data = dev_get_drvdata(dev); - int index = to_sensor_dev_attr(devattr)->index; - int fan_speed; + int ret; + + switch (type) { + case hwmon_temp: + switch (attr) { + case hwmon_temp_input: + ret = i8k_get_temp(channel); + if (ret < 0) + return ret; + + *val = ret * 1000; + + return 0; + default: + break; + } + break; + case hwmon_fan: + switch (attr) { + case hwmon_fan_input: + ret = i8k_get_fan_speed(data, channel); + if (ret < 0) + return ret; + + *val = ret; + + return 0; + default: + break; + } + break; + case hwmon_pwm: + switch (attr) { + case hwmon_pwm_input: + ret = i8k_get_fan_status(data, channel); + if (ret < 0) + return ret; + + *val = clamp_val(ret * data->i8k_pwm_mult, 0, 255); + + return 0; + case hwmon_pwm_enable: + *val = data->auto_fan_enable; + + return 0; + default: + break; + } + break; + default: + break; + } - fan_speed = i8k_get_fan_speed(data, index); - if (fan_speed < 0) - return fan_speed; - return sprintf(buf, "%d\n", fan_speed); + return -EOPNOTSUPP; } -static ssize_t i8k_hwmon_pwm_show(struct device *dev, - struct device_attribute *devattr, char *buf) +static int dell_smm_read_string(struct device *dev, enum hwmon_sensor_types type, u32 attr, + int channel, const char **str) { struct dell_smm_data *data = dev_get_drvdata(dev); - int index = to_sensor_dev_attr(devattr)->index; - int status; - status = i8k_get_fan_status(data, index); - if (status < 0) - return -EIO; - return sprintf(buf, "%d\n", clamp_val(status * data->i8k_pwm_mult, 0, 255)); + switch (type) { + case hwmon_temp: + switch (attr) { + case hwmon_temp_label: + *str = data->temp_label[channel]; + return 0; + default: + break; + } + break; + case hwmon_fan: + switch (attr) { + case hwmon_fan_label: + *str = data->fan_label[channel]; + return 0; + default: + break; + } + break; + default: + break; + } + + return -EOPNOTSUPP; } -static ssize_t i8k_hwmon_pwm_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) +static int dell_smm_write(struct device *dev, enum hwmon_sensor_types type, u32 attr, int channel, + long val) { struct dell_smm_data *data = dev_get_drvdata(dev); - int index = to_sensor_dev_attr(attr)->index; - unsigned long val; + unsigned long pwm; + bool enable; int err; - err = kstrtoul(buf, 10, &val); - if (err) - return err; - val = clamp_val(DIV_ROUND_CLOSEST(val, data->i8k_pwm_mult), 0, data->i8k_fan_max); + switch (type) { + case hwmon_pwm: + switch (attr) { + case hwmon_pwm_input: + pwm = clamp_val(DIV_ROUND_CLOSEST(val, data->i8k_pwm_mult), 0, + data->i8k_fan_max); - mutex_lock(&data->i8k_mutex); - err = i8k_set_fan(data, index, val); - mutex_unlock(&data->i8k_mutex); + mutex_lock(&data->i8k_mutex); + err = i8k_set_fan(data, channel, pwm); + mutex_unlock(&data->i8k_mutex); - return err < 0 ? -EIO : count; -} + if (err < 0) + return err; -static ssize_t i8k_hwmon_pwm_enable_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct dell_smm_data *data = dev_get_drvdata(dev); - int err; - bool enable; - unsigned long val; + return 0; + case hwmon_pwm_enable: + if (!val) + return -EINVAL; - if (!data->auto_fan) - return -ENODEV; + if (val == 1) + enable = false; + else + enable = true; - err = kstrtoul(buf, 10, &val); - if (err) - return err; + mutex_lock(&data->i8k_mutex); + err = i8k_enable_fan_auto_mode(data, enable); + mutex_unlock(&data->i8k_mutex); - if (val == 1) - enable = false; - else if (val == 2) - enable = true; - else - return -EINVAL; + if (err < 0) + return err; - mutex_lock(&data->i8k_mutex); - err = i8k_enable_fan_auto_mode(data, enable); - mutex_unlock(&data->i8k_mutex); + data->auto_fan_enable = val; - return err ? err : count; + return 0; + default: + break; + } + break; + default: + break; + } + + return -EOPNOTSUPP; } -static SENSOR_DEVICE_ATTR_RO(temp1_input, i8k_hwmon_temp, 0); -static SENSOR_DEVICE_ATTR_RO(temp1_label, i8k_hwmon_temp_label, 0); -static SENSOR_DEVICE_ATTR_RO(temp2_input, i8k_hwmon_temp, 1); -static SENSOR_DEVICE_ATTR_RO(temp2_label, i8k_hwmon_temp_label, 1); -static SENSOR_DEVICE_ATTR_RO(temp3_input, i8k_hwmon_temp, 2); -static SENSOR_DEVICE_ATTR_RO(temp3_label, i8k_hwmon_temp_label, 2); -static SENSOR_DEVICE_ATTR_RO(temp4_input, i8k_hwmon_temp, 3); -static SENSOR_DEVICE_ATTR_RO(temp4_label, i8k_hwmon_temp_label, 3); -static SENSOR_DEVICE_ATTR_RO(temp5_input, i8k_hwmon_temp, 4); -static SENSOR_DEVICE_ATTR_RO(temp5_label, i8k_hwmon_temp_label, 4); -static SENSOR_DEVICE_ATTR_RO(temp6_input, i8k_hwmon_temp, 5); -static SENSOR_DEVICE_ATTR_RO(temp6_label, i8k_hwmon_temp_label, 5); -static SENSOR_DEVICE_ATTR_RO(temp7_input, i8k_hwmon_temp, 6); -static SENSOR_DEVICE_ATTR_RO(temp7_label, i8k_hwmon_temp_label, 6); -static SENSOR_DEVICE_ATTR_RO(temp8_input, i8k_hwmon_temp, 7); -static SENSOR_DEVICE_ATTR_RO(temp8_label, i8k_hwmon_temp_label, 7); -static SENSOR_DEVICE_ATTR_RO(temp9_input, i8k_hwmon_temp, 8); -static SENSOR_DEVICE_ATTR_RO(temp9_label, i8k_hwmon_temp_label, 8); -static SENSOR_DEVICE_ATTR_RO(temp10_input, i8k_hwmon_temp, 9); -static SENSOR_DEVICE_ATTR_RO(temp10_label, i8k_hwmon_temp_label, 9); -static SENSOR_DEVICE_ATTR_RO(fan1_input, i8k_hwmon_fan, 0); -static SENSOR_DEVICE_ATTR_RO(fan1_label, i8k_hwmon_fan_label, 0); -static SENSOR_DEVICE_ATTR_RW(pwm1, i8k_hwmon_pwm, 0); -static SENSOR_DEVICE_ATTR_WO(pwm1_enable, i8k_hwmon_pwm_enable, 0); -static SENSOR_DEVICE_ATTR_RO(fan2_input, i8k_hwmon_fan, 1); -static SENSOR_DEVICE_ATTR_RO(fan2_label, i8k_hwmon_fan_label, 1); -static SENSOR_DEVICE_ATTR_RW(pwm2, i8k_hwmon_pwm, 1); -static SENSOR_DEVICE_ATTR_RO(fan3_input, i8k_hwmon_fan, 2); -static SENSOR_DEVICE_ATTR_RO(fan3_label, i8k_hwmon_fan_label, 2); -static SENSOR_DEVICE_ATTR_RW(pwm3, i8k_hwmon_pwm, 2); - -static struct attribute *i8k_attrs[] = { - &sensor_dev_attr_temp1_input.dev_attr.attr, /* 0 */ - &sensor_dev_attr_temp1_label.dev_attr.attr, /* 1 */ - &sensor_dev_attr_temp2_input.dev_attr.attr, /* 2 */ - &sensor_dev_attr_temp2_label.dev_attr.attr, /* 3 */ - &sensor_dev_attr_temp3_input.dev_attr.attr, /* 4 */ - &sensor_dev_attr_temp3_label.dev_attr.attr, /* 5 */ - &sensor_dev_attr_temp4_input.dev_attr.attr, /* 6 */ - &sensor_dev_attr_temp4_label.dev_attr.attr, /* 7 */ - &sensor_dev_attr_temp5_input.dev_attr.attr, /* 8 */ - &sensor_dev_attr_temp5_label.dev_attr.attr, /* 9 */ - &sensor_dev_attr_temp6_input.dev_attr.attr, /* 10 */ - &sensor_dev_attr_temp6_label.dev_attr.attr, /* 11 */ - &sensor_dev_attr_temp7_input.dev_attr.attr, /* 12 */ - &sensor_dev_attr_temp7_label.dev_attr.attr, /* 13 */ - &sensor_dev_attr_temp8_input.dev_attr.attr, /* 14 */ - &sensor_dev_attr_temp8_label.dev_attr.attr, /* 15 */ - &sensor_dev_attr_temp9_input.dev_attr.attr, /* 16 */ - &sensor_dev_attr_temp9_label.dev_attr.attr, /* 17 */ - &sensor_dev_attr_temp10_input.dev_attr.attr, /* 18 */ - &sensor_dev_attr_temp10_label.dev_attr.attr, /* 19 */ - &sensor_dev_attr_fan1_input.dev_attr.attr, /* 20 */ - &sensor_dev_attr_fan1_label.dev_attr.attr, /* 21 */ - &sensor_dev_attr_pwm1.dev_attr.attr, /* 22 */ - &sensor_dev_attr_pwm1_enable.dev_attr.attr, /* 23 */ - &sensor_dev_attr_fan2_input.dev_attr.attr, /* 24 */ - &sensor_dev_attr_fan2_label.dev_attr.attr, /* 25 */ - &sensor_dev_attr_pwm2.dev_attr.attr, /* 26 */ - &sensor_dev_attr_fan3_input.dev_attr.attr, /* 27 */ - &sensor_dev_attr_fan3_label.dev_attr.attr, /* 28 */ - &sensor_dev_attr_pwm3.dev_attr.attr, /* 29 */ +static const struct hwmon_ops dell_smm_ops = { + .is_visible = dell_smm_is_visible, + .read = dell_smm_read, + .read_string = dell_smm_read_string, + .write = dell_smm_write, +}; + +static const struct hwmon_channel_info *dell_smm_info[] = { + HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ), + HWMON_CHANNEL_INFO(temp, + HWMON_T_INPUT | HWMON_T_LABEL, + HWMON_T_INPUT | HWMON_T_LABEL, + HWMON_T_INPUT | HWMON_T_LABEL, + HWMON_T_INPUT | HWMON_T_LABEL, + HWMON_T_INPUT | HWMON_T_LABEL, + HWMON_T_INPUT | HWMON_T_LABEL, + HWMON_T_INPUT | HWMON_T_LABEL, + HWMON_T_INPUT | HWMON_T_LABEL, + HWMON_T_INPUT | HWMON_T_LABEL, + HWMON_T_INPUT | HWMON_T_LABEL + ), + HWMON_CHANNEL_INFO(fan, + HWMON_F_INPUT | HWMON_F_LABEL, + HWMON_F_INPUT | HWMON_F_LABEL, + HWMON_F_INPUT | HWMON_F_LABEL + ), + HWMON_CHANNEL_INFO(pwm, + HWMON_PWM_INPUT | HWMON_PWM_ENABLE, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT + ), NULL }; -static umode_t i8k_is_visible(struct kobject *kobj, struct attribute *attr, - int index) -{ - struct device *dev = kobj_to_dev(kobj); - struct dell_smm_data *data = dev_get_drvdata(dev); +static const struct hwmon_chip_info dell_smm_chip_info = { + .ops = &dell_smm_ops, + .info = dell_smm_info, +}; - if (data->disallow_fan_support && index >= 20) - return 0; - if (data->disallow_fan_type_call && - (index == 21 || index == 25 || index == 28)) - return 0; - if (index >= 0 && index <= 1 && - !(data->i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP1)) - return 0; - if (index >= 2 && index <= 3 && - !(data->i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP2)) - return 0; - if (index >= 4 && index <= 5 && - !(data->i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP3)) - return 0; - if (index >= 6 && index <= 7 && - !(data->i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP4)) - return 0; - if (index >= 8 && index <= 9 && - !(data->i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP5)) - return 0; - if (index >= 10 && index <= 11 && - !(data->i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP6)) - return 0; - if (index >= 12 && index <= 13 && - !(data->i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP7)) - return 0; - if (index >= 14 && index <= 15 && - !(data->i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP8)) - return 0; - if (index >= 16 && index <= 17 && - !(data->i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP9)) - return 0; - if (index >= 18 && index <= 19 && - !(data->i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP10)) - return 0; +static const char __init *dell_smm_temp_label(int channel) +{ + int type = i8k_get_temp_type(channel); - if (index >= 20 && index <= 23 && - !(data->i8k_hwmon_flags & I8K_HWMON_HAVE_FAN1)) - return 0; - if (index >= 24 && index <= 26 && - !(data->i8k_hwmon_flags & I8K_HWMON_HAVE_FAN2)) - return 0; - if (index >= 27 && index <= 29 && - !(data->i8k_hwmon_flags & I8K_HWMON_HAVE_FAN3)) - return 0; + if (type < 0) + return ERR_PTR(type); - if (index == 23 && !data->auto_fan) - return 0; + if (type >= ARRAY_SIZE(temp_labels)) + type = ARRAY_SIZE(temp_labels) - 1; - return attr->mode; + return temp_labels[type]; } -static const struct attribute_group i8k_group = { - .attrs = i8k_attrs, - .is_visible = i8k_is_visible, -}; -__ATTRIBUTE_GROUPS(i8k); +static const char __init *dell_smm_fan_label(struct dell_smm_data *data, int channel) +{ + bool dock = false; + int type = i8k_get_fan_type(data, channel); + + if (type < 0) + return ERR_PTR(type); + + if (type & 0x10) { + dock = true; + type &= 0x0F; + } + + if (type >= ARRAY_SIZE(fan_labels)) + type = ARRAY_SIZE(fan_labels) - 1; + + return dock ? docking_labels[type] : fan_labels[type]; +} static int __init dell_smm_init_hwmon(struct device *dev) { struct dell_smm_data *data = dev_get_drvdata(dev); - struct device *i8k_hwmon_dev; - int err; + struct device *dell_smm_hwmon_dev; + int i; + + for (i = 0; i < DELL_SMM_NO_TEMP; i++) + data->temp_label[i] = dell_smm_temp_label(i); + + for (i = 0; i < DELL_SMM_NO_FANS; i++) + data->fan_label[i] = dell_smm_fan_label(data, i); + + dell_smm_hwmon_dev = devm_hwmon_device_register_with_info(dev, "dell_smm", data, + &dell_smm_chip_info, NULL); - /* CPU temperature attributes, if temperature type is OK */ - err = i8k_get_temp_type(0); - if (err >= 0) - data->i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP1; - /* check for additional temperature sensors */ - err = i8k_get_temp_type(1); - if (err >= 0) - data->i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP2; - err = i8k_get_temp_type(2); - if (err >= 0) - data->i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP3; - err = i8k_get_temp_type(3); - if (err >= 0) - data->i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP4; - err = i8k_get_temp_type(4); - if (err >= 0) - data->i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP5; - err = i8k_get_temp_type(5); - if (err >= 0) - data->i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP6; - err = i8k_get_temp_type(6); - if (err >= 0) - data->i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP7; - err = i8k_get_temp_type(7); - if (err >= 0) - data->i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP8; - err = i8k_get_temp_type(8); - if (err >= 0) - data->i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP9; - err = i8k_get_temp_type(9); - if (err >= 0) - data->i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP10; - - /* First fan attributes, if fan status or type is OK */ - err = i8k_get_fan_status(data, 0); - if (err < 0) - err = i8k_get_fan_type(data, 0); - if (err >= 0) - data->i8k_hwmon_flags |= I8K_HWMON_HAVE_FAN1; - - /* Second fan attributes, if fan status or type is OK */ - err = i8k_get_fan_status(data, 1); - if (err < 0) - err = i8k_get_fan_type(data, 1); - if (err >= 0) - data->i8k_hwmon_flags |= I8K_HWMON_HAVE_FAN2; - - /* Third fan attributes, if fan status or type is OK */ - err = i8k_get_fan_status(data, 2); - if (err < 0) - err = i8k_get_fan_type(data, 2); - if (err >= 0) - data->i8k_hwmon_flags |= I8K_HWMON_HAVE_FAN3; - - i8k_hwmon_dev = devm_hwmon_device_register_with_groups(dev, "dell_smm", data, i8k_groups); - - return PTR_ERR_OR_ZERO(i8k_hwmon_dev); + return PTR_ERR_OR_ZERO(dell_smm_hwmon_dev); } struct i8k_config_data { @@ -1240,9 +1204,7 @@ static int __init dell_smm_probe(struct platform_device *pdev) mutex_init(&data->i8k_mutex); data->i8k_fan_mult = I8K_FAN_MULT; data->i8k_fan_max = I8K_FAN_HIGH; - data->types[0] = INT_MIN; - data->types[1] = INT_MIN; - data->types[2] = INT_MIN; + data->auto_fan_enable = 2; platform_set_drvdata(pdev, data); if (dmi_check_system(i8k_blacklist_fan_support_dmi_table)) { From patchwork Fri May 28 17:37:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 12287323 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34D6CC4708C for ; Fri, 28 May 2021 17:37:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1BE0B613F0 for ; Fri, 28 May 2021 17:37:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229463AbhE1Rj0 (ORCPT ); Fri, 28 May 2021 13:39:26 -0400 Received: from mout.gmx.net ([212.227.17.21]:55667 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229493AbhE1Rj0 (ORCPT ); Fri, 28 May 2021 13:39:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1622223455; bh=KuMTUIIsIrpb4G+jJ2PFkRLp1LBaTpZJra+7FRfTOa8=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=ayNQCZyVH6N5PMhS1zLHwRCEEkl+okS8EeoDeBnMUnw3ff7qHBsyD6LkrXOzSp2PC 11kyVeY8yufbkX8CpATzODsiuF/exJDgyterSKq2uHN9LGI9uyY3cpzzJ1uIJFbIlI i/9sEkF/s9GL2sCxaPOzGCUeQm3Hx9J18J7MdTnI= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from esprimo-mx.fritz.box ([79.242.180.99]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MulqN-1lVZ5339Rj-00rmvh; Fri, 28 May 2021 19:37:34 +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 6/6] hwmon: (dell-smm-hwmon) Update docs Date: Fri, 28 May 2021 19:37:16 +0200 Message-Id: <20210528173716.10975-7-W_Armin@gmx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210528173716.10975-1-W_Armin@gmx.de> References: <20210528173716.10975-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:acdOMRJjFjil+MS983GRums+e2HdOo5jCncNDkJv9w3M75RQ7pm wByJGLaCuUq7zwhThH5duexvmJkcC2XT2A2VScuUoUeX8/s4lkM2yDHghXvWfDn6BnAuad6 ZDfn0CB+2FSGTM4FwYK+SlByczEzHBg+XepMTzHcNr7fDpV3A8mkxvZyZca8EasKm5M9/W7 PfKXN9RDqT9j7237HOcug== X-UI-Out-Filterresults: notjunk:1;V03:K0:8uQ4UMUU5kE=:VC3xa+6dUNntTVYLpEs1EK a99R2Twk5zZoduVQ0g4mOG3WSP4hcqHcpRQS+uSNnw3yKTTf573hZz7Tm0pSawTUAJIuja/7x Djk4pbji3lEx1UzzHXWuXWoEKSlLTGX/QlUK8x2c3CvHKaknjJtjFo2YNRfAfhRaCntFNRh8f st9+vPXLhPVHD2WcafW2oisyYjbeRJGVcz3YYvKdqq/eGdxbfZyQalqa0BnVMLptoykHBDggl TCJKdr4qgxjKKfS5xt3pJ7QVDCB27T7L7AMTMdb4u0QeLKmU0l76wnO+npxxd/lPBjgvJbGZu SwQe21pL5wPo5YbcIPvkDpG12JCvEry5vx6KdCAWzOKCNbuQVR4me1WihZ6aYAjcvgWkSY+wn mPsIIo+z2gzdhiFmKpRe2+aZFf/6bxUWkv2tS6gaaq7OCqgOcryyUM0GhNup7+0ZgJEGJ1UnA zhnCdi9fOO+SpenZQXD0nRsYd6YCayTwLmRBEqZWUwRjdc0q/KbUS8D5sE0kz2quXw+wUB3Rz mL73iJlH3hRQKD82K/6p176sQi0QxFXs401gKytUM5wTKiuGGAKsJOd7WLndQXfHk/MOTfwxi moSzI2/UEIrUvfYYB5r7kBb08yZ58XeveL07G44x+s9nbn9aF0Hl5xqt0KFALeJPNmjkYZWe6 yj03KulrRS+dr8Qkt2EtMCCfUYVcpwJx7H8LsAcZzFYgJmj5RJr3JdmWPM/CY+cwRzCxlTekn b5IECxy2EwJnYE0hryG0nx4OPiXdy4lyjgpOD630TMcRrhItyIQCsAd7aSnqbXniB5If19Tg/ owTSBh9AfWFztVDCrX/TyhMDu4s/DplTQFSC3B9sqdisYgq394JRwmB7cI4xC0SmDU6nKy4ul gGNS0XHpcxNGbXcqCeSZT565cFCTwIbHkuQE1AQXSqBIaZZn2fEcQfuN9qlD2mM3jF4GznX+H w9NB9OOqjMygZv43FQFLsoPEPWGwHUxuTgDhV0QsfFsiG0DZizDJaWE80RD/AumzGy+vCmt56 McMbFILTKOsNESQ29jOgvxpT3eGeRDgZPcdGhOj/rynXi/30ihER1l8xSLVRvoTVxK7VXwTQz HH0pQOEcv1vBLWfwW3W8YEFUT1IPiC88STyame1cSfKhKrB1YInNTFDdjl1I1XRXT83IJsxlX R/n9Zi5v7jfU0ZCFL3uhYuQ2OsdUbxf5xOjKzXAPrMJ0GFsP9YsnkDD+MLYPunDeYNwFc= Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Armin Wolf pwm1_enable is now readable too. Signed-off-by: Armin Wolf --- Documentation/hwmon/dell-smm-hwmon.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 diff --git a/Documentation/hwmon/dell-smm-hwmon.rst b/Documentation/hwmon/dell-smm-hwmon.rst index 3bf77a5df995..d6fe9b8a2c40 100644 --- a/Documentation/hwmon/dell-smm-hwmon.rst +++ b/Documentation/hwmon/dell-smm-hwmon.rst @@ -35,7 +35,7 @@ Name Perm Description fan[1-3]_input RO Fan speed in RPM. fan[1-3]_label RO Fan label. pwm[1-3] RW Control the fan PWM duty-cycle. -pwm1_enable WO Enable or disable automatic BIOS fan +pwm1_enable RW Enable or disable automatic BIOS fan control (not supported on all laptops, see below for details). temp[1-10]_input RO Temperature reading in milli-degrees