From patchwork Sun Apr 12 18:44:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Moon X-Patchwork-Id: 6203831 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DD74CBF4A6 for ; Sun, 12 Apr 2015 18:45:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 13C4F20122 for ; Sun, 12 Apr 2015 18:45:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 26A3A20268 for ; Sun, 12 Apr 2015 18:45:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752145AbbDLSpZ (ORCPT ); Sun, 12 Apr 2015 14:45:25 -0400 Received: from mail-pd0-f196.google.com ([209.85.192.196]:36253 "EHLO mail-pd0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752152AbbDLSpY (ORCPT ); Sun, 12 Apr 2015 14:45:24 -0400 Received: by pdev10 with SMTP id v10so21617598pde.3; Sun, 12 Apr 2015 11:45:24 -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:in-reply-to:references; bh=7i0DJW0ALZd2Egx+/UnHf/F+WIuNGPRgu/7jw5FyESk=; b=GiQz8scm7bZvgl4+0BzE3vOTapzZxlY9JMJCdwVkITxz8x1+XBc3zADgtoHdRXt64x gQcPzflbR0SLKnUYYBtq/crvo6HRWcGT2BzLnMowto/MHqIy1LKxg6NsUgezH/WRb1Q5 ykdFXvEa34Q5x4zm0BqAUCy62JI6dn9jDXx1/rmio3FJ/D8GPsbrNupHgUMHYSMTwcMX nOn0+Pphuz4b5F5cCOkbg8mv3wD5Sn4szdqG8dMwgAiLsX79uifiFjb1pY+iHjI53JS5 YqTv+MdXm6XjP8/8KJWItlJgZ0oEi6jd3Idll0rQwCuLMvg20Oe2zrxEPME60Mp3BVrg b8DQ== X-Received: by 10.70.129.10 with SMTP id ns10mr19825005pdb.87.1428864324425; Sun, 12 Apr 2015 11:45:24 -0700 (PDT) Received: from odroidxu3.localdomain ([115.117.44.43]) by mx.google.com with ESMTPSA id xt9sm4958539pbc.14.2015.04.12.11.45.17 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 12 Apr 2015 11:45:23 -0700 (PDT) From: Anand Moon To: Lukasz Majewski , Guenter Roeck , Eduardo Valentin , Sjoerd Simons , Markus Reichl , Russell King , Kukjin Kim Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, Anand Moon Subject: [PATCH v4 6/6] hwmon: pwm-fan: Update the duty cycle inorder to control the pwm-fan Date: Mon, 13 Apr 2015 04:14:11 +0930 Message-Id: <1428864251-31780-7-git-send-email-linux.amoon@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1428864251-31780-1-git-send-email-linux.amoon@gmail.com> References: <1428864251-31780-1-git-send-email-linux.amoon@gmail.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP pwm_config() must be called with a duty cycle of 0 prior to calling pwm_disable() to ensure that the pwm signal is set to low. Changes since v1 : None. Changes since v2 : None Changes since v3 : Simplify the comment. Reported-by: Markus Reichl Tested-by: Markus Reichl Reviewed-by: Lukasz Majewski Reviewed-by: Sjoerd Simons Signed-off-by: Anand Moon --- drivers/hwmon/pwm-fan.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c index 7c83dc4..c2a469e 100644 --- a/drivers/hwmon/pwm-fan.c +++ b/drivers/hwmon/pwm-fan.c @@ -47,23 +47,20 @@ static int __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm) if (ctx->pwm_value == pwm) goto exit_set_pwm_err; - if (pwm == 0) { - pwm_disable(ctx->pwm); - goto exit_set_pwm; - } - duty = DIV_ROUND_UP(pwm * (ctx->pwm->period - 1), MAX_PWM); ret = pwm_config(ctx->pwm, duty, ctx->pwm->period); if (ret) goto exit_set_pwm_err; + if (pwm == 0) + pwm_disable(ctx->pwm); + if (ctx->pwm_value == 0) { ret = pwm_enable(ctx->pwm); if (ret) goto exit_set_pwm_err; } -exit_set_pwm: ctx->pwm_value = pwm; exit_set_pwm_err: mutex_unlock(&ctx->lock);