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: 3470521 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BA34A9F2E9 for ; Sat, 11 Jan 2014 21:39:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EB0DC20127 for ; Sat, 11 Jan 2014 21:39:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2A46D2015E for ; Sat, 11 Jan 2014 21:39:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751057AbaAKVj2 (ORCPT ); Sat, 11 Jan 2014 16:39:28 -0500 Received: from mail-ea0-f180.google.com ([209.85.215.180]:48711 "EHLO mail-ea0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751005AbaAKVj0 (ORCPT ); Sat, 11 Jan 2014 16:39:26 -0500 Received: by mail-ea0-f180.google.com with SMTP id f15so2633778eak.25 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 Cc: linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ben Dooks , Chris Ball , Jaehoon Chung , Seungwon Jeon , Marek Szyprowski , Tomasz Figa 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> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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);