Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2138697ybh; Fri, 17 Jul 2020 10:09:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMBcVGwEhrsCzQRgo2Wk98krftAqsh6PJXZKk4xlDzmSEnrRWMmmgv3gbAZPQRyf1xWvAG X-Received: by 2002:a05:6402:31b4:: with SMTP id dj20mr3287639edb.158.1595005777866; Fri, 17 Jul 2020 10:09:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595005777; cv=none; d=google.com; s=arc-20160816; b=mf7F5xrXzQzLN/aVFTHDuboMkAl+98GppiH/DzCXNIsuNwIEEw6OeO3wn0TdkdkVxC 6Zv1b/Jy+7DGfWX9Ij6ZkD/i66KLjP+ALYV/GNUni3Z3Ue8+UfIxfB+a4tehjoNwnJwW wkJufxGZlZSfY4thwOb90XwY9vJIn74aYr05N79bH+2CLUqau0XUF2Ov8blTpUTZk075 VXXwPnzMsqVxvpLbxqf+xeNXrpb3apGbTVd1XdxVabCXDCKQ5BrV/Gac6/Q0FhiBZYzb wv7wOS/BViIKShI2pIUlnuSLcR+DTZq+0M8bleuhHZrX42DnLNLYXdjXCUOJVFKwNPMz eK9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=pXdlEIgb0R2eqM6YdIY4bxUBQ/fZpt56c2B8bap1rNQ=; b=XhZAJnJIZKU0ojB4e5vmicjhCTknB2qLHW2RRhMcHAOK4qjcpDfosZtiQp9Pw7POTy k8cX3JnbTKhn9fCirg9ovH/MUXgUONVclQYamq23cHxTbT2T7SVkoFmSNdZre2wSpobi DYccrnsHsFFI19JJXMMbc9J/8DRxlOfFBN3Uk1T4jwF7KiIMd52J+YC+VDqW7Wc/SSS8 9xr0bhIJ+MwpQowLe31X/xn0zqk3FuTKvTKzXS3ecR1kTiPXfyCCSXNjzuJCnCvEOY0k A8GQiXrVGuLcCmYMwNm4L8Fi06AsYEXwtzMc+vv6/+HljAQLSdIeEnfpOO14jJxTnbtw OPQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b="eu/Idpav"; 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 h28si6601386edj.267.2020.07.17.10.09.14; Fri, 17 Jul 2020 10:09:37 -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="eu/Idpav"; 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 S1726852AbgGQRH5 (ORCPT + 99 others); Fri, 17 Jul 2020 13:07:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726811AbgGQRH4 (ORCPT ); Fri, 17 Jul 2020 13:07:56 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96E8BC0619D2 for ; Fri, 17 Jul 2020 10:07:56 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id g10so7579997wmc.1 for ; Fri, 17 Jul 2020 10:07:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id; bh=pXdlEIgb0R2eqM6YdIY4bxUBQ/fZpt56c2B8bap1rNQ=; b=eu/Idpav/OdqgVR6qapiS1bO3wnmOzjcE1OUoAvo5H5oEuDQbjZcnZ+Fbax2Yv6hDb HYMFLf2931dNSUpYBsBUTl9Zm0XUb9PdV3QDWbh57oxIiVXlcdwlcLrvYUaKOUu+ULVg C8DAKsbnyY7FKcOTbxqFPARhb4SuJOPnFzQ7o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=pXdlEIgb0R2eqM6YdIY4bxUBQ/fZpt56c2B8bap1rNQ=; b=N5/nKkKqHASi2Hga1rgUgiBzwRURoaXakWHvq4lVN8tUpgO9Una1zVE7NE0D3LJP7u KSg26SIYoBC4zDpJICXHvcKrnnnvCVVhe/xl1V4JQA8ckjm7AmnfbBpa/bm35TXXSmb2 mvrl7Qs0raClfitHZI/z6tW9cd66UZTLn6c7yw7P0Vfz4edG1ozRESRzyULp2Faje/8t CMyNSRQRc5DSWp0t77O1ME2eGHbiC4yO2UiPzSBnbCQCM/N9vH6NEUfBubey2Rcqw1ri lHvL78g9djbTDZyBFL6GbWkemWSUzOO4MIs5m6XqDDUL2vRjR2mX+s4h4VxG/fv//PC0 q6Rw== X-Gm-Message-State: AOAM531+78kPFq3MTUo6QPCQ/JB2oznKqWvQ2d0QS4WPzYLW1RK2fLh3 9CmtpN0FzEghiwd9UXVMNvS3bg== X-Received: by 2002:a1c:ab84:: with SMTP id u126mr9951175wme.43.1595005675222; Fri, 17 Jul 2020 10:07:55 -0700 (PDT) Received: from lbrmn-lnxub113.broadcom.net ([192.19.228.250]) by smtp.gmail.com with ESMTPSA id g145sm19294145wmg.23.2020.07.17.10.07.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2020 10:07:54 -0700 (PDT) From: Scott Branden To: Thierry Reding , Lee Jones Cc: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , BCM Kernel Feedback , linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, Rayagonda Kokatanur , Scott Branden Subject: [PATCH] pwm: bcm-iproc: handle clk_get_rate() return Date: Fri, 17 Jul 2020 10:07:43 -0700 Message-Id: <20200717170743.25466-1-scott.branden@broadcom.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; + } value = readl(ip->base + IPROC_PWM_CTRL_OFFSET); -- 2.17.1