Received: by 10.192.165.148 with SMTP id m20csp2482281imm; Sun, 22 Apr 2018 07:59:21 -0700 (PDT) X-Google-Smtp-Source: AIpwx49pcLalzSlxOgwjfxtpH4PXp54Ycm5Hh3W10xqDGM6NgkLrHXBGnr231FMnKSo9KRVytVZj X-Received: by 10.98.219.5 with SMTP id f5mr8012403pfg.137.1524409161304; Sun, 22 Apr 2018 07:59:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524409161; cv=none; d=google.com; s=arc-20160816; b=Yx3SVJtu5j1/mEOYo8MMyXdRs/jW7x5i4lhaOmCHdSw7pxD+50Ap6ibdNxHooqgRE8 T5hTAoB6Rk4zrluG6yJP6zKdeA/PBJ/ZVlygA+e+k+TQosOkjsCWJaeZxB8HuldIPBUo KA4BgUnA2LI1llMyl9/E/J1WyYd33Q+LX/hfUqF/hsTEPlv6PFRqOweOudLONI14+KO2 mKDdLLN82d6HA5YQdv5XHOeF28eTLJnPiI25zTpGE80wyyA1KwqeqgoE0ziakNTqzwaD UF3tlGv28Mw4XRuYIJpOTaM40mHvEmtKP72ACkieHLtAm85z0Jm/9hf7ttTCx+B1AXWS +P7Q== 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=ML/2hBxGPoiADxK77zuImUl377uibHk2n/IIVdMyGcw=; b=lCSdp9v6bY5bhbNOEHVIFjvzQlE8wSYWeiQ5rNPq8OaDIBuBf26iNKAtCkguD98O1s NLHIv9pKH5xHd2zIi3/ZWm1Hn/cCELEpKASVUlf2DOFzSDU1FYKGSc4Y07HCBNVWjh3R IgSA+qLNRIQR3dpCw8Az2W/0+Z0Xcp6T7WagR6WxkEMi0deYM8jo5hvE0NEsxmIaNDFQ vGHNaq7qIu8P3VLInCQNu+yxB2frnP6ua6MtR+fY8ss9RPFKpsxlePu3W5vfETQhScce CMeekMNgUp+kJhNBDK1tXJRI7lKY/2VyuuCikYG78npsTVGriDA7wgp0T5IPGb5UCzon f6fg== 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 n16-v6si10107612pll.66.2018.04.22.07.59.07; Sun, 22 Apr 2018 07:59: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 S1756852AbeDVON1 (ORCPT + 99 others); Sun, 22 Apr 2018 10:13:27 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:55620 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756578AbeDVONS (ORCPT ); Sun, 22 Apr 2018 10:13:18 -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 1ADCECC6; Sun, 22 Apr 2018 14:13:16 +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.9 55/95] pwm: rcar: Fix a condition to prevent mismatch value setting to duty Date: Sun, 22 Apr 2018 15:53:24 +0200 Message-Id: <20180422135212.672734362@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135210.432103639@linuxfoundation.org> References: <20180422135210.432103639@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.9-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);