mirror of
https://github.com/torvalds/linux.git
synced 2024-12-21 10:31:54 +00:00
wl12xx: use kstrtoul_from_user
simplify code by calling kstrtoul_from_user() (instead of copy_from_user() + kstrtoul()) Signed-off-by: Eliad Peller <eliad@wizery.com> Signed-off-by: Luciano Coelho <coelho@ti.com>
This commit is contained in:
parent
04907011d5
commit
b6883582a8
@ -265,18 +265,10 @@ static ssize_t gpio_power_write(struct file *file,
|
|||||||
size_t count, loff_t *ppos)
|
size_t count, loff_t *ppos)
|
||||||
{
|
{
|
||||||
struct wl1271 *wl = file->private_data;
|
struct wl1271 *wl = file->private_data;
|
||||||
char buf[10];
|
|
||||||
size_t len;
|
|
||||||
unsigned long value;
|
unsigned long value;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
len = min(count, sizeof(buf) - 1);
|
ret = kstrtoul_from_user(user_buf, count, 10, &value);
|
||||||
if (copy_from_user(buf, user_buf, len)) {
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
buf[len] = '\0';
|
|
||||||
|
|
||||||
ret = kstrtoul(buf, 0, &value);
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wl1271_warning("illegal value in gpio_power");
|
wl1271_warning("illegal value in gpio_power");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@ -427,17 +419,10 @@ static ssize_t dtim_interval_write(struct file *file,
|
|||||||
size_t count, loff_t *ppos)
|
size_t count, loff_t *ppos)
|
||||||
{
|
{
|
||||||
struct wl1271 *wl = file->private_data;
|
struct wl1271 *wl = file->private_data;
|
||||||
char buf[10];
|
|
||||||
size_t len;
|
|
||||||
unsigned long value;
|
unsigned long value;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
len = min(count, sizeof(buf) - 1);
|
ret = kstrtoul_from_user(user_buf, count, 10, &value);
|
||||||
if (copy_from_user(buf, user_buf, len))
|
|
||||||
return -EFAULT;
|
|
||||||
buf[len] = '\0';
|
|
||||||
|
|
||||||
ret = kstrtoul(buf, 0, &value);
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wl1271_warning("illegal value for dtim_interval");
|
wl1271_warning("illegal value for dtim_interval");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@ -492,17 +477,10 @@ static ssize_t beacon_interval_write(struct file *file,
|
|||||||
size_t count, loff_t *ppos)
|
size_t count, loff_t *ppos)
|
||||||
{
|
{
|
||||||
struct wl1271 *wl = file->private_data;
|
struct wl1271 *wl = file->private_data;
|
||||||
char buf[10];
|
|
||||||
size_t len;
|
|
||||||
unsigned long value;
|
unsigned long value;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
len = min(count, sizeof(buf) - 1);
|
ret = kstrtoul_from_user(user_buf, count, 10, &value);
|
||||||
if (copy_from_user(buf, user_buf, len))
|
|
||||||
return -EFAULT;
|
|
||||||
buf[len] = '\0';
|
|
||||||
|
|
||||||
ret = kstrtoul(buf, 0, &value);
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wl1271_warning("illegal value for beacon_interval");
|
wl1271_warning("illegal value for beacon_interval");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@ -542,17 +520,10 @@ static ssize_t rx_streaming_interval_write(struct file *file,
|
|||||||
size_t count, loff_t *ppos)
|
size_t count, loff_t *ppos)
|
||||||
{
|
{
|
||||||
struct wl1271 *wl = file->private_data;
|
struct wl1271 *wl = file->private_data;
|
||||||
char buf[10];
|
|
||||||
size_t len;
|
|
||||||
unsigned long value;
|
unsigned long value;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
len = min(count, sizeof(buf) - 1);
|
ret = kstrtoul_from_user(user_buf, count, 10, &value);
|
||||||
if (copy_from_user(buf, user_buf, len))
|
|
||||||
return -EFAULT;
|
|
||||||
buf[len] = '\0';
|
|
||||||
|
|
||||||
ret = kstrtoul(buf, 0, &value);
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wl1271_warning("illegal value in rx_streaming_interval!");
|
wl1271_warning("illegal value in rx_streaming_interval!");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@ -601,17 +572,10 @@ static ssize_t rx_streaming_always_write(struct file *file,
|
|||||||
size_t count, loff_t *ppos)
|
size_t count, loff_t *ppos)
|
||||||
{
|
{
|
||||||
struct wl1271 *wl = file->private_data;
|
struct wl1271 *wl = file->private_data;
|
||||||
char buf[10];
|
|
||||||
size_t len;
|
|
||||||
unsigned long value;
|
unsigned long value;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
len = min(count, sizeof(buf) - 1);
|
ret = kstrtoul_from_user(user_buf, count, 10, &value);
|
||||||
if (copy_from_user(buf, user_buf, len))
|
|
||||||
return -EFAULT;
|
|
||||||
buf[len] = '\0';
|
|
||||||
|
|
||||||
ret = kstrtoul(buf, 0, &value);
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wl1271_warning("illegal value in rx_streaming_write!");
|
wl1271_warning("illegal value in rx_streaming_write!");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
Loading…
Reference in New Issue
Block a user