From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AIpwx48Xh0nc4RZGqKC7td4LERmJ3ru9C3hxnCoDuRgfAiZh+JV/HFr0dXQMK/wMA+ThmOfVVx9E ARC-Seal: i=1; a=rsa-sha256; t=1524406189; cv=none; d=google.com; s=arc-20160816; b=DzL8ULy1H4sGY6GlI4y0SH/k69mhHv3nRFMa5h7oFRD9aUkLLuyhyfGTiHGr1xY8vv 7KzCwQJ3d7/StiUKqcmJd/KlmaP2/AGjIQCKZigdFqUzz2vMgqcOHA7sTQB6i4PpgSEE 1hzEEawPGy0yxeyhWVb472QVG0QMxYLQMvNtE+lbuCLHZi/E727WeHGZFoIAL+zP9BJX TndpxUoBJO+URx5k0bnFWtAKUlV2BvrPOKSrQXWZWJuu3a6mQBmoE0WRmaWPSVJVFlCg f9k8Q+FyMqMUT6U1fi9gI3l5r2grY20Yx61UyeZgtAzPwcwMALclVYRJa/ZnINS7cxow ar2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=+frRstWfNxGZF+2RJ3Sn5Q3Bz8/1KoxtdP9V8Akokf4=; b=itUOgRGHoYOiYeU8vmV5cxA3LAX6TJ+ga33VfXoLqg8UpEX0lBhWy5wyocYzA55AoW Fo1pTtI3IuOZ5KOiE/hhPLVvHKoiDNszQKaDAKxVEO5r4FHu2cuSh8EbNlDoBXcOfHua dl11EPoCiKiDPX7nH+R9DhUqIBIChVIYROcZlHuIVxIAiF7T54RkzC453mVCZxqOrfQO SvdIpBw1X5kw/CX17cOXNsA2dHQxhqYErBzGUPgS3HtYSac9q49TTOy7ac5lETG1Lg7b t7mwIFXsfGDDB+/Y3SbBHgpINAroPlRaF0CfhMhF7UGWX+hs1nzw8kRIUvztyBCuKuhX /xDg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.61.202 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.61.202 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ryo Kodama , Yoshihiro Shimoda , Thierry Reding Subject: [PATCH 4.14 110/164] pwm: rcar: Fix a condition to prevent mismatch value setting to duty Date: Sun, 22 Apr 2018 15:52:57 +0200 Message-Id: <20180422135139.921304179@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135135.400265110@linuxfoundation.org> References: <20180422135135.400265110@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-LABELS: =?utf-8?b?IlxcU2VudCI=?= X-GMAIL-THRID: =?utf-8?q?1598455179558779076?= X-GMAIL-MSGID: =?utf-8?q?1598455744418852532?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ryo Kodama commit 6225f9c64b40bc8a22503e9cda70f55d7a9dd3c6 upstream. This patch fixes an issue that is possible to set mismatch value to duty for R-Car PWM if we input the following commands: # cd /sys/class/pwm// # echo 0 > export # cd pwm0 # echo 30 > period # echo 30 > duty_cycle # echo 0 > duty_cycle # cat duty_cycle 0 # echo 1 > enable --> Then, the actual duty_cycle is 30, not 0. So, this patch adds a condition into rcar_pwm_config() to fix this issue. Signed-off-by: Ryo Kodama [shimoda: revise the commit log and add Fixes and Cc tags] Fixes: ed6c1476bf7f ("pwm: Add support for R-Car PWM Timer") Cc: Cc: # v4.4+ Signed-off-by: Yoshihiro Shimoda Signed-off-by: Thierry Reding Signed-off-by: Greg Kroah-Hartman --- drivers/pwm/pwm-rcar.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/pwm/pwm-rcar.c +++ b/drivers/pwm/pwm-rcar.c @@ -156,8 +156,12 @@ static int rcar_pwm_config(struct pwm_ch if (div < 0) return div; - /* Let the core driver set pwm->period if disabled and duty_ns == 0 */ - if (!pwm_is_enabled(pwm) && !duty_ns) + /* + * Let the core driver set pwm->period if disabled and duty_ns == 0. + * But, this driver should prevent to set the new duty_ns if current + * duty_cycle is not set + */ + if (!pwm_is_enabled(pwm) && !duty_ns && !pwm->state.duty_cycle) return 0; rcar_pwm_update(rp, RCAR_PWMCR_SYNC, RCAR_PWMCR_SYNC, RCAR_PWMCR);