From patchwork Mon Aug 18 16:56:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishanth Menon X-Patchwork-Id: 35531 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oi0-f70.google.com (mail-oi0-f70.google.com [209.85.218.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7F25320523 for ; Mon, 18 Aug 2014 16:57:34 +0000 (UTC) Received: by mail-oi0-f70.google.com with SMTP id u20sf31965978oif.9 for ; Mon, 18 Aug 2014 09:57:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=NDW4xEosQHDL4o6QsJzTzZzBoP4L2jPMYhHz3qB1jBQ=; b=PC9w3dV1hWkIOec8WExDPf6ZHvRq4NKC7E8b0Hdrn5ioBsM9cyupLXv6csiPufOZH1 wUgPaCb1rnPcqzKkWN4MpvCGH1Z/x+zJjdYVr4NeHzDmHSRXmIyTH5iHlLbTLYqSczLa ZQ0EIhxNiVYBDX7iO77WVXSlY7UHPoTdVErcW4wl9PPCU5z7+zLPoj0LiJw437gXOA+q weKuh2Ip81mv57BLkzPcNUgY8SqmQ5ComaMdZUKmF/c8LVMvqmJN8V7kQ/LpoBVoGhqG 8/vfr8cz43keNwvWN67NniWp9p7iZyJqkzBLcWEMCymrvRykWq2oejhu89qr8cqiEEDZ 7Dwg== X-Gm-Message-State: ALoCoQkgkEfVz8S/OlbZFNBp8IYNC6ca0+aHLZm4aJx0YCf7kDwzWOl1dOLehxlzrAcqGf5MNoTJ X-Received: by 10.42.212.207 with SMTP id gt15mr805447icb.31.1408381054043; Mon, 18 Aug 2014 09:57:34 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.96.202 with SMTP id k68ls2229683qge.48.gmail; Mon, 18 Aug 2014 09:57:33 -0700 (PDT) X-Received: by 10.220.97.138 with SMTP id l10mr7669504vcn.25.1408381053835; Mon, 18 Aug 2014 09:57:33 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id f18si5708736veh.12.2014.08.18.09.57.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 18 Aug 2014 09:57:33 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id le20so6136282vcb.28 for ; Mon, 18 Aug 2014 09:57:33 -0700 (PDT) X-Received: by 10.52.120.51 with SMTP id kz19mr437996vdb.95.1408381053674; Mon, 18 Aug 2014 09:57:33 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp168397vcb; Mon, 18 Aug 2014 09:57:32 -0700 (PDT) X-Received: by 10.68.87.101 with SMTP id w5mr37200721pbz.130.1408381052477; Mon, 18 Aug 2014 09:57:32 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id uj2si22586190pbc.60.2014.08.18.09.57.23 for ; Mon, 18 Aug 2014 09:57:23 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751800AbaHRQ5W (ORCPT + 23 others); Mon, 18 Aug 2014 12:57:22 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:56615 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751652AbaHRQ5U (ORCPT ); Mon, 18 Aug 2014 12:57:20 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id s7IGuu9C006691; Mon, 18 Aug 2014 11:56:56 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s7IGuuWj021557; Mon, 18 Aug 2014 11:56:56 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.174.1; Mon, 18 Aug 2014 11:56:56 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s7IGuuc9019678; Mon, 18 Aug 2014 11:56:56 -0500 From: Nishanth Menon To: Tero Kristo , Mike Turquette CC: , , , Nishanth Menon Subject: [PATCH 1/2] clk: ti: divider: Provide error check for incoming parameters in set_rate Date: Mon, 18 Aug 2014 11:56:54 -0500 Message-ID: <1408381015-16042-2-git-send-email-nm@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1408381015-16042-1-git-send-email-nm@ti.com> References: <1408381015-16042-1-git-send-email-nm@ti.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: nm@ti.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Check for valid parameters in check rate. Else, we end up getting errors like: [ 0.000000] Division by zero in kernel. [ 0.000000] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 3.17.0-rc1 #1 [ 0.000000] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [ 0.000000] [] (show_stack) from [] (dump_stack+0x78/0x94) [ 0.000000] [] (dump_stack) from [] (Ldiv0+0x8/0x10) [ 0.000000] [] (Ldiv0) from [] (ti_clk_divider_set_rate+0x14/0x14c) [ 0.000000] [] (ti_clk_divider_set_rate) from [] (clk_change_rate+0x138/0x180) [ 0.000000] [] (clk_change_rate) from [] (clk_change_rate+0x108/0x180) This occurs as part of the inital clock tree update of child clock nodes where new_rate could be 0 for non functional clocks. Fixes: b4761198bfaf296 ("CLK: ti: add support for ti divider-clock") Signed-off-by: Nishanth Menon --- drivers/clk/ti/divider.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/clk/ti/divider.c b/drivers/clk/ti/divider.c index e6aa10d..a837f70 100644 --- a/drivers/clk/ti/divider.c +++ b/drivers/clk/ti/divider.c @@ -211,11 +211,16 @@ static long ti_clk_divider_round_rate(struct clk_hw *hw, unsigned long rate, static int ti_clk_divider_set_rate(struct clk_hw *hw, unsigned long rate, unsigned long parent_rate) { - struct clk_divider *divider = to_clk_divider(hw); + struct clk_divider *divider; unsigned int div, value; unsigned long flags = 0; u32 val; + if (!hw || !rate) + return -EINVAL; + + divider = to_clk_divider(hw); + div = DIV_ROUND_UP(parent_rate, rate); value = _get_val(divider, div);