提交 ad9082ad 编写于 作者: A Akinobu Mita 提交者: John W. Linville

airo: use simple_write_to_buffer

Simplify write file operation for /proc files by using
simple_write_to_buffer().
Signed-off-by: NAkinobu Mita <akinobu.mita@gmail.com>
Cc: "John W. Linville" <linville@tuxdriver.com>
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 52671e43
...@@ -4652,24 +4652,18 @@ static ssize_t proc_write( struct file *file, ...@@ -4652,24 +4652,18 @@ static ssize_t proc_write( struct file *file,
size_t len, size_t len,
loff_t *offset ) loff_t *offset )
{ {
loff_t pos = *offset; ssize_t ret;
struct proc_data *priv = file->private_data; struct proc_data *priv = file->private_data;
if (!priv->wbuffer) if (!priv->wbuffer)
return -EINVAL; return -EINVAL;
if (pos < 0) ret = simple_write_to_buffer(priv->wbuffer, priv->maxwritelen, offset,
return -EINVAL; buffer, len);
if (pos >= priv->maxwritelen) if (ret > 0)
return 0; priv->writelen = max_t(int, priv->writelen, *offset);
if (len > priv->maxwritelen - pos)
len = priv->maxwritelen - pos; return ret;
if (copy_from_user(priv->wbuffer + pos, buffer, len))
return -EFAULT;
if ( pos + len > priv->writelen )
priv->writelen = len + file->f_pos;
*offset = pos + len;
return len;
} }
static int proc_status_open(struct inode *inode, struct file *file) static int proc_status_open(struct inode *inode, struct file *file)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册