From patchwork Thu Sep 20 13:45:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10607775 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 19F97157B for ; Thu, 20 Sep 2018 13:45:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0015D2D741 for ; Thu, 20 Sep 2018 13:45:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E7B9F2D74D; Thu, 20 Sep 2018 13:45:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,URIBL_SBL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5AC212D741 for ; Thu, 20 Sep 2018 13:45:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727710AbeITT3U (ORCPT ); Thu, 20 Sep 2018 15:29:20 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:35165 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727242AbeITT3U (ORCPT ); Thu, 20 Sep 2018 15:29:20 -0400 Received: by mail-pl1-f195.google.com with SMTP id g2-v6so4389450plo.2 for ; Thu, 20 Sep 2018 06:45:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=wkjR9+nQdrJACBFMmtoNDV7f+Ynf6Nvbn0UuPGd5MA4=; b=M490evZIFmLu74Yj+uPquq+pm0rfeGfzZltu161PSNQvPM2OMd2aw9tiZf1Fslys8l Lr1lyCbxBQo4w/8ez9An/hKR0re3lakoyMy1kxXnPR8P/doHJeY48eGMgbEmWCc5SLOm LoFNEYm49j12jy+JOnIlXd3ZUttCrGJs0eUDPKEDY8jpU/Id2DuaZhFc1Jw03P5ZgK2b LI8q0cNj5O35horMWMXyvBhQo5OIdhBuTXU53FjPRneE5CY4qdxCM7WO3WIQViFE7Cl3 A0Py2Gonc13F5A3pSLs+wNiiNMpIIrn+2vBBAKsngkk7HIZxUSU1Qh4fxE4TrJ1T5MUb OOGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=wkjR9+nQdrJACBFMmtoNDV7f+Ynf6Nvbn0UuPGd5MA4=; b=NOBV/nGxK1A3VG/f4yVKHcIlpV2Bqgjk0eKka8PI9qYDjlTqubSfjno0ulTTJJulNX suqWkjlDKt5OzrYSUly8FDbP5we+CxzlgiD48QdVRVl/rvdhZ7oYwozV1Dy8nrXDa7k1 /u3CeHFnSrqDqAj8iMlZQKQC5z+0Yve8NImSXmvX0QUMMQBMrMXoiaGNDCsypCOyL8NI 918Iv4P61xtWlHgy+ugND7VuvbeM45bw6LJWIFmrq4YHkxFrCoHFBhvZHY4PkpBvBfEb fA+GYrhOYfSTYTMmq9WulaNf74pb0XedMEaSHkVQPrVizqNbC6ePp8dd6hBo0in5W14d /aUA== X-Gm-Message-State: APzg51CMd+6ECY6N78clScp6u2tsquIP4eqjV82UlmBQpaP0Bzoo8TKa V9L1mGSL9atu5DnzQPDyLplRqk7p X-Google-Smtp-Source: ANB0VdbWDmb5oWjwO4FDzws+IQ0h73onXzzrXLPcDtBR/sFvjv1wacQZnSZWwRJIby41hCl6VJ6umw== X-Received: by 2002:a17:902:d24:: with SMTP id 33-v6mr39092828plu.211.1537451146110; Thu, 20 Sep 2018 06:45:46 -0700 (PDT) Received: from localhost (108-223-40-66.lightspeed.sntcca.sbcglobal.net. [108.223.40.66]) by smtp.gmail.com with ESMTPSA id u13-v6sm33066125pfn.59.2018.09.20.06.45.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Sep 2018 06:45:45 -0700 (PDT) From: Guenter Roeck To: Hardware Monitoring Cc: Jean Delvare , Guenter Roeck Subject: [PATCH 01/13] hwmon: (nct6775) Rename configuration register variables Date: Thu, 20 Sep 2018 06:45:29 -0700 Message-Id: <1537451141-27242-1-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use variable names from chip datasheets (crXX) instead of regval_XX for configuration register variables. This is shorter and, together with subsequent changes, makes the code easier to read. No functional change. Signed-off-by: Guenter Roeck --- drivers/hwmon/nct6775.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c index 2a9fc8c9fb9e..7a3a1d59553e 100644 --- a/drivers/hwmon/nct6775.c +++ b/drivers/hwmon/nct6775.c @@ -3497,7 +3497,7 @@ nct6775_check_fan_inputs(struct nct6775_data *data) pwm3pin = regval & 0x08; } else { /* NCT6779D, NCT6791D, NCT6792D, NCT6793D, NCT6795D, NCT6796D */ - int regval_1b, regval_2a, regval_2f; + int cr1b, cr2a, cr2f; bool dsw_en; regval = superio_inb(sioreg, 0x1c); @@ -3520,20 +3520,20 @@ nct6775_check_fan_inputs(struct nct6775_data *data) case nct6793: case nct6795: case nct6796: - regval_1b = superio_inb(sioreg, 0x1b); - regval_2a = superio_inb(sioreg, 0x2a); - regval_2f = superio_inb(sioreg, 0x2f); - dsw_en = regval_2f & BIT(3); + cr1b = superio_inb(sioreg, 0x1b); + cr2a = superio_inb(sioreg, 0x2a); + cr2f = superio_inb(sioreg, 0x2f); + dsw_en = cr2f & BIT(3); if (!pwm5pin) pwm5pin = regval & BIT(7); if (!fan5pin) - fan5pin = regval_1b & BIT(5); + fan5pin = cr1b & BIT(5); superio_select(sioreg, NCT6775_LD_12); if (data->kind != nct6796) { - int regval_eb = superio_inb(sioreg, 0xeb); + int creb = superio_inb(sioreg, 0xeb); if (!dsw_en) { fan6pin = regval & BIT(1); @@ -3541,33 +3541,33 @@ nct6775_check_fan_inputs(struct nct6775_data *data) } if (!fan5pin) - fan5pin = regval_eb & BIT(5); + fan5pin = creb & BIT(5); if (!pwm5pin) - pwm5pin = (regval_eb & BIT(4)) && - !(regval_2a & BIT(0)); + pwm5pin = (creb & BIT(4)) && + !(cr2a & BIT(0)); if (!fan6pin) - fan6pin = regval_eb & BIT(3); + fan6pin = creb & BIT(3); if (!pwm6pin) - pwm6pin = regval_eb & BIT(2); + pwm6pin = creb & BIT(2); } if (data->kind == nct6795 || data->kind == nct6796) { - int regval_ed = superio_inb(sioreg, 0xed); + int cred = superio_inb(sioreg, 0xed); if (!fan6pin) - fan6pin = (regval_2a & BIT(4)) && - (!dsw_en || (regval_ed & BIT(4))); + fan6pin = (cr2a & BIT(4)) && + (!dsw_en || (cred & BIT(4))); if (!pwm6pin) - pwm6pin = (regval_2a & BIT(3)) && - (regval_ed & BIT(2)); + pwm6pin = (cr2a & BIT(3)) && + (cred & BIT(2)); } if (data->kind == nct6796) { - int regval_1d = superio_inb(sioreg, 0x1d); - int regval_2b = superio_inb(sioreg, 0x2b); + int cr1d = superio_inb(sioreg, 0x1d); + int cr2b = superio_inb(sioreg, 0x2b); - fan7pin = !(regval_2b & BIT(2)); - pwm7pin = !(regval_1d & (BIT(2) | BIT(3))); + fan7pin = !(cr2b & BIT(2)); + pwm7pin = !(cr1d & (BIT(2) | BIT(3))); } break; From patchwork Thu Sep 20 13:45:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10607777 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9089D157B for ; Thu, 20 Sep 2018 13:45:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 817C02D741 for ; Thu, 20 Sep 2018 13:45:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 758802D74D; Thu, 20 Sep 2018 13:45:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,URIBL_SBL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14B6A2D741 for ; Thu, 20 Sep 2018 13:45:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728444AbeITT3W (ORCPT ); Thu, 20 Sep 2018 15:29:22 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:39738 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727242AbeITT3W (ORCPT ); Thu, 20 Sep 2018 15:29:22 -0400 Received: by mail-pf1-f195.google.com with SMTP id j8-v6so4403790pff.6 for ; Thu, 20 Sep 2018 06:45:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=U/srKjTxSDDT1c9eO+/HQds52WZ76uFEnnTW9+eUqRQ=; b=D8NKZYwHkiNYxFfBd3GEv/SMYJHFpt0givkDxn6FFl2ouGuU+mcvvndaw7Qf3ddtDX MgkskoosAIugrr6PGam5tc62t+zfAQqJyD5hluuhRHXR+qJGC+Na0nRJKUcmGV+0e80C 8XVPXGnrZtV5jmzYaGyKYYoft2PWMc6zYM7pl15eDDGdQt9ZqRP1ms+WyEfSmBjL0xnA czI46Kmcvvt2SEwK0Ni9It2vXXKpAoqI1nTJlQ9eONmnzPdZZ0zP3bl461VkCeKzIitv AgWKdWlmE80GJ24VmImJeOxhI6lxozgLz5R4xqsscHkFre/9lruODtyW68xnat1TMIBk ARgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=U/srKjTxSDDT1c9eO+/HQds52WZ76uFEnnTW9+eUqRQ=; b=cf+RhfXFTJHBtvGm+kuH6zCV+sbJE7xZBA82uV+om84D1oZjkE7BUiSflm0Jt5Nyh5 H4LN35GhUdTlirzfh944bz7PQkVOe5pP/FkfXQuZOo0jOkBcoxm9Mi0Ac94RkQzmfyNu d3sh8hbqX8spWsuierFVJq21dI5ieeUJWvb5E4PeUa+kp9+1iimckZfmD35fQYr4U2SF g3MJEHjZs74G9syiQPmtwMdrCFQsRfiPsUV3KPM8BpBRdzQM35zZCaEzLlgmk0RbaHG9 8kvszvAP11SlnxZNUWpDT5qZ9MFoLkuduFfRuhDhSbn5UIUPcqXJ1nb6hitV8HJq+CWq ZZkg== X-Gm-Message-State: APzg51CatYamImnvo94E1CDXiXTm1OGIo8sIfknybDi272s1XZgZv3uy LjJWOiQwAbammWoB9UiEtz9aj9v5 X-Google-Smtp-Source: ANB0VdbrvtYXYn0UyOPmnxUyswRpLHpI/qN4JFw4/3JPDnByPcBN0ShgrMJ3b5OWCcKGFRykX1Wuyg== X-Received: by 2002:a63:be4a:: with SMTP id g10-v6mr35679858pgo.378.1537451147650; Thu, 20 Sep 2018 06:45:47 -0700 (PDT) Received: from localhost (108-223-40-66.lightspeed.sntcca.sbcglobal.net. [108.223.40.66]) by smtp.gmail.com with ESMTPSA id 1-v6sm43360908pfm.145.2018.09.20.06.45.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Sep 2018 06:45:46 -0700 (PDT) From: Guenter Roeck To: Hardware Monitoring Cc: Jean Delvare , Guenter Roeck Subject: [PATCH 02/13] hwmon: (nct6775) Replace 'regval' with variables named after config registers Date: Thu, 20 Sep 2018 06:45:30 -0700 Message-Id: <1537451141-27242-2-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537451141-27242-1-git-send-email-linux@roeck-us.net> References: <1537451141-27242-1-git-send-email-linux@roeck-us.net> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Using variables named after configuration registers makes it more obvious which configuration register value is used, especially if more than one configuration register value is used to determine a configuration detail. No functional change. Signed-off-by: Guenter Roeck --- drivers/hwmon/nct6775.c | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c index 7a3a1d59553e..bd1c4772994a 100644 --- a/drivers/hwmon/nct6775.c +++ b/drivers/hwmon/nct6775.c @@ -3436,7 +3436,8 @@ nct6775_check_fan_inputs(struct nct6775_data *data) bool pwm3pin = false, pwm4pin = false, pwm5pin = false; bool pwm6pin = false, pwm7pin = false; int sioreg = data->sioreg; - int regval; + int cr24; + int cr2c; /* Store SIO_REG_ENABLE for use during resume */ superio_select(sioreg, NCT6775_LD_HWM); @@ -3444,10 +3445,10 @@ nct6775_check_fan_inputs(struct nct6775_data *data) /* fan4 and fan5 share some pins with the GPIO and serial flash */ if (data->kind == nct6775) { - regval = superio_inb(sioreg, 0x2c); + cr2c = superio_inb(sioreg, 0x2c); - fan3pin = regval & BIT(6); - pwm3pin = regval & BIT(7); + fan3pin = cr2c & BIT(6); + pwm3pin = cr2c & BIT(7); /* On NCT6775, fan4 shares pins with the fdc interface */ fan4pin = !(superio_inb(sioreg, 0x2A) & 0x80); @@ -3492,30 +3493,32 @@ nct6775_check_fan_inputs(struct nct6775_data *data) fan4min = fan4pin; pwm3pin = fan3pin; } else if (data->kind == nct6106) { - regval = superio_inb(sioreg, 0x24); - fan3pin = !(regval & 0x80); - pwm3pin = regval & 0x08; + cr24 = superio_inb(sioreg, 0x24); + fan3pin = !(cr24 & 0x80); + pwm3pin = cr24 & 0x08; } else { /* NCT6779D, NCT6791D, NCT6792D, NCT6793D, NCT6795D, NCT6796D */ int cr1b, cr2a, cr2f; + int cr1c; + int cr2d; bool dsw_en; - regval = superio_inb(sioreg, 0x1c); + cr1c = superio_inb(sioreg, 0x1c); - fan3pin = !(regval & BIT(5)); - fan4pin = !(regval & BIT(6)); - fan5pin = !(regval & BIT(7)); + fan3pin = !(cr1c & BIT(5)); + fan4pin = !(cr1c & BIT(6)); + fan5pin = !(cr1c & BIT(7)); - pwm3pin = !(regval & BIT(0)); - pwm4pin = !(regval & BIT(1)); - pwm5pin = !(regval & BIT(2)); + pwm3pin = !(cr1c & BIT(0)); + pwm4pin = !(cr1c & BIT(1)); + pwm5pin = !(cr1c & BIT(2)); - regval = superio_inb(sioreg, 0x2d); + cr2d = superio_inb(sioreg, 0x2d); switch (data->kind) { case nct6791: case nct6792: - fan6pin = regval & BIT(1); - pwm6pin = regval & BIT(0); + fan6pin = cr2d & BIT(1); + pwm6pin = cr2d & BIT(0); break; case nct6793: case nct6795: @@ -3526,7 +3529,7 @@ nct6775_check_fan_inputs(struct nct6775_data *data) dsw_en = cr2f & BIT(3); if (!pwm5pin) - pwm5pin = regval & BIT(7); + pwm5pin = cr2d & BIT(7); if (!fan5pin) fan5pin = cr1b & BIT(5); @@ -3536,8 +3539,8 @@ nct6775_check_fan_inputs(struct nct6775_data *data) int creb = superio_inb(sioreg, 0xeb); if (!dsw_en) { - fan6pin = regval & BIT(1); - pwm6pin = regval & BIT(0); + fan6pin = cr2d & BIT(1); + pwm6pin = cr2d & BIT(0); } if (!fan5pin) From patchwork Thu Sep 20 13:45:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10607779 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D1A996CB for ; Thu, 20 Sep 2018 13:45:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1A272D741 for ; Thu, 20 Sep 2018 13:45:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B60952D74D; Thu, 20 Sep 2018 13:45:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,URIBL_SBL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55A952D741 for ; Thu, 20 Sep 2018 13:45:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730758AbeITT3X (ORCPT ); Thu, 20 Sep 2018 15:29:23 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:37639 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727242AbeITT3X (ORCPT ); Thu, 20 Sep 2018 15:29:23 -0400 Received: by mail-pg1-f193.google.com with SMTP id 2-v6so4473371pgo.4 for ; Thu, 20 Sep 2018 06:45:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=wEGprfwjzCgPgiZFGXQRLh6FKaBN5UIhRejpyc1LPuQ=; b=PXt1cEhr61EdbnGi/6ZQgYsKe+1xe3yT5y7sQtJQfo60QazV1X6dVvDzCzthF+3ZWH 3SLo6V0OkJ7gDuH1CQSXAO9L0fMru1z67jZywRp7qb/dwJ4o2nmxU5wKiO51p5HQUo0B y+266PfVTEMaYDO14/pVFVRXNFBoL0+66p0a0qP5ccElfWJ79/yfnR1wmgTN1Rf/e3bL R3Xta3T9hydf5zU4sUGyjfps1h7ZGd3LwbPEmi756PnN1rQ+52QnJ3KrD5hqoALsQ1VJ pr65JU+s7wwXwNaptTpXNViCOm26ucPY31/xJReyW0HqMPhmHk5O3pF12kEtGbL9+jtu 0T1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=wEGprfwjzCgPgiZFGXQRLh6FKaBN5UIhRejpyc1LPuQ=; b=WXukj26F+iknIH+CrKCNOvqLMKdzUrjBTkt5knkRNVReyQ18TPCocvQJHBEzuYd/Hw udndg6MVhz4Azr4pivPz9nQ/pLTl7+MtagNkBWTW7GioxjHXJs32NkCvOxIr1rEekgtl UUGUX4FAueu00ykWBNnbwjCAmJrouYGH+yhEzVPchps9twEcB4FGYY5glijz0qvHco1v VGuQ6xTPKFeqn/+NCSDpgLR9ABc4zADGkVvpFa2nYFauLXtLFJAMdiUsUaeQYJ97LLBs 6gusn4palMq+7SzJ6SRihNPoCNhy1GMODgZDsGbIxsDgMINkxe4Go8RFYX2lPvQkfmvy +jrw== X-Gm-Message-State: APzg51BZAEFYuNUTc5Ds7SIpgc2QjuaSp2WQkILDi7VTTFWTpMRN6d29 NzjT1Faa9KnjufRQSBErlCL2xMu7 X-Google-Smtp-Source: ANB0VdYPPfU2QK3/naPs0D3OgFsX5gr8tB7klEZ6pu8JCHATuSTRm2PJIY/jO2jAc5NXRaBGjImZDA== X-Received: by 2002:a63:b104:: with SMTP id r4-v6mr1282031pgf.442.1537451149005; Thu, 20 Sep 2018 06:45:49 -0700 (PDT) Received: from localhost (108-223-40-66.lightspeed.sntcca.sbcglobal.net. [108.223.40.66]) by smtp.gmail.com with ESMTPSA id w5-v6sm28880610pfn.44.2018.09.20.06.45.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Sep 2018 06:45:48 -0700 (PDT) From: Guenter Roeck To: Hardware Monitoring Cc: Jean Delvare , Guenter Roeck Subject: [PATCH 03/13] hwmon: (nct6775) Move config variable declarations and initializations Date: Thu, 20 Sep 2018 06:45:31 -0700 Message-Id: <1537451141-27242-3-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537451141-27242-1-git-send-email-linux@roeck-us.net> References: <1537451141-27242-1-git-send-email-linux@roeck-us.net> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Group configuration variable declarations and initialization together. While this results in reading more registers than necessary for a given chip, it improves code readability and simplifies extending the code. Signed-off-by: Guenter Roeck --- drivers/hwmon/nct6775.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c index bd1c4772994a..aa8a44608ca3 100644 --- a/drivers/hwmon/nct6775.c +++ b/drivers/hwmon/nct6775.c @@ -3436,8 +3436,6 @@ nct6775_check_fan_inputs(struct nct6775_data *data) bool pwm3pin = false, pwm4pin = false, pwm5pin = false; bool pwm6pin = false, pwm7pin = false; int sioreg = data->sioreg; - int cr24; - int cr2c; /* Store SIO_REG_ENABLE for use during resume */ superio_select(sioreg, NCT6775_LD_HWM); @@ -3445,7 +3443,7 @@ nct6775_check_fan_inputs(struct nct6775_data *data) /* fan4 and fan5 share some pins with the GPIO and serial flash */ if (data->kind == nct6775) { - cr2c = superio_inb(sioreg, 0x2c); + int cr2c = superio_inb(sioreg, 0x2c); fan3pin = cr2c & BIT(6); pwm3pin = cr2c & BIT(7); @@ -3493,17 +3491,20 @@ nct6775_check_fan_inputs(struct nct6775_data *data) fan4min = fan4pin; pwm3pin = fan3pin; } else if (data->kind == nct6106) { - cr24 = superio_inb(sioreg, 0x24); + int cr24 = superio_inb(sioreg, 0x24); + fan3pin = !(cr24 & 0x80); pwm3pin = cr24 & 0x08; } else { /* NCT6779D, NCT6791D, NCT6792D, NCT6793D, NCT6795D, NCT6796D */ - int cr1b, cr2a, cr2f; - int cr1c; - int cr2d; - bool dsw_en; - - cr1c = superio_inb(sioreg, 0x1c); + int cr1b = superio_inb(sioreg, 0x1b); + int cr1c = superio_inb(sioreg, 0x1c); + int cr1d = superio_inb(sioreg, 0x1d); + int cr2a = superio_inb(sioreg, 0x2a); + int cr2b = superio_inb(sioreg, 0x2b); + int cr2d = superio_inb(sioreg, 0x2d); + int cr2f = superio_inb(sioreg, 0x2f); + bool dsw_en = cr2f & BIT(3); fan3pin = !(cr1c & BIT(5)); fan4pin = !(cr1c & BIT(6)); @@ -3513,7 +3514,6 @@ nct6775_check_fan_inputs(struct nct6775_data *data) pwm4pin = !(cr1c & BIT(1)); pwm5pin = !(cr1c & BIT(2)); - cr2d = superio_inb(sioreg, 0x2d); switch (data->kind) { case nct6791: case nct6792: @@ -3523,11 +3523,6 @@ nct6775_check_fan_inputs(struct nct6775_data *data) case nct6793: case nct6795: case nct6796: - cr1b = superio_inb(sioreg, 0x1b); - cr2a = superio_inb(sioreg, 0x2a); - cr2f = superio_inb(sioreg, 0x2f); - dsw_en = cr2f & BIT(3); - if (!pwm5pin) pwm5pin = cr2d & BIT(7); @@ -3566,9 +3561,6 @@ nct6775_check_fan_inputs(struct nct6775_data *data) } if (data->kind == nct6796) { - int cr1d = superio_inb(sioreg, 0x1d); - int cr2b = superio_inb(sioreg, 0x2b); - fan7pin = !(cr2b & BIT(2)); pwm7pin = !(cr1d & (BIT(2) | BIT(3))); } From patchwork Thu Sep 20 13:45:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10607781 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 98E196CB for ; Thu, 20 Sep 2018 13:45:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 890122D741 for ; Thu, 20 Sep 2018 13:45:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D04B2D74C; Thu, 20 Sep 2018 13:45:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,URIBL_SBL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E49752D74C for ; Thu, 20 Sep 2018 13:45:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730955AbeITT3Z (ORCPT ); Thu, 20 Sep 2018 15:29:25 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:37643 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727242AbeITT3Z (ORCPT ); Thu, 20 Sep 2018 15:29:25 -0400 Received: by mail-pg1-f194.google.com with SMTP id 2-v6so4473403pgo.4 for ; Thu, 20 Sep 2018 06:45:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=n6CKeGa52GsnTbjbF5TQuSRQYZs9nvVqXSUV2P8mTi0=; b=h8FVtb5pwY+EQjhV0oxmc0bfEzkClx8g5bkSOtbc8bSQKJbcH8rxYHh8YsL2BTy60a TsvmjKWwBk7FHwRmUMJ84i00LI2NpDY+IN2y0hxlAaf+vkPC3NwIGhpSjVGjDk4N3ikb ML5LvlFpLF8xpxzes0W/GLAlBUkh1YSCgpJVtAr212xohm1hl/NS5v2fSb2bMilvovvs /9u3qLXokFVdIfhzna/Ks4K35ZUyJUu0FI9it22Sjocan3cTYDz8AQaB01KKzrI572YG ISNPqxohDT7ltFOW64jP6UuYrJkDplA+H2OFYNWyr3faq688m0RbNGtnTS5fEkbstdfu 3pqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=n6CKeGa52GsnTbjbF5TQuSRQYZs9nvVqXSUV2P8mTi0=; b=iBi6oW0jzkFuGk8xtXp0RrSD8xBnO31rTAltlBbyfFUd7jikIwlNc6dso3QWlzKW3J dgtz73xk+sKCYYFjiLXDFAYcle5pulEDVlOpv/veMiyUmnEgJxhJ050gDzi/TNTga4xi RSXAbBlLTrvYAddoxxeIFErK1EzZ5fXg8JL/0qLrEb2KJJpZDDirEW4uuUnyncL9E/RL odxqYOGs0NA4fZoJhBwsaDbBxWccAHmLp7e9D3+dKwmIXCSNdlLfwAmImTj6YvaxeC5Z GbbRkAzHrofPrPCH5VGAgpQgWYRobDcMLyr6PGZuyvw8Xn7DWhNskR34Qk6j6004piUO hTbQ== X-Gm-Message-State: APzg51AsIlfT8O9e3Z/kiyzzAsr2cIKfEdyKoOZ9X+bojRa6DGkWFpUd EO8aYAoUC/IO9z7cPs4OZHNYzXO6 X-Google-Smtp-Source: ANB0VdZ2royoMH3d58kzWJcXJTw9ilVVJJsTl56C98NINcreadq8KIILj7OsbQnbzWWuA2ifd9mFTQ== X-Received: by 2002:a62:5882:: with SMTP id m124-v6mr41420392pfb.249.1537451150467; Thu, 20 Sep 2018 06:45:50 -0700 (PDT) Received: from localhost (108-223-40-66.lightspeed.sntcca.sbcglobal.net. [108.223.40.66]) by smtp.gmail.com with ESMTPSA id o3-v6sm27011686pgv.53.2018.09.20.06.45.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Sep 2018 06:45:49 -0700 (PDT) From: Guenter Roeck To: Hardware Monitoring Cc: Jean Delvare , Guenter Roeck Subject: [PATCH 04/13] hwmon: (nct6775) Declare and initialize LDN specific config variables earlier Date: Thu, 20 Sep 2018 06:45:32 -0700 Message-Id: <1537451141-27242-4-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537451141-27242-1-git-send-email-linux@roeck-us.net> References: <1537451141-27242-1-git-send-email-linux@roeck-us.net> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Declare and initialize LDN / chip specific configuration variables earlier. This simplifies re-using the configuration variables for multiple chips and makes the code easier to read. Signed-off-by: Guenter Roeck --- drivers/hwmon/nct6775.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c index aa8a44608ca3..984b22d4999a 100644 --- a/drivers/hwmon/nct6775.c +++ b/drivers/hwmon/nct6775.c @@ -3505,6 +3505,12 @@ nct6775_check_fan_inputs(struct nct6775_data *data) int cr2d = superio_inb(sioreg, 0x2d); int cr2f = superio_inb(sioreg, 0x2f); bool dsw_en = cr2f & BIT(3); + int creb; + int cred; + + superio_select(sioreg, NCT6775_LD_12); + creb = superio_inb(sioreg, 0xeb); + cred = superio_inb(sioreg, 0xed); fan3pin = !(cr1c & BIT(5)); fan4pin = !(cr1c & BIT(6)); @@ -3529,10 +3535,7 @@ nct6775_check_fan_inputs(struct nct6775_data *data) if (!fan5pin) fan5pin = cr1b & BIT(5); - superio_select(sioreg, NCT6775_LD_12); if (data->kind != nct6796) { - int creb = superio_inb(sioreg, 0xeb); - if (!dsw_en) { fan6pin = cr2d & BIT(1); pwm6pin = cr2d & BIT(0); @@ -3550,8 +3553,6 @@ nct6775_check_fan_inputs(struct nct6775_data *data) } if (data->kind == nct6795 || data->kind == nct6796) { - int cred = superio_inb(sioreg, 0xed); - if (!fan6pin) fan6pin = (cr2a & BIT(4)) && (!dsw_en || (cred & BIT(4))); From patchwork Thu Sep 20 13:45:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10607783 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A5DA5157B for ; Thu, 20 Sep 2018 13:45:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 984932D74D for ; Thu, 20 Sep 2018 13:45:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8BC162D750; Thu, 20 Sep 2018 13:45:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,URIBL_SBL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3696C2D741 for ; Thu, 20 Sep 2018 13:45:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731025AbeITT30 (ORCPT ); Thu, 20 Sep 2018 15:29:26 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:45076 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727242AbeITT30 (ORCPT ); Thu, 20 Sep 2018 15:29:26 -0400 Received: by mail-pf1-f196.google.com with SMTP id i26-v6so4393398pfo.12 for ; Thu, 20 Sep 2018 06:45:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=wF8iGMgL9HBZTYYPDNDFemkKFe8K9YOqf4lPbqO2En4=; b=GosxkrIS8rfm//RALd+UkQ7Fm0kqBwL6eXEMzm8rv7X74VpZUY7RxrMWdXVS3Md7pJ Dc1Vm7/xaEnl13ecQwK7/wReKxb3CW/MsedtjLVwouVxVqcET7CuWEMb9DHIrjpd0NIH svOyZeA45nyuFiTp9PsxtSAPhInJqvmgZe+LCKl+MIMMEqJNqhshzNO3c1tpNBFjo62C b4W3r3dBIUhZKx3vcOosm2ia4mfvJSijLWYO8q0D3bFq0OnWj2ApQ93P9prYh5GXxvb/ M9ZgO1glfVqT7FdlQbl0lVzSFHkV/3HmqbGFaQn04v3sTeOz2NthPnnzsvycS1dfVahr 42pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=wF8iGMgL9HBZTYYPDNDFemkKFe8K9YOqf4lPbqO2En4=; b=CZek3IT3pJQESjDoGrkMW8u3LY0oSQGvipQxDQqD6zwNVkA4Ogf49dgXIu7Mq1Dswu 6fBxOyZjRNd2wtqbqEc9jcAT0tq0Mua24XvKsxhfXB4yXKsy5tYczwGhW34e6pp8dWtH gaeH3QhZgMbUw0av6PiE6NLForKrI5QAyChDDLKr+MDyivOw1z9B/TIfUCVl+dQNpUjI 6mnHXceUbekrtE14/Xw8tg85wr25TH0iRW9CX9LPim/ETvxn5h8da3Aj6mRy9ZVHbaur StmzpW8wA+1smQ79O91Ngpl7zZgzMh5CdbvIghfiBn3u31mRigzOaecDXlu+VmGrxDTU +y2Q== X-Gm-Message-State: APzg51BHrvRFdnPHG2MF9gcbbY+rwkwHm2R1l+Y+IB1R7HpxUtO84j1d +c/UfRpp8uFuuRd2mHi38pwU0yOr X-Google-Smtp-Source: ANB0VdY96gWjdHrOoTKFuy116cnijBmejwCgIC3pNGuWeFMtyOJPUCffwGK/VAjv/8SCFj0oGV80pg== X-Received: by 2002:a62:3184:: with SMTP id x126-v6mr41138690pfx.49.1537451151765; Thu, 20 Sep 2018 06:45:51 -0700 (PDT) Received: from localhost (108-223-40-66.lightspeed.sntcca.sbcglobal.net. [108.223.40.66]) by smtp.gmail.com with ESMTPSA id g20-v6sm32138341pfo.94.2018.09.20.06.45.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Sep 2018 06:45:51 -0700 (PDT) From: Guenter Roeck To: Hardware Monitoring Cc: Jean Delvare , Guenter Roeck Subject: [PATCH 05/13] hwmon: (nct6775) Use logical or instead of if statements where possible Date: Thu, 20 Sep 2018 06:45:33 -0700 Message-Id: <1537451141-27242-5-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537451141-27242-1-git-send-email-linux@roeck-us.net> References: <1537451141-27242-1-git-send-email-linux@roeck-us.net> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use boolean |= ; instead of if (!boolean) boolean = ; to assign values to boolean variables. No functional change. Signed-off-by: Guenter Roeck --- drivers/hwmon/nct6775.c | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c index 984b22d4999a..0f20f7c2a96b 100644 --- a/drivers/hwmon/nct6775.c +++ b/drivers/hwmon/nct6775.c @@ -3529,36 +3529,24 @@ nct6775_check_fan_inputs(struct nct6775_data *data) case nct6793: case nct6795: case nct6796: - if (!pwm5pin) - pwm5pin = cr2d & BIT(7); + pwm5pin |= cr2d & BIT(7); - if (!fan5pin) - fan5pin = cr1b & BIT(5); + fan5pin |= cr1b & BIT(5); if (data->kind != nct6796) { - if (!dsw_en) { - fan6pin = cr2d & BIT(1); - pwm6pin = cr2d & BIT(0); - } + fan6pin = !dsw_en && (cr2d & BIT(1)); + pwm6pin = !dsw_en && (cr2d & BIT(0)); - if (!fan5pin) - fan5pin = creb & BIT(5); - if (!pwm5pin) - pwm5pin = (creb & BIT(4)) && - !(cr2a & BIT(0)); - if (!fan6pin) - fan6pin = creb & BIT(3); - if (!pwm6pin) - pwm6pin = creb & BIT(2); + fan5pin |= creb & BIT(5); + pwm5pin |= (creb & BIT(4)) && !(cr2a & BIT(0)); + fan6pin |= creb & BIT(3); + pwm6pin |= creb & BIT(2); } if (data->kind == nct6795 || data->kind == nct6796) { - if (!fan6pin) - fan6pin = (cr2a & BIT(4)) && - (!dsw_en || (cred & BIT(4))); - if (!pwm6pin) - pwm6pin = (cr2a & BIT(3)) && - (cred & BIT(2)); + fan6pin |= (cr2a & BIT(4)) && + (!dsw_en || (cred & BIT(4))); + pwm6pin |= (cr2a & BIT(3)) && (cred & BIT(2)); } if (data->kind == nct6796) { From patchwork Thu Sep 20 13:45:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10607785 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 93170157B for ; Thu, 20 Sep 2018 13:45:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82A5A2D750 for ; Thu, 20 Sep 2018 13:45:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 770232D758; Thu, 20 Sep 2018 13:45:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,URIBL_SBL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2701C2D750 for ; Thu, 20 Sep 2018 13:45:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731135AbeITT31 (ORCPT ); Thu, 20 Sep 2018 15:29:27 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:36073 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727242AbeITT31 (ORCPT ); Thu, 20 Sep 2018 15:29:27 -0400 Received: by mail-pl1-f196.google.com with SMTP id p5-v6so4388759plk.3 for ; Thu, 20 Sep 2018 06:45:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=U84X9DhH9gGiGZsqpiBrpklJ9uT28MhelfO1xFt1owg=; b=Nec5DuEQM1jP+qASeV73fj6GDgU+OFZEaadKdLBvNLZXSlGs3WNh+y2CkYbI2eDaFz B8/tPq1Hp/9s4+sw2H3VwBK6OQLjWfZ+tSWKyxnxYc3Geq1v4VhmEZiwRI5J5jsRs72m HlZL1c0YU2sc2a+JXYh5y1Ufzzn/1hN6D/gMJo1ImG+KawfJDK3yrvy6gz84Vt81eCZ/ PYH2PqEmVbeUCha+Csul6yz69A1+QlbFqrLDfIYCs2wS/sdm4/4OlTiVQjDgIfzFiYbg dOKhA0GEyIR0uSzPwt1D+VD+ropUUPFZ4qLTNd5nEuy8fNAJtM/FdwKJTdwLAutcEOZr +Qtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=U84X9DhH9gGiGZsqpiBrpklJ9uT28MhelfO1xFt1owg=; b=NFXRb4wsv0+e1h0yM/+Ajk1BfOVbUEsyCL446saGQRiEYjObCYQ0MMVZERSj91jVtU locMY7o+j09jgec4R/wmPZxFh7xC/MU9367PaOTlJ87V6xP4j3g0OXk4kqz+vdGtBkxq WxMcM6CpHeHXARyK4g6yjOITgMmMgfeTOEzfPnh5vTcTkXstwDDqQr06F33hcOqtcpPY y03cRbUcCS9r+WGYipg/aJQ8DdRi36kPbFDppKuTHADUd1q4WtnY++7q5Lvs+Hxkxmki HRODmK5BzIj4U6zKuEPyigDS1LZ1ZeZoTlBPC8XIWIILuNSsrBxeOOZh0PUEIWHdmaYm IRpg== X-Gm-Message-State: APzg51CMe8NLwMYYXFfXH5RoU5MUyxA1v2HF2/7DLzI4bKckjmpotatv f91qn9elYeZZH2M8uxG+rPy3L5Jd X-Google-Smtp-Source: ANB0VdaVZI6OHoyD7XVqgJ0z6t+C5T37KynDXZCIn2DPXP96ENHLbxtzG/UavF34jiOFsqktOvWvlg== X-Received: by 2002:a17:902:76c1:: with SMTP id j1-v6mr3830151plt.278.1537451153094; Thu, 20 Sep 2018 06:45:53 -0700 (PDT) Received: from localhost (108-223-40-66.lightspeed.sntcca.sbcglobal.net. [108.223.40.66]) by smtp.gmail.com with ESMTPSA id g66-v6sm35772158pfk.39.2018.09.20.06.45.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Sep 2018 06:45:52 -0700 (PDT) From: Guenter Roeck To: Hardware Monitoring Cc: Jean Delvare , Guenter Roeck Subject: [PATCH 06/13] hwmon: (nct6775) Improve instruction grouping Date: Thu, 20 Sep 2018 06:45:34 -0700 Message-Id: <1537451141-27242-6-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537451141-27242-1-git-send-email-linux@roeck-us.net> References: <1537451141-27242-1-git-send-email-linux@roeck-us.net> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When determining support for a given fan or pwm control, the code is easier to read if the necessary instructions are grouped together. No functional change. Signed-off-by: Guenter Roeck --- drivers/hwmon/nct6775.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c index 0f20f7c2a96b..0ad4bf0ab8be 100644 --- a/drivers/hwmon/nct6775.c +++ b/drivers/hwmon/nct6775.c @@ -3530,16 +3530,16 @@ nct6775_check_fan_inputs(struct nct6775_data *data) case nct6795: case nct6796: pwm5pin |= cr2d & BIT(7); - fan5pin |= cr1b & BIT(5); if (data->kind != nct6796) { - fan6pin = !dsw_en && (cr2d & BIT(1)); - pwm6pin = !dsw_en && (cr2d & BIT(0)); - fan5pin |= creb & BIT(5); pwm5pin |= (creb & BIT(4)) && !(cr2a & BIT(0)); + + fan6pin = !dsw_en && (cr2d & BIT(1)); fan6pin |= creb & BIT(3); + + pwm6pin = !dsw_en && (cr2d & BIT(0)); pwm6pin |= creb & BIT(2); } From patchwork Thu Sep 20 13:45:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10607787 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DF0266CB for ; Thu, 20 Sep 2018 13:45:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CEB342D750 for ; Thu, 20 Sep 2018 13:45:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C26A82D758; Thu, 20 Sep 2018 13:45:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,URIBL_SBL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79A3A2D750 for ; Thu, 20 Sep 2018 13:45:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731223AbeITT32 (ORCPT ); Thu, 20 Sep 2018 15:29:28 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:45966 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727242AbeITT32 (ORCPT ); Thu, 20 Sep 2018 15:29:28 -0400 Received: by mail-pg1-f193.google.com with SMTP id w9-v6so1268444pgc.12 for ; Thu, 20 Sep 2018 06:45:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=6iS+go2Y5C4wrfNb93pgvF6YyJT4YAPS+PR/zvmUxdo=; b=Ptj2mWdZ4xG7yACUs7B8FGZVrb4yIlaYA+0eMo3I9g/1fsXxWUtGUY8Vm45f+CABOl UMZE7K2GK1qXOA1gnnD/zivES22csme0jweAJvd8Wn7/SP79fajNAqY2CFVSB3wsIkKY sglH2QCZMF8IB6i6V9AFL+UaTDg8+iCbxybcA6OWuUFXkEKIyeFBKbisFyjvWxVhP8bA ZKTbeXM2xIk8epggwDbKWKP0GAXnCwsGErvfYKwqzCT+Xs/poNI0T72HEV3V2CfLfKjb +IsECx26DGnEBKAdRZ7uimgg5MFlVNKNxqCRx7oAnsn1SyWEFhRg6OdAyR0ezsmPfv3G W2xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=6iS+go2Y5C4wrfNb93pgvF6YyJT4YAPS+PR/zvmUxdo=; b=m9tVT1WMyZRWu2W/nvbTGAAO5MnEEsRE1XREhIIpSq6TDjoDC11YRfudGSvGi8XTDL MTiOUa7TRbMAZ2kX4z9K5UsF01SJG92nCLNo6W1I9wKWDDB160KVO13Bz53kWAUOZf7+ ALxsonXucuv0MPVwzJAdNJk4UpDndco6Dmla6MrfyGggOukFfSrRGKXIakMQiv+82ri1 yMZ1ngZCrj4G8D/2eFVO6H9hMXphqxGhfeyDvUGUcWmGBGn7TqFZqVd7iIjecxc7sVk1 AqvIZNtuyH/kPiLxy1HyT0eHx6VDVyLV8Na0OLgoH3rnd+7HI+Ci9ZDGw8gkXAVSwKoY R7Hg== X-Gm-Message-State: APzg51CJVND7Cb11GlLTyeax1uxzdlbITfE9o9MkAZ0NoSRLnYgV2DOM y019HbjG37g0YOuoEBVYZQ2oUkQq X-Google-Smtp-Source: ANB0VdZx8fr3eHUPkKO3ymGo0Tg/oivyPSQcDQ3nT/+IW4LzaHTk5fQZEE/uNBeFv5aAlarEUKr1NQ== X-Received: by 2002:a63:c00b:: with SMTP id h11-v6mr36759790pgg.279.1537451154383; Thu, 20 Sep 2018 06:45:54 -0700 (PDT) Received: from localhost (108-223-40-66.lightspeed.sntcca.sbcglobal.net. [108.223.40.66]) by smtp.gmail.com with ESMTPSA id 5-v6sm31367896pgc.86.2018.09.20.06.45.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Sep 2018 06:45:53 -0700 (PDT) From: Guenter Roeck To: Hardware Monitoring Cc: Jean Delvare , Guenter Roeck Subject: [PATCH 07/13] hwmon: (nct6775) Fix fan6/pwm6 detection for NCT6792D Date: Thu, 20 Sep 2018 06:45:35 -0700 Message-Id: <1537451141-27242-7-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537451141-27242-1-git-send-email-linux@roeck-us.net> References: <1537451141-27242-1-git-send-email-linux@roeck-us.net> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Per datasheet, AUXFANIN3 (fan6) and AUXFANOUT3 (pwm6) are only connected if DSW_EN is false. Signed-off-by: Guenter Roeck --- drivers/hwmon/nct6775.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c index 0ad4bf0ab8be..6e11df697e6e 100644 --- a/drivers/hwmon/nct6775.c +++ b/drivers/hwmon/nct6775.c @@ -3522,10 +3522,13 @@ nct6775_check_fan_inputs(struct nct6775_data *data) switch (data->kind) { case nct6791: - case nct6792: fan6pin = cr2d & BIT(1); pwm6pin = cr2d & BIT(0); break; + case nct6792: + fan6pin = !dsw_en && (cr2d & BIT(1)); + pwm6pin = !dsw_en && (cr2d & BIT(0)); + break; case nct6793: case nct6795: case nct6796: From patchwork Thu Sep 20 13:45:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10607789 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 79C79157B for ; Thu, 20 Sep 2018 13:45:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 68B212D751 for ; Thu, 20 Sep 2018 13:45:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C48C2D762; Thu, 20 Sep 2018 13:45:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,URIBL_SBL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 347622D751 for ; Thu, 20 Sep 2018 13:45:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731225AbeITT3a (ORCPT ); Thu, 20 Sep 2018 15:29:30 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:44474 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727242AbeITT3a (ORCPT ); Thu, 20 Sep 2018 15:29:30 -0400 Received: by mail-pg1-f196.google.com with SMTP id r1-v6so4456183pgp.11 for ; Thu, 20 Sep 2018 06:45:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=mafq+EhCJJN7tDlJpUBAK1VKpLU0nVFqbQp2YeBLeZM=; b=GgUbJOtsj7i7YoycCQsN82muAc7hxi8fivOB04tFdM7kd35CgBMzSEBWNu0XXpYPMd +3mIliwdjwoQARWd5bg0txbtphFv3CBO1xJT4l6v7N88kplP1utxlmuZhV77/qZHg9YV CJ/hcrxfQcdn6lrKaObEVWY6MUroNa+nXiE7421HE6OpgKqvJMr/sAeGYI6V6wuuLPqP 2Ylwnk5B82V1jOuia6Q6Qk+PNlGLgmYK2bgwFtPDgTC5FtUClCJMJKnkolB2OtIQMqGg nH9qKteyvVmm89YuKq/uqgrmkJdNDxPSmoFiVeQww2e/4dPlSp+HJQ5Cra316LPfGyWa b5aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=mafq+EhCJJN7tDlJpUBAK1VKpLU0nVFqbQp2YeBLeZM=; b=t8270Av2rzHh/E3djZIm/7T1fXm5nEMuOn276VSmL4PcZ2oMugQ+SgDWX+zjHmRydD jlAIVlAeGfcboUqBLOjuuDOpPoz5xOuf715w7NGcE+6iyxxvwZyfV/onrI92zL9qDn61 hFrcRB+29QB58FcGnmpF51SMjpiDf005zTgDW6Ca4eGU3zgDYQSW0YUSl/sgpooowzy/ zmJqbdXpIlVYVkYJYFZ7wUioWYqloozYdShbqjL5ikKIr60YZkAoVxfEFd4cD44VXIC6 JkpCE1vh/6VuTUGXqH7BR0f4bsNo4mcUAuy6nMNqfcxWt+FQd2HkRcnuX4alTl4sDhVe HniA== X-Gm-Message-State: APzg51Cy+un7b45W+aiqXD2ixYjgD7ex8xBwvljG9lWoacYGStrJ8iwZ az+K3pfvTXOGeAZagSU8W0MhpZ6y X-Google-Smtp-Source: ANB0VdZ93yPvJrq7Dul0+rbjMrChXxV3NcHi/yZJ5Ob68i5eTDsTIh7KhwZwrIQ/bZkLtQ48dqnD6Q== X-Received: by 2002:a62:174a:: with SMTP id 71-v6mr41998818pfx.217.1537451155748; Thu, 20 Sep 2018 06:45:55 -0700 (PDT) Received: from localhost (108-223-40-66.lightspeed.sntcca.sbcglobal.net. [108.223.40.66]) by smtp.gmail.com with ESMTPSA id c1-v6sm31374547pfi.142.2018.09.20.06.45.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Sep 2018 06:45:55 -0700 (PDT) From: Guenter Roeck To: Hardware Monitoring Cc: Jean Delvare , Guenter Roeck Subject: [PATCH 08/13] hwmon: (nct6775) Separate fan/pwm configuration detection for NCT6793D Date: Thu, 20 Sep 2018 06:45:36 -0700 Message-Id: <1537451141-27242-8-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537451141-27242-1-git-send-email-linux@roeck-us.net> References: <1537451141-27242-1-git-send-email-linux@roeck-us.net> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP While detecting the configuration for multiple chips in one go reduces code size, it also increases code complexity. Separate chip detection to improve code readability. As first step, separate detection for NCT6793D. No functional change. Signed-off-by: Guenter Roeck --- drivers/hwmon/nct6775.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c index 6e11df697e6e..556b4cfacbd1 100644 --- a/drivers/hwmon/nct6775.c +++ b/drivers/hwmon/nct6775.c @@ -3530,6 +3530,17 @@ nct6775_check_fan_inputs(struct nct6775_data *data) pwm6pin = !dsw_en && (cr2d & BIT(0)); break; case nct6793: + fan5pin |= cr1b & BIT(5); + fan5pin |= creb & BIT(5); + + fan6pin = creb & BIT(3); + + pwm5pin |= cr2d & BIT(7); + pwm5pin |= (creb & BIT(4)) && !(cr2a & BIT(0)); + + pwm6pin = !dsw_en && (cr2d & BIT(0)); + pwm6pin |= creb & BIT(2); + break; case nct6795: case nct6796: pwm5pin |= cr2d & BIT(7); @@ -3546,11 +3557,9 @@ nct6775_check_fan_inputs(struct nct6775_data *data) pwm6pin |= creb & BIT(2); } - if (data->kind == nct6795 || data->kind == nct6796) { - fan6pin |= (cr2a & BIT(4)) && - (!dsw_en || (cred & BIT(4))); - pwm6pin |= (cr2a & BIT(3)) && (cred & BIT(2)); - } + fan6pin |= (cr2a & BIT(4)) && + (!dsw_en || (cred & BIT(4))); + pwm6pin |= (cr2a & BIT(3)) && (cred & BIT(2)); if (data->kind == nct6796) { fan7pin = !(cr2b & BIT(2)); From patchwork Thu Sep 20 13:45:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10607791 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B4015174F for ; Thu, 20 Sep 2018 13:45:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4CAA2D74D for ; Thu, 20 Sep 2018 13:45:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9935D2D758; Thu, 20 Sep 2018 13:45:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,URIBL_SBL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 466B32D74D for ; Thu, 20 Sep 2018 13:45:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731305AbeITT3b (ORCPT ); Thu, 20 Sep 2018 15:29:31 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:41154 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727242AbeITT3b (ORCPT ); Thu, 20 Sep 2018 15:29:31 -0400 Received: by mail-pl1-f196.google.com with SMTP id b12-v6so4380315plr.8 for ; Thu, 20 Sep 2018 06:45:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=FzHoMUq7yfce1Pvwjy3Tw993wl3QUEadnx2UDnCrnYo=; b=fa76n6dDtYdS06sApY0NJeClz/hTyb7sbN6jE0C3XVgvJDHRrxBWs+3xDuEVEkaSPx lNaLT2xJrFoOGo8MnQ3jThNNBtYdrLgWuOZY0m8zsTKC65CxOkE0EyrQWzw8gJieoh8D o0b122Er3D5uEctVUWHSpgpv8C+SzuEpu8f4z+3PQUzRH9VU4RbE3v9agXfGb0rpvZ2E 6DegGXohtfhRczK22eFD7wDhvqeF2qsxKp/lTs9KUhWOl0qH1JPkiXsBGnbqIVcKFlvU xAz6SZB21tBAGbi9U3EK258HXoGiXYdWfVv5Aurs2+Y5v2w7cNRfWdYJ2UoSetM1NWNJ +3SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=FzHoMUq7yfce1Pvwjy3Tw993wl3QUEadnx2UDnCrnYo=; b=Q/IB3bI06g0GXegLl9e3U0RnvDJVP09xoIFKDuY6D538AgSWrUcer4h70U+m98Q5nF oL2+SoMCyBcLrYAmt3MnqnRm8DI9ZfTUXBNgTBdNKo76HalRz+UwOfAzvC2Xrfu5vc/E T0nk4/+wACq9c/yQd7FOKK6crOvrAFJUUubzM+5LctPTL6uu+7JTPueo7SOHMKmg4azc ltVDCE1yUaGx7kVSZOAaJPcYfF9qYmKf0MB/U0p4xJ51tqEOJEqzqegOju1lt4BxAxeK Jn7Eo9VZOyuQC+RpRVSCBZAmHB6HtUtfODgrj1tKbOBPJ/QE2b3ay448AKvNjyslRWQ7 hu+g== X-Gm-Message-State: APzg51AlJBAGHLMBja3KFaEQTirhYoEF2vlkVhNBJ9QfgBNYzr4lP48P MPXXJxJQT3DPb4Qc5wwQkMmmAdJt X-Google-Smtp-Source: ANB0VdZwZUGv2BEvpRumJaWE49HiPbb9psLfDjhYKTLCw8erfuOSb/7H/neKKFNlgX8hmouavwr7PA== X-Received: by 2002:a17:902:848d:: with SMTP id c13-v6mr33483872plo.194.1537451157169; Thu, 20 Sep 2018 06:45:57 -0700 (PDT) Received: from localhost (108-223-40-66.lightspeed.sntcca.sbcglobal.net. [108.223.40.66]) by smtp.gmail.com with ESMTPSA id y7-v6sm28920437pge.8.2018.09.20.06.45.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Sep 2018 06:45:56 -0700 (PDT) From: Guenter Roeck To: Hardware Monitoring Cc: Jean Delvare , Guenter Roeck Subject: [PATCH 09/13] hwmon: (nct6775) Separate fan/pwm configuration detection for NCT6795D Date: Thu, 20 Sep 2018 06:45:37 -0700 Message-Id: <1537451141-27242-9-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537451141-27242-1-git-send-email-linux@roeck-us.net> References: <1537451141-27242-1-git-send-email-linux@roeck-us.net> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Separate fan/pwm configuration detection for NCT6795D into separate case statement to make the code easier to read. No functional change. Signed-off-by: Guenter Roeck --- drivers/hwmon/nct6775.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c index 556b4cfacbd1..d9c2b934321d 100644 --- a/drivers/hwmon/nct6775.c +++ b/drivers/hwmon/nct6775.c @@ -3542,6 +3542,19 @@ nct6775_check_fan_inputs(struct nct6775_data *data) pwm6pin |= creb & BIT(2); break; case nct6795: + fan5pin |= cr1b & BIT(5); + fan5pin |= creb & BIT(5); + + fan6pin = (cr2a & BIT(4)) && + (!dsw_en || (cred & BIT(4))); + fan6pin |= creb & BIT(3); + + pwm5pin |= cr2d & BIT(7); + pwm5pin |= (creb & BIT(4)) && !(cr2a & BIT(0)); + + pwm6pin = (cr2a & BIT(3)) && (cred & BIT(2)); + pwm6pin |= creb & BIT(2); + break; case nct6796: pwm5pin |= cr2d & BIT(7); fan5pin |= cr1b & BIT(5); @@ -3561,10 +3574,8 @@ nct6775_check_fan_inputs(struct nct6775_data *data) (!dsw_en || (cred & BIT(4))); pwm6pin |= (cr2a & BIT(3)) && (cred & BIT(2)); - if (data->kind == nct6796) { - fan7pin = !(cr2b & BIT(2)); - pwm7pin = !(cr1d & (BIT(2) | BIT(3))); - } + fan7pin = !(cr2b & BIT(2)); + pwm7pin = !(cr1d & (BIT(2) | BIT(3))); break; default: /* NCT6779D */ From patchwork Thu Sep 20 13:45:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10607793 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3C6696CB for ; Thu, 20 Sep 2018 13:46:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2CF1B2D74D for ; Thu, 20 Sep 2018 13:46:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2111E2D758; Thu, 20 Sep 2018 13:46:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,URIBL_SBL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C01D92D74D for ; Thu, 20 Sep 2018 13:45:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731416AbeITT3d (ORCPT ); Thu, 20 Sep 2018 15:29:33 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:39435 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727242AbeITT3d (ORCPT ); Thu, 20 Sep 2018 15:29:33 -0400 Received: by mail-pl1-f195.google.com with SMTP id w14-v6so4382779plp.6 for ; Thu, 20 Sep 2018 06:45:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=wJ+e20JFb7CNZ75XebiVJ+fNiWdTFTCThd6HRogpUyY=; b=D9scAJ5RNzpyji+FHY/SMk1VLPoDLi0yiolGx4/+e5AnW+ZfkJMNaZYDOBpCZN0gFH JWEvijSo1WDQpcLiXzqiCb82+3510eF9o0l/JSnJKTyyuT2GZP4idFFFSimzXVGY6WIG TxfralwbekZ1t4HH/h09Yx5bnN8rjDrbZKcT7m1/HgjRMsbYOzjw7tF/BuKehFxJj7KM 1qQHSLVJ5U0EPZkf9w6KhVAbBymui8WyatzJ85xpZ+6U0xSq74GUKLHk3A3kOfbvvxJX MmJLVYD2JsCOcwKJxOZq5HHYHWsG5BYWd+0zEfWeMQuJUrkdA75bnn1hAz1PK5kZ2QKD OLEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=wJ+e20JFb7CNZ75XebiVJ+fNiWdTFTCThd6HRogpUyY=; b=QjjFiLu3OAnSE7dHdFyl364EZ1PjEK23B24R9fNXeXJu5BCAHIkuBEXzzSgZrvUVVB ZqXfEMhXAKif0hFAZ/I7pZhjwrcFcXXooWgzfLbe9TNvtssosYrHhhAOgLNZG9Xz9YPa Tx7Yu9CSDNo0CfIdACEEIGWh0yc/rOpM+VTELLfrfRd/eD0LBiKts63ui729bulUSpxl xv783qR3NmxQlpp/r7lnuxns+SUZvRdb62JphwiA39Zi/JH3v9KWLvfYbn7v4VMP7WPr tiBeOxeiaB1iznL5zTwaIKBgWCFYsODU4SpAAel1D7pwmf6vPu4g/ixDmtV2lWXFLOYm 6NLQ== X-Gm-Message-State: APzg51DT0BMu9E5PcTyGD2JAHE95/3INTVuoiOoF/n1ohPGhC4Jn3p8N 9SKG1lAi6nX8/i6lKRiJPbl/FGKX X-Google-Smtp-Source: ANB0Vdb+Bve12Qo5k72MNEWa2RYbUynhu3pf5GTzPqSF0JyjsSfKGayIvQViGZX0RH2BLR+lVPZlWQ== X-Received: by 2002:a17:902:286a:: with SMTP id e97-v6mr39771482plb.340.1537451158592; Thu, 20 Sep 2018 06:45:58 -0700 (PDT) Received: from localhost (108-223-40-66.lightspeed.sntcca.sbcglobal.net. [108.223.40.66]) by smtp.gmail.com with ESMTPSA id a20-v6sm55948761pfc.14.2018.09.20.06.45.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Sep 2018 06:45:58 -0700 (PDT) From: Guenter Roeck To: Hardware Monitoring Cc: Jean Delvare , Guenter Roeck Subject: [PATCH 10/13] hwmon: (nct6796) Clean up and amend fan/pwm configuration for NCT6796D Date: Thu, 20 Sep 2018 06:45:38 -0700 Message-Id: <1537451141-27242-10-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537451141-27242-1-git-send-email-linux@roeck-us.net> References: <1537451141-27242-1-git-send-email-linux@roeck-us.net> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Now that everything is separated, clean up fan and pwm configuration for NCT6796D. While doing that, take the forgotten configuration register cre0 into account to determine if AUXFANIN2 (fan5) and AUXFANOUT2 (pwm5) are connected. Signed-off-by: Guenter Roeck --- drivers/hwmon/nct6775.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c index d9c2b934321d..c07414dd38dd 100644 --- a/drivers/hwmon/nct6775.c +++ b/drivers/hwmon/nct6775.c @@ -3505,10 +3505,12 @@ nct6775_check_fan_inputs(struct nct6775_data *data) int cr2d = superio_inb(sioreg, 0x2d); int cr2f = superio_inb(sioreg, 0x2f); bool dsw_en = cr2f & BIT(3); + int cre0; int creb; int cred; superio_select(sioreg, NCT6775_LD_12); + cre0 = superio_inb(sioreg, 0xe0); creb = superio_inb(sioreg, 0xeb); cred = superio_inb(sioreg, 0xed); @@ -3556,27 +3558,24 @@ nct6775_check_fan_inputs(struct nct6775_data *data) pwm6pin |= creb & BIT(2); break; case nct6796: - pwm5pin |= cr2d & BIT(7); fan5pin |= cr1b & BIT(5); + fan5pin |= (cre0 & BIT(3)) && !(cr1b & BIT(0)); + fan5pin |= creb & BIT(5); - if (data->kind != nct6796) { - fan5pin |= creb & BIT(5); - pwm5pin |= (creb & BIT(4)) && !(cr2a & BIT(0)); + fan6pin = (cr2a & BIT(4)) && + (!dsw_en || (cred & BIT(4))); + fan6pin |= creb & BIT(3); - fan6pin = !dsw_en && (cr2d & BIT(1)); - fan6pin |= creb & BIT(3); + fan7pin = !(cr2b & BIT(2)); - pwm6pin = !dsw_en && (cr2d & BIT(0)); - pwm6pin |= creb & BIT(2); - } + pwm5pin |= cr2d & BIT(7); + pwm5pin |= (cre0 & BIT(4)) && !(cr1b & BIT(0)); + pwm5pin |= (creb & BIT(4)) && !(cr2a & BIT(0)); - fan6pin |= (cr2a & BIT(4)) && - (!dsw_en || (cred & BIT(4))); - pwm6pin |= (cr2a & BIT(3)) && (cred & BIT(2)); + pwm6pin = (cr2a & BIT(3)) && (cred & BIT(2)); + pwm6pin |= creb & BIT(2); - fan7pin = !(cr2b & BIT(2)); pwm7pin = !(cr1d & (BIT(2) | BIT(3))); - break; default: /* NCT6779D */ break; From patchwork Thu Sep 20 13:45:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10607795 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BF2C0157B for ; Thu, 20 Sep 2018 13:46:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF9292D74D for ; Thu, 20 Sep 2018 13:46:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A3F9B2D751; Thu, 20 Sep 2018 13:46:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,URIBL_SBL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 592F92D77D for ; Thu, 20 Sep 2018 13:46:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731463AbeITT3e (ORCPT ); Thu, 20 Sep 2018 15:29:34 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:43707 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727242AbeITT3e (ORCPT ); Thu, 20 Sep 2018 15:29:34 -0400 Received: by mail-pg1-f194.google.com with SMTP id q19-v6so3604878pgn.10 for ; Thu, 20 Sep 2018 06:46:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZxRuSss+/78FTA9PCAijV+0gX/r7qR5FmFFv6U68wUc=; b=JH6pvdObUtt+Rb5Q3/pCYxOf60qyye35zMleouzzJmaxfnBfngbp9auiBcI6LRhAG0 Qln+LRXXRbgKnjqZIVVWlKM+nq+UEq52xy7iGlxO/T2ZVNNqhcQIhL/OjQTrYln6J6Rn T9rQitmJj68dz/qf1dTQbhcX5DAiGNYAqoCsYsTlaLZFuz/9LhMvB9g2QyiUVdY2P9Yb A8c4EAcb0JGRo7YA99Tqq2ij9C3ePRBFpNjYRaJLfe1mAl35YEHiihnxRY8ozN9/2W3B HbA6EOPZgPISPgzdWvJPaeaAO7Xckq1TKDlZHnEH+KLFSVqA8y0aZjmDZMHVi+rDLJTL Q5jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=ZxRuSss+/78FTA9PCAijV+0gX/r7qR5FmFFv6U68wUc=; b=a1DqJoYfpXPNAB5hf184MVhy3yJtUajXCY5p4jjRRsoJWVZi/IDacLCCpHH8jVtgOg up1vKdAXDYRXm96+AgBRaNRjBs+DbCrRtKVNc6wVRQOtCexWGXJS1VzwjaoLDRrZKnMF dqevrhtnX1GoylCAhB6HqGmOBABWdegsjtNy8qRjKZqFcjmmNy2hPK95hvyg/tYgg3dN axJGcOZqgOU4lkfvDx6RdiGcgFd1crIGR1NsszYCOBODpkw8IX/5hA0WCrUil+rxKpI1 SRIWtclipVC1lN9cMup5YtGHQv7dgBdX+7cz/VWvcBv04XOfLBpq8GtSml8EHQcuQuTk VT1Q== X-Gm-Message-State: APzg51A9DppBUdnSZcfjUJndCOSO0jstW3600zEKqwPCoPEmxbwUnarO YZJjrE82j+keEUIQIq/tNNXyjKen X-Google-Smtp-Source: ANB0VdbbHAV5WKM54ozfkgpPPD+tQG+TnvQ+zVI2RhGoW2PGeDUpEuffB7g7OKnCln4Tz+s4ioxyZw== X-Received: by 2002:a63:115f:: with SMTP id 31-v6mr37088137pgr.53.1537451160150; Thu, 20 Sep 2018 06:46:00 -0700 (PDT) Received: from localhost (108-223-40-66.lightspeed.sntcca.sbcglobal.net. [108.223.40.66]) by smtp.gmail.com with ESMTPSA id v22-v6sm47407376pfi.60.2018.09.20.06.45.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Sep 2018 06:45:59 -0700 (PDT) From: Guenter Roeck To: Hardware Monitoring Cc: Jean Delvare , Guenter Roeck Subject: [PATCH 11/13] hwmon: (nct6775) Fix names of DIMM temperature sources Date: Thu, 20 Sep 2018 06:45:39 -0700 Message-Id: <1537451141-27242-11-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537451141-27242-1-git-send-email-linux@roeck-us.net> References: <1537451141-27242-1-git-send-email-linux@roeck-us.net> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For NCT6795D and NCT6796D, the DIMM temperature sources are named "Agent[01] Dimm [01]" per datasheet. Match names in datasheets to avoid confusion. Signed-off-by: Guenter Roeck --- drivers/hwmon/nct6775.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c index c07414dd38dd..77255f7da974 100644 --- a/drivers/hwmon/nct6775.c +++ b/drivers/hwmon/nct6775.c @@ -704,10 +704,10 @@ static const char *const nct6795_temp_label[] = { "PCH_CHIP_TEMP", "PCH_CPU_TEMP", "PCH_MCH_TEMP", - "PCH_DIM0_TEMP", - "PCH_DIM1_TEMP", - "PCH_DIM2_TEMP", - "PCH_DIM3_TEMP", + "Agent0 Dimm0", + "Agent0 Dimm1", + "Agent1 Dimm0", + "Agent1 Dimm1", "BYTE_TEMP0", "BYTE_TEMP1", "PECI Agent 0 Calibration", @@ -742,10 +742,10 @@ static const char *const nct6796_temp_label[] = { "PCH_CHIP_TEMP", "PCH_CPU_TEMP", "PCH_MCH_TEMP", - "PCH_DIM0_TEMP", - "PCH_DIM1_TEMP", - "PCH_DIM2_TEMP", - "PCH_DIM3_TEMP", + "Agent0 Dimm0", + "Agent0 Dimm1", + "Agent1 Dimm0", + "Agent1 Dimm1", "BYTE_TEMP0", "BYTE_TEMP1", "PECI Agent 0 Calibration", From patchwork Thu Sep 20 13:45:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10607797 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 57507157B for ; Thu, 20 Sep 2018 13:46:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 469B72D74D for ; Thu, 20 Sep 2018 13:46:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3AEFD2D758; Thu, 20 Sep 2018 13:46:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,URIBL_SBL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABEC32D74D for ; Thu, 20 Sep 2018 13:46:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731487AbeITT3g (ORCPT ); Thu, 20 Sep 2018 15:29:36 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:40593 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727242AbeITT3g (ORCPT ); Thu, 20 Sep 2018 15:29:36 -0400 Received: by mail-pl1-f193.google.com with SMTP id s17-v6so4380878plp.7 for ; Thu, 20 Sep 2018 06:46:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=7YRk73VKGtvm9kKRLWMUEa41fZXyi8gPmGW3RMb+37Q=; b=Coe2p9EULSMx6fK55JduTfRssB/TnBMt9+o77DOuhDux8A+QTi0F3aQRT8EnnJMz2Q HI1MSpODAZMjdIKrQ7x4/AWa30koLIVsaRulCD/OglPfv4tSHrDEsDZw6/gU5tlLO+LK HaZVsRlArJN5uGbGWPHIH/aCPnnH4WQNFYHhlCDY8MehXK3W/PzB3PIcFtxgGTk6Z0tp TS0VNhIqU3jRJpMy7lL7tQWVMO6po26vXvu8QP6iuOjYZ8ABbH7lSVFg1gMoRVihXq+6 RA8A4GodigT/QqkRf7EppzX0WPxk0PzLz7UJMDbKC85QaTazGNCdqd04iIHCU2YQbRCG piPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=7YRk73VKGtvm9kKRLWMUEa41fZXyi8gPmGW3RMb+37Q=; b=kiAIkdOgS1H7dP7tIb+b0xi7Q/XdP8geQNqoY+4Bq1FM4z5CGfQnyldk3sAlsZHotc y98LI3jYMEfC3Zd3y1MEPRgs1OTE+xWGWCloDfkXsJBTjN02vXEqBjmYvQ29y5OuYRTd uGjFHcYvUlEJgnzMnNEjgeUXqyJnBCewKn/jgLR/+JYO4IKNFyLDNvTTqTlRFr2nM8iM jSGAJIIUNV2MHBejIgavHQxuaGfFUwFl7vNXUFSCqA+ZpRxjcV5SLPEmASnSgAPRrxuO jqpwVQZ7l2qZdCm4sSewR4/gVAqTCEalefpwTwLaohFWHaYY73SX8MPCe7vCYD79C5l/ 3hdw== X-Gm-Message-State: APzg51AxcvPqwLvB6zHTCMJoVW2MYTO25mMmw3/WT6TBnjMfcd4a4RWg bvsT0nZIm35O3BZbElSEPI5zRppk X-Google-Smtp-Source: ANB0VdZb9pkGkCfyg1j9LemRaBJ/r8cj208PCe2+tKLzF15vEmMJ+Pj//rmMhD01A/NGPs0rbls7iA== X-Received: by 2002:a17:902:7086:: with SMTP id z6-v6mr39707940plk.236.1537451161452; Thu, 20 Sep 2018 06:46:01 -0700 (PDT) Received: from localhost (108-223-40-66.lightspeed.sntcca.sbcglobal.net. [108.223.40.66]) by smtp.gmail.com with ESMTPSA id h4-v6sm34544474pfe.49.2018.09.20.06.46.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Sep 2018 06:46:00 -0700 (PDT) From: Guenter Roeck To: Hardware Monitoring Cc: Jean Delvare , Guenter Roeck Subject: [PATCH 12/13] hwmon: (nct6775) Add support for NCT6797D Date: Thu, 20 Sep 2018 06:45:40 -0700 Message-Id: <1537451141-27242-12-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537451141-27242-1-git-send-email-linux@roeck-us.net> References: <1537451141-27242-1-git-send-email-linux@roeck-us.net> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add support for NCT6797D. With the exception of fan/pwm configuration registers, it is mostly compatible with NCT6795D. Signed-off-by: Guenter Roeck --- drivers/hwmon/nct6775.c | 45 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c index 77255f7da974..9569acf80e18 100644 --- a/drivers/hwmon/nct6775.c +++ b/drivers/hwmon/nct6775.c @@ -42,6 +42,7 @@ * nct6793d 15 6 6 2+6 0xd120 0xc1 0x5ca3 * nct6795d 14 6 6 2+6 0xd350 0xc1 0x5ca3 * nct6796d 14 7 7 2+6 0xd420 0xc1 0x5ca3 + * nct6797d 14 7 7 2+6 0xd450 0xc1 0x5ca3 * * #temp lists the number of monitored temperature sources (first value) plus * the number of directly connectable temperature sensors (second value). @@ -69,7 +70,7 @@ #define USE_ALTERNATE enum kinds { nct6106, nct6775, nct6776, nct6779, nct6791, nct6792, nct6793, - nct6795, nct6796 }; + nct6795, nct6796, nct6797 }; /* used to set data->name = nct6775_device_names[data->sio_kind] */ static const char * const nct6775_device_names[] = { @@ -82,6 +83,7 @@ static const char * const nct6775_device_names[] = { "nct6793", "nct6795", "nct6796", + "nct6797", }; static const char * const nct6775_sio_names[] __initconst = { @@ -94,6 +96,7 @@ static const char * const nct6775_sio_names[] __initconst = { "NCT6793D", "NCT6795D", "NCT6796D", + "NCT6797D", }; static unsigned short force_id; @@ -129,6 +132,7 @@ MODULE_PARM_DESC(fan_debounce, "Enable debouncing for fan RPM signal"); #define SIO_NCT6793_ID 0xd120 #define SIO_NCT6795_ID 0xd350 #define SIO_NCT6796_ID 0xd420 +#define SIO_NCT6797_ID 0xd450 #define SIO_ID_MASK 0xFFF0 enum pwm_enable { off, manual, thermal_cruise, speed_cruise, sf3, sf4 }; @@ -504,7 +508,7 @@ static const s8 NCT6779_BEEP_BITS[] = { static const u16 NCT6779_REG_FAN[] = { 0x4c0, 0x4c2, 0x4c4, 0x4c6, 0x4c8, 0x4ca, 0x4ce }; static const u16 NCT6779_REG_FAN_PULSES[NUM_FAN] = { - 0x644, 0x645, 0x646, 0x647, 0x648, 0x649 }; + 0x644, 0x645, 0x646, 0x647, 0x648, 0x649, 0x64f }; static const u16 NCT6779_REG_CRITICAL_PWM_ENABLE[] = { 0x136, 0x236, 0x336, 0x836, 0x936, 0xa36, 0xb36 }; @@ -1288,6 +1292,7 @@ static bool is_word_sized(struct nct6775_data *data, u16 reg) case nct6793: case nct6795: case nct6796: + case nct6797: return reg == 0x150 || reg == 0x153 || reg == 0x155 || (reg & 0xfff0) == 0x4c0 || reg == 0x402 || @@ -1643,6 +1648,7 @@ static void nct6775_update_pwm_limits(struct device *dev) case nct6793: case nct6795: case nct6796: + case nct6797: reg = nct6775_read_value(data, data->REG_CRITICAL_PWM_ENABLE[i]); if (reg & data->CRITICAL_PWM_ENABLE_MASK) @@ -3077,6 +3083,7 @@ store_auto_pwm(struct device *dev, struct device_attribute *attr, case nct6793: case nct6795: case nct6796: + case nct6797: nct6775_write_value(data, data->REG_CRITICAL_PWM[nr], val); reg = nct6775_read_value(data, @@ -3496,7 +3503,11 @@ nct6775_check_fan_inputs(struct nct6775_data *data) fan3pin = !(cr24 & 0x80); pwm3pin = cr24 & 0x08; } else { - /* NCT6779D, NCT6791D, NCT6792D, NCT6793D, NCT6795D, NCT6796D */ + /* + * NCT6779D, NCT6791D, NCT6792D, NCT6793D, NCT6795D, NCT6796D, + * NCT6797D + */ + int cr1a = superio_inb(sioreg, 0x1a); int cr1b = superio_inb(sioreg, 0x1b); int cr1c = superio_inb(sioreg, 0x1c); int cr1d = superio_inb(sioreg, 0x1d); @@ -3505,6 +3516,7 @@ nct6775_check_fan_inputs(struct nct6775_data *data) int cr2d = superio_inb(sioreg, 0x2d); int cr2f = superio_inb(sioreg, 0x2f); bool dsw_en = cr2f & BIT(3); + bool ddr4_en = cr2f & BIT(4); int cre0; int creb; int cred; @@ -3577,6 +3589,23 @@ nct6775_check_fan_inputs(struct nct6775_data *data) pwm7pin = !(cr1d & (BIT(2) | BIT(3))); break; + case nct6797: + fan5pin |= !ddr4_en && (cr1b & BIT(5)); + fan5pin |= creb & BIT(5); + + fan6pin = cr2a & BIT(4); + fan6pin |= creb & BIT(3); + + fan7pin = cr1a & BIT(1); + + pwm5pin |= (creb & BIT(4)) && !(cr2a & BIT(0)); + pwm5pin |= !ddr4_en && (cr2d & BIT(7)); + + pwm6pin = creb & BIT(2); + pwm6pin |= cred & BIT(2); + + pwm7pin = cr1d & BIT(4); + break; default: /* NCT6779D */ break; } @@ -3954,8 +3983,10 @@ static int nct6775_probe(struct platform_device *pdev) case nct6793: case nct6795: case nct6796: + case nct6797: data->in_num = 15; - data->pwm_num = (data->kind == nct6796) ? 7 : 6; + data->pwm_num = (data->kind == nct6796 || + data->kind == nct6797) ? 7 : 6; data->auto_pwm_num = 4; data->has_fan_div = false; data->temp_fixed_num = 6; @@ -3989,6 +4020,7 @@ static int nct6775_probe(struct platform_device *pdev) data->virt_temp_mask = NCT6793_VIRT_TEMP_MASK; break; case nct6795: + case nct6797: data->temp_label = nct6795_temp_label; data->temp_mask = NCT6795_TEMP_MASK; data->virt_temp_mask = NCT6795_VIRT_TEMP_MASK; @@ -4267,6 +4299,7 @@ static int nct6775_probe(struct platform_device *pdev) case nct6793: case nct6795: case nct6796: + case nct6797: break; } @@ -4302,6 +4335,7 @@ static int nct6775_probe(struct platform_device *pdev) case nct6793: case nct6795: case nct6796: + case nct6797: tmp |= 0x7e; break; } @@ -4504,6 +4538,9 @@ static int __init nct6775_find(int sioaddr, struct nct6775_sio_data *sio_data) case SIO_NCT6796_ID: sio_data->kind = nct6796; break; + case SIO_NCT6797_ID: + sio_data->kind = nct6797; + break; default: if (val != 0xffff) pr_debug("unsupported chip ID: 0x%04x\n", val); From patchwork Thu Sep 20 13:45:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10607799 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 438ED6CB for ; Thu, 20 Sep 2018 13:46:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 338922D74D for ; Thu, 20 Sep 2018 13:46:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 27E262D758; Thu, 20 Sep 2018 13:46:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,URIBL_SBL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E6D32D74D for ; Thu, 20 Sep 2018 13:46:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727242AbeITT3i (ORCPT ); Thu, 20 Sep 2018 15:29:38 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:35161 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726990AbeITT3h (ORCPT ); Thu, 20 Sep 2018 15:29:37 -0400 Received: by mail-pf1-f196.google.com with SMTP id p12-v6so4413250pfh.2 for ; Thu, 20 Sep 2018 06:46:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=GXqF5FQqMUL2ch8DUVPVVLfJtwXKyIj7kFtNtgwu4E4=; b=reJIVftsxG33rnB92Z12QwELIaxVwCL77O2MHzcHq7qTEQQsU85rWk7sOCsgPcuC19 A6A6shQanhlg0J+ojuUaHWl79W7EY/vn1umxPL1z9z4Up/kQqyw/XEpsqa1b+hXK1VdR 2C1Fx0CrfnjtrmcrOtJ0KlnRb+wpnfFVIfj915kaaElOQ1WpyDW4LNYXtHMD04sbHNkl TiYHQJd4cgaDRAK+cDclpnbw38Hly8JLHgywrO844TgwCx20Kh3mSzQ137Vp6njvHRXr PEBgAG864ScfbiCJ1w8YUQ4oTsogbmJoMO/78G4F6gWy7qHILLPtdfjuzAaAjNW0ukFl rWhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=GXqF5FQqMUL2ch8DUVPVVLfJtwXKyIj7kFtNtgwu4E4=; b=hAeIUS/uKv1m4bY87/bPCwTcV8Un86vO1DfCQQxgS06EzoJhDbestnwainxiFBQBWl DKUnR/NCK8QBA/pkE5+wwhHNKGamZGbTDaM3rIVnZLF0ELVvYQ9x2TlZxkrloXnD71Tp h7YwWSzAVKBJJ9cIUiLRrT1TOxj0a+rYGW+WWHEDIahBzsVHr/r8OmvXnzrB2P8rW5Em 7meGGac4TKM4Y1s8dKaRHvivcYwoyeB60TUmJAJAWU+WK6B65N6SfEWdaJRL7gJGj+RB act8k6Iwl6ZO4hFJ2WLHeUYNaoLzmeyq2Aba7YLpR0r6dQscDc1U5bRPTp9qjTTCppRT c0jQ== X-Gm-Message-State: APzg51AnnTkrMukQyIvAOr0mdU0A9TupJsYzLtQbjUZEgyy4Mw/kZw7H yeQ1n248rD+vSjF3HZivGwsr4x44 X-Google-Smtp-Source: ANB0VdYhsuGMs7RYuiyYvjY1VBySBN/nYctedxRXi2/L9sxkza64IXB/SU0sLOkLKSiT2T3bQ0KEAg== X-Received: by 2002:a63:6385:: with SMTP id x127-v6mr37498564pgb.413.1537451162818; Thu, 20 Sep 2018 06:46:02 -0700 (PDT) Received: from localhost (108-223-40-66.lightspeed.sntcca.sbcglobal.net. [108.223.40.66]) by smtp.gmail.com with ESMTPSA id h85-v6sm37993801pfk.71.2018.09.20.06.46.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Sep 2018 06:46:02 -0700 (PDT) From: Guenter Roeck To: Hardware Monitoring Cc: Jean Delvare , Guenter Roeck Subject: [PATCH 13/13] hwmon: (nct6775) Add support for NCT6798D Date: Thu, 20 Sep 2018 06:45:41 -0700 Message-Id: <1537451141-27242-13-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537451141-27242-1-git-send-email-linux@roeck-us.net> References: <1537451141-27242-1-git-send-email-linux@roeck-us.net> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP NCT6798D is, with the exception of fan and pwm channel configuration registers, similar to other chips of the series. One interesting difference is the chip ID, which is now extended to 13 bit (the 12-bit chip ID value overlaps with the chip ID of NCT6797D). Signed-off-by: Guenter Roeck --- drivers/hwmon/nct6775.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 80 insertions(+), 4 deletions(-) diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c index 9569acf80e18..c3040079b1cb 100644 --- a/drivers/hwmon/nct6775.c +++ b/drivers/hwmon/nct6775.c @@ -43,6 +43,9 @@ * nct6795d 14 6 6 2+6 0xd350 0xc1 0x5ca3 * nct6796d 14 7 7 2+6 0xd420 0xc1 0x5ca3 * nct6797d 14 7 7 2+6 0xd450 0xc1 0x5ca3 + * (0xd451) + * nct6798d 14 7 7 2+6 0xd458 0xc1 0x5ca3 + * (0xd459) * * #temp lists the number of monitored temperature sources (first value) plus * the number of directly connectable temperature sensors (second value). @@ -70,7 +73,7 @@ #define USE_ALTERNATE enum kinds { nct6106, nct6775, nct6776, nct6779, nct6791, nct6792, nct6793, - nct6795, nct6796, nct6797 }; + nct6795, nct6796, nct6797, nct6798 }; /* used to set data->name = nct6775_device_names[data->sio_kind] */ static const char * const nct6775_device_names[] = { @@ -84,6 +87,7 @@ static const char * const nct6775_device_names[] = { "nct6795", "nct6796", "nct6797", + "nct6798", }; static const char * const nct6775_sio_names[] __initconst = { @@ -97,6 +101,7 @@ static const char * const nct6775_sio_names[] __initconst = { "NCT6795D", "NCT6796D", "NCT6797D", + "NCT6798D", }; static unsigned short force_id; @@ -133,7 +138,8 @@ MODULE_PARM_DESC(fan_debounce, "Enable debouncing for fan RPM signal"); #define SIO_NCT6795_ID 0xd350 #define SIO_NCT6796_ID 0xd420 #define SIO_NCT6797_ID 0xd450 -#define SIO_ID_MASK 0xFFF0 +#define SIO_NCT6798_ID 0xd458 +#define SIO_ID_MASK 0xFFF8 enum pwm_enable { off, manual, thermal_cruise, speed_cruise, sf3, sf4 }; @@ -761,6 +767,44 @@ static const char *const nct6796_temp_label[] = { #define NCT6796_TEMP_MASK 0xbfff0ffe #define NCT6796_VIRT_TEMP_MASK 0x80000c00 +static const char *const nct6798_temp_label[] = { + "", + "SYSTIN", + "CPUTIN", + "AUXTIN0", + "AUXTIN1", + "AUXTIN2", + "AUXTIN3", + "AUXTIN4", + "SMBUSMASTER 0", + "SMBUSMASTER 1", + "Virtual_TEMP", + "Virtual_TEMP", + "", + "", + "", + "", + "PECI Agent 0", + "PECI Agent 1", + "PCH_CHIP_CPU_MAX_TEMP", + "PCH_CHIP_TEMP", + "PCH_CPU_TEMP", + "PCH_MCH_TEMP", + "Agent0 Dimm0", + "Agent0 Dimm1", + "Agent1 Dimm0", + "Agent1 Dimm1", + "BYTE_TEMP0", + "BYTE_TEMP1", + "", + "", + "", + "Virtual_TEMP" +}; + +#define NCT6798_TEMP_MASK 0x8fff0ffe +#define NCT6798_VIRT_TEMP_MASK 0x80000c00 + /* NCT6102D/NCT6106D specific data */ #define NCT6106_REG_VBAT 0x318 @@ -1293,6 +1337,7 @@ static bool is_word_sized(struct nct6775_data *data, u16 reg) case nct6795: case nct6796: case nct6797: + case nct6798: return reg == 0x150 || reg == 0x153 || reg == 0x155 || (reg & 0xfff0) == 0x4c0 || reg == 0x402 || @@ -1649,6 +1694,7 @@ static void nct6775_update_pwm_limits(struct device *dev) case nct6795: case nct6796: case nct6797: + case nct6798: reg = nct6775_read_value(data, data->REG_CRITICAL_PWM_ENABLE[i]); if (reg & data->CRITICAL_PWM_ENABLE_MASK) @@ -3084,6 +3130,7 @@ store_auto_pwm(struct device *dev, struct device_attribute *attr, case nct6795: case nct6796: case nct6797: + case nct6798: nct6775_write_value(data, data->REG_CRITICAL_PWM[nr], val); reg = nct6775_read_value(data, @@ -3505,7 +3552,7 @@ nct6775_check_fan_inputs(struct nct6775_data *data) } else { /* * NCT6779D, NCT6791D, NCT6792D, NCT6793D, NCT6795D, NCT6796D, - * NCT6797D + * NCT6797D, NCT6798D */ int cr1a = superio_inb(sioreg, 0x1a); int cr1b = superio_inb(sioreg, 0x1b); @@ -3606,6 +3653,23 @@ nct6775_check_fan_inputs(struct nct6775_data *data) pwm7pin = cr1d & BIT(4); break; + case nct6798: + fan6pin = !(cr1b & BIT(0)) && (cre0 & BIT(3)); + fan6pin |= cr2a & BIT(4); + fan6pin |= creb & BIT(5); + + fan7pin = cr1b & BIT(5); + fan7pin |= !(cr2b & BIT(2)); + fan7pin |= creb & BIT(3); + + pwm6pin = !(cr1b & BIT(0)) && (cre0 & BIT(4)); + pwm6pin |= !(cred & BIT(2)) && (cr2a & BIT(3)); + pwm6pin |= (creb & BIT(4)) && !(cr2a & BIT(0)); + + pwm7pin = !(cr1d & (BIT(2) | BIT(3))); + pwm7pin |= cr2d & BIT(7); + pwm7pin |= creb & BIT(2); + break; default: /* NCT6779D */ break; } @@ -3984,9 +4048,11 @@ static int nct6775_probe(struct platform_device *pdev) case nct6795: case nct6796: case nct6797: + case nct6798: data->in_num = 15; data->pwm_num = (data->kind == nct6796 || - data->kind == nct6797) ? 7 : 6; + data->kind == nct6797 || + data->kind == nct6798) ? 7 : 6; data->auto_pwm_num = 4; data->has_fan_div = false; data->temp_fixed_num = 6; @@ -4030,6 +4096,11 @@ static int nct6775_probe(struct platform_device *pdev) data->temp_mask = NCT6796_TEMP_MASK; data->virt_temp_mask = NCT6796_VIRT_TEMP_MASK; break; + case nct6798: + data->temp_label = nct6798_temp_label; + data->temp_mask = NCT6798_TEMP_MASK; + data->virt_temp_mask = NCT6798_VIRT_TEMP_MASK; + break; } data->REG_CONFIG = NCT6775_REG_CONFIG; @@ -4300,6 +4371,7 @@ static int nct6775_probe(struct platform_device *pdev) case nct6795: case nct6796: case nct6797: + case nct6798: break; } @@ -4336,6 +4408,7 @@ static int nct6775_probe(struct platform_device *pdev) case nct6795: case nct6796: case nct6797: + case nct6798: tmp |= 0x7e; break; } @@ -4541,6 +4614,9 @@ static int __init nct6775_find(int sioaddr, struct nct6775_sio_data *sio_data) case SIO_NCT6797_ID: sio_data->kind = nct6797; break; + case SIO_NCT6798_ID: + sio_data->kind = nct6798; + break; default: if (val != 0xffff) pr_debug("unsupported chip ID: 0x%04x\n", val);