From patchwork Wed May 7 16:48:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime COQUELIN X-Patchwork-Id: 29812 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f198.google.com (mail-pd0-f198.google.com [209.85.192.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EF771202E4 for ; Wed, 7 May 2014 16:49:43 +0000 (UTC) Received: by mail-pd0-f198.google.com with SMTP id w10sf5027699pde.1 for ; Wed, 07 May 2014 09:49:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=cBJvOD0LkCXQ4o4NeOT+vCtMG5xKtESiFnky6mGouzY=; b=HAqqdNFAwO6xNE+6jMCI9v8ox+629yPkO6HOAtuQCpCy2t2CcrFtgg49oMQpJ1bFui wEXbNxU1rSzqorfBndIG1CIOP8nb5DfhanwPNzCJxjOi6MLCyFzoHfovcZVJPiacNc8W n/M0b97fq1Mp+73THY/tPYsYxaGWF3f/G/s9UgxET1NAVzccpMdc8fOg6bHgS/ADBFO4 PjNBoGo44FO7MOdn2U19xUWWOgs6NwCnaX6RZ5rJP18HGvRPy1zRrQHjRqarhRO90wLt ufH8v/RZVnJAeI/LfWBuw6AySZjpJGrjCb2Cje7pb6P7Diamee7aU/TEp5U0XLQZQ0DX XmHg== X-Gm-Message-State: ALoCoQkHr6jM+TF971sBd6ddqfcghh8xkeqq4Xced4HTAJR4ki/pPxTCrSBKvHfjavYcZYAA6zv5 X-Received: by 10.66.233.8 with SMTP id ts8mr5487681pac.38.1399481383160; Wed, 07 May 2014 09:49:43 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.104.234 with SMTP id a97ls1537706qgf.51.gmail; Wed, 07 May 2014 09:49:42 -0700 (PDT) X-Received: by 10.58.122.164 with SMTP id lt4mr39953754veb.2.1399481382919; Wed, 07 May 2014 09:49:42 -0700 (PDT) Received: from mail-vc0-f172.google.com (mail-vc0-f172.google.com [209.85.220.172]) by mx.google.com with ESMTPS id at8si3008349vec.91.2014.05.07.09.49.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 07 May 2014 09:49:42 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.220.172; Received: by mail-vc0-f172.google.com with SMTP id hr9so1650543vcb.31 for ; Wed, 07 May 2014 09:49:42 -0700 (PDT) X-Received: by 10.58.179.115 with SMTP id df19mr2564277vec.41.1399481382834; Wed, 07 May 2014 09:49:42 -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.220.221.72 with SMTP id ib8csp325696vcb; Wed, 7 May 2014 09:49:42 -0700 (PDT) X-Received: by 10.66.149.102 with SMTP id tz6mr20883234pab.76.1399481381985; Wed, 07 May 2014 09:49:41 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id uc7si2189743pbc.2.2014.05.07.09.49.40; Wed, 07 May 2014 09:49:40 -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 S933015AbaEGQtd (ORCPT + 27 others); Wed, 7 May 2014 12:49:33 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:43194 "EHLO mx08-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932134AbaEGQtc (ORCPT ); Wed, 7 May 2014 12:49:32 -0400 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.14.5/8.14.5) with SMTP id s47Gi7kQ020902; Wed, 7 May 2014 18:49:02 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 1kq7huc4nd-1 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Wed, 07 May 2014 18:49:02 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id BDEDA4E; Wed, 7 May 2014 16:48:55 +0000 (GMT) Received: from mail7.sgp.st.com (unknown [164.129.223.81]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 7325659C28; Wed, 7 May 2014 16:48:55 +0000 (GMT) Received: from lmenx29l.st.com ([10.129.6.132]) by mail7.sgp.st.com (MOS 4.3.3-GA) with ESMTP id BZG35416 (AUTH lme00137); Wed, 7 May 2014 18:48:54 +0200 From: Maxime COQUELIN To: Mike Turquette , Fabio Estevam , Shawn Guo , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: maxime.coquelin@st.com Subject: [PATCH] clk: divider: Fix table round up function Date: Wed, 7 May 2014 18:48:52 +0200 Message-Id: <1399481332-9550-1-git-send-email-maxime.coquelin@st.com> X-Mailer: git-send-email 1.9.1 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.11.96, 1.0.14, 0.0.0000 definitions=2014-05-07_05:2014-05-07, 2014-05-07, 1970-01-01 signatures=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: maxime.coquelin@st.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) 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: , Commit 1d9fe6b97 ("clk: divider: Fix best div calculation for power-of-two and table dividers") introduces a regression in its _table_round_up function. When the divider passed to this function is greater than the max divider available in the table, this function returns table's max divider. Problem is that it causes an infinite loop in clk_divider_bestdiv() because _next_div() will never return a value greater than maxdiv. Instead of returning table's max divider, this patch returns INT_MAX. Reported-by: Fabio Estevam Reported-by: Shawn Guo Tested-by: Fabio Estevam Cc: Mike Turquette Signed-off-by: Maxime Coquelin --- drivers/clk/clk-divider.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c index b3c8396..cf9114a 100644 --- a/drivers/clk/clk-divider.c +++ b/drivers/clk/clk-divider.c @@ -158,7 +158,7 @@ static bool _is_valid_div(struct clk_divider *divider, unsigned int div) static int _round_up_table(const struct clk_div_table *table, int div) { const struct clk_div_table *clkt; - int up = _get_table_maxdiv(table); + int up = INT_MAX; for (clkt = table; clkt->div; clkt++) { if (clkt->div == div)