aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2011-07-22 09:13:36 -0400
committerChris Ball <cjb@laptop.org>2011-08-13 14:50:22 -0400
commitd5a5bd1c3f7e8d010393530d60df8da75218a488 (patch)
treee24b1d592f2ddec088af5d61488b034c1409480c
parent7199e2b61d715c5e8901ff32513d2b80db8d3737 (diff)
mmc: mmc_test: avoid stalled file in debugfs
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> Acked-by: Per Forlin <per.forlin@linaro.org> Signed-off-by: Chris Ball <cjb@laptop.org>
-rw-r--r--drivers/mmc/card/mmc_test.c56
1 files changed, 30 insertions, 26 deletions
diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c
index 006a5e9f8ab8..742dc98a034c 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 = {
2900 .release = single_release, 2900 .release = single_release,
2901}; 2901};
2902 2902
2903static void mmc_test_free_file_test(struct mmc_card *card) 2903static void mmc_test_free_dbgfs_file(struct mmc_card *card)
2904{ 2904{
2905 struct mmc_test_dbgfs_file *df, *dfs; 2905 struct mmc_test_dbgfs_file *df, *dfs;
2906 2906
@@ -2917,34 +2917,21 @@ static void mmc_test_free_file_test(struct mmc_card *card)
2917 mutex_unlock(&mmc_test_lock); 2917 mutex_unlock(&mmc_test_lock);
2918} 2918}
2919 2919
2920static int mmc_test_register_file_test(struct mmc_card *card) 2920static int __mmc_test_register_dbgfs_file(struct mmc_card *card,
2921 const char *name, mode_t mode, const struct file_operations *fops)
2921{ 2922{
2922 struct dentry *file = NULL; 2923 struct dentry *file = NULL;
2923 struct mmc_test_dbgfs_file *df; 2924 struct mmc_test_dbgfs_file *df;
2924 int ret = 0;
2925
2926 mutex_lock(&mmc_test_lock);
2927
2928 if (card->debugfs_root)
2929 file = debugfs_create_file("test", S_IWUSR | S_IRUGO,
2930 card->debugfs_root, card, &mmc_test_fops_test);
2931
2932 if (IS_ERR_OR_NULL(file)) {
2933 dev_err(&card->dev,
2934 "Can't create test. Perhaps debugfs is disabled.\n");
2935 ret = -ENODEV;
2936 goto err;
2937 }
2938 2925
2939 if (card->debugfs_root) 2926 if (card->debugfs_root)
2940 file = debugfs_create_file("testlist", S_IRUGO, 2927 file = debugfs_create_file(name, mode, card->debugfs_root,
2941 card->debugfs_root, card, &mmc_test_fops_testlist); 2928 card, fops);
2942 2929
2943 if (IS_ERR_OR_NULL(file)) { 2930 if (IS_ERR_OR_NULL(file)) {
2944 dev_err(&card->dev, 2931 dev_err(&card->dev,
2945 "Can't create testlist. Perhaps debugfs is disabled.\n"); 2932 "Can't create %s. Perhaps debugfs is disabled.\n",
2946 ret = -ENODEV; 2933 name);
2947 goto err; 2934 return -ENODEV;
2948 } 2935 }
2949 2936
2950 df = kmalloc(sizeof(struct mmc_test_dbgfs_file), GFP_KERNEL); 2937 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)
2952 debugfs_remove(file); 2939 debugfs_remove(file);
2953 dev_err(&card->dev, 2940 dev_err(&card->dev,
2954 "Can't allocate memory for internal usage.\n"); 2941 "Can't allocate memory for internal usage.\n");
2955 ret = -ENOMEM; 2942 return -ENOMEM;
2956 goto err;
2957 } 2943 }
2958 2944
2959 df->card = card; 2945 df->card = card;
2960 df->file = file; 2946 df->file = file;
2961 2947
2962 list_add(&df->link, &mmc_test_file_test); 2948 list_add(&df->link, &mmc_test_file_test);
2949 return 0;
2950}
2951
2952static int mmc_test_register_dbgfs_file(struct mmc_card *card)
2953{
2954 int ret;
2955
2956 mutex_lock(&mmc_test_lock);
2957
2958 ret = __mmc_test_register_dbgfs_file(card, "test", S_IWUSR | S_IRUGO,
2959 &mmc_test_fops_test);
2960 if (ret)
2961 goto err;
2962
2963 ret = __mmc_test_register_dbgfs_file(card, "testlist", S_IRUGO,
2964 &mmc_test_fops_testlist);
2965 if (ret)
2966 goto err;
2963 2967
2964err: 2968err:
2965 mutex_unlock(&mmc_test_lock); 2969 mutex_unlock(&mmc_test_lock);
@@ -2974,7 +2978,7 @@ static int mmc_test_probe(struct mmc_card *card)
2974 if (!mmc_card_mmc(card) && !mmc_card_sd(card)) 2978 if (!mmc_card_mmc(card) && !mmc_card_sd(card))
2975 return -ENODEV; 2979 return -ENODEV;
2976 2980
2977 ret = mmc_test_register_file_test(card); 2981 ret = mmc_test_register_dbgfs_file(card);
2978 if (ret) 2982 if (ret)
2979 return ret; 2983 return ret;
2980 2984
@@ -2986,7 +2990,7 @@ static int mmc_test_probe(struct mmc_card *card)
2986static void mmc_test_remove(struct mmc_card *card) 2990static void mmc_test_remove(struct mmc_card *card)
2987{ 2991{
2988 mmc_test_free_result(card); 2992 mmc_test_free_result(card);
2989 mmc_test_free_file_test(card); 2993 mmc_test_free_dbgfs_file(card);
2990} 2994}
2991 2995
2992static struct mmc_driver mmc_driver = { 2996static struct mmc_driver mmc_driver = {
@@ -3006,7 +3010,7 @@ static void __exit mmc_test_exit(void)
3006{ 3010{
3007 /* Clear stalled data if card is still plugged */ 3011 /* Clear stalled data if card is still plugged */
3008 mmc_test_free_result(NULL); 3012 mmc_test_free_result(NULL);
3009 mmc_test_free_file_test(NULL); 3013 mmc_test_free_dbgfs_file(NULL);
3010 3014
3011 mmc_unregister_driver(&mmc_driver); 3015 mmc_unregister_driver(&mmc_driver);
3012} 3016}