147 goto out_free;
148 }
149
150 mutex_lock(&bb->mutex);
151
152 memcpy(bb->buffer, temp, count);
153
154 count = flush_write(dentry, bb->buffer, offs, count);
155 mutex_unlock(&bb->mutex);
156
157 if (count > 0)
158 *off = offs + count;
159
160out_free:
161 kfree(temp);
162 return count;
163}
164
165static int mmap(struct file *file, struct vm_area_struct *vma)
166{
167 struct bin_buffer *bb = file->private_data;
168 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
169 struct bin_attribute *attr = attr_sd->s_bin_attr.bin_attr;
170 struct kobject *kobj = attr_sd->s_parent->s_dir.kobj;
171 int rc;
172
173 mutex_lock(&bb->mutex);
174
175
176 if (!sysfs_get_active_two(attr_sd))
177 return -ENODEV;
178
179 rc = -EINVAL;
180 if (attr->mmap)
181 rc = attr->mmap(kobj, attr, vma);
182
183 if (rc == 0 && !bb->mmapped)
184 bb->mmapped = 1;
185 else
186 sysfs_put_active_two(attr_sd);
187