rc = -EIO;
if (attr->read)
- rc = attr->read(kobj, buffer, off, count);
+ rc = attr->read(kobj, attr, buffer, off, count);
sysfs_put_active_two(attr_sd);
rc = -EIO;
if (attr->write)
- rc = attr->write(kobj, buffer, offset, count);
+ rc = attr->write(kobj, attr, buffer, offset, count);
sysfs_put_active_two(attr_sd);
if (!sysfs_get_active(attr_sd))
return -ENODEV;
- /* Grab the module reference for this attribute */
- error = -ENODEV;
- if (!try_module_get(attr->attr.owner))
- goto err_sput;
-
error = -EACCES;
if ((file->f_mode & FMODE_WRITE) && !(attr->write || attr->mmap))
- goto err_mput;
+ goto err_out;
if ((file->f_mode & FMODE_READ) && !(attr->read || attr->mmap))
- goto err_mput;
+ goto err_out;
error = -ENOMEM;
bb = kzalloc(sizeof(*bb), GFP_KERNEL);
if (!bb)
- goto err_mput;
+ goto err_out;
bb->buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
if (!bb->buffer)
- goto err_mput;
+ goto err_out;
mutex_init(&bb->mutex);
file->private_data = bb;
sysfs_get(attr_sd);
return 0;
- err_mput:
- module_put(attr->attr.owner);
- err_sput:
+ err_out:
sysfs_put_active(attr_sd);
kfree(bb);
return error;
static int release(struct inode * inode, struct file * file)
{
struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
- struct bin_attribute *attr = attr_sd->s_elem.bin_attr.bin_attr;
struct bin_buffer *bb = file->private_data;
if (bb->mmapped)
sysfs_put_active_two(attr_sd);
sysfs_put(attr_sd);
- module_put(attr->attr.owner);
kfree(bb->buffer);
kfree(bb);
return 0;
int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr)
{
- BUG_ON(!kobj || !kobj->dentry || !attr);
+ BUG_ON(!kobj || !kobj->sd || !attr);
- return sysfs_add_file(kobj->dentry, &attr->attr, SYSFS_KOBJ_BIN_ATTR);
+ return sysfs_add_file(kobj->sd, &attr->attr, SYSFS_KOBJ_BIN_ATTR);
}
void sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr)
{
- if (sysfs_hash_and_remove(kobj->dentry, attr->attr.name) < 0) {
+ if (sysfs_hash_and_remove(kobj->sd, attr->attr.name) < 0) {
printk(KERN_ERR "%s: "
"bad dentry or inode or no such file: \"%s\"\n",
__FUNCTION__, attr->attr.name);