From patchwork Thu Feb 9 15:06:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 9565235 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 CD7A7601C3 for ; Thu, 9 Feb 2017 17:18:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE1CA2840B for ; Thu, 9 Feb 2017 17:18:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2C5828446; Thu, 9 Feb 2017 17:18:13 +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_SIGNED, 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 27F202840B for ; Thu, 9 Feb 2017 17:18:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752347AbdBIRSM (ORCPT ); Thu, 9 Feb 2017 12:18:12 -0500 Received: from bh-25.webhostbox.net ([208.91.199.152]:57330 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751670AbdBIRSK (ORCPT ); Thu, 9 Feb 2017 12:18:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=roeck-us.net; s=default; h=References:In-Reply-To:Message-Id:Date:Subject: Cc:To:From; bh=2wWrX47FiQ3xDH0gXhuKNDW1aZyQg0vwp+gCIOPJ8QM=; b=aERIVzdNY16EjR BBRrLtqMFxtqzLDfJqrxikDGvyBRPebknJFpOOZGICFBRswOEbOjuNhDeWi3wmSTpmspA3td+LyBx PIOYhT5z03Gu/6x6AqW+9OMpC8aggKiIvHR6bHhnGlu6p+dQzGEqEM8oulBTBfEFAnC9ljl88c8+f 8ojZPTlgteusMWYA63l97lNvL3fYgomO/ncABqf0fGyzJku7ZIfKQxhS7NeUZ3oht8layWK/8DTiw epanJ71AMmokGZaB3kiM70PixkwfWeF668ybXBlks99hy9+TAm3TJgihpkNzEr76fzINN0dUqGXk1 H+ttscQeacgUE7cnvt7w==; Received: from 108-223-40-66.lightspeed.sntcca.sbcglobal.net ([108.223.40.66]:59142 helo=localhost) by bh-25.webhostbox.net with esmtpa (Exim 4.86_1) (envelope-from ) id 1cbqIe-003zB5-8G; Thu, 09 Feb 2017 15:06:20 +0000 From: Guenter Roeck To: Hardware Monitoring Cc: Jean Delvare , Guenter Roeck Subject: [PATCH 4/7] hwmon: (it87) Ensure that pwm control cache is current before updating values Date: Thu, 9 Feb 2017 07:06:12 -0800 Message-Id: <1486652775-3926-4-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1486652775-3926-1-git-send-email-linux@roeck-us.net> References: <1486652775-3926-1-git-send-email-linux@roeck-us.net> X-Authenticated_sender: guenter@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: guenter@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: guenter@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: 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 If sensor attributes were never read, the pwm control data has not been initiialized, which can cause wrong driver behavior. Ensure that cached data is current before acting on it. Cc: stable@vger.kernel.org # 4.4+ Reported-by: Kevin Folz Signed-off-by: Guenter Roeck --- drivers/hwmon/it87.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index 11a28b233006..85918d8a747a 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -1360,6 +1360,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, return -EINVAL; mutex_lock(&data->update_lock); + it87_update_pwm_ctrl(data, nr); if (has_newer_autopwm(data)) { /* * If we are in automatic mode, the PWM duty cycle register @@ -1472,6 +1473,7 @@ static ssize_t set_pwm_temp_map(struct device *dev, } mutex_lock(&data->update_lock); + it87_update_pwm_ctrl(data, nr); data->pwm_temp_map[nr] = reg; /* * If we are in automatic mode, write the temp mapping immediately;