aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/core/debugfs.c
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2017-08-20 17:39:08 -0400
committerUlf Hansson <ulf.hansson@linaro.org>2017-08-30 09:03:39 -0400
commit627c3ccfb46ada2583eac434127ad5d75e1ac33c (patch)
tree0b47d6c685823ff30e76fc50a4f8cf43b5125307 /drivers/mmc/core/debugfs.c
parent1bee324a5627ab05ff9899709a613b8739813eda (diff)
mmc: debugfs: Move block debugfs into block module
If we don't have the block layer enabled, we do not present card status and extcsd in the debugfs. Debugfs is not ABI, and maintaining files of no relevance for non-block devices comes at a high maintenance cost if we shall support it with the block layer compiled out. The debugfs entries suffer from all the same starvation issues as the other userspace things, under e.g. a heavy dd operation. The expected number of debugfs users utilizing these two debugfs files is already low as there is an ioctl() to get the same information using the mmc-tools, and of these few users the expected number of people using it on SDIO or combo cards are expected to be zero. It is therefore logical to move this over to the block layer when it is enabled, using the new custom requests and issue it using the block request queue. On the other hand it moves some debugfs code from debugfs.c and into block.c. Tested during heavy dd load by cat:in the status file. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Diffstat (limited to 'drivers/mmc/core/debugfs.c')
-rw-r--r--drivers/mmc/core/debugfs.c89
1 files changed, 0 insertions, 89 deletions
diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
index a1fba5732d66..01e459a34f33 100644
--- a/drivers/mmc/core/debugfs.c
+++ b/drivers/mmc/core/debugfs.c
@@ -281,85 +281,6 @@ void mmc_remove_host_debugfs(struct mmc_host *host)
281 debugfs_remove_recursive(host->debugfs_root); 281 debugfs_remove_recursive(host->debugfs_root);
282} 282}
283 283
284static int mmc_dbg_card_status_get(void *data, u64 *val)
285{
286 struct mmc_card *card = data;
287 u32 status;
288 int ret;
289
290 mmc_get_card(card);
291
292 ret = mmc_send_status(data, &status);
293 if (!ret)
294 *val = status;
295
296 mmc_put_card(card);
297
298 return ret;
299}
300DEFINE_SIMPLE_ATTRIBUTE(mmc_dbg_card_status_fops, mmc_dbg_card_status_get,
301 NULL, "%08llx\n");
302
303#define EXT_CSD_STR_LEN 1025
304
305static int mmc_ext_csd_open(struct inode *inode, struct file *filp)
306{
307 struct mmc_card *card = inode->i_private;
308 char *buf;
309 ssize_t n = 0;
310 u8 *ext_csd;
311 int err, i;
312
313 buf = kmalloc(EXT_CSD_STR_LEN + 1, GFP_KERNEL);
314 if (!buf)
315 return -ENOMEM;
316
317 mmc_get_card(card);
318 err = mmc_get_ext_csd(card, &ext_csd);
319 mmc_put_card(card);
320 if (err)
321 goto out_free;
322
323 for (i = 0; i < 512; i++)
324 n += sprintf(buf + n, "%02x", ext_csd[i]);
325 n += sprintf(buf + n, "\n");
326
327 if (n != EXT_CSD_STR_LEN) {
328 err = -EINVAL;
329 goto out_free;
330 }
331
332 filp->private_data = buf;
333 kfree(ext_csd);
334 return 0;
335
336out_free:
337 kfree(buf);
338 return err;
339}
340
341static ssize_t mmc_ext_csd_read(struct file *filp, char __user *ubuf,
342 size_t cnt, loff_t *ppos)
343{
344 char *buf = filp->private_data;
345
346 return simple_read_from_buffer(ubuf, cnt, ppos,
347 buf, EXT_CSD_STR_LEN);
348}
349
350static int mmc_ext_csd_release(struct inode *inode, struct file *file)
351{
352 kfree(file->private_data);
353 return 0;
354}
355
356static const struct file_operations mmc_dbg_ext_csd_fops = {
357 .open = mmc_ext_csd_open,
358 .read = mmc_ext_csd_read,
359 .release = mmc_ext_csd_release,
360 .llseek = default_llseek,
361};
362
363void mmc_add_card_debugfs(struct mmc_card *card) 284void mmc_add_card_debugfs(struct mmc_card *card)
364{ 285{
365 struct mmc_host *host = card->host; 286 struct mmc_host *host = card->host;
@@ -382,16 +303,6 @@ void mmc_add_card_debugfs(struct mmc_card *card)
382 if (!debugfs_create_x32("state", S_IRUSR, root, &card->state)) 303 if (!debugfs_create_x32("state", S_IRUSR, root, &card->state))
383 goto err; 304 goto err;
384 305
385 if (mmc_card_mmc(card) || mmc_card_sd(card))
386 if (!debugfs_create_file("status", S_IRUSR, root, card,
387 &mmc_dbg_card_status_fops))
388 goto err;
389
390 if (mmc_card_mmc(card))
391 if (!debugfs_create_file("ext_csd", S_IRUSR, root, card,
392 &mmc_dbg_ext_csd_fops))
393 goto err;
394
395 return; 306 return;
396 307
397err: 308err: