Skip to content

Commit

Permalink
airo: use simple_write_to_buffer
Browse files Browse the repository at this point in the history
Simplify write file operation for /proc files by using
simple_write_to_buffer().

Signed-off-by: Akinobu 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: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Akinobu Mita authored and John W. Linville committed Jan 4, 2011
1 parent 52671e4 commit ad9082a
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions drivers/net/wireless/airo.c
Original file line number Diff line number Diff line change
Expand Up @@ -4652,24 +4652,18 @@ static ssize_t proc_write( struct file *file,
size_t len,
loff_t *offset )
{
loff_t pos = *offset;
ssize_t ret;
struct proc_data *priv = file->private_data;

if (!priv->wbuffer)
return -EINVAL;

if (pos < 0)
return -EINVAL;
if (pos >= priv->maxwritelen)
return 0;
if (len > priv->maxwritelen - pos)
len = priv->maxwritelen - pos;
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;
ret = simple_write_to_buffer(priv->wbuffer, priv->maxwritelen, offset,
buffer, len);
if (ret > 0)
priv->writelen = max_t(int, priv->writelen, *offset);

return ret;
}

static int proc_status_open(struct inode *inode, struct file *file)
Expand Down

0 comments on commit ad9082a

Please sign in to comment.