.. | .. |
---|
955 | 955 | EXPORT_SYMBOL_GPL(simple_attr_read); |
---|
956 | 956 | |
---|
957 | 957 | /* interpret the buffer as a number to call the set function with */ |
---|
958 | | -ssize_t simple_attr_write(struct file *file, const char __user *buf, |
---|
959 | | - size_t len, loff_t *ppos) |
---|
| 958 | +static ssize_t simple_attr_write_xsigned(struct file *file, const char __user *buf, |
---|
| 959 | + size_t len, loff_t *ppos, bool is_signed) |
---|
960 | 960 | { |
---|
961 | 961 | struct simple_attr *attr; |
---|
962 | 962 | unsigned long long val; |
---|
.. | .. |
---|
977 | 977 | goto out; |
---|
978 | 978 | |
---|
979 | 979 | attr->set_buf[size] = '\0'; |
---|
980 | | - ret = kstrtoull(attr->set_buf, 0, &val); |
---|
| 980 | + if (is_signed) |
---|
| 981 | + ret = kstrtoll(attr->set_buf, 0, &val); |
---|
| 982 | + else |
---|
| 983 | + ret = kstrtoull(attr->set_buf, 0, &val); |
---|
981 | 984 | if (ret) |
---|
982 | 985 | goto out; |
---|
983 | 986 | ret = attr->set(attr->data, val); |
---|
.. | .. |
---|
987 | 990 | mutex_unlock(&attr->mutex); |
---|
988 | 991 | return ret; |
---|
989 | 992 | } |
---|
| 993 | + |
---|
| 994 | +ssize_t simple_attr_write(struct file *file, const char __user *buf, |
---|
| 995 | + size_t len, loff_t *ppos) |
---|
| 996 | +{ |
---|
| 997 | + return simple_attr_write_xsigned(file, buf, len, ppos, false); |
---|
| 998 | +} |
---|
990 | 999 | EXPORT_SYMBOL_GPL(simple_attr_write); |
---|
991 | 1000 | |
---|
| 1001 | +ssize_t simple_attr_write_signed(struct file *file, const char __user *buf, |
---|
| 1002 | + size_t len, loff_t *ppos) |
---|
| 1003 | +{ |
---|
| 1004 | + return simple_attr_write_xsigned(file, buf, len, ppos, true); |
---|
| 1005 | +} |
---|
| 1006 | +EXPORT_SYMBOL_GPL(simple_attr_write_signed); |
---|
| 1007 | + |
---|
992 | 1008 | /** |
---|
993 | 1009 | * generic_fh_to_dentry - generic helper for the fh_to_dentry export operation |
---|
994 | 1010 | * @sb: filesystem to do the file handle conversion on |
---|