From patchwork Sat May 21 14:52:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 9130585 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CA84260221 for ; Sat, 21 May 2016 14:53:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB4E327B89 for ; Sat, 21 May 2016 14:53:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8ED0B28135; Sat, 21 May 2016 14:53:04 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 2E89727B89 for ; Sat, 21 May 2016 14:53:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752053AbcEUOxD (ORCPT ); Sat, 21 May 2016 10:53:03 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:35718 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751209AbcEUOxB (ORCPT ); Sat, 21 May 2016 10:53:01 -0400 Received: by mail-wm0-f68.google.com with SMTP id s63so3896728wme.2; Sat, 21 May 2016 07:53:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LMYMfkhWUYQiof45FUoJoFcIKts7jPcS3eE2js/QNnM=; b=RZ50V2S4mBbAhvhAORXPIPTn8AC9FnxYhFekGL60QrXygZSZGkOGe4POS0lVnci+cF ANuz/JFpXBIj9IFq+i6AfXZjRr99mW60y80FmlGKDbzlVh8GMKMiykyM3aT2nMvQ0KL2 6WpW/cvl04jTivuEjpr5SVxMpEThCcrnTHyqe1qW9T7JyzBuIrDXvwQsYPiJmswDS/z/ kizM7+N7ZyX+8+pspm2YW2MheFmXH8h4fP1frjtN/3pw5x17XB5Z9ZAA//F5V/rqx9wc 47OXUhxba02c+Sl77PVNJpvwjg4jWPQltAfohqEa1ND6LNZ99tkwVadUbcJfQVEAoHlT eEGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LMYMfkhWUYQiof45FUoJoFcIKts7jPcS3eE2js/QNnM=; b=OGepVblnQU6OSl2i5Lq3rEioWux667QhtM686Mw/uV0kp/W6X2yDbdhh74ad/rVeuG oBqZ5E3fg696g4HnYsmxZdGoDddwQUXAwrIDwBr37z+j0McJPheEyuSzqqW3TchX32aY SSsxRZpJmCa8UHoEagL5lzWgXriktaOtkcbWqNFMbzA/EQDj80LvBezvWt5ZlE5MbXRc odUS2dzBWe6EANY9eB15lZg/qN6wVaJiufX9cDBxDtPErRRr5wfekuABgcrCduPvmhxE YOPkFnt+25mKQbNtQQoGodoYqsMvNsSuel/18EF1MikhHzqAOMXZDhlTOk8gYqDWXOq4 w2wQ== X-Gm-Message-State: AOPr4FVmzRJQLEmJM3JVfdzZYsrCojoJ/5zha4KMHzNKYypUQFIMFRPCrXYJ3KwZOHoN9A== X-Received: by 10.194.216.33 with SMTP id on1mr8322437wjc.120.1463842380056; Sat, 21 May 2016 07:53:00 -0700 (PDT) Received: from Pali-Latitude.lan (pali.kolej.mff.cuni.cz. [78.128.193.202]) by smtp.gmail.com with ESMTPSA id g197sm3727034wme.15.2016.05.21.07.52.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 21 May 2016 07:52:59 -0700 (PDT) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Jean Delvare , Guenter Roeck , Tolga Cakir Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= Subject: [PATCH] dell-smm-hwmon: Detect fan with index=2 Date: Sat, 21 May 2016 16:52:46 +0200 Message-Id: <1463842366-17964-1-git-send-email-pali.rohar@gmail.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 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 Some Dell machines (e.g. Dell Precision M3800) have two fans, first with index=0 and second with index=2. So export also attributes for third fan device with index=2. Reported-by: Tolga Cakir Signed-off-by: Pali Rohár Tested-by: without explicit permission (some people don't want to see --- drivers/hwmon/dell-smm-hwmon.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) --- Hi Tolga! Can you test this patch if sensors see fan device correctly? diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c index 577445f..7a2764a 100644 --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -78,6 +78,7 @@ static uint i8k_fan_max = I8K_FAN_HIGH; #define I8K_HWMON_HAVE_TEMP4 (1 << 3) #define I8K_HWMON_HAVE_FAN1 (1 << 4) #define I8K_HWMON_HAVE_FAN2 (1 << 5) +#define I8K_HWMON_HAVE_FAN3 (1 << 6) MODULE_AUTHOR("Massimo Dal Zotto (dz@debian.org)"); MODULE_AUTHOR("Pali Rohár "); @@ -246,7 +247,7 @@ static int _i8k_get_fan_type(int fan) static int i8k_get_fan_type(int fan) { /* I8K_SMM_GET_FAN_TYPE SMM call is expensive, so cache values */ - static int types[2] = { INT_MIN, INT_MIN }; + static int types[3] = { INT_MIN, INT_MIN, INT_MIN }; if (types[fan] == INT_MIN) types[fan] = _i8k_get_fan_type(fan); @@ -707,6 +708,12 @@ static SENSOR_DEVICE_ATTR(fan2_label, S_IRUGO, i8k_hwmon_show_fan_label, NULL, 1); static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, i8k_hwmon_show_pwm, i8k_hwmon_set_pwm, 1); +static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, i8k_hwmon_show_fan, NULL, + 2); +static SENSOR_DEVICE_ATTR(fan3_label, S_IRUGO, i8k_hwmon_show_fan_label, NULL, + 2); +static SENSOR_DEVICE_ATTR(pwm3, S_IRUGO | S_IWUSR, i8k_hwmon_show_pwm, + i8k_hwmon_set_pwm, 2); static struct attribute *i8k_attrs[] = { &sensor_dev_attr_temp1_input.dev_attr.attr, /* 0 */ @@ -723,6 +730,9 @@ static struct attribute *i8k_attrs[] = { &sensor_dev_attr_fan2_input.dev_attr.attr, /* 11 */ &sensor_dev_attr_fan2_label.dev_attr.attr, /* 12 */ &sensor_dev_attr_pwm2.dev_attr.attr, /* 13 */ + &sensor_dev_attr_fan3_input.dev_attr.attr, /* 14 */ + &sensor_dev_attr_fan3_label.dev_attr.attr, /* 15 */ + &sensor_dev_attr_pwm3.dev_attr.attr, /* 16 */ NULL }; @@ -747,6 +757,9 @@ static umode_t i8k_is_visible(struct kobject *kobj, struct attribute *attr, if (index >= 11 && index <= 13 && !(i8k_hwmon_flags & I8K_HWMON_HAVE_FAN2)) return 0; + if (index >= 14 && index <= 16 && + !(i8k_hwmon_flags & I8K_HWMON_HAVE_FAN3)) + return 0; return attr->mode; } @@ -788,6 +801,11 @@ static int __init i8k_init_hwmon(void) if (err >= 0) i8k_hwmon_flags |= I8K_HWMON_HAVE_FAN2; + /* Third fan attributes, if fan status is OK */ + err = i8k_get_fan_status(2); + 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)) {