Received: by 10.192.165.148 with SMTP id m20csp2433210imm; Sun, 22 Apr 2018 07:02:21 -0700 (PDT) X-Google-Smtp-Source: AIpwx48lD6kd/K7y62UWfPxASfNy6e7vI5ePG2msgjDqfZ2g36pFsDs+pukiMAW4r3afpNi1eoKI X-Received: by 10.101.77.198 with SMTP id q6mr14441833pgt.61.1524405741321; Sun, 22 Apr 2018 07:02:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524405741; cv=none; d=google.com; s=arc-20160816; b=EzSOE1+hmz6O4jTYPsFXzAXLDRCWRk6J2zZXBkhU0UNIXtgmdVxW07ZWiYp2UhThqM ve2X2VqqU3acB8QF8NB/9XYduM0LQ1MCzmwiS3bzjGzwvF0tMZb1+30BQKKQ8NPCiVed xRg3FCRiTCvLZvADVlg17ApB7Ln6BkETdJRXyshmPjbcdTTZaqjv/zxEJf0mPaxG3WMw vmQ9ayMPRFNK8osI1Bu95euLr/TfHrgCLi+M5f24/Q1jZatYhGG9FSRdIpIr6uIdH4w2 efiMjORCmIlQjp/lHCE/6/1BxrvyOLi1PJNDCk52vYy9Mmrw2w12MpFvNH2hI6cKpJ3P Zv7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=yelcw4EGyCFgi1XTVusKbBfzuAxQUd8akiIJdBsZfaI=; b=Kk3jNETIvMJPYvKCStUGRNRE2KWeqHCnllcXIWOYhH4nuN8dVKGdwndNZ6Zsh9p8i/ GArF1RNmXb/PoIwcND/6u026f6gZDbCfRlxir3C3sYkydrAxV6ARICg6cDUkUUI0OYZT 00Oj9PMs0Znxz7Wkuk4Agk+r3S2vr376+1hZzfTQZ1lqqfL2TkCZcuQoVVcFocWsUEd+ 8vJ56MWCjxMvZLZiiZpVC2ek0wVFLBFjd9TOEJrwYty+Erxx/u0ebM5V36bAkHEO14qp ZFcEw8JZXtzV+9wDH5JU1dS7HEFWjbuWAQLB1xOlXmOW99oFmWI+WlynX6fCFPLbsFZE YG9A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e17si8172377pgr.475.2018.04.22.07.02.06; Sun, 22 Apr 2018 07:02:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754613AbeDVOAx (ORCPT + 99 others); Sun, 22 Apr 2018 10:00:53 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47640 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754598AbeDVOAu (ORCPT ); Sun, 22 Apr 2018 10:00:50 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 0E705BC8; Sun, 22 Apr 2018 14:00:49 +0000 (UTC) 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.16 144/196] pwm: rcar: Fix a condition to prevent mismatch value setting to duty Date: Sun, 22 Apr 2018 15:52:44 +0200 Message-Id: <20180422135111.678772845@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135104.278511750@linuxfoundation.org> References: <20180422135104.278511750@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-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);