diff options
-rw-r--r-- | drivers/infiniband/hw/cxgb4/device.c | 35 | ||||
-rw-r--r-- | drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 9 | ||||
-rw-r--r-- | drivers/scsi/csiostor/csio_init.c | 9 | ||||
-rw-r--r-- | drivers/usb/gadget/udc/atmel_usba_udc.c | 15 | ||||
-rw-r--r-- | fs/debugfs/inode.c | 40 | ||||
-rw-r--r-- | include/linux/debugfs.h | 13 |
6 files changed, 79 insertions, 42 deletions
diff --git a/drivers/infiniband/hw/cxgb4/device.c b/drivers/infiniband/hw/cxgb4/device.c index eb5df4e62703..391309a55360 100644 --- a/drivers/infiniband/hw/cxgb4/device.c +++ b/drivers/infiniband/hw/cxgb4/device.c | |||
@@ -700,37 +700,24 @@ static const struct file_operations ep_debugfs_fops = { | |||
700 | 700 | ||
701 | static int setup_debugfs(struct c4iw_dev *devp) | 701 | static int setup_debugfs(struct c4iw_dev *devp) |
702 | { | 702 | { |
703 | struct dentry *de; | ||
704 | |||
705 | if (!devp->debugfs_root) | 703 | if (!devp->debugfs_root) |
706 | return -1; | 704 | return -1; |
707 | 705 | ||
708 | de = debugfs_create_file("qps", S_IWUSR, devp->debugfs_root, | 706 | debugfs_create_file_size("qps", S_IWUSR, devp->debugfs_root, |
709 | (void *)devp, &qp_debugfs_fops); | 707 | (void *)devp, &qp_debugfs_fops, 4096); |
710 | if (de && de->d_inode) | ||
711 | de->d_inode->i_size = 4096; | ||
712 | 708 | ||
713 | de = debugfs_create_file("stags", S_IWUSR, devp->debugfs_root, | 709 | debugfs_create_file_size("stags", S_IWUSR, devp->debugfs_root, |
714 | (void *)devp, &stag_debugfs_fops); | 710 | (void *)devp, &stag_debugfs_fops, 4096); |
715 | if (de && de->d_inode) | ||
716 | de->d_inode->i_size = 4096; | ||
717 | 711 | ||
718 | de = debugfs_create_file("stats", S_IWUSR, devp->debugfs_root, | 712 | debugfs_create_file_size("stats", S_IWUSR, devp->debugfs_root, |
719 | (void *)devp, &stats_debugfs_fops); | 713 | (void *)devp, &stats_debugfs_fops, 4096); |
720 | if (de && de->d_inode) | ||
721 | de->d_inode->i_size = 4096; | ||
722 | 714 | ||
723 | de = debugfs_create_file("eps", S_IWUSR, devp->debugfs_root, | 715 | debugfs_create_file_size("eps", S_IWUSR, devp->debugfs_root, |
724 | (void *)devp, &ep_debugfs_fops); | 716 | (void *)devp, &ep_debugfs_fops, 4096); |
725 | if (de && de->d_inode) | ||
726 | de->d_inode->i_size = 4096; | ||
727 | 717 | ||
728 | if (c4iw_wr_log) { | 718 | if (c4iw_wr_log) |
729 | de = debugfs_create_file("wr_log", S_IWUSR, devp->debugfs_root, | 719 | debugfs_create_file_size("wr_log", S_IWUSR, devp->debugfs_root, |
730 | (void *)devp, &wr_log_debugfs_fops); | 720 | (void *)devp, &wr_log_debugfs_fops, 4096); |
731 | if (de && de->d_inode) | ||
732 | de->d_inode->i_size = 4096; | ||
733 | } | ||
734 | return 0; | 721 | return 0; |
735 | } | 722 | } |
736 | 723 | ||
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c index c98a350d857e..4c7fe447e407 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | |||
@@ -91,12 +91,9 @@ static const struct file_operations mem_debugfs_fops = { | |||
91 | static void add_debugfs_mem(struct adapter *adap, const char *name, | 91 | static void add_debugfs_mem(struct adapter *adap, const char *name, |
92 | unsigned int idx, unsigned int size_mb) | 92 | unsigned int idx, unsigned int size_mb) |
93 | { | 93 | { |
94 | struct dentry *de; | 94 | debugfs_create_file_size(name, S_IRUSR, adap->debugfs_root, |
95 | 95 | (void *)adap + idx, &mem_debugfs_fops, | |
96 | de = debugfs_create_file(name, S_IRUSR, adap->debugfs_root, | 96 | size_mb << 20); |
97 | (void *)adap + idx, &mem_debugfs_fops); | ||
98 | if (de && de->d_inode) | ||
99 | de->d_inode->i_size = size_mb << 20; | ||
100 | } | 97 | } |
101 | 98 | ||
102 | /* Add an array of Debug FS files. | 99 | /* Add an array of Debug FS files. |
diff --git a/drivers/scsi/csiostor/csio_init.c b/drivers/scsi/csiostor/csio_init.c index 34d20cc3e110..2617f15eaeeb 100644 --- a/drivers/scsi/csiostor/csio_init.c +++ b/drivers/scsi/csiostor/csio_init.c | |||
@@ -113,12 +113,9 @@ static const struct file_operations csio_mem_debugfs_fops = { | |||
113 | void csio_add_debugfs_mem(struct csio_hw *hw, const char *name, | 113 | void csio_add_debugfs_mem(struct csio_hw *hw, const char *name, |
114 | unsigned int idx, unsigned int size_mb) | 114 | unsigned int idx, unsigned int size_mb) |
115 | { | 115 | { |
116 | struct dentry *de; | 116 | debugfs_create_file_size(name, S_IRUSR, hw->debugfs_root, |
117 | 117 | (void *)hw + idx, &csio_mem_debugfs_fops, | |
118 | de = debugfs_create_file(name, S_IRUSR, hw->debugfs_root, | 118 | size_mb << 20); |
119 | (void *)hw + idx, &csio_mem_debugfs_fops); | ||
120 | if (de && de->d_inode) | ||
121 | de->d_inode->i_size = size_mb << 20; | ||
122 | } | 119 | } |
123 | 120 | ||
124 | static int csio_setup_debugfs(struct csio_hw *hw) | 121 | static int csio_setup_debugfs(struct csio_hw *hw) |
diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c index 9f93bed42052..b2239a2d4941 100644 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c | |||
@@ -264,14 +264,17 @@ static void usba_init_debugfs(struct usba_udc *udc) | |||
264 | goto err_root; | 264 | goto err_root; |
265 | udc->debugfs_root = root; | 265 | udc->debugfs_root = root; |
266 | 266 | ||
267 | regs = debugfs_create_file("regs", 0400, root, udc, ®s_dbg_fops); | ||
268 | if (!regs) | ||
269 | goto err_regs; | ||
270 | |||
271 | regs_resource = platform_get_resource(udc->pdev, IORESOURCE_MEM, | 267 | regs_resource = platform_get_resource(udc->pdev, IORESOURCE_MEM, |
272 | CTRL_IOMEM_ID); | 268 | CTRL_IOMEM_ID); |
273 | regs->d_inode->i_size = resource_size(regs_resource); | 269 | |
274 | udc->debugfs_regs = regs; | 270 | if (regs_resource) { |
271 | regs = debugfs_create_file_size("regs", 0400, root, udc, | ||
272 | ®s_dbg_fops, | ||
273 | resource_size(regs_resource)); | ||
274 | if (!regs) | ||
275 | goto err_regs; | ||
276 | udc->debugfs_regs = regs; | ||
277 | } | ||
275 | 278 | ||
276 | usba_ep_init_debugfs(udc, to_usba_ep(udc->gadget.ep0)); | 279 | usba_ep_init_debugfs(udc, to_usba_ep(udc->gadget.ep0)); |
277 | 280 | ||
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index 957c40ce09f6..45b18a5e225c 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c | |||
@@ -338,6 +338,46 @@ struct dentry *debugfs_create_file(const char *name, umode_t mode, | |||
338 | EXPORT_SYMBOL_GPL(debugfs_create_file); | 338 | EXPORT_SYMBOL_GPL(debugfs_create_file); |
339 | 339 | ||
340 | /** | 340 | /** |
341 | * debugfs_create_file_size - create a file in the debugfs filesystem | ||
342 | * @name: a pointer to a string containing the name of the file to create. | ||
343 | * @mode: the permission that the file should have. | ||
344 | * @parent: a pointer to the parent dentry for this file. This should be a | ||
345 | * directory dentry if set. If this parameter is NULL, then the | ||
346 | * file will be created in the root of the debugfs filesystem. | ||
347 | * @data: a pointer to something that the caller will want to get to later | ||
348 | * on. The inode.i_private pointer will point to this value on | ||
349 | * the open() call. | ||
350 | * @fops: a pointer to a struct file_operations that should be used for | ||
351 | * this file. | ||
352 | * @file_size: initial file size | ||
353 | * | ||
354 | * This is the basic "create a file" function for debugfs. It allows for a | ||
355 | * wide range of flexibility in creating a file, or a directory (if you want | ||
356 | * to create a directory, the debugfs_create_dir() function is | ||
357 | * recommended to be used instead.) | ||
358 | * | ||
359 | * This function will return a pointer to a dentry if it succeeds. This | ||
360 | * pointer must be passed to the debugfs_remove() function when the file is | ||
361 | * to be removed (no automatic cleanup happens if your module is unloaded, | ||
362 | * you are responsible here.) If an error occurs, %NULL will be returned. | ||
363 | * | ||
364 | * If debugfs is not enabled in the kernel, the value -%ENODEV will be | ||
365 | * returned. | ||
366 | */ | ||
367 | struct dentry *debugfs_create_file_size(const char *name, umode_t mode, | ||
368 | struct dentry *parent, void *data, | ||
369 | const struct file_operations *fops, | ||
370 | loff_t file_size) | ||
371 | { | ||
372 | struct dentry *de = debugfs_create_file(name, mode, parent, data, fops); | ||
373 | |||
374 | if (de) | ||
375 | de->d_inode->i_size = file_size; | ||
376 | return de; | ||
377 | } | ||
378 | EXPORT_SYMBOL_GPL(debugfs_create_file_size); | ||
379 | |||
380 | /** | ||
341 | * debugfs_create_dir - create a directory in the debugfs filesystem | 381 | * debugfs_create_dir - create a directory in the debugfs filesystem |
342 | * @name: a pointer to a string containing the name of the directory to | 382 | * @name: a pointer to a string containing the name of the directory to |
343 | * create. | 383 | * create. |
diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h index ea149a24a1f2..cb25af461054 100644 --- a/include/linux/debugfs.h +++ b/include/linux/debugfs.h | |||
@@ -51,6 +51,11 @@ struct dentry *debugfs_create_file(const char *name, umode_t mode, | |||
51 | struct dentry *parent, void *data, | 51 | struct dentry *parent, void *data, |
52 | const struct file_operations *fops); | 52 | const struct file_operations *fops); |
53 | 53 | ||
54 | struct dentry *debugfs_create_file_size(const char *name, umode_t mode, | ||
55 | struct dentry *parent, void *data, | ||
56 | const struct file_operations *fops, | ||
57 | loff_t file_size); | ||
58 | |||
54 | struct dentry *debugfs_create_dir(const char *name, struct dentry *parent); | 59 | struct dentry *debugfs_create_dir(const char *name, struct dentry *parent); |
55 | 60 | ||
56 | struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent, | 61 | struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent, |
@@ -129,6 +134,14 @@ static inline struct dentry *debugfs_create_file(const char *name, umode_t mode, | |||
129 | return ERR_PTR(-ENODEV); | 134 | return ERR_PTR(-ENODEV); |
130 | } | 135 | } |
131 | 136 | ||
137 | static inline struct dentry *debugfs_create_file_size(const char *name, umode_t mode, | ||
138 | struct dentry *parent, void *data, | ||
139 | const struct file_operations *fops, | ||
140 | loff_t file_size) | ||
141 | { | ||
142 | return ERR_PTR(-ENODEV); | ||
143 | } | ||
144 | |||
132 | static inline struct dentry *debugfs_create_dir(const char *name, | 145 | static inline struct dentry *debugfs_create_dir(const char *name, |
133 | struct dentry *parent) | 146 | struct dentry *parent) |
134 | { | 147 | { |