From patchwork Sat Jan 11 21:39:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 3470611 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BD850C02DC for ; Sat, 11 Jan 2014 21:43:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0FCAC2015A for ; Sat, 11 Jan 2014 21:43:04 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F251B2012F for ; Sat, 11 Jan 2014 21:43:02 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W26Ip-0007MQ-Qw; Sat, 11 Jan 2014 21:41:13 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W26IJ-0001zV-8t; Sat, 11 Jan 2014 21:40:39 +0000 Received: from mail-ea0-x22f.google.com ([2a00:1450:4013:c01::22f]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W26HT-0001v7-Fs for linux-arm-kernel@lists.infradead.org; Sat, 11 Jan 2014 21:39:54 +0000 Received: by mail-ea0-f175.google.com with SMTP id z10so2646025ead.34 for ; Sat, 11 Jan 2014 13:39:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8P45dSvuJ7THUU2qbF0P7rB6QL7C1nZK3/JVRV6vJnk=; b=w9ixwJlX36Vnsm/zSb4CpW3hPhtRG0C8AdXx94pG89+J3WIF0Hygo4urdlg5si8yGT iviQD5TF+g5KQYsK0uOkn84Go+MVLwvT6lWOtY8b7rqgSf04PvUcsEig1oIsk3U6Yzub s5FK6i651ixKe6mmV0N8mbqvfs64a44nJ2jqgl5kl6yN92PIjBCrtoTGrunT/OwIE6YE 3NqCnTSgaKyeDhAC6VSklOAHpU45dTK0rPwj+dTqObOmPANzT/scJ5eaxW+LtHPo5AsH YUXOKfzjwA5vJ9TT9eJadTtMtjGKeBaEhqfYyo5V1nl4Fxq15R+66AYgoX05+byY2Tha TpUg== X-Received: by 10.14.53.65 with SMTP id f41mr1349463eec.105.1389476365626; Sat, 11 Jan 2014 13:39:25 -0800 (PST) Received: from flatron.tomeq (87-207-52-162.dynamic.chello.pl. [87.207.52.162]) by mx.google.com with ESMTPSA id p45sm26014591eeg.1.2014.01.11.13.39.24 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 11 Jan 2014 13:39:25 -0800 (PST) From: Tomasz Figa To: linux-mmc@vger.kernel.org Subject: [PATCH 6/6] mmc: sdhci-s3c: Do not allow frequencies higher than requested Date: Sat, 11 Jan 2014 22:39:06 +0100 Message-Id: <1389476346-20396-7-git-send-email-tomasz.figa@gmail.com> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: <1389476346-20396-1-git-send-email-tomasz.figa@gmail.com> References: <1389476346-20396-1-git-send-email-tomasz.figa@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140111_163947_976552_9F44CEA7 X-CRM114-Status: UNSURE ( 9.81 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.0 (--) Cc: linux-samsung-soc@vger.kernel.org, Seungwon Jeon , Chris Ball , Tomasz Figa , Jaehoon Chung , Ben Dooks , linux-arm-kernel@lists.infradead.org, Marek Szyprowski X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch modifies sdhci_s3c_consider_clock() to fail if bus clock being considered can not provide frequency lower or equal requested, instead of returning the lowest supported. Signed-off-by: Tomasz Figa --- drivers/mmc/host/sdhci-s3c.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c index bad0e00..d61eb5a 100644 --- a/drivers/mmc/host/sdhci-s3c.c +++ b/drivers/mmc/host/sdhci-s3c.c @@ -126,11 +126,18 @@ static unsigned int sdhci_s3c_consider_clock(struct sdhci_s3c *ourhost, rate = ourhost->clk_rates[src]; - for (shift = 0; shift < 8; ++shift) { + for (shift = 0; shift <= 8; ++shift) { if ((rate >> shift) <= wanted) break; } + if (shift > 8) { + dev_dbg(&ourhost->pdev->dev, + "clk %d: rate %ld, min rate %lu > wanted %u\n", + src, rate, rate / 256, wanted); + return UINT_MAX; + } + dev_dbg(&ourhost->pdev->dev, "clk %d: rate %ld, want %d, got %ld\n", src, rate, wanted, rate >> shift);