提交 995982ca 编写于 作者: R Randy.Dunlap 提交者: Greg Kroah-Hartman

sysfs_remove_bin_file: no return value, dump_stack on error

Make sysfs_remove_bin_file() void.  If it detects an error,
printk the file name and call dump_stack().

sysfs_hash_and_remove() now returns an error code indicating
its success or failure so that sysfs_remove_bin_file() can
know success/failure.

Convert the only driver that checked the return value of
sysfs_remove_bin_file().
Signed-off-by: NRandy Dunlap <rdunlap@xenotime.net>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 10188012
...@@ -487,9 +487,7 @@ static void __exit ibm_acpiphp_exit(void) ...@@ -487,9 +487,7 @@ static void __exit ibm_acpiphp_exit(void)
if (ACPI_FAILURE(status)) if (ACPI_FAILURE(status))
err("%s: Notification handler removal failed\n", __FUNCTION__); err("%s: Notification handler removal failed\n", __FUNCTION__);
/* remove the /sys entries */ /* remove the /sys entries */
if (sysfs_remove_bin_file(sysdir, &ibm_apci_table_attr)) sysfs_remove_bin_file(sysdir, &ibm_apci_table_attr);
err("%s: removal of sysfs file apci_table failed\n",
__FUNCTION__);
} }
module_init(ibm_acpiphp_init); module_init(ibm_acpiphp_init);
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/kernel.h>
#include <linux/kobject.h> #include <linux/kobject.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -176,7 +177,6 @@ const struct file_operations bin_fops = { ...@@ -176,7 +177,6 @@ const struct file_operations bin_fops = {
* sysfs_create_bin_file - create binary file for object. * sysfs_create_bin_file - create binary file for object.
* @kobj: object. * @kobj: object.
* @attr: attribute descriptor. * @attr: attribute descriptor.
*
*/ */
int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr) int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr)
...@@ -191,13 +191,16 @@ int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr) ...@@ -191,13 +191,16 @@ int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr)
* sysfs_remove_bin_file - remove binary file for object. * sysfs_remove_bin_file - remove binary file for object.
* @kobj: object. * @kobj: object.
* @attr: attribute descriptor. * @attr: attribute descriptor.
*
*/ */
int sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr) void sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr)
{ {
sysfs_hash_and_remove(kobj->dentry,attr->attr.name); if (sysfs_hash_and_remove(kobj->dentry, attr->attr.name) < 0) {
return 0; printk(KERN_ERR "%s: "
"bad dentry or inode or no such file: \"%s\"\n",
__FUNCTION__, attr->attr.name);
dump_stack();
}
} }
EXPORT_SYMBOL_GPL(sysfs_create_bin_file); EXPORT_SYMBOL_GPL(sysfs_create_bin_file);
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <linux/namei.h> #include <linux/namei.h>
#include <linux/backing-dev.h> #include <linux/backing-dev.h>
#include <linux/capability.h> #include <linux/capability.h>
#include <linux/errno.h>
#include "sysfs.h" #include "sysfs.h"
extern struct super_block * sysfs_sb; extern struct super_block * sysfs_sb;
...@@ -234,17 +235,18 @@ void sysfs_drop_dentry(struct sysfs_dirent * sd, struct dentry * parent) ...@@ -234,17 +235,18 @@ void sysfs_drop_dentry(struct sysfs_dirent * sd, struct dentry * parent)
} }
} }
void sysfs_hash_and_remove(struct dentry * dir, const char * name) int sysfs_hash_and_remove(struct dentry * dir, const char * name)
{ {
struct sysfs_dirent * sd; struct sysfs_dirent * sd;
struct sysfs_dirent * parent_sd; struct sysfs_dirent * parent_sd;
int found = 0;
if (!dir) if (!dir)
return; return -ENOENT;
if (dir->d_inode == NULL) if (dir->d_inode == NULL)
/* no inode means this hasn't been made visible yet */ /* no inode means this hasn't been made visible yet */
return; return -ENOENT;
parent_sd = dir->d_fsdata; parent_sd = dir->d_fsdata;
mutex_lock(&dir->d_inode->i_mutex); mutex_lock(&dir->d_inode->i_mutex);
...@@ -255,8 +257,11 @@ void sysfs_hash_and_remove(struct dentry * dir, const char * name) ...@@ -255,8 +257,11 @@ void sysfs_hash_and_remove(struct dentry * dir, const char * name)
list_del_init(&sd->s_sibling); list_del_init(&sd->s_sibling);
sysfs_drop_dentry(sd, dir); sysfs_drop_dentry(sd, dir);
sysfs_put(sd); sysfs_put(sd);
found = 1;
break; break;
} }
} }
mutex_unlock(&dir->d_inode->i_mutex); mutex_unlock(&dir->d_inode->i_mutex);
return found ? 0 : -ENOENT;
} }
...@@ -10,7 +10,7 @@ extern int sysfs_make_dirent(struct sysfs_dirent *, struct dentry *, void *, ...@@ -10,7 +10,7 @@ extern int sysfs_make_dirent(struct sysfs_dirent *, struct dentry *, void *,
umode_t, int); umode_t, int);
extern int sysfs_add_file(struct dentry *, const struct attribute *, int); extern int sysfs_add_file(struct dentry *, const struct attribute *, int);
extern void sysfs_hash_and_remove(struct dentry * dir, const char * name); extern int sysfs_hash_and_remove(struct dentry * dir, const char * name);
extern struct sysfs_dirent *sysfs_find(struct sysfs_dirent *dir, const char * name); extern struct sysfs_dirent *sysfs_find(struct sysfs_dirent *dir, const char * name);
extern int sysfs_create_subdir(struct kobject *, const char *, struct dentry **); extern int sysfs_create_subdir(struct kobject *, const char *, struct dentry **);
......
...@@ -114,7 +114,7 @@ extern void ...@@ -114,7 +114,7 @@ extern void
sysfs_remove_link(struct kobject *, const char * name); sysfs_remove_link(struct kobject *, const char * name);
int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr); int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr);
int sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr); void sysfs_remove_bin_file(struct kobject *kobj, struct bin_attribute *attr);
int sysfs_create_group(struct kobject *, const struct attribute_group *); int sysfs_create_group(struct kobject *, const struct attribute_group *);
void sysfs_remove_group(struct kobject *, const struct attribute_group *); void sysfs_remove_group(struct kobject *, const struct attribute_group *);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册