From patchwork Tue Oct 12 15:17: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: 247901 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 o9CFHnWi001719 for ; Tue, 12 Oct 2010 15:17:50 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752983Ab0JLPRr (ORCPT ); Tue, 12 Oct 2010 11:17:47 -0400 Received: from mail-ew0-f46.google.com ([209.85.215.46]:46690 "EHLO mail-ew0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752034Ab0JLPRr (ORCPT ); Tue, 12 Oct 2010 11:17:47 -0400 Received: by ewy20 with SMTP id 20so1308907ewy.19 for ; Tue, 12 Oct 2010 08:17:45 -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; bh=VH1M5zD1sxIxC7u7nbUoLeYs8W5oEKdowJE6zqPwr/4=; b=nblxMYLrh4UJoQaiv9fzaTP8bi/h1tr5lMx98yvrdpOBTc6j0G94aPjXirqHF5fW2q GXdjRNj+VM/3xgKv7HHLY39ZNq2gXT8Nt6cGWpESgYdvZS9xN0bShGBYztUHxaYXYkfs vI73WxrxWGsGx/aHw/s7SpBBomWFJeu+GzdIM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=dcXpKhPMY0Ohr5oeypI/wP6jjoHdvmNWl3B3kqbiO83c7X/UPNpeqCnIRHAqFF1jOK y+X87c67zKvlQDE5A6rP4/SuSGch39SFGkvjUPxJkdZV1o3UypxUJRxOF0NYPNdA3ovM GsVUaN5cWjYtE5Fmkm1YcF8laY9GtJoGmIKfs= Received: by 10.213.113.147 with SMTP id a19mr4214937ebq.24.1286896665093; Tue, 12 Oct 2010 08:17:45 -0700 (PDT) Received: from localhost.localdomain (starua.cc.colocall.com [62.149.23.157]) by mx.google.com with ESMTPS id z55sm13063042eeh.3.2010.10.12.08.17.40 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 12 Oct 2010 08:17:41 -0700 (PDT) From: Andy Shevchenko To: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Chris Ball , Andrew Morton , Andy Shevchenko Subject: [PATCH] mmc: append a file to change host clock at run time Date: Tue, 12 Oct 2010 18:17:22 +0300 Message-Id: <1286896642-27772-1-git-send-email-ext-andriy.shevchenko@nokia.com> X-Mailer: git-send-email 1.6.3.3 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]); Tue, 12 Oct 2010 15:17:50 +0000 (UTC) diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c index 96d10f4..4ff109f 100644 --- a/drivers/mmc/core/debugfs.c +++ b/drivers/mmc/core/debugfs.c @@ -133,6 +133,31 @@ 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_set_clock(host, (unsigned int) val); + + 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 +174,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: