Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 262967
b: refs/heads/master
c: d5a5bd1
h: refs/heads/master
i:
  262965: 23447f6
  262963: fbed495
  262959: 86bd746
v: v3
  • Loading branch information
Andy Shevchenko authored and Chris Ball committed Aug 13, 2011
1 parent 9d7d37c commit 656a150
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 27 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7199e2b61d715c5e8901ff32513d2b80db8d3737
refs/heads/master: d5a5bd1c3f7e8d010393530d60df8da75218a488
56 changes: 30 additions & 26 deletions trunk/drivers/mmc/card/mmc_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -2900,7 +2900,7 @@ static const struct file_operations mmc_test_fops_testlist = {
.release = single_release,
};

static void mmc_test_free_file_test(struct mmc_card *card)
static void mmc_test_free_dbgfs_file(struct mmc_card *card)
{
struct mmc_test_dbgfs_file *df, *dfs;

Expand All @@ -2917,49 +2917,53 @@ static void mmc_test_free_file_test(struct mmc_card *card)
mutex_unlock(&mmc_test_lock);
}

static int mmc_test_register_file_test(struct mmc_card *card)
static int __mmc_test_register_dbgfs_file(struct mmc_card *card,
const char *name, mode_t mode, const struct file_operations *fops)
{
struct dentry *file = NULL;
struct mmc_test_dbgfs_file *df;
int ret = 0;

mutex_lock(&mmc_test_lock);

if (card->debugfs_root)
file = debugfs_create_file("test", S_IWUSR | S_IRUGO,
card->debugfs_root, card, &mmc_test_fops_test);

if (IS_ERR_OR_NULL(file)) {
dev_err(&card->dev,
"Can't create test. Perhaps debugfs is disabled.\n");
ret = -ENODEV;
goto err;
}

if (card->debugfs_root)
file = debugfs_create_file("testlist", S_IRUGO,
card->debugfs_root, card, &mmc_test_fops_testlist);
file = debugfs_create_file(name, mode, card->debugfs_root,
card, fops);

if (IS_ERR_OR_NULL(file)) {
dev_err(&card->dev,
"Can't create testlist. Perhaps debugfs is disabled.\n");
ret = -ENODEV;
goto err;
"Can't create %s. Perhaps debugfs is disabled.\n",
name);
return -ENODEV;
}

df = kmalloc(sizeof(struct mmc_test_dbgfs_file), GFP_KERNEL);
if (!df) {
debugfs_remove(file);
dev_err(&card->dev,
"Can't allocate memory for internal usage.\n");
ret = -ENOMEM;
goto err;
return -ENOMEM;
}

df->card = card;
df->file = file;

list_add(&df->link, &mmc_test_file_test);
return 0;
}

static int mmc_test_register_dbgfs_file(struct mmc_card *card)
{
int ret;

mutex_lock(&mmc_test_lock);

ret = __mmc_test_register_dbgfs_file(card, "test", S_IWUSR | S_IRUGO,
&mmc_test_fops_test);
if (ret)
goto err;

ret = __mmc_test_register_dbgfs_file(card, "testlist", S_IRUGO,
&mmc_test_fops_testlist);
if (ret)
goto err;

err:
mutex_unlock(&mmc_test_lock);
Expand All @@ -2974,7 +2978,7 @@ static int mmc_test_probe(struct mmc_card *card)
if (!mmc_card_mmc(card) && !mmc_card_sd(card))
return -ENODEV;

ret = mmc_test_register_file_test(card);
ret = mmc_test_register_dbgfs_file(card);
if (ret)
return ret;

Expand All @@ -2986,7 +2990,7 @@ static int mmc_test_probe(struct mmc_card *card)
static void mmc_test_remove(struct mmc_card *card)
{
mmc_test_free_result(card);
mmc_test_free_file_test(card);
mmc_test_free_dbgfs_file(card);
}

static struct mmc_driver mmc_driver = {
Expand All @@ -3006,7 +3010,7 @@ static void __exit mmc_test_exit(void)
{
/* Clear stalled data if card is still plugged */
mmc_test_free_result(NULL);
mmc_test_free_file_test(NULL);
mmc_test_free_dbgfs_file(NULL);

mmc_unregister_driver(&mmc_driver);
}
Expand Down

0 comments on commit 656a150

Please sign in to comment.