Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 106392
b: refs/heads/master
c: f4b7f92
h: refs/heads/master
v: v3
  • Loading branch information
Haavard Skinnemoen authored and Pierre Ossman committed Jul 26, 2008
1 parent 1ddc7e0 commit 1c87d74
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6edd8ee60ac9b974bd6ec3b1bcb2aab02762fa8c
refs/heads/master: f4b7f927b531ca350cfc4ca1bdc3377dac7f9a32
8 changes: 8 additions & 0 deletions trunk/drivers/mmc/core/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ int mmc_add_card(struct mmc_card *card)
if (ret)
return ret;

#ifdef CONFIG_DEBUG_FS
mmc_add_card_debugfs(card);
#endif

mmc_card_set_present(card);

return 0;
Expand All @@ -263,6 +267,10 @@ int mmc_add_card(struct mmc_card *card)
*/
void mmc_remove_card(struct mmc_card *card)
{
#ifdef CONFIG_DEBUG_FS
mmc_remove_card_debugfs(card);
#endif

if (mmc_card_present(card)) {
if (mmc_host_is_spi(card->host)) {
printk(KERN_INFO "%s: SPI card removed\n",
Expand Down
3 changes: 3 additions & 0 deletions trunk/drivers/mmc/core/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,8 @@ extern int use_spi_crc;
void mmc_add_host_debugfs(struct mmc_host *host);
void mmc_remove_host_debugfs(struct mmc_host *host);

void mmc_add_card_debugfs(struct mmc_card *card);
void mmc_remove_card_debugfs(struct mmc_card *card);

#endif

61 changes: 61 additions & 0 deletions trunk/drivers/mmc/core/debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
#include <linux/seq_file.h>
#include <linux/stat.h>

#include <linux/mmc/card.h>
#include <linux/mmc/host.h>

#include "core.h"
#include "mmc_ops.h"

/* The debugfs functions are optimized away when CONFIG_DEBUG_FS isn't set. */
static int mmc_ios_show(struct seq_file *s, void *data)
Expand Down Expand Up @@ -162,3 +164,62 @@ void mmc_remove_host_debugfs(struct mmc_host *host)
{
debugfs_remove_recursive(host->debugfs_root);
}

static int mmc_dbg_card_status_get(void *data, u64 *val)
{
struct mmc_card *card = data;
u32 status;
int ret;

mmc_claim_host(card->host);

ret = mmc_send_status(data, &status);
if (!ret)
*val = status;

mmc_release_host(card->host);

return ret;
}
DEFINE_SIMPLE_ATTRIBUTE(mmc_dbg_card_status_fops, mmc_dbg_card_status_get,
NULL, "%08llx\n");

void mmc_add_card_debugfs(struct mmc_card *card)
{
struct mmc_host *host = card->host;
struct dentry *root;

if (!host->debugfs_root)
return;

root = debugfs_create_dir(mmc_card_id(card), host->debugfs_root);
if (IS_ERR(root))
/* Don't complain -- debugfs just isn't enabled */
return;
if (!root)
/* Complain -- debugfs is enabled, but it failed to
* create the directory. */
goto err;

card->debugfs_root = root;

if (!debugfs_create_x32("state", S_IRUSR, root, &card->state))
goto err;

if (mmc_card_mmc(card) || mmc_card_sd(card))
if (!debugfs_create_file("status", S_IRUSR, root, card,
&mmc_dbg_card_status_fops))
goto err;

return;

err:
debugfs_remove_recursive(root);
card->debugfs_root = NULL;
dev_err(&card->dev, "failed to initialize debugfs\n");
}

void mmc_remove_card_debugfs(struct mmc_card *card)
{
debugfs_remove_recursive(card->debugfs_root);
}
2 changes: 2 additions & 0 deletions trunk/include/linux/mmc/card.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ struct mmc_card {
unsigned num_info; /* number of info strings */
const char **info; /* info strings */
struct sdio_func_tuple *tuples; /* unknown common tuples */

struct dentry *debugfs_root;
};

#define mmc_card_mmc(c) ((c)->type == MMC_TYPE_MMC)
Expand Down

0 comments on commit 1c87d74

Please sign in to comment.