aboutsummaryrefslogtreecommitdiffstats
path: root/fs/debugfs/file.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-04-27 15:58:54 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-04-27 15:58:54 -0400
commitd868772fff6c4b881d66af8640251714e1aefa98 (patch)
treec95a68d358d5c875d25763ffe9a44fe9f2081f34 /fs/debugfs/file.c
parenta205752d1ad2d37d6597aaae5a56fc396a770868 (diff)
parent404d5b185b4eb56d6fa2f7bd27833f8df1c38ce4 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6: (46 commits) dev_dbg: check dev_dbg() arguments drivers/base/attribute_container.c: use mutex instead of binary semaphore mod_sysfs_setup() doesn't return errno when kobject_add_dir() failure occurs s2ram: add arch irq disable/enable hooks define platform wakeup hook, use in pci_enable_wake() security: prevent permission checking of file removal via sysfs_remove_group() device_schedule_callback() needs a module reference s390: cio: Delay uevents for subchannels sysfs: bin.c printk fix Driver core: use mutex instead of semaphore in DMA pool handler driver core: bus_add_driver should return an error if no bus debugfs: Add debugfs_create_u64() the overdue removal of the mount/umount uevents kobject: Comment and warning fixes to kobject.c Driver core: warn when userspace writes to the uevent file in a non-supported way Driver core: make uevent-environment available in uevent-file kobject core: remove rwsem from struct subsystem qeth: Remove usage of subsys.rwsem PHY: remove rwsem use from phy core IEEE1394: remove rwsem use from ieee1394 core ...
Diffstat (limited to 'fs/debugfs/file.c')
-rw-r--r--fs/debugfs/file.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index 682f928b7f4d..2e124e0075c5 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -179,6 +179,48 @@ struct dentry *debugfs_create_u32(const char *name, mode_t mode,
179} 179}
180EXPORT_SYMBOL_GPL(debugfs_create_u32); 180EXPORT_SYMBOL_GPL(debugfs_create_u32);
181 181
182static void debugfs_u64_set(void *data, u64 val)
183{
184 *(u64 *)data = val;
185}
186
187static u64 debugfs_u64_get(void *data)
188{
189 return *(u64 *)data;
190}
191DEFINE_SIMPLE_ATTRIBUTE(fops_u64, debugfs_u64_get, debugfs_u64_set, "%llu\n");
192
193/**
194 * debugfs_create_u64 - create a debugfs file that is used to read and write an unsigned 64-bit value
195 * @name: a pointer to a string containing the name of the file to create.
196 * @mode: the permission that the file should have
197 * @parent: a pointer to the parent dentry for this file. This should be a
198 * directory dentry if set. If this parameter is %NULL, then the
199 * file will be created in the root of the debugfs filesystem.
200 * @value: a pointer to the variable that the file should read to and write
201 * from.
202 *
203 * This function creates a file in debugfs with the given name that
204 * contains the value of the variable @value. If the @mode variable is so
205 * set, it can be read from, and written to.
206 *
207 * This function will return a pointer to a dentry if it succeeds. This
208 * pointer must be passed to the debugfs_remove() function when the file is
209 * to be removed (no automatic cleanup happens if your module is unloaded,
210 * you are responsible here.) If an error occurs, %NULL will be returned.
211 *
212 * If debugfs is not enabled in the kernel, the value -%ENODEV will be
213 * returned. It is not wise to check for this value, but rather, check for
214 * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling
215 * code.
216 */
217struct dentry *debugfs_create_u64(const char *name, mode_t mode,
218 struct dentry *parent, u64 *value)
219{
220 return debugfs_create_file(name, mode, parent, value, &fops_u64);
221}
222EXPORT_SYMBOL_GPL(debugfs_create_u64);
223
182static ssize_t read_file_bool(struct file *file, char __user *user_buf, 224static ssize_t read_file_bool(struct file *file, char __user *user_buf,
183 size_t count, loff_t *ppos) 225 size_t count, loff_t *ppos)
184{ 226{