Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2189100ybh; Fri, 17 Jul 2020 11:25:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgd2BDIpdG/ZWFuQjxNN8a6ww4aZV/hA+zBFKIqFWK+sMDay147V9DrziGWb5stXporDFH X-Received: by 2002:a17:907:1114:: with SMTP id qu20mr10219421ejb.41.1595010323999; Fri, 17 Jul 2020 11:25:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595010323; cv=none; d=google.com; s=arc-20160816; b=Ik1ef+cRKNP439vfXzBznyftHLOGy7aAxyxua//DMueInd/b3U4xxivQl0NSyqVY+h tqiSCdNb1OEwB8/OoLyVbb20aIjDCe7IXQd2OxndNqnYw8CJJ2NvMwhQ2YpZXSI67As2 FjRv7AF+tSXwcijBnO3X9ZriwXdvUJBFBzVN6vr9ItPrdwd/W6lRljRgZN4aTz2Zhi8v fKDcRR9jVKWl8IGLt4uwm1/Y6BsFq6qC8XgxvXDaqxvIOoc/ouyzfq1QM3dgSxucPCFU x6ZjbrHOAvOu1lWoX/+5vPJHRqtokoSkU8ec7gJbyM75ww+QjW2fjKiWmoT1C2uv6/UM VtfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=DDNq82UFJqZNA4W/58Gu3txutqShlfCsws0dFK3kxJE=; b=M1ubot3yU3cXwgwbaLo1p3w6zC+5H8iD3G9sD7RfldnW/A4KBNsPBI8bDncFvYP/tk A7GNquovgR2zDaokG6dtFKn2nVCZ09X/i+q2GtloihDXGM+mgRdgxOF7cp90/9lj9Bgs tCb6yzaD58UEG7To1W+dIaW8s0Lk0WKLpV2F0E9BLZwyoCHkF19fscyWjliEC5t+ZxoK WJ4oUEasjhzR1kjCOmL1EuuVSlRcBvm83Dp0SMIWBQw5jx0b7JqOx8eHcjFrXezS8vEz MQMjP1l6AlA5iQBDioEryvCE9fs7URH7Kkh390ws/J6jDoHMpBr1taJBH1lslvkjW1E/ 2nvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=LLG+jSbK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bk19si5763047ejb.338.2020.07.17.11.25.00; Fri, 17 Jul 2020 11:25:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=LLG+jSbK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726322AbgGQSYv (ORCPT + 99 others); Fri, 17 Jul 2020 14:24:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726104AbgGQSYu (ORCPT ); Fri, 17 Jul 2020 14:24:50 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF0AAC0619D2 for ; Fri, 17 Jul 2020 11:24:50 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id x72so5805825pfc.6 for ; Fri, 17 Jul 2020 11:24:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=DDNq82UFJqZNA4W/58Gu3txutqShlfCsws0dFK3kxJE=; b=LLG+jSbKBImbmDFyI1xmUqQ8xLaVWPxVVlBhinJlrp11+Qk9Pz/8Y8lOvrj2H/XFZG lR0bYUIVNJYfGHVeK8GJn4GjqjS3tXTclQ1E2EVjbZ+/80+DnnwH5ga1gRkDGr8PjwLM Psh3JwTCEgHNPQ7Zk0WL9iOaxSbp3q2+AqlBw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=DDNq82UFJqZNA4W/58Gu3txutqShlfCsws0dFK3kxJE=; b=IcwHO1/+12Ft/ojTqjHn5fiTgBysq4dOJ36tfrfI+p9O4R71NjbpJOB6mtcV/l3TWP z/K7OLSAKDzfHBC3YE4dvbPkJNzrXNl2/zKuRYqrkwGKW68vcWnBvzyisfS+6U7ba0tL kKtrZcPR75MILce4SPVDJWGMGrgxP3BW5hlbSxNkbHPmtmzPZnVDYdF+MNv5wqtyEfRk lmcwk1CjNQQDE/Y3KsK7MtdQ4wGwDA6pTN8XFd8YlsZYwvccbH5RkLgxBrRWOeBYMrKX 5OJdNK0g1kfRa9eW6dUpTJcUnQZbng2+VnyJt4IgcdoT8Q9jA29eDYSBIghs7uUbBRfH qsQw== X-Gm-Message-State: AOAM532yi84QW6n0pUp0X8H+o055BOD1FEkAQo3urcrV8hdhSBh5WCNp RrUI0pVHSyJRjzt6+pqr/cfP9g== X-Received: by 2002:a63:9d87:: with SMTP id i129mr9829976pgd.412.1595010289936; Fri, 17 Jul 2020 11:24:49 -0700 (PDT) Received: from [10.136.13.65] ([192.19.228.250]) by smtp.gmail.com with ESMTPSA id e18sm8344527pff.37.2020.07.17.11.24.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 Jul 2020 11:24:49 -0700 (PDT) Subject: Re: [PATCH] pwm: bcm-iproc: handle clk_get_rate() return To: Ray Jui , Thierry Reding , Lee Jones Cc: =?UTF-8?Q?Uwe_Kleine-K=c3=b6nig?= , BCM Kernel Feedback , linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, Rayagonda Kokatanur References: <20200717170743.25466-1-scott.branden@broadcom.com> <94f2aed1-d88d-3ee0-6e57-917f665951f2@broadcom.com> From: Scott Branden Message-ID: <6f9b0a94-6289-990b-84b3-80d70e17d3e2@broadcom.com> Date: Fri, 17 Jul 2020 11:24:40 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <94f2aed1-d88d-3ee0-6e57-917f665951f2@broadcom.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-07-17 10:22 a.m., Ray Jui wrote: > > On 7/17/2020 10:07 AM, Scott Branden wrote: >> From: Rayagonda Kokatanur >> >> Handle clk_get_rate() returning <= 0 condition to avoid >> possible division by zero. >> >> Fixes: daa5abc41c80 ("pwm: Add support for Broadcom iProc PWM controller") >> Signed-off-by: Rayagonda Kokatanur >> Signed-off-by: Scott Branden >> --- >> drivers/pwm/pwm-bcm-iproc.c | 5 +++++ >> 1 file changed, 5 insertions(+) >> >> diff --git a/drivers/pwm/pwm-bcm-iproc.c b/drivers/pwm/pwm-bcm-iproc.c >> index 1f829edd8ee7..72a8607b6c8d 100644 >> --- a/drivers/pwm/pwm-bcm-iproc.c >> +++ b/drivers/pwm/pwm-bcm-iproc.c >> @@ -86,6 +86,11 @@ static void iproc_pwmc_get_state(struct pwm_chip *chip, struct pwm_device *pwm, >> u32 value, prescale; >> >> rate = clk_get_rate(ip->clk); >> + if (rate == 0) { >> + state->period = 0; >> + state->duty_cycle = 0; >> + return; >> + } I'll move the logic after the polarity and enabled fields are populated. > Based on the pwm core code, 'get_state' expects the following fields to > be populated: 'polarity', 'enabled', 'period', and 'duty cycle'. > > The above logic will leave 'polarity' and 'enabled' completely > unpopulated when clock rate is zero. > >> >> value = readl(ip->base + IPROC_PWM_CTRL_OFFSET); >> >>