Commit c6b1de1b authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'debugfs_automount' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull debugfs patches from Al Viro:
 "debugfs patches, mostly to make it possible for something like tracefs
  to be transparently automounted on given directory in debugfs.

  New primitive in there is debugfs_create_automount(name, parent, func,
  arg), which creates a directory and makes its ->d_automount() return
  func(arg).  Another missing primitive was debugfs_create_file_size() -
  open-coded in quite a few places.  Dave's patch adds it and converts
  the open-code instances to calling it"

* 'debugfs_automount' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  debugfs: Provide a file creation function that also takes an initial size
  new primitive: debugfs_create_automount()
  debugfs: split end_creating() into success and failure cases
  debugfs: take mode-dependent parts of debugfs_get_inode() into callers
  fold debugfs_mknod() into callers
  fold debugfs_create() into caller
  fold debugfs_mkdir() into caller
  debugfs_mknod(): get rid useless arguments
  fold debugfs_link() into caller
  debugfs: kill __create_file()
  debugfs: split the beginning and the end of __create_file() off
  debugfs_{mkdir,create,link}(): get rid of redundant argument
parents 50652963 e59b4e91
......@@ -700,37 +700,24 @@ static const struct file_operations ep_debugfs_fops = {
static int setup_debugfs(struct c4iw_dev *devp)
{
struct dentry *de;
if (!devp->debugfs_root)
return -1;
de = debugfs_create_file("qps", S_IWUSR, devp->debugfs_root,
(void *)devp, &qp_debugfs_fops);
if (de && de->d_inode)
de->d_inode->i_size = 4096;
debugfs_create_file_size("qps", S_IWUSR, devp->debugfs_root,
(void *)devp, &qp_debugfs_fops, 4096);
de = debugfs_create_file("stags", S_IWUSR, devp->debugfs_root,
(void *)devp, &stag_debugfs_fops);
if (de && de->d_inode)
de->d_inode->i_size = 4096;
debugfs_create_file_size("stags", S_IWUSR, devp->debugfs_root,
(void *)devp, &stag_debugfs_fops, 4096);
de = debugfs_create_file("stats", S_IWUSR, devp->debugfs_root,
(void *)devp, &stats_debugfs_fops);
if (de && de->d_inode)
de->d_inode->i_size = 4096;
debugfs_create_file_size("stats", S_IWUSR, devp->debugfs_root,
(void *)devp, &stats_debugfs_fops, 4096);
de = debugfs_create_file("eps", S_IWUSR, devp->debugfs_root,
(void *)devp, &ep_debugfs_fops);
if (de && de->d_inode)
de->d_inode->i_size = 4096;
debugfs_create_file_size("eps", S_IWUSR, devp->debugfs_root,
(void *)devp, &ep_debugfs_fops, 4096);
if (c4iw_wr_log) {
de = debugfs_create_file("wr_log", S_IWUSR, devp->debugfs_root,
(void *)devp, &wr_log_debugfs_fops);
if (de && de->d_inode)
de->d_inode->i_size = 4096;
}
if (c4iw_wr_log)
debugfs_create_file_size("wr_log", S_IWUSR, devp->debugfs_root,
(void *)devp, &wr_log_debugfs_fops, 4096);
return 0;
}
......
......@@ -1950,12 +1950,9 @@ static void set_debugfs_file_size(struct dentry *de, loff_t size)
static void add_debugfs_mem(struct adapter *adap, const char *name,
unsigned int idx, unsigned int size_mb)
{
struct dentry *de;
de = debugfs_create_file(name, S_IRUSR, adap->debugfs_root,
(void *)adap + idx, &mem_debugfs_fops);
if (de && de->d_inode)
de->d_inode->i_size = size_mb << 20;
debugfs_create_file_size(name, S_IRUSR, adap->debugfs_root,
(void *)adap + idx, &mem_debugfs_fops,
size_mb << 20);
}
/* Add an array of Debug FS files.
......
......@@ -113,12 +113,9 @@ static const struct file_operations csio_mem_debugfs_fops = {
void csio_add_debugfs_mem(struct csio_hw *hw, const char *name,
unsigned int idx, unsigned int size_mb)
{
struct dentry *de;
de = debugfs_create_file(name, S_IRUSR, hw->debugfs_root,
(void *)hw + idx, &csio_mem_debugfs_fops);
if (de && de->d_inode)
de->d_inode->i_size = size_mb << 20;
debugfs_create_file_size(name, S_IRUSR, hw->debugfs_root,
(void *)hw + idx, &csio_mem_debugfs_fops,
size_mb << 20);
}
static int csio_setup_debugfs(struct csio_hw *hw)
......
......@@ -265,14 +265,17 @@ static void usba_init_debugfs(struct usba_udc *udc)
goto err_root;
udc->debugfs_root = root;
regs = debugfs_create_file("regs", 0400, root, udc, &regs_dbg_fops);
if (!regs)
goto err_regs;
regs_resource = platform_get_resource(udc->pdev, IORESOURCE_MEM,
CTRL_IOMEM_ID);
regs->d_inode->i_size = resource_size(regs_resource);
if (regs_resource) {
regs = debugfs_create_file_size("regs", 0400, root, udc,
&regs_dbg_fops,
resource_size(regs_resource));
if (!regs)
goto err_regs;
udc->debugfs_regs = regs;
}
usba_ep_init_debugfs(udc, to_usba_ep(udc->gadget.ep0));
......
This diff is collapsed.
......@@ -51,11 +51,21 @@ struct dentry *debugfs_create_file(const char *name, umode_t mode,
struct dentry *parent, void *data,
const struct file_operations *fops);
struct dentry *debugfs_create_file_size(const char *name, umode_t mode,
struct dentry *parent, void *data,
const struct file_operations *fops,
loff_t file_size);
struct dentry *debugfs_create_dir(const char *name, struct dentry *parent);
struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent,
const char *dest);
struct dentry *debugfs_create_automount(const char *name,
struct dentry *parent,
struct vfsmount *(*f)(void *),
void *data);
void debugfs_remove(struct dentry *dentry);
void debugfs_remove_recursive(struct dentry *dentry);
......@@ -124,6 +134,14 @@ static inline struct dentry *debugfs_create_file(const char *name, umode_t mode,
return ERR_PTR(-ENODEV);
}
static inline struct dentry *debugfs_create_file_size(const char *name, umode_t mode,
struct dentry *parent, void *data,
const struct file_operations *fops,
loff_t file_size)
{
return ERR_PTR(-ENODEV);
}
static inline struct dentry *debugfs_create_dir(const char *name,
struct dentry *parent)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment