aboutsummaryrefslogtreecommitdiffstats
path: root/fs/debugfs/file.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-12-14 19:10:09 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-12-14 19:10:09 -0500
commite6b5be2be4e30037eb551e0ed09dd97bd00d85d3 (patch)
tree88801365987a0dc64d62d47e8a11f3b44691c37f /fs/debugfs/file.c
parent37da7bbbe84fe9e8862940d3f9194fd27dce59bb (diff)
parentf1c488a78d9f1a22cdb15648c15e70fd82ed229a (diff)
Merge tag 'driver-core-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
Pull driver core update from Greg KH: "Here's the set of driver core patches for 3.19-rc1. They are dominated by the removal of the .owner field in platform drivers. They touch a lot of files, but they are "simple" changes, just removing a line in a structure. Other than that, a few minor driver core and debugfs changes. There are some ath9k patches coming in through this tree that have been acked by the wireless maintainers as they relied on the debugfs changes. Everything has been in linux-next for a while" * tag 'driver-core-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (324 commits) Revert "ath: ath9k: use debugfs_create_devm_seqfile() helper for seq_file entries" fs: debugfs: add forward declaration for struct device type firmware class: Deletion of an unnecessary check before the function call "vunmap" firmware loader: fix hung task warning dump devcoredump: provide a one-way disable function device: Add dev_<level>_once variants ath: ath9k: use debugfs_create_devm_seqfile() helper for seq_file entries ath: use seq_file api for ath9k debugfs files debugfs: add helper function to create device related seq_file drivers/base: cacheinfo: remove noisy error boot message Revert "core: platform: add warning if driver has no owner" drivers: base: support cpu cache information interface to userspace via sysfs drivers: base: add cpu_device_create to support per-cpu devices topology: replace custom attribute macros with standard DEVICE_ATTR* cpumask: factor out show_cpumap into separate helper function driver core: Fix unbalanced device reference in drivers_probe driver core: fix race with userland in device_add() sysfs/kernfs: make read requests on pre-alloc files use the buffer. sysfs/kernfs: allow attributes to request write buffer be pre-allocated. fs: sysfs: return EGBIG on write if offset is larger than file size ...
Diffstat (limited to 'fs/debugfs/file.c')
-rw-r--r--fs/debugfs/file.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index 8e0f2f410189..517e64938438 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -22,6 +22,7 @@
22#include <linux/io.h> 22#include <linux/io.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/atomic.h> 24#include <linux/atomic.h>
25#include <linux/device.h>
25 26
26static ssize_t default_read_file(struct file *file, char __user *buf, 27static ssize_t default_read_file(struct file *file, char __user *buf,
27 size_t count, loff_t *ppos) 28 size_t count, loff_t *ppos)
@@ -762,3 +763,56 @@ struct dentry *debugfs_create_regset32(const char *name, umode_t mode,
762EXPORT_SYMBOL_GPL(debugfs_create_regset32); 763EXPORT_SYMBOL_GPL(debugfs_create_regset32);
763 764
764#endif /* CONFIG_HAS_IOMEM */ 765#endif /* CONFIG_HAS_IOMEM */
766
767struct debugfs_devm_entry {
768 int (*read)(struct seq_file *seq, void *data);
769 struct device *dev;
770};
771
772static int debugfs_devm_entry_open(struct inode *inode, struct file *f)
773{
774 struct debugfs_devm_entry *entry = inode->i_private;
775
776 return single_open(f, entry->read, entry->dev);
777}
778
779static const struct file_operations debugfs_devm_entry_ops = {
780 .owner = THIS_MODULE,
781 .open = debugfs_devm_entry_open,
782 .release = single_release,
783 .read = seq_read,
784 .llseek = seq_lseek
785};
786
787/**
788 * debugfs_create_devm_seqfile - create a debugfs file that is bound to device.
789 *
790 * @dev: device related to this debugfs file.
791 * @name: name of the debugfs file.
792 * @parent: a pointer to the parent dentry for this file. This should be a
793 * directory dentry if set. If this parameter is %NULL, then the
794 * file will be created in the root of the debugfs filesystem.
795 * @read_fn: function pointer called to print the seq_file content.
796 */
797struct dentry *debugfs_create_devm_seqfile(struct device *dev, const char *name,
798 struct dentry *parent,
799 int (*read_fn)(struct seq_file *s,
800 void *data))
801{
802 struct debugfs_devm_entry *entry;
803
804 if (IS_ERR(parent))
805 return ERR_PTR(-ENOENT);
806
807 entry = devm_kzalloc(dev, sizeof(*entry), GFP_KERNEL);
808 if (!entry)
809 return ERR_PTR(-ENOMEM);
810
811 entry->read = read_fn;
812 entry->dev = dev;
813
814 return debugfs_create_file(name, S_IRUGO, parent, entry,
815 &debugfs_devm_entry_ops);
816}
817EXPORT_SYMBOL_GPL(debugfs_create_devm_seqfile);
818