* [PATCH] mmc: mmc_test: avoid stalled file in debugfs
@ 2011-07-22 13:13 Andy Shevchenko
2011-07-25 22:15 ` Per Forlin
2011-07-28 22:31 ` Chris Ball
0 siblings, 2 replies; 4+ messages in thread
From: Andy Shevchenko @ 2011-07-22 13:13 UTC (permalink / raw)
To: linux-mmc, linux-kernel, Per Forlin, Chris Ball; +Cc: Andy Shevchenko
During card removal and inserting cycle the test file in the debugfs could be
stalled until the host driver removes it. Let's keep the file in the linked
list and destroy it when card is removed.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/mmc/card/mmc_test.c | 56 +++++++++++++++++++++++--------------------
1 files changed, 30 insertions(+), 26 deletions(-)
diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c
index 006a5e9..915a221 100644
--- a/drivers/mmc/card/mmc_test.c
+++ b/drivers/mmc/card/mmc_test.c
@@ -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;
@@ -2917,34 +2917,21 @@ 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);
@@ -2952,14 +2939,31 @@ static int mmc_test_register_file_test(struct mmc_card *card)
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);
@@ -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;
@@ -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 = {
@@ -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);
}
--
1.7.5.4
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] mmc: mmc_test: avoid stalled file in debugfs
2011-07-22 13:13 [PATCH] mmc: mmc_test: avoid stalled file in debugfs Andy Shevchenko
@ 2011-07-25 22:15 ` Per Forlin
2011-07-26 7:01 ` Andy Shevchenko
2011-07-28 22:31 ` Chris Ball
1 sibling, 1 reply; 4+ messages in thread
From: Per Forlin @ 2011-07-25 22:15 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-mmc, linux-kernel, Chris Ball
On 22 July 2011 15:13, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> During card removal and inserting cycle the test file in the debugfs could be
> stalled until the host driver removes it. Let's keep the file in the linked
> list and destroy it when card is removed.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Thanks for catching and fixing this mistake. The two debugfs files
test and testlist were created but only testlist was added to the
list. This patch takes care of that and adds both test and testlist to
the linked list, and makes the code cleaner too.
> ---
> drivers/mmc/card/mmc_test.c | 56 +++++++++++++++++++++++--------------------
> 1 files changed, 30 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c
> index 006a5e9..915a221 100644
> --- a/drivers/mmc/card/mmc_test.c
> +++ b/drivers/mmc/card/mmc_test.c
> @@ -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;
>
> @@ -2917,34 +2917,21 @@ 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);
Move card to next line together with fops and indent.
+ 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);
> @@ -2952,14 +2939,31 @@ static int mmc_test_register_file_test(struct mmc_card *card)
> 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);
> @@ -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;
>
> @@ -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 = {
> @@ -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);
> }
> --
> 1.7.5.4
>
>
Acked-by: Per Forlin <per.forlin@linaro.org>
Thanks,
Per
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] mmc: mmc_test: avoid stalled file in debugfs
2011-07-25 22:15 ` Per Forlin
@ 2011-07-26 7:01 ` Andy Shevchenko
0 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2011-07-26 7:01 UTC (permalink / raw)
To: Per Forlin; +Cc: linux-mmc, linux-kernel, Chris Ball
On Tue, 2011-07-26 at 00:15 +0200, Per Forlin wrote:
> > + file = debugfs_create_file(name, mode, card->debugfs_root,card,
> > + fops);
> Move card to next line together with fops and indent.
> + file = debugfs_create_file(name, mode, card->debugfs_root,
> + card, fops);
Hmm... Its length is exact 80 symbols which is OK for checkpatch.pl.
Anyway, thanks for review.
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mmc: mmc_test: avoid stalled file in debugfs
2011-07-22 13:13 [PATCH] mmc: mmc_test: avoid stalled file in debugfs Andy Shevchenko
2011-07-25 22:15 ` Per Forlin
@ 2011-07-28 22:31 ` Chris Ball
1 sibling, 0 replies; 4+ messages in thread
From: Chris Ball @ 2011-07-28 22:31 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-mmc, linux-kernel, Per Forlin
Hi Andy,
On Fri, Jul 22 2011, Andy Shevchenko wrote:
> During card removal and inserting cycle the test file in the debugfs could be
> stalled until the host driver removes it. Let's keep the file in the linked
> list and destroy it when card is removed.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Pushed to mmc-next for 3.1 with Per's ACK and suggested change, thanks,
- Chris.
--
Chris Ball <cjb@laptop.org> <http://printf.net/>
One Laptop Per Child
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-07-28 22:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-22 13:13 [PATCH] mmc: mmc_test: avoid stalled file in debugfs Andy Shevchenko
2011-07-25 22:15 ` Per Forlin
2011-07-26 7:01 ` Andy Shevchenko
2011-07-28 22:31 ` Chris Ball
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox