public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@nokia.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Chris Ball <cjb@laptop.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	"Shevchenko Andriy (EXT-Teleca/Helsinki)" 
	<ext-andriy.shevchenko@nokia.com>
Subject: Re: [PATCH] mmc: append a file to change host clock at run time
Date: Wed, 13 Oct 2010 11:07:28 +0300	[thread overview]
Message-ID: <4CB568C0.9030906@nokia.com> (raw)
In-Reply-To: <1286896642-27772-1-git-send-email-ext-andriy.shevchenko@nokia.com>

On 12/10/10 18:17, Andy Shevchenko wrote:
> For debugging power managment features there is quite convenient to have a
> possibility to change MMC host controller clock at run time. This patch adds
> 'clock' file under MMC host root of debugfs.
>
> Usage as follows:
>
> 	# cat /sys/kernel/debug/mmc0/clock
> 	24000000
>
> 	# echo "1000000000">  /sys/kernel/debug/mmc0/clock
> 	# cat /sys/kernel/debug/mmc0/clock
> 	52000000
>
> 	# echo "48000000">  /sys/kernel/debug/mmc0/clock
> 	# cat /sys/kernel/debug/mmc0/clock
> 	48000000
>
> The second piece of example shows limits which are applied accordingly to used
> host driver.
>
> Signed-off-by: Andy Shevchenko<ext-andriy.shevchenko@nokia.com>
> ---
>   drivers/mmc/core/debugfs.c |   33 +++++++++++++++++++++++++++++++--
>   1 files changed, 31 insertions(+), 2 deletions(-)
>
> 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);

Probably need to claim the host here otherwise you might
be changing the clock while a request is in progress

> +
> +	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:


  parent reply	other threads:[~2010-10-13  8:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-12 15:17 [PATCH] mmc: append a file to change host clock at run time Andy Shevchenko
2010-10-13  7:08 ` Andy Shevchenko
2010-10-13  8:07 ` Adrian Hunter [this message]
2010-10-13  8:15   ` Andy Shevchenko
2010-10-13  8:22   ` [PATCHv2] " Andy Shevchenko
2010-10-14  1:57     ` Chris Ball

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4CB568C0.9030906@nokia.com \
    --to=adrian.hunter@nokia.com \
    --cc=akpm@linux-foundation.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=cjb@laptop.org \
    --cc=ext-andriy.shevchenko@nokia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox