From patchwork Wed Oct 13 08:22:22 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 249941 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o9D8MdeQ004451 for ; Wed, 13 Oct 2010 08:22:39 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753289Ab0JMIWg (ORCPT ); Wed, 13 Oct 2010 04:22:36 -0400 Received: from mail-ew0-f46.google.com ([209.85.215.46]:64946 "EHLO mail-ew0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753133Ab0JMIWf (ORCPT ); Wed, 13 Oct 2010 04:22:35 -0400 Received: by ewy20 with SMTP id 20so1918122ewy.19 for ; Wed, 13 Oct 2010 01:22:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=TnhX1C20h3dTMMEaOfJhHuxgyZvZivTtVI3UtHhwWyk=; b=aiccxW2fNaNTnmCRov3qO5J/15vi2NjQAhhKnNRsaQMJd7NSByZOSaB2+xU2ndrVPh eSQk6fxoQkfRL9r2fK43e3R47oIkiwaiI4QQOL0BBSv80vT0pRhFomPJHKTSwhfjO6M6 GzP1a+3B/C6VgYwrMB7ZX8lNJvYy3zZmEc/kM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=PAmPP4fexOb2+Tx+6nhSzZpUv0LkXW63yDyjXRYcyCeJUkAs3/pXEuVvjAcY2ELkD9 uH3EhQ1hi+b6ARODN+RVcLhnTgQcBgSY82SNIc25FIMmozh+ScqhTEPhvQxO9Q7Jvqz1 Pu+v9Ufm6WUG9+lzFkwPAMxYD5Ti9vPl0vNFI= Received: by 10.14.119.7 with SMTP id m7mr4975270eeh.40.1286958153916; Wed, 13 Oct 2010 01:22:33 -0700 (PDT) Received: from localhost.localdomain (starua.cc.colocall.com [62.149.23.157]) by mx.google.com with ESMTPS id v8sm14498879eeh.20.2010.10.13.01.22.31 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 13 Oct 2010 01:22:33 -0700 (PDT) From: Andy Shevchenko To: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Chris Ball , Andrew Morton , Adrian Hunter , Andy Shevchenko Subject: [PATCHv2] mmc: append a file to change host clock at run time Date: Wed, 13 Oct 2010 11:22:22 +0300 Message-Id: <1286958142-22461-1-git-send-email-ext-andriy.shevchenko@nokia.com> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <4CB568C0.9030906@nokia.com> References: <4CB568C0.9030906@nokia.com> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Wed, 13 Oct 2010 08:22:39 +0000 (UTC) diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c index 96d10f4..9b6ec07 100644 --- a/drivers/mmc/core/debugfs.c +++ b/drivers/mmc/core/debugfs.c @@ -133,6 +133,33 @@ static const struct file_operations mmc_ios_fops = { .release = single_release, }; +static int mmc_clock_opt_get(void *data, u64 *val) +{ + struct mmc_host *host = data; + + *val = host->ios.clock; + + return 0; +} + +static int mmc_clock_opt_set(void *data, u64 val) +{ + struct mmc_host *host = data; + + /* We need this check due to input value is u64 */ + if (val > host->f_max) + return -EINVAL; + + mmc_claim_host(host); + mmc_set_clock(host, (unsigned int) val); + mmc_release_host(host); + + return 0; +} + +DEFINE_SIMPLE_ATTRIBUTE(mmc_clock_fops, mmc_clock_opt_get, mmc_clock_opt_set, + "%llu\n"); + void mmc_add_host_debugfs(struct mmc_host *host) { struct dentry *root; @@ -149,11 +176,15 @@ void mmc_add_host_debugfs(struct mmc_host *host) host->debugfs_root = root; if (!debugfs_create_file("ios", S_IRUSR, root, host, &mmc_ios_fops)) - goto err_ios; + goto err_node; + + if (!debugfs_create_file("clock", S_IRUSR | S_IWUSR, root, host, + &mmc_clock_fops)) + goto err_node; return; -err_ios: +err_node: debugfs_remove_recursive(root); host->debugfs_root = NULL; err_root: