Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3346485pxv; Sun, 4 Jul 2021 16:11:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWVKRsQYXVfji1uSCbp8jFG9PU0u/uvs2QENDBzexft8YKkt9zOezqmznFB9h03+aQ86hu X-Received: by 2002:a05:6402:2681:: with SMTP id w1mr12638539edd.275.1625440270423; Sun, 04 Jul 2021 16:11:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625440270; cv=none; d=google.com; s=arc-20160816; b=X/jHCj7r3DGNDGhmnwyePMgpM76m2D6E/McRrru1WKD8hgSUJzPx9cyVwtHtLeByK0 b6T9iI7DFm3CkA+3G5MR3PH9C05QCjferlEmXd+2IofV3JEeVZub+y4pP17tF/Vpy49l HgUucBQCY18fwOLJKjw4zZKbXoD7NLL/Z0fguUIfAKBCWBF2oocJIKdp0FE3JwfGhvBg hQJElG6JyMxFQlYrslF82AolE+zKp12+Yh+U/oJoSYTETG9SVK8R+LncyO7T1j39FIOF KA8WuX2Octj/xTSZmfkcO0lWBbOXqoNtZXVwZEXFxbuB7vuWGI1ZJQj/Z4cU/H+5IcmQ Pepw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=S0Trz+TeAUXpDN4AsHDe6K5wzmv97lbwp8pJnCMU1l8=; b=GsP44UCainqON/JbYV79qs+FTy1ztJwdpLVEzmewcGnqjflptxhM+vj0f2HmiNrqzq L1/uNOBTVjOTjOKUpMhHW3l3FXaN7j+d3OkUf0izpxmtLoS7akUuIkNhESiWGgXPOQyh sAqRcHNjPDi9pcTQg/3af5qHxDwF21HiTEALPIDWRtTOyFdvLjLvozcUXVjkVhhn2XJq c9p6rc/m6iQ/BbERtXnMINJID8ZkuT7Rp8m5GQ6ejbjwQntdDehZAcUC4eMClwLNY3v3 7f1LYHo+9mVywQzZkH+Kxph51YCoJHfAGpU8Jqkj5uNkPSGeKr6EkLlIMYsqIjIcVTf8 lSWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SdWL3FTG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cm7si9725274edb.599.2021.07.04.16.10.46; Sun, 04 Jul 2021 16:11:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SdWL3FTG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229728AbhGDXMF (ORCPT + 99 others); Sun, 4 Jul 2021 19:12:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:47610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232391AbhGDXKO (ORCPT ); Sun, 4 Jul 2021 19:10:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 530BD61283; Sun, 4 Jul 2021 23:07:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625440057; bh=VuBZkuYORyCKJqQ3ug2x8UyRbKpNijoZunM6p8muHn4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SdWL3FTGhB7PsiPOCgTS1GVbzdLCQcI3Ci77Ql6v6g+osfFDeM/xnKGc/Y9zjlWNL SOdtYUjt0+UOnqufeARy0aw7HMiygCIFfs4yU5DtungBszTBsZWFWGq3WmSw3rz+PF S7uexF1wTaYINXOjMh7KUMHVGtko6UHm31k8Qr2gr9DdYj6bTjhYkV3FCclgq7GLEz k9WoSZV807QSd4gjeLjnWmUbdy2ipNDr+88CUlBTz9wX2bTe+TFDeaeyUGc4DX9+e5 Fqc+nQLv78I8Fd9C9C8Xxb4Hk8HjZuGtO6C7SyUO+WeyUC7ZpBfMVesorGyBzwuzLB WvfteTU4pD6BQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Guenter Roeck , =?UTF-8?q?Jan=20Kundr=C3=A1t?= , =?UTF-8?q?V=C3=A1clav=20Kubern=C3=A1t?= , =?UTF-8?q?V=C3=A1clav=20Kubern=C3=A1t?= , Sasha Levin , linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH AUTOSEL 5.12 60/80] hwmon: (max31790) Report correct current pwm duty cycles Date: Sun, 4 Jul 2021 19:05:56 -0400 Message-Id: <20210704230616.1489200-60-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210704230616.1489200-1-sashal@kernel.org> References: <20210704230616.1489200-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Guenter Roeck [ Upstream commit 897f6339893b741a5d68ae8e2475df65946041c2 ] The MAX31790 has two sets of registers for pwm duty cycles, one to request a duty cycle and one to read the actual current duty cycle. Both do not have to be the same. When reporting the pwm duty cycle to the user, the actual pwm duty cycle from pwm duty cycle registers needs to be reported. When setting it, the pwm target duty cycle needs to be written. Since we don't know the actual pwm duty cycle after a target pwm duty cycle has been written, set the valid flag to false to indicate that actual pwm duty cycle should be read from the chip instead of using cached values. Cc: Jan Kundrát Cc: Václav Kubernát Signed-off-by: Guenter Roeck Tested-by: Václav Kubernát Reviewed-by: Jan Kundrát Link: https://lore.kernel.org/r/20210526154022.3223012-3-linux@roeck-us.net Signed-off-by: Sasha Levin --- Documentation/hwmon/max31790.rst | 3 ++- drivers/hwmon/max31790.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Documentation/hwmon/max31790.rst b/Documentation/hwmon/max31790.rst index f301385d8cef..54ff0f49e28f 100644 --- a/Documentation/hwmon/max31790.rst +++ b/Documentation/hwmon/max31790.rst @@ -39,5 +39,6 @@ fan[1-12]_input RO fan tachometer speed in RPM fan[1-12]_fault RO fan experienced fault fan[1-6]_target RW desired fan speed in RPM pwm[1-6]_enable RW regulator mode, 0=disabled, 1=manual mode, 2=rpm mode -pwm[1-6] RW fan target duty cycle (0-255) +pwm[1-6] RW read: current pwm duty cycle, + write: target pwm duty cycle (0-255) ================== === ======================================================= diff --git a/drivers/hwmon/max31790.c b/drivers/hwmon/max31790.c index 86e6c71db685..8ad7a45bfe68 100644 --- a/drivers/hwmon/max31790.c +++ b/drivers/hwmon/max31790.c @@ -104,7 +104,7 @@ static struct max31790_data *max31790_update_device(struct device *dev) data->tach[NR_CHANNEL + i] = rv; } else { rv = i2c_smbus_read_word_swapped(client, - MAX31790_REG_PWMOUT(i)); + MAX31790_REG_PWM_DUTY_CYCLE(i)); if (rv < 0) goto abort; data->pwm[i] = rv; @@ -299,10 +299,10 @@ static int max31790_write_pwm(struct device *dev, u32 attr, int channel, err = -EINVAL; break; } - data->pwm[channel] = val << 8; + data->valid = false; err = i2c_smbus_write_word_swapped(client, MAX31790_REG_PWMOUT(channel), - data->pwm[channel]); + val << 8); break; case hwmon_pwm_enable: fan_config = data->fan_config[channel]; -- 2.30.2