kstrtox: converting strings to integers done (hopefully) right
Subsystems (126)
PATCH 1/52 kstrtox: converting strings to integers done (hopefully) right
1. simple_strto*() do not contain overflow checks and crufty, libc way to indicate failure.
2. strict_strto*() also do not have overflow checks but the name and comments pretend they do.
3. Both families have only "long long" and "long" variants, but users want strtou8()
4. Both "simple" and "strict" prefixes are wrong:
Simple doesn't exactly say what's so simple, strict should not exist because conversion should be strict by default.
The solution is to use "k" prefix and add convertors for more types. Enter
kstrtoull() kstrtoll() kstrtoul() kstrtol() kstrtouint() kstrtoint() kstrtou64() kstrtos64() kstrtou32() kstrtos32() kstrtou16() kstrtos16() kstrtou8() kstrtos8()
Include runtime testsuite (somewhat incomplete) as well.
strict_strto*() become deprecated, stubbed to kstrto*() and eventually will be removed altogether.
Use kstrto*() in code today!
Note: sizeof and __alignof__ trick is done to save function call
where types aren't distinguishable.
--- drivers/video/via/viafbdev.h | 3 - include/linux/kernel.h | 62 ++++- lib/Kconfig.debug | 3 + lib/Makefile | 2 + lib/kstrtox.c | 227 +++++++++++++ lib/test-kstrtox.c | 739 ++++++++++++++++++++++++++++++++++++++++++ lib/vsprintf.c | 141 -------- scripts/checkpatch.pl | 4 +- 8 files changed, 1031 insertions(+), 150 deletions(-) create mode 100644 lib/kstrtox.c create mode 100644 lib/test-kstrtox.c
drivers/video/via/viafbdev.h +0 -3
@@ -94,9 +94,6 @@ extern int viafb_LCD_ON;extern int viafb_DVI_ON;extern int viafb_hotplug; -extern int strict_strtoul (const char *cp,unsigned int base, -unsigned long *res); -u8 viafb_gpio_i2c_read_lvds (struct lvds_setting_information *plvds_setting_info,struct lvds_chip_information *plvds_chip_info,u8 index);
include/linux/kernel.h +58 -4
72 lines not on this page · raw message
lib/Kconfig.debug +3 -0
@@ -1236,3 +1236,6 @@ source "samples/Kconfig" source "lib/Kconfig.kgdb" source "lib/Kconfig.kmemcheck" + +config TEST_KSTRTOX + tristate "Test kstrto*() family of functions at runtime"
lib/Makefile +2 -0
@@ -22,6 +22,8 @@ lib-y += kobject.o kref.o klist.o obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \ bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \ string_helpers.o gcd.o lcm.o list_sort.o uuid.o flex_array.o +obj-y += kstrtox.o +obj-$(CONFIG_TEST_KSTRTOX) += test-kstrtox.o ifeq ($(CONFIG_DEBUG_KOBJECT),y) CFLAGS_kobject.o += -DDEBUG
lib/kstrtox.c new file +227 -0
227 lines not on this page · raw message
lib/test-kstrtox.c new file +739 -0
739 lines not on this page · raw message
lib/vsprintf.c +0 -141
147 lines not on this page · raw message
scripts/checkpatch.pl +2 -2
@@ -2809,9 +2809,9 @@ sub process { WARN("consider using a completion\n" . $herecurr); } -# recommend strict_strto* over simple_strto* +# recommend kstrto* over simple_strto* if ($line =~ /\bsimple_(strto.*?)\s*\(/) { - WARN("consider using strict_$1 in preference to simple_$1\n" . $herecurr); + WARN("consider using kstrto* in preference to simple_$1\n" . $herecurr); } # check for __initcall(), use device_initcall() explicitly please if ($line =~ /^.\s*__initcall\s*\(/) {
Signature · 1 line
1.7.3.4
PATCH 2/52 kstrtox: convert kernel/
--- kernel/gcov/fs.c | 5 +---- kernel/ksysfs.c | 5 +++-- kernel/params.c | 24 +++++++++++------------- kernel/power/main.c | 8 +++++--- 4 files changed, 20 insertions(+), 22 deletions(-)
kernel/gcov/fs.c +1 -4
@@ -72,13 +72,10 @@ static int gcov_persist = 1;static int __init gcov_persist_setup (char *str) { -unsigned long val; - -if (strict_strtoul (str,0 , &val)) { +if (kstrtoint (str,0 , &gcov_persist) <0 ) {pr_warning ("invalid gcov_persist parameter '%s'\n" , str);return 0 ; } - gcov_persist = val;pr_info ("setting gcov_persist to %d\n" , gcov_persist);return 1 ;
kernel/ksysfs.c +3 -2
@@ -112,8 +112,9 @@ static ssize_t kexec_crash_size_store(struct kobject *kobj,unsigned long cnt;int ret; -if (strict_strtoul (buf,0 , &cnt)) -return -EINVAL ; + ret =kstrtoul (buf,0 , &cnt); +if (ret <0 ) +return ret; ret =crash_shrink_memory (cnt);return ret <0 ? ret : count;
kernel/params.c +11 -13
@@ -218,16 +218,14 @@ int parse_args(const char *name, }/* Lazy bastard, eh? */ -#define STANDARD_PARAM_DEF (name, type, format, tmptype, strtolfn) \ +#define STANDARD_PARAM_DEF (name, type, format, strtolfn) \ int param_set_##name(const char *val, const struct kernel_param *kp) \ { \ - tmptype l; \ int ret; \ \ - ret = strtolfn(val, 0, &l); \ - if (ret == -EINVAL || ((type)l != l)) \ - return -EINVAL; \ - *((type *)kp->arg) = l; \ + ret = strtolfn(val, 0, (type *)kp->arg); \ + if (ret < 0) \ + return ret; \ return 0; \ } \ int param_get_##name(char *buffer, const struct kernel_param *kp) \
@@ -243,13 +241,13 @@ int parse_args(const char *name, EXPORT_SYMBOL(param_ops_##name) -STANDARD_PARAM_DEF(byte, unsigned char, "%c", unsigned long, strict_strtoul); -STANDARD_PARAM_DEF (short, short,"%hi" , long, strict_strtol); -STANDARD_PARAM_DEF(ushort, unsigned short, "%hu", unsigned long, strict_strtoul); -STANDARD_PARAM_DEF (int, int,"%i" , long, strict_strtol); -STANDARD_PARAM_DEF(uint, unsigned int, "%u", unsigned long, strict_strtoul); -STANDARD_PARAM_DEF (long, long,"%li" , long, strict_strtol); -STANDARD_PARAM_DEF(ulong, unsigned long, "%lu", unsigned long, strict_strtoul); +STANDARD_PARAM_DEF(byte, u8, "%c", kstrtou8); +STANDARD_PARAM_DEF(short, s16, "%hi", kstrtos16); +STANDARD_PARAM_DEF (ushort, u16,"%hu" , kstrtou16); +STANDARD_PARAM_DEF (int, int,"%i" , kstrtoint); +STANDARD_PARAM_DEF(uint, unsigned int, "%u", kstrtouint); +STANDARD_PARAM_DEF (long, long,"%li" , kstrtol); +STANDARD_PARAM_DEF(ulong, unsigned long, "%lu", kstrtoul);int param_set_charp (const char *val,const struct kernel_param *kp) {
kernel/power/main.c +5 -3
@@ -56,10 +56,12 @@ static ssize_t pm_async_show(struct kobject *kobj, struct kobj_attribute *attr,static ssize_t pm_async_store (struct kobject *kobj,struct kobj_attribute *attr,const char *buf,size_t n) { -unsigned long val; +unsigned int val; +int rv; -if (strict_strtoul (buf,10 , &val)) -return -EINVAL ; + rv =kstrtouint (buf,10 , &val); +if (rv <0 ) +return rv;if (val >1 )return -EINVAL ;
Signature · 1 line
1.7.3.4
PATCH 4/52 kstrtox: convert mm/
In reply to Alexey Dobriyan--- include/linux/slub_def.h | 2 +- mm/huge_memory.c | 35 ++++++++++++++++------------------- mm/hugetlb.c | 8 ++++---- mm/kmemleak.c | 4 ++-- mm/ksm.c | 28 ++++++++++------------------ mm/slub.c | 19 ++++++++++--------- mm/vmscan.c | 25 ++++++++++--------------- 7 files changed, 53 insertions(+), 68 deletions(-)
include/linux/slub_def.h +1 -1
@@ -94,7 +94,7 @@ struct kmem_cache {/* * Defragmentation by allocating from a remote node. */ -int remote_node_defrag_ratio; +unsigned int remote_node_defrag_ratio;#endif struct kmem_cache_node *node[MAX_NUMNODES ]; };
mm/huge_memory.c +16 -19
@@ -331,14 +331,11 @@ static ssize_t scan_sleep_millisecs_store(struct kobject *kobj,struct kobj_attribute *attr, const char *buf, size_t count) { - unsigned long msecs; int err; - err =strict_strtoul (buf,10 , &msecs); -if (err || msecs >UINT_MAX ) -return -EINVAL ; - - khugepaged_scan_sleep_millisecs = msecs; + err =kstrtouint (buf,10 , &khugepaged_scan_sleep_millisecs); +if (err <0 ) +return err;wake_up_interruptible (&khugepaged_wait);return count;
@@ -358,14 +355,11 @@ static ssize_t alloc_sleep_millisecs_store(struct kobject *kobj,struct kobj_attribute *attr, const char *buf, size_t count) { - unsigned long msecs; int err; - err =strict_strtoul (buf,10 , &msecs); -if (err || msecs >UINT_MAX ) -return -EINVAL ; - - khugepaged_alloc_sleep_millisecs = msecs; + err =kstrtouint (buf,10 , &khugepaged_alloc_sleep_millisecs); +if (err <0 ) +return err;wake_up_interruptible (&khugepaged_wait);return count;
@@ -384,13 +378,14 @@ static ssize_t pages_to_scan_store(struct kobject *kobj,struct kobj_attribute *attr, const char *buf, size_t count) { + unsigned int pages;int err; -unsigned long pages; - err =strict_strtoul (buf,10 , &pages); -if (err || !pages || pages >UINT_MAX ) + err =kstrtouint (buf,10 , &pages); +if (err <0 ) +return err; +if (pages ==0 )return -EINVAL ; - khugepaged_pages_to_scan = pages;return count;
@@ -452,11 +447,13 @@ static ssize_t khugepaged_max_ptes_none_store(struct kobject *kobj,struct kobj_attribute *attr, const char *buf, size_t count) { + unsigned int max_ptes_none;int err; -unsigned long max_ptes_none; - err =strict_strtoul (buf,10 , &max_ptes_none); -if (err || max_ptes_none >HPAGE_PMD_NR -1 ) + err =kstrtouint (buf,10 , &max_ptes_none); +if (err <0 ) +return err; +if (max_ptes_none >HPAGE_PMD_NR -1 )return -EINVAL ; khugepaged_max_ptes_none = max_ptes_none;
mm/hugetlb.c +4 -4
@@ -1374,8 +1374,8 @@ static ssize_t nr_hugepages_store_common(bool obey_mempolicy,struct hstate *h;NODEMASK_ALLOC (nodemask_t, nodes_allowed,GFP_KERNEL | __GFP_NORETRY); - err =strict_strtoul (buf,10 , &count); -if (err) + err =kstrtoul (buf,10 , &count); +if (err <0 ) goto out; h =kobj_to_hstate (kobj, &nid);
@@ -1465,8 +1465,8 @@ static ssize_t nr_overcommit_hugepages_store(struct kobject *kobj,if (h->order >=MAX_ORDER )return -EINVAL ; - err =strict_strtoul (buf,10 , &input); -if (err) + err =kstrtoul (buf,10 , &input); +if (err <0 )return err;spin_lock (&hugetlb_lock);
mm/kmemleak.c +2 -2
@@ -1560,9 +1560,9 @@ static ssize_t kmemleak_write(struct file *file, const char __user *user_buf,else if (strncmp (buf,"scan=off" ,8 ) ==0 )stop_scan_thread ();else if (strncmp (buf,"scan=" ,5 ) ==0 ) { -unsigned long secs; +unsigned int secs; - ret =strict_strtoul (buf +5 ,0 , &secs); + ret =kstrtouint (buf +5 ,0 , &secs);if (ret <0 ) goto out;stop_scan_thread ();
mm/ksm.c +10 -18
@@ -1842,15 +1842,11 @@ static ssize_t sleep_millisecs_store(struct kobject *kobj,struct kobj_attribute *attr, const char *buf, size_t count) { - unsigned long msecs; int err; - err =strict_strtoul (buf,10 , &msecs); -if (err || msecs >UINT_MAX ) -return -EINVAL ; - - ksm_thread_sleep_millisecs = msecs; - + err =kstrtouint (buf,10 , &ksm_thread_sleep_millisecs); +if (err <0 ) +return err;return count; }KSM_ATTR (sleep_millisecs);
@@ -1866,14 +1862,10 @@ static ssize_t pages_to_scan_store(struct kobject *kobj, const char *buf, size_t count) { int err; -unsigned long nr_pages; - - err =strict_strtoul (buf,10 , &nr_pages); -if (err || nr_pages >UINT_MAX ) -return -EINVAL ; - - ksm_thread_pages_to_scan = nr_pages; + err =kstrtouint (buf,10 , &ksm_thread_pages_to_scan); +if (err <0 ) +return err;return count; }KSM_ATTR (pages_to_scan);
@@ -1888,11 +1880,11 @@ static ssize_t run_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { int err; -unsigned long flags; +unsigned int flags; - err =strict_strtoul (buf,10 , &flags); -if (err || flags >UINT_MAX ) -return -EINVAL ; + err =kstrtouint (buf,10 , &flags); +if (err <0 ) +return err;if (flags >KSM_RUN_UNMERGE )return -EINVAL ;
mm/slub.c +10 -9
@@ -3904,11 +3904,11 @@ SLAB_ATTR_RO(objs_per_slab);static ssize_t order_store (struct kmem_cache *s,const char *buf,size_t length) { -unsigned long order; +int order;int err; - err =strict_strtoul (buf,10 , &order); -if (err) + err =kstrtoint (buf,10 , &order); +if (err <0 )return err;if (order > slub_max_order || order < slub_min_order)
@@ -3935,7 +3935,7 @@ static ssize_t min_partial_store(struct kmem_cache *s, const char *buf,unsigned long min;int err; - err =strict_strtoul (buf,10 , &min); + err =kstrtoul (buf,10 , &min);if (err)return err;
@@ -4192,21 +4192,22 @@ SLAB_ATTR(shrink);#ifdef CONFIG_NUMA static ssize_t remote_node_defrag_ratio_show (struct kmem_cache *s,char *buf) { -return sprintf (buf,"%d\n" , s->remote_node_defrag_ratio /10 ); +return sprintf (buf,"%u\n" , s->remote_node_defrag_ratio /10 ); }static ssize_t remote_node_defrag_ratio_store (struct kmem_cache *s,const char *buf,size_t length) { -unsigned long ratio; +unsigned int ratio;int err; - err =strict_strtoul (buf,10 , &ratio); + err =kstrtouint (buf,10 , &ratio);if (err)return err; +if (ratio >100 ) +return -EINVAL ; -if (ratio <=100 ) - s->remote_node_defrag_ratio = ratio *10 ; + s->remote_node_defrag_ratio = ratio *10 ;return length; }
mm/vmscan.c +10 -15
@@ -3284,37 +3284,32 @@ int scan_unevictable_handler(struct ctl_table *table, int write,* per node 'scan_unevictable_pages' attribute. On demand re-scan of * a specified node's per zone unevictable lists for evictable pages. */ - -static ssize_t read_scan_unevictable_node (struct sys_device *dev, -struct sysdev_attribute *attr, -char *buf) -{ -return sprintf (buf,"0\n" );/* always zero; should fit... */ -} -static ssize_t write_scan_unevictable_node (struct sys_device *dev,struct sysdev_attribute *attr,const char *buf,size_t count) {struct zone *node_zones =NODE_DATA (dev->id)->node_zones;struct zone *zone; -unsigned long res; -unsigned long req =strict_strtoul (buf,10 , &res); +unsigned long val; +int rv; -if (!req) -return 1 ;/* zero is no-op */ + rv =kstrtoul (buf,10 , &val); +if (rv <0 ) +return rv; +if (val ==0 ) +return count;for (zone = node_zones; zone - node_zones <MAX_NR_ZONES ; ++zone) {if (!populated_zone (zone))continue ;scan_zone_unevictable_pages (zone); } -return 1 ; +return count; } -static SYSDEV_ATTR(scan_unevictable_pages, S_IRUGO | S_IWUSR, - read_scan_unevictable_node, +static SYSDEV_ATTR(scan_unevictable_pages, S_IWUSR, + NULL, write_scan_unevictable_node);int scan_unevictable_register_node (struct node *node)
Signature · 1 line
1.7.3.4
PATCH 5/52 kstrtox: convert block/
In reply to Alexey Dobriyan--- block/blk-cgroup.c | 47 ++++++++++++++++++++++++----------------------- 1 files changed, 24 insertions(+), 23 deletions(-)
block/blk-cgroup.c +24 -23
@@ -656,10 +656,9 @@ static int blkio_policy_parse_and_set(char *buf, {char *s[4 ], *p, *major_s =NULL , *minor_s =NULL ;int ret; -unsigned long major, minor, temp; +unsigned int major, minor;int i =0 ;dev_t dev; -u64 bps, iops;memset (s,0 ,sizeof (s));
@@ -687,15 +686,15 @@ static int blkio_policy_parse_and_set(char *buf,if (!minor_s)return -EINVAL ; - ret =strict_strtoul (major_s,10 , &major); -if (ret) -return -EINVAL ; - - ret =strict_strtoul (minor_s,10 , &minor); + ret =kstrtouint (major_s,10 , &major); +if (ret <0 ) +return ret; + ret =kstrtouint (minor_s,10 , &minor);if (ret) -return -EINVAL ; - +return ret; dev =MKDEV (major, minor); +if (MAJOR (dev) != major ||MINOR (dev) != minor) +return -EINVAL ; ret =blkio_check_dev_num (dev);if (ret)
@@ -707,40 +706,42 @@ static int blkio_policy_parse_and_set(char *buf,return -EINVAL ;switch (plid) { +unsigned int weigth; +case BLKIO_POLICY_PROP : - ret =strict_strtoul (s[1 ],10 , &temp); -if (ret || (temp <BLKIO_WEIGHT_MIN && temp >0 ) || - temp >BLKIO_WEIGHT_MAX ) + ret =kstrtouint (s[1 ],10 , &weigth); +if (ret <0 ) +return ret; +if (weigth <BLKIO_WEIGHT_MIN || weigth >BLKIO_WEIGHT_MAX )return -EINVAL ; newpn->plid = plid; newpn->fileid = fileid; - newpn->val.weight = temp; + newpn->val.weight = weigth;break ;case BLKIO_POLICY_THROTL :switch (fileid) { +unsigned int iops; +case BLKIO_THROTL_read_bps_device:case BLKIO_THROTL_write_bps_device: - ret =strict_strtoull (s[1 ],10 , &bps); -if (ret) -return -EINVAL ; - newpn->plid = plid; newpn->fileid = fileid; - newpn->val.bps = bps; + ret =kstrtou64 (s[1 ],10 , &newpn->val.bps); +if (ret <0 ) +return ret;break ;case BLKIO_THROTL_read_iops_device:case BLKIO_THROTL_write_iops_device: - ret =strict_strtoull (s[1 ],10 , &iops); -if (ret) -return -EINVAL ; - + ret =kstrtouint (s[1 ],10 , &iops); +if (ret <0 ) +return ret;if (iops >THROTL_IOPS_MAX )return -EINVAL ; newpn->plid = plid; newpn->fileid = fileid; - newpn->val.iops = (unsigned int )iops; + newpn->val.iops = iops;break ; }break ;
Signature · 1 line
1.7.3.4
PATCH 7/52 kstrtox: convert fs/fuse/
In reply to Alexey Dobriyan--- fs/fuse/control.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
fs/fuse/control.c +2 -2
@@ -74,7 +74,7 @@ static ssize_t fuse_conn_limit_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos, unsigned *val, unsigned global_limit) { - unsigned long t; + unsigned int t;char tmp[32 ];unsigned limit = (1 <<16 ) -1 ;int err;
@@ -87,7 +87,7 @@ static ssize_t fuse_conn_limit_write(struct file *file, const char __user *buf, tmp[count] ='\0' ; - err =strict_strtoul (tmp,0 , &t); + err =kstrtouint (tmp,0 , &t);if (err)return err;
Signature · 1 line
1.7.3.4
PATCH 8/52 kstrtox: convert fs/nfs/
In reply to Alexey Dobriyan--- fs/nfs/callback.c | 8 +++-- fs/nfs/idmap.c | 12 +++------ fs/nfs/internal.h | 8 +++--- fs/nfs/super.c | 73 ++++++++++++++++++++++++----------------------------- 4 files changed, 46 insertions(+), 55 deletions(-)
fs/nfs/callback.c +5 -3
@@ -44,13 +44,15 @@ unsigned short nfs_callback_tcpport6;static int param_set_portnr (const char *val,const struct kernel_param *kp) { -unsigned long num; +unsigned int num;int ret;if (!val)return -EINVAL ; - ret =strict_strtoul (val,0 , &num); -if (ret == -EINVAL || num >NFS_CALLBACK_MAXPORTNR ) + ret =kstrtouint (val,0 , &num); +if (ret <0 ) +return ret; +if (num >NFS_CALLBACK_MAXPORTNR )return -EINVAL ; *((unsigned int *)kp->arg) = num;return 0 ;
fs/nfs/idmap.c +4 -8
@@ -205,17 +205,13 @@ static int nfs_idmap_lookup_id(const char *name, size_t namelen, const char *type, __u32 *id) { char id_str[NFS_UINT_MAXLEN]; -long id_long;ssize_t data_size; -int ret =0 ; +int ret; data_size =nfs_idmap_request_key (name, namelen, type, id_str,NFS_UINT_MAXLEN ); -if (data_size <=0 ) { - ret = -EINVAL ; - }else { - ret =strict_strtol (id_str,10 , &id_long); - *id = (__u32 )id_long; - } + ret = -EINVAL ; +if (data_size >0 ) + ret =kstrtou32 (id_str,10 , id);return ret; }
fs/nfs/internal.h +4 -4
@@ -73,11 +73,11 @@ struct nfs_clone_mount {*/ struct nfs_parsed_mount_data {int flags; -int rsize, wsize; -int timeo, retrans; -int acregmin, acregmax, +unsigned int rsize, wsize; +unsigned int timeo, retrans; +unsigned int acregmin, acregmax, acdirmin, acdirmax; -int namlen; +unsigned int namlen;unsigned int options;unsigned int bsize;unsigned int auth_flavor_len;
fs/nfs/super.c +33 -40
207 lines not on this page · raw message
Signature · 1 line
1.7.3.4
PATCH 9/52 kstrtox: convert fs/proc/
In reply to Alexey Dobriyan--- fs/proc/base.c | 21 ++++++++++----------- fs/proc/task_mmu.c | 8 +++++--- include/linux/sched.h | 2 +- kernel/sched_autogroup.c | 12 ++++++------ 4 files changed, 22 insertions(+), 21 deletions(-)
fs/proc/base.c +10 -11
@@ -1005,7 +1005,7 @@ static ssize_t oom_adjust_write(struct file *file, const char __user *buf, {struct task_struct *task;char buffer[PROC_NUMBUF ]; -long oom_adjust; +int oom_adjust;unsigned long flags;int err;
@@ -1017,8 +1017,8 @@ static ssize_t oom_adjust_write(struct file *file, const char __user *buf, goto out; } - err =strict_strtol (strstrip (buffer),0 , &oom_adjust); -if (err) + err =kstrtoint (strstrip (buffer),0 , &oom_adjust); +if (err <0 ) goto out;if ((oom_adjust <OOM_ADJUST_MIN || oom_adjust >OOM_ADJUST_MAX ) && oom_adjust !=OOM_DISABLE ) {
@@ -1114,7 +1114,7 @@ static ssize_t oom_score_adj_write(struct file *file, const char __user *buf,struct task_struct *task;char buffer[PROC_NUMBUF ];unsigned long flags; -long oom_score_adj; +int oom_score_adj;int err;memset (buffer,0 ,sizeof (buffer));
@@ -1125,8 +1125,8 @@ static ssize_t oom_score_adj_write(struct file *file, const char __user *buf, goto out; } - err =strict_strtol (strstrip (buffer),0 , &oom_score_adj); -if (err) + err =kstrtoint (strstrip (buffer),0 , &oom_score_adj); +if (err <0 ) goto out;if (oom_score_adj <OOM_SCORE_ADJ_MIN || oom_score_adj >OOM_SCORE_ADJ_MAX ) {
@@ -1414,7 +1414,7 @@ sched_autogroup_write(struct file *file, const char __user *buf,struct inode *inode = file->f_path.dentry->d_inode;struct task_struct *p;char buffer[PROC_NUMBUF ]; -long nice; +int nice;int err;memset (buffer,0 ,sizeof (buffer));
@@ -1423,16 +1423,15 @@ sched_autogroup_write(struct file *file, const char __user *buf,if (copy_from_user (buffer, buf, count))return -EFAULT ; - err =strict_strtol (strstrip (buffer),0 , &nice); + err =kstrtoint (strstrip (buffer),0 , &nice);if (err) -return -EINVAL ; +return err; p =get_proc_task (inode);if (!p)return -ESRCH ; - err = nice; - err =proc_sched_autogroup_set_nice (p, &err); + err =proc_sched_autogroup_set_nice (p, nice);if (err) count = err;
fs/proc/task_mmu.c +5 -3
@@ -497,15 +497,17 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,char buffer[PROC_NUMBUF ];struct mm_struct *mm;struct vm_area_struct *vma; -long type; +int type; +int rv;memset (buffer,0 ,sizeof (buffer));if (count >sizeof (buffer) -1 ) count =sizeof (buffer) -1 ;if (copy_from_user (buffer, buf, count))return -EFAULT ; -if (strict_strtol (strstrip (buffer),10 , &type)) -return -EINVAL ; + rv =kstrtoint (strstrip (buffer),10 , &type); +if (rv <0 ) +return rv;if (type <CLEAR_REFS_ALL || type >CLEAR_REFS_MAPPED )return -EINVAL ; task =get_proc_task (file->f_path.dentry->d_inode);
include/linux/sched.h +1 -1
@@ -1956,7 +1956,7 @@ extern void sched_autogroup_fork(struct signal_struct *sig);extern void sched_autogroup_exit (struct signal_struct *sig);#ifdef CONFIG_PROC_FS extern void proc_sched_autogroup_show_task (struct task_struct *p,struct seq_file *m); -extern int proc_sched_autogroup_set_nice (struct task_struct *p,int *nice); +extern int proc_sched_autogroup_set_nice (struct task_struct *p,int nice);#endif #else static inline void sched_autogroup_create_attach (struct task_struct *p) { }
kernel/sched_autogroup.c +6 -6
@@ -209,20 +209,20 @@ __setup("noautogroup", setup_autogroup);#ifdef CONFIG_PROC_FS -int proc_sched_autogroup_set_nice (struct task_struct *p,int *nice) +int proc_sched_autogroup_set_nice (struct task_struct *p,int nice) {static unsigned long next =INITIAL_JIFFIES ;struct autogroup *ag;int err; -if (*nice <-20 || *nice >19 ) +if (nice <-20 || nice >19 )return -EINVAL ; - err =security_task_setnice (current, *nice); + err =security_task_setnice (current, nice);if (err)return err; -if (*nice <0 && !can_nice (current, *nice)) +if (nice <0 && !can_nice (current, nice))return -EPERM ;/* this is a heavy operation taking global locks.. */
@@ -233,9 +233,9 @@ int proc_sched_autogroup_set_nice(struct task_struct *p, int *nice) ag =autogroup_task_get (p);down_write (&ag->lock); - err =sched_group_set_shares (ag->tg, prio_to_weight[*nice +20 ]); + err =sched_group_set_shares (ag->tg, prio_to_weight[nice +20 ]);if (!err) - ag->nice = *nice; + ag->nice = nice;up_write (&ag->lock);autogroup_kref_put (ag);
Signature · 1 line
1.7.3.4
PATCH 11/52 kstrtox: convert drivers/ata/
In reply to Alexey Dobriyan--- drivers/ata/libata-scsi.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/ata/libata-scsi.c +1 -1
@@ -204,7 +204,7 @@ static ssize_t ata_scsi_park_store(struct device *device,unsigned long flags;int rc; - rc =strict_strtol (buf,10 , &input); + rc =kstrtol (buf,10 , &input);if (rc || input <-2 )return -EINVAL ;if (input >ATA_TMOUT_MAX_PARK ) {
Signature · 1 line
1.7.3.4
PATCH 12/52 kstrtox: convert drivers/base/
In reply to Alexey Dobriyan--- drivers/base/core.c | 6 +++--- drivers/base/memory.c | 10 ++++++---- drivers/base/power/sysfs.c | 9 +++++---- include/linux/device.h | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-)
drivers/base/core.c +3 -3
@@ -28,13 +28,13 @@#ifdef CONFIG_SYSFS_DEPRECATED #ifdef CONFIG_SYSFS_DEPRECATED_V2 -long sysfs_deprecated =1 ; +int sysfs_deprecated =1 ;#else -long sysfs_deprecated =0 ; +int sysfs_deprecated =0 ;#endif static __init int sysfs_deprecated_setup (char *arg) { -return strict_strtol (arg,10 , &sysfs_deprecated); +return kstrtoint (arg,10 , &sysfs_deprecated); }early_param ("sysfs.deprecated" , sysfs_deprecated_setup);#endif
drivers/base/memory.c +6 -4
@@ -380,8 +380,9 @@ store_soft_offline_page(struct class *class,u64 pfn;if (!capable (CAP_SYS_ADMIN ))return -EPERM ; -if (strict_strtoull (buf,0 , &pfn) <0 ) -return -EINVAL ; + ret =kstrtou64 (buf,0 , &pfn); +if (ret <0 ) +return ret; pfn >>=PAGE_SHIFT ;if (!pfn_valid (pfn))return -ENXIO ;
@@ -399,8 +400,9 @@ store_hard_offline_page(struct class *class,u64 pfn;if (!capable (CAP_SYS_ADMIN ))return -EPERM ; -if (strict_strtoull (buf,0 , &pfn) <0 ) -return -EINVAL ; + ret =kstrtou64 (buf,0 , &pfn); +if (ret <0 ) +return ret; pfn >>=PAGE_SHIFT ; ret =__memory_failure (pfn,0 ,0 );return ret ? ret : count;
drivers/base/power/sysfs.c +5 -4
@@ -197,14 +197,15 @@ static ssize_t autosuspend_delay_ms_show(struct device *dev,static ssize_t autosuspend_delay_ms_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t n) { -long delay; +int delay; +int rv;if (!dev->power.use_autosuspend)return -EIO ; -if (strict_strtol (buf,10 , &delay) !=0 || delay != (int ) delay) -return -EINVAL ; - + rv =kstrtoint (buf,10 , &delay); +if (rv <0 ) +return rv;pm_runtime_set_autosuspend_delay (dev, delay);return n; }
include/linux/device.h +1 -1
@@ -753,7 +753,7 @@ do { \ MODULE_ALIAS("char-major-" __stringify(major) "-*")#ifdef CONFIG_SYSFS_DEPRECATED -extern long sysfs_deprecated; +extern int sysfs_deprecated;#else #define sysfs_deprecated 0#endif
Signature · 1 line
1.7.3.4
PATCH 14/52 kstrtox: convert drivers/bluetooth/
In reply to Alexey Dobriyan--- drivers/bluetooth/btmrvl_debugfs.c | 50 +++++++++++++++++------------------ 1 files changed, 24 insertions(+), 26 deletions(-)
drivers/bluetooth/btmrvl_debugfs.c +24 -26
@@ -56,16 +56,16 @@ static ssize_t btmrvl_hscfgcmd_write(struct file *file, {struct btmrvl_private *priv = file->private_data;char buf[16 ]; -long result, ret; +int ret;memset (buf,0 ,sizeof (buf));if (copy_from_user (&buf, ubuf,min_t (size_t,sizeof (buf) -1 , count)))return -EFAULT ; - ret =strict_strtol (buf,10 , &result); - - priv->btmrvl_dev.hscfgcmd = result; + ret =kstrtou8 (buf,10 , &priv->btmrvl_dev.hscfgcmd); +if (ret <0 ) +return ret;if (priv->btmrvl_dev.hscfgcmd) {btmrvl_prepare_command (priv);
@@ -100,17 +100,16 @@ static ssize_t btmrvl_psmode_write(struct file *file, const char __user *ubuf, {struct btmrvl_private *priv = file->private_data;char buf[16 ]; -long result, ret; +int ret;memset (buf,0 ,sizeof (buf));if (copy_from_user (&buf, ubuf,min_t (size_t,sizeof (buf) -1 , count)))return -EFAULT ; - ret =strict_strtol (buf,10 , &result); - - priv->btmrvl_dev.psmode = result; - + ret =kstrtou8 (buf,10 , &priv->btmrvl_dev.psmode); +if (ret <0 ) +return ret;return count; }
@@ -139,16 +138,16 @@ static ssize_t btmrvl_pscmd_write(struct file *file, const char __user *ubuf, {struct btmrvl_private *priv = file->private_data;char buf[16 ]; -long result, ret; +int ret;memset (buf,0 ,sizeof (buf));if (copy_from_user (&buf, ubuf,min_t (size_t,sizeof (buf) -1 , count)))return -EFAULT ; - ret =strict_strtol (buf,10 , &result); - - priv->btmrvl_dev.pscmd = result; + ret =kstrtou8 (buf,10 , &priv->btmrvl_dev.pscmd); +if (ret <0 ) +return ret;if (priv->btmrvl_dev.pscmd) {btmrvl_prepare_command (priv);
@@ -183,17 +182,16 @@ static ssize_t btmrvl_gpiogap_write(struct file *file, const char __user *ubuf, {struct btmrvl_private *priv = file->private_data;char buf[16 ]; -long result, ret; +int ret;memset (buf,0 ,sizeof (buf));if (copy_from_user (&buf, ubuf,min_t (size_t,sizeof (buf) -1 , count)))return -EFAULT ; - ret =strict_strtol (buf,16 , &result); - - priv->btmrvl_dev.gpio_gap = result; - + ret =kstrtou16 (buf,16 , &priv->btmrvl_dev.gpio_gap); +if (ret <0 ) +return ret;return count; }
@@ -222,16 +220,17 @@ static ssize_t btmrvl_hscmd_write(struct file *file, const char __user *ubuf, {struct btmrvl_private *priv = file->private_data;char buf[16 ]; -long result, ret; +int ret;memset (buf,0 ,sizeof (buf));if (copy_from_user (&buf, ubuf,min_t (size_t,sizeof (buf) -1 , count)))return -EFAULT ; - ret =strict_strtol (buf,10 , &result); + ret =kstrtou8 (buf,10 , &priv->btmrvl_dev.hscmd); +if (ret <0 ) +return ret; - priv->btmrvl_dev.hscmd = result;if (priv->btmrvl_dev.hscmd) {btmrvl_prepare_command (priv);wake_up_interruptible (&priv->main_thread.wait_q);
@@ -264,17 +263,16 @@ static ssize_t btmrvl_hsmode_write(struct file *file, const char __user *ubuf, {struct btmrvl_private *priv = file->private_data;char buf[16 ]; -long result, ret; +int ret;memset (buf,0 ,sizeof (buf));if (copy_from_user (&buf, ubuf,min_t (size_t,sizeof (buf) -1 , count)))return -EFAULT ; - ret =strict_strtol (buf,10 , &result); - - priv->btmrvl_dev.hsmode = result; - + ret =kstrtou8 (buf,10 , &priv->btmrvl_dev.hsmode); +if (ret <0 ) +return ret;return count; }
Signature · 1 line
1.7.3.4
PATCH 15/52 kstrtox: convert drivers/clocksource/
In reply to Alexey Dobriyan--- drivers/clocksource/acpi_pm.c | 14 ++++++-------- 1 files changed, 6 insertions(+), 8 deletions(-)
drivers/clocksource/acpi_pm.c +6 -8
@@ -233,15 +233,13 @@ fs_initcall(init_acpi_pm_clocksource);*/ static int __init parse_pmtmr (char *arg) { -unsigned long base; +u32 base; +int rv; -if (strict_strtoul (arg,16 , &base)) -return -EINVAL ; -#ifdef CONFIG_X86_64 -if (base >UINT_MAX ) -return -ERANGE ; -#endif -printk (KERN_INFO "PMTMR IOPort override: 0x%04x -> 0x%04lx\n" , + rv =kstrtou32 (arg,16 , &base); +if (rv <0 ) +return rv; +printk (KERN_INFO "PMTMR IOPort override: 0x%04x -> 0x%04x\n" , pmtmr_ioport, base); pmtmr_ioport = base;
Signature · 1 line
1.7.3.4
PATCH 18/52 kstrtox: convert drivers/gpu/drm/nouveau/
In reply to Alexey Dobriyan--- drivers/gpu/drm/nouveau/nouveau_pm.c | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/nouveau/nouveau_pm.c +10 -6
@@ -319,10 +319,12 @@ nouveau_hwmon_set_max_temp(struct device *d, struct device_attribute *a,struct drm_nouveau_private *dev_priv = dev->dev_private;struct nouveau_pm_engine *pm = &dev_priv->engine.pm;struct nouveau_pm_threshold_temp *temp = &pm->threshold_temp; -long value; +int value; +int rv; -if (strict_strtol (buf,10 , &value) == -EINVAL ) -return count; + rv =kstrtoint (buf,10 , &value); +if (rv <0 ) +return rv; temp->down_clock = value/1000 ;
@@ -354,10 +356,12 @@ nouveau_hwmon_set_critical_temp(struct device *d, struct device_attribute *a,struct drm_nouveau_private *dev_priv = dev->dev_private;struct nouveau_pm_engine *pm = &dev_priv->engine.pm;struct nouveau_pm_threshold_temp *temp = &pm->threshold_temp; -long value; +int value; +int rv; -if (strict_strtol (buf,10 , &value) == -EINVAL ) -return count; + rv =kstrtoint (buf,10 , &value); +if (rv <0 ) +return rv; temp->critical = value/1000 ;
Signature · 1 line
1.7.3.4
PATCH 19/52 kstrtox: convert drivers/hid/
In reply to Alexey Dobriyan--- drivers/hid/hid-magicmouse.c | 14 +++++++-- drivers/hid/hid-ntrig.c | 54 ++++++++++++++++++++---------------- drivers/hid/hid-roccat-kone.c | 8 +++--- drivers/hid/hid-roccat-koneplus.c | 4 +- 4 files changed, 47 insertions(+), 33 deletions(-)
drivers/hid/hid-magicmouse.c +11 -3
@@ -34,9 +34,17 @@ module_param(emulate_scroll_wheel, bool, 0644);MODULE_PARM_DESC (emulate_scroll_wheel,"Emulate a scroll wheel" );static unsigned int scroll_speed =32 ; -static int param_set_scroll_speed (const char *val,struct kernel_param *kp) { -unsigned long speed; -if (!val ||strict_strtoul (val,0 , &speed) || speed >63 ) +static int param_set_scroll_speed (const char *val,struct kernel_param *kp) +{ +unsigned int speed; +int rv; + +if (!val) +return -EINVAL ; + rv =kstrtouint (val,0 , &speed); +if (rv <0 ) +return rv; +if (speed >63 )return -EINVAL ; scroll_speed = speed;return 0 ;
drivers/hid/hid-ntrig.c +30 -24
96 lines not on this page · raw message
drivers/hid/hid-roccat-kone.c +4 -4
@@ -464,13 +464,13 @@ static ssize_t kone_sysfs_set_tcu(struct device *dev,struct kone_device *kone;struct usb_device *usb_dev;int retval; -unsigned long state; +int state; dev = dev->parent->parent; kone =hid_get_drvdata (dev_get_drvdata (dev)); usb_dev =interface_to_usbdev (to_usb_interface (dev)); - retval =strict_strtoul (buf,10 , &state); + retval =kstrtoint (buf,10 , &state);if (retval)return retval;
@@ -551,13 +551,13 @@ static ssize_t kone_sysfs_set_startup_profile(struct device *dev,struct kone_device *kone;struct usb_device *usb_dev;int retval; -unsigned long new_startup_profile; +int new_startup_profile; dev = dev->parent->parent; kone =hid_get_drvdata (dev_get_drvdata (dev)); usb_dev =interface_to_usbdev (to_usb_interface (dev)); - retval =strict_strtoul (buf,10 , &new_startup_profile); + retval =kstrtoint (buf,10 , &new_startup_profile);if (retval)return retval;
drivers/hid/hid-roccat-koneplus.c +2 -2
@@ -463,14 +463,14 @@ static ssize_t koneplus_sysfs_set_startup_profile(struct device *dev, {struct koneplus_device *koneplus;struct usb_device *usb_dev; -unsigned long profile; +u8 profile;int retval; dev = dev->parent->parent; koneplus =hid_get_drvdata (dev_get_drvdata (dev)); usb_dev =interface_to_usbdev (to_usb_interface (dev)); - retval =strict_strtoul (buf,10 , &profile); + retval =kstrtou8 (buf,10 , &profile);if (retval)return retval;
Signature · 1 line
1.7.3.4
PATCH 21/52 kstrtox: convert drivers/ide/
In reply to Alexey Dobriyan--- drivers/ide/ide-park.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
drivers/ide/ide-park.c +5 -3
@@ -113,11 +113,13 @@ ssize_t ide_park_store(struct device *dev, struct device_attribute *attr, {#define MAX_PARK_TIMEOUT 30000ide_drive_t *drive =to_ide_device (dev); -long int input; +int input;int rc; - rc =strict_strtol (buf,10 , &input); -if (rc || input <-2 ) + rc =kstrtoint (buf,10 , &input); +if (rc <0 ) +return rc; +if (input <-2 )return -EINVAL ;if (input >MAX_PARK_TIMEOUT ) { input =MAX_PARK_TIMEOUT ;
Signature · 1 line
1.7.3.4
PATCH 20/52 kstrtox: convert drivers/hwmon/
In reply to Alexey Dobriyan--- drivers/hwmon/adcxx.c | 8 ++- drivers/hwmon/adm1031.c | 6 +- drivers/hwmon/adm9240.c | 2 +- drivers/hwmon/adt7411.c | 8 ++- drivers/hwmon/adt7462.c | 87 +++++++++++++++++++++++++---------- drivers/hwmon/adt7470.c | 80 +++++++++++++++++++++++---------- drivers/hwmon/adt7475.c | 83 +++++++++++++++++++--------------- drivers/hwmon/amc6821.c | 45 ++++++++++++------- drivers/hwmon/applesmc.c | 27 +++++++----- drivers/hwmon/asc7621.c | 83 ++++++++++++++++++++++------------ drivers/hwmon/ds620.c | 2 +- drivers/hwmon/emc1403.c | 17 ++++--- drivers/hwmon/emc2103.c | 32 +++++++------ drivers/hwmon/f71882fg.c | 62 +++++++++++++------------- drivers/hwmon/g760a.c | 6 ++- drivers/hwmon/gpio-fan.c | 24 +++++++--- drivers/hwmon/ibmaem.c | 4 +- drivers/hwmon/it87.c | 109 ++++++++++++++++++++++++++++++--------------- drivers/hwmon/jc42.c | 34 +++++++------- drivers/hwmon/lis3lv02d.c | 8 ++- drivers/hwmon/lm73.c | 3 +- drivers/hwmon/lm75.c | 4 +- drivers/hwmon/lm90.c | 16 +++--- drivers/hwmon/lm95241.c | 8 ++-- drivers/hwmon/pc87427.c | 20 ++++++--- drivers/hwmon/tmp102.c | 5 +- drivers/hwmon/tmp401.c | 37 +++++++++------ drivers/hwmon/w83791d.c | 28 +++++++---- drivers/hwmon/w83792d.c | 2 +- drivers/hwmon/w83793.c | 2 +- drivers/hwmon/w83795.c | 109 +++++++++++++++++++++++++++++--------------- 31 files changed, 603 insertions(+), 358 deletions(-)
drivers/hwmon/adcxx.c +5 -3
@@ -123,10 +123,12 @@ static ssize_t adcxx_set_max(struct device *dev, {struct spi_device *spi =to_spi_device (dev);struct adcxx *adc =dev_get_drvdata (&spi->dev); -unsigned long value; +u32 value; +int rv; -if (strict_strtoul (buf,10 , &value)) -return -EINVAL ; + rv =kstrtou32 (buf,10 , &value); +if (rv <0 ) +return rv;if (mutex_lock_interruptible (&adc->lock))return -ERESTARTSYS ;
drivers/hwmon/adm1031.c +3 -3
@@ -763,12 +763,12 @@ static ssize_t set_update_interval(struct device *dev, {struct i2c_client *client =to_i2c_client (dev);struct adm1031_data *data =i2c_get_clientdata (client); -unsigned long val; +unsigned int val;int i, err;u8 reg; - err =strict_strtoul (buf,10 , &val); -if (err) + err =kstrtouint (buf,10 , &val); +if (err <0 )return err;/*
drivers/hwmon/adm9240.c +1 -1
@@ -503,7 +503,7 @@ static ssize_t chassis_clear(struct device *dev,struct adm9240_data *data =i2c_get_clientdata (client);unsigned long val; -if (strict_strtoul (buf,10 , &val) || val !=0 ) +if (kstrtoul (buf,10 , &val) || val !=0 )return -EINVAL ;mutex_lock (&data->update_lock);
drivers/hwmon/adt7411.c +5 -3
@@ -195,10 +195,12 @@ static ssize_t adt7411_set_bit(struct device *dev,struct i2c_client *client =to_i2c_client (dev);struct adt7411_data *data =i2c_get_clientdata (client);int ret; -unsigned long flag; +unsigned int flag; - ret =strict_strtoul (buf,0 , &flag); -if (ret || flag >1 ) + ret =kstrtouint (buf,0 , &flag); +if (ret <0 ) +return ret; +if (flag >1 )return -EINVAL ; ret =adt7411_modify_bit (client, s_attr2->index, s_attr2->nr, flag);
drivers/hwmon/adt7462.c +62 -25
185 lines not on this page · raw message
drivers/hwmon/adt7470.c +55 -25
172 lines not on this page · raw message
drivers/hwmon/adt7475.c +47 -36
165 lines not on this page · raw message
drivers/hwmon/amc6821.c +29 -16
88 lines not on this page · raw message
drivers/hwmon/applesmc.c +16 -11
@@ -777,12 +777,15 @@ static ssize_t applesmc_store_fan_speed(struct device *dev,struct device_attribute *attr, const char *sysfsbuf, size_t count) { - int ret; unsigned long speed;char newkey[5 ];u8 buffer[2 ]; +int ret; -if (strict_strtoul (sysfsbuf,10 , &speed) <0 || speed >=0x4000 ) + ret =kstrtoul (sysfsbuf,10 , &speed); +if (ret <0 ) +return ret; +if (speed >=0x4000 )return -EINVAL ;/* Bigger than a 14-bit value */ sprintf (newkey, fan_speed_fmt[to_option (attr)],to_index (attr));
@@ -790,11 +793,9 @@ static ssize_t applesmc_store_fan_speed(struct device *dev, buffer[0 ] = (speed >>6 ) &0xff ; buffer[1 ] = (speed <<2 ) &0xff ; ret =applesmc_write_key (newkey, buffer,2 ); -if (ret)return ret; -else -return count; +return count; } static ssize_t applesmc_show_fan_manual(struct device *dev,
@@ -817,13 +818,14 @@ static ssize_t applesmc_store_fan_manual(struct device *dev,struct device_attribute *attr, const char *sysfsbuf, size_t count) { - int ret; u8 buffer[2];unsigned long input;u16 val; +int ret; -if (strict_strtoul (sysfsbuf,10 , &input) <0 ) -return -EINVAL ; + ret =kstrtoul (sysfsbuf,10 , &input); +if (ret <0 ) +return ret; ret =applesmc_read_key (FANS_MANUAL , buffer,2 ); val = (buffer[0 ] <<8 | buffer[1 ]);
@@ -975,10 +977,13 @@ static ssize_t applesmc_key_at_index_show(struct device *dev,static ssize_t applesmc_key_at_index_store (struct device *dev,struct device_attribute *attr,const char *sysfsbuf,size_t count) { -unsigned long newkey; +unsigned int newkey; +int rv; -if (strict_strtoul (sysfsbuf,10 , &newkey) <0 - || newkey >= smcreg.key_count) + rv =kstrtouint (sysfsbuf,10 , &newkey); +if (rv <0 ) +return rv; +if (newkey >= smcreg.key_count)return -EINVAL ; key_at_index = newkey;
drivers/hwmon/asc7621.c +53 -30
180 lines not on this page · raw message
drivers/hwmon/ds620.c +1 -1
@@ -182,7 +182,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,struct i2c_client *client =to_i2c_client (dev);struct ds620_data *data =i2c_get_clientdata (client); - res =strict_strtol (buf,10 , &val); + res =kstrtol (buf,10 , &val);if (res)return res;
drivers/hwmon/emc1403.c +10 -7
@@ -80,8 +80,9 @@ static ssize_t store_temp(struct device *dev,unsigned long val;int retval; -if (strict_strtoul (buf,10 , &val)) -return -EINVAL ; + retval =kstrtoul (buf,10 , &val); +if (retval <0 ) +return retval; retval =i2c_smbus_write_byte_data (client, sda->index,DIV_ROUND_CLOSEST (val,1000 ));if (retval <0 )
@@ -95,11 +96,12 @@ static ssize_t store_bit(struct device *dev,struct i2c_client *client =to_i2c_client (dev);struct thermal_data *data =i2c_get_clientdata (client);struct sensor_device_attribute_2 *sda =to_sensor_dev_attr_2 (attr); -unsigned long val; +int val;int retval; -if (strict_strtoul (buf,10 , &val)) -return -EINVAL ; + retval =kstrtoint (buf,10 , &val); +if (retval <0 ) +return retval;mutex_lock (&data->mutex); retval =i2c_smbus_read_byte_data (client, sda->nr);
@@ -151,8 +153,9 @@ static ssize_t store_hyst(struct device *dev,int hyst;unsigned long val; -if (strict_strtoul (buf,10 , &val)) -return -EINVAL ; + retval =kstrtoul (buf,10 , &val); +if (retval <0 ) +return retval;mutex_lock (&data->mutex); retval =i2c_smbus_read_byte_data (client, sda->index);
drivers/hwmon/emc2103.c +18 -14
@@ -243,10 +243,11 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *da,struct i2c_client *client =to_i2c_client (dev);struct emc2103_data *data =i2c_get_clientdata (client);long val; +int result; -int result =strict_strtol (buf,10 , &val); + result =kstrtol (buf,10 , &val);if (result <0 ) -return -EINVAL ; +return result; val =DIV_ROUND_CLOSEST (val,1000 );if ((val <-63 ) || (val >127 ))
@@ -267,10 +268,11 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *da,struct i2c_client *client =to_i2c_client (dev);struct emc2103_data *data =i2c_get_clientdata (client);long val; +int result; -int result =strict_strtol (buf,10 , &val); + result =kstrtol (buf,10 , &val);if (result <0 ) -return -EINVAL ; +return result; val =DIV_ROUND_CLOSEST (val,1000 );if ((val <-63 ) || (val >127 ))
@@ -313,10 +315,11 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *da,struct i2c_client *client =to_i2c_client (dev);int new_range_bits, old_div =8 / data->fan_multiplier;long new_div; +int status; -int status =strict_strtol (buf,10 , &new_div); + status =kstrtol (buf,10 , &new_div);if (status <0 ) -return -EINVAL ; +return status;if (new_div == old_div)/* No change */ return count;
@@ -386,14 +389,14 @@ static ssize_t set_fan_target(struct device *dev, struct device_attribute *da, {struct emc2103_data *data =emc2103_update_device (dev);struct i2c_client *client =to_i2c_client (dev); -long rpm_target; +unsigned int rpm_target; +int result; -int result =strict_strtol (buf,10 , &rpm_target); + result =kstrtouint (buf,10 , &rpm_target);if (result <0 ) -return -EINVAL ; - +return result;/* Datasheet states 16384 as maximum RPM target (table 3.2) */ -if ((rpm_target <0 ) || (rpm_target >16384 )) +if (rpm_target >16384 )return -EINVAL ;mutex_lock (&data->update_lock);
@@ -431,12 +434,13 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *da, {struct i2c_client *client =to_i2c_client (dev);struct emc2103_data *data =i2c_get_clientdata (client); -long new_value; +int new_value;u8 conf_reg; +int result; -int result =strict_strtol (buf,10 , &new_value); + result =kstrtoint (buf,10 , &new_value);if (result <0 ) -return -EINVAL ; +return result;mutex_lock (&data->update_lock);switch (new_value) {
drivers/hwmon/f71882fg.c +31 -31
153 lines not on this page · raw message
drivers/hwmon/g760a.c +4 -2
@@ -165,9 +165,11 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *da,struct i2c_client *client =to_i2c_client (dev);struct g760a_data *data =g760a_update_client (dev);unsigned long val; +int rv; -if (strict_strtoul (buf,10 , &val)) -return -EINVAL ; + rv =kstrtoul (buf,10 , &val); +if (rv <0 ) +return rv;mutex_lock (&data->update_lock); data->set_cnt =PWM_TO_CNT (SENSORS_LIMIT (val,0 ,255 ));
drivers/hwmon/gpio-fan.c +17 -7
@@ -222,11 +222,15 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,struct gpio_fan_data *fan_data =dev_get_drvdata (dev);unsigned long pwm;int speed_index; -int ret = count; +int ret; -if (strict_strtoul (buf,10 , &pwm) || pwm >255 ) + ret =kstrtoul (buf,10 , &pwm); +if (ret <0 ) +return ret; +if (pwm >255 )return -EINVAL ; + ret = count;mutex_lock (&fan_data->lock);if (!fan_data->pwm_enable) {
@@ -255,9 +259,13 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) {struct gpio_fan_data *fan_data =dev_get_drvdata (dev); -unsigned long val; +int val; +int rv; -if (strict_strtoul (buf,10 , &val) || val >1 ) + rv =kstrtoint (buf,10 , &val); +if (rv <0 ) +return rv; +if (val >1 )return -EINVAL ;if (fan_data->pwm_enable == val)
@@ -312,11 +320,13 @@ static ssize_t set_rpm(struct device *dev, struct device_attribute *attr, {struct gpio_fan_data *fan_data =dev_get_drvdata (dev);unsigned long rpm; -int ret = count; +int ret; -if (strict_strtoul (buf,10 , &rpm)) -return -EINVAL ; + ret =kstrtoul (buf,10 , &rpm); +if (ret <0 ) +return ret; + ret = count;mutex_lock (&fan_data->lock);if (!fan_data->pwm_enable) {
drivers/hwmon/ibmaem.c +2 -2
@@ -922,8 +922,8 @@ static ssize_t aem_set_power_period(struct device *dev,unsigned long temp;int res; - res =strict_strtoul (buf,10 , &temp); -if (res) + res =kstrtoul (buf,10 , &temp); +if (res <0 )return res;if (temp <AEM_MIN_POWER_INTERVAL )
drivers/hwmon/it87.c +73 -36
228 lines not on this page · raw message
drivers/hwmon/jc42.c +18 -16
@@ -307,17 +307,19 @@ static ssize_t set_##value(struct device *dev, \ { \struct i2c_client *client =to_i2c_client (dev); \struct jc42_data *data =i2c_get_clientdata (client); \ -int err, ret = count; \ -long val; \ -if (strict_strtol (buf,10 , &val) <0 ) \ -return -EINVAL ; \ +int val; \ +int ret; \ + \ + ret =kstrtoint (buf,10 , &val); \ +if (ret <0 ) \ +return ret; \mutex_lock (&data->update_lock); \ data->value =jc42_temp_to_reg (val, data->extended); \ - err =jc42_write_value (client, reg, data->value); \ -if (err <0 ) \ - ret = err; \ + ret =jc42_write_value (client, reg, data->value); \mutex_unlock (&data->update_lock); \ -return ret; \ +if (ret <0 ) \ +return ret; \ +return count; \ }set (temp_min,JC42_REG_TEMP_LOWER );
@@ -334,11 +336,11 @@ static ssize_t set_temp_crit_hyst(struct device *dev,struct jc42_data *data =i2c_get_clientdata (client);long val;int diff, hyst; -int err; -int ret = count; +int ret; -if (strict_strtoul (buf,10 , &val) <0 ) -return -EINVAL ; + ret =kstrtoul (buf,10 , &val); +if (ret <0 ) +return ret; diff =jc42_temp_from_reg (data->temp_crit) - val; hyst =0 ;
@@ -355,11 +357,11 @@ static ssize_t set_temp_crit_hyst(struct device *dev, data->config = (data->config & ~(JC42_CFG_HYST_MASK <<JC42_CFG_HYST_SHIFT )) | (hyst <<JC42_CFG_HYST_SHIFT ); - err =jc42_write_value (client,JC42_REG_CONFIG , data->config); -if (err <0 ) - ret = err; + ret =jc42_write_value (client,JC42_REG_CONFIG , data->config);mutex_unlock (&data->update_lock); -return ret; +if (ret <0 ) +return ret; +return count; } static ssize_t show_alarm(struct device *dev,
drivers/hwmon/lis3lv02d.c +5 -3
@@ -754,10 +754,12 @@ static ssize_t lis3lv02d_rate_set(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - unsigned long rate; + int rate; +int rv; -if (strict_strtoul (buf,0 , &rate)) -return -EINVAL ; + rv =kstrtoint (buf,0 , &rate); +if (rv <0 ) +return rv;lis3lv02d_sysfs_poweron (&lis3_dev);if (lis3lv02d_set_odr (rate))
drivers/hwmon/lm73.c +2 -1
@@ -49,8 +49,9 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,struct i2c_client *client =to_i2c_client (dev);long temp;short value; +int status; -int status =strict_strtol (buf,10 , &temp); + status =kstrtol (buf,10 , &temp);if (status <0 )return status;
drivers/hwmon/lm75.c +2 -2
@@ -106,8 +106,8 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,long temp;int error; - error =strict_strtol (buf,10 , &temp); -if (error) + error =kstrtol (buf,10 , &temp); +if (error <0 )return error;mutex_lock (&data->update_lock);
drivers/hwmon/lm90.c +8 -8
@@ -708,7 +708,7 @@ static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr,long val;int err; - err =strict_strtol (buf,10 , &val); + err =kstrtol (buf,10 , &val);if (err <0 )return err;
@@ -776,7 +776,7 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,long val;int err; - err =strict_strtol (buf,10 , &val); + err =kstrtol (buf,10 , &val);if (err <0 )return err;
@@ -837,7 +837,7 @@ static ssize_t set_temphyst(struct device *dev, struct device_attribute *dummy,int err;int temp; - err =strict_strtol (buf,10 , &val); + err =kstrtol (buf,10 , &val);if (err <0 )return err;
@@ -887,11 +887,11 @@ static ssize_t set_update_interval(struct device *dev, {struct i2c_client *client =to_i2c_client (dev);struct lm90_data *data =i2c_get_clientdata (client); -unsigned long val; +unsigned int val;int err; - err =strict_strtoul (buf,10 , &val); -if (err) + err =kstrtouint (buf,10 , &val); +if (err <0 )return err;mutex_lock (&data->update_lock);
@@ -1055,10 +1055,10 @@ static ssize_t set_pec(struct device *dev, struct device_attribute *dummy, const char *buf, size_t count) {struct i2c_client *client =to_i2c_client (dev); -long val; +int val;int err; - err =strict_strtol (buf,10 , &val); + err =kstrtoint (buf,10 , &val);if (err <0 )return err;
drivers/hwmon/lm95241.c +4 -4
@@ -160,7 +160,7 @@ static ssize_t set_type(struct device *dev, struct device_attribute *attr,int shift;u8 mask =to_sensor_dev_attr (attr)->index; -if (strict_strtoul (buf,10 , &val) <0 ) +if (kstrtoul (buf,10 , &val) <0 )return -EINVAL ;if (val !=1 && val !=2 )return -EINVAL ;
@@ -207,7 +207,7 @@ static ssize_t set_min(struct device *dev, struct device_attribute *attr,struct lm95241_data *data =i2c_get_clientdata (client);long val; -if (strict_strtol (buf,10 , &val) <0 ) +if (kstrtol (buf,10 , &val) <0 )return -EINVAL ;if (val <-128000 )return -EINVAL ;
@@ -245,7 +245,7 @@ static ssize_t set_max(struct device *dev, struct device_attribute *attr,struct lm95241_data *data =i2c_get_clientdata (client);long val; -if (strict_strtol (buf,10 , &val) <0 ) +if (kstrtol (buf,10 , &val) <0 )return -EINVAL ;if (val >=256000 )return -EINVAL ;
@@ -281,7 +281,7 @@ static ssize_t set_interval(struct device *dev, struct device_attribute *attr,struct lm95241_data *data =i2c_get_clientdata (client);unsigned long val; -if (strict_strtoul (buf,10 , &val) <0 ) +if (kstrtoul (buf,10 , &val) <0 )return -EINVAL ; data->interval = val *HZ /1000 ;
drivers/hwmon/pc87427.c +14 -6
@@ -417,9 +417,11 @@ static ssize_t set_fan_min(struct device *dev, struct device_attributeint nr =to_sensor_dev_attr (devattr)->index;unsigned long val;int iobase = data->address[LD_FAN ]; +int rv; -if (strict_strtoul (buf,10 , &val) <0 ) -return -EINVAL ; + rv =kstrtoul (buf,10 , &val); +if (rv <0 ) +return rv;mutex_lock (&data->lock);outb (BANK_FM (nr), iobase +PC87427_REG_BANK );
@@ -571,8 +573,12 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attributestruct pc87427_data *data =dev_get_drvdata (dev);int nr =to_sensor_dev_attr (devattr)->index;unsigned long val; +int rv; -if (strict_strtoul (buf,10 , &val) <0 || val >2 ) + rv =kstrtoul (buf,10 , &val); +if (rv <0 ) +return rv; +if (val >2 )return -EINVAL ;/* Can't go to automatic mode if it isn't configured */ if (val ==2 && !(data->pwm_auto_ok & (1 << nr)))
@@ -600,12 +606,14 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute {struct pc87427_data *data =dev_get_drvdata (dev);int nr =to_sensor_dev_attr (devattr)->index; -unsigned long val; +u8 val;int iobase = data->address[LD_FAN ];u8 mode; +int rv; -if (strict_strtoul (buf,10 , &val) <0 || val >0xff ) -return -EINVAL ; + rv =kstrtou8 (buf,10 , &val); +if (rv <0 ) +return rv;mutex_lock (&data->lock);pc87427_readall_pwm (data, nr);
drivers/hwmon/tmp102.c +3 -2
@@ -124,8 +124,9 @@ static ssize_t tmp102_set_temp(struct device *dev,long val;int status; -if (strict_strtol (buf,10 , &val) <0 ) -return -EINVAL ; + status =kstrtol (buf,10 , &val); +if (status <0 ) +return status; val =SENSORS_LIMIT (val,-256000 ,255000 );mutex_lock (&tmp102->lock);
drivers/hwmon/tmp401.c +23 -14
@@ -333,9 +333,11 @@ static ssize_t store_temp_min(struct device *dev, struct device_attributestruct tmp401_data *data =tmp401_update_device (dev);long val;u16 reg; +int rv; -if (strict_strtol (buf,10 , &val)) -return -EINVAL ; + rv =kstrtol (buf,10 , &val); +if (rv <0 ) +return rv; reg =tmp401_temp_to_register (val, data->config);
@@ -360,9 +362,11 @@ static ssize_t store_temp_max(struct device *dev, struct device_attributestruct tmp401_data *data =tmp401_update_device (dev);long val;u16 reg; +int rv; -if (strict_strtol (buf,10 , &val)) -return -EINVAL ; + rv =kstrtol (buf,10 , &val); +if (rv <0 ) +return rv; reg =tmp401_temp_to_register (val, data->config);
@@ -387,9 +391,11 @@ static ssize_t store_temp_crit(struct device *dev, struct device_attributestruct tmp401_data *data =tmp401_update_device (dev);long val;u8 reg; +int rv; -if (strict_strtol (buf,10 , &val)) -return -EINVAL ; + rv =kstrtol (buf,10 , &val); +if (rv <0 ) +return rv; reg =tmp401_crit_temp_to_register (val, data->config);
@@ -412,9 +418,11 @@ static ssize_t store_temp_crit_hyst(struct device *dev, struct device_attributestruct tmp401_data *data =tmp401_update_device (dev);long val;u8 reg; +int rv; -if (strict_strtol (buf,10 , &val)) -return -EINVAL ; + rv =kstrtol (buf,10 , &val); +if (rv <0 ) +return rv;if (data->config &TMP401_CONFIG_RANGE ) val =SENSORS_LIMIT (val,-64000 ,191000 );
@@ -445,18 +453,19 @@ static ssize_t store_temp_crit_hyst(struct device *dev, struct device_attributestatic ssize_t reset_temp_history (struct device *dev,struct device_attribute *devattr,const char *buf,size_t count) { -long val; - -if (strict_strtol (buf,10 , &val)) -return -EINVAL ; +int val; +int rv; + rv =kstrtoint (buf,10 , &val); +if (rv <0 ) +return rv;if (val !=1 ) { -dev_err (dev,"temp_reset_history value %ld not" +dev_err (dev,"temp_reset_history value %d not" " supported. Use 1 to reset the history!\n" , val);return -EINVAL ; }i2c_smbus_write_byte_data (to_i2c_client (dev), -TMP411_TEMP_LOWEST_MSB [0 ], val); +TMP411_TEMP_LOWEST_MSB [0 ],1 );return count; }
drivers/hwmon/w83791d.c +18 -10
@@ -710,9 +710,11 @@ static ssize_t store_pwm(struct device *dev, struct device_attribute *attr,struct w83791d_data *data =i2c_get_clientdata (client);int nr = sensor_attr->index;unsigned long val; +int rv; -if (strict_strtoul (buf,10 , &val)) -return -EINVAL ; + rv =kstrtoul (buf,10 , &val); +if (rv <0 ) +return rv;mutex_lock (&data->update_lock); data->pwm[nr] =SENSORS_LIMIT (val,0 ,255 );
@@ -750,15 +752,17 @@ static ssize_t store_pwmenable(struct device *dev,struct i2c_client *client =to_i2c_client (dev);struct w83791d_data *data =i2c_get_clientdata (client);int nr = sensor_attr->index; -unsigned long val; +u8 val;u8 reg_cfg_tmp;u8 reg_idx =0 ;u8 val_shift =0 ;u8 keep_mask =0 ; +int ret; -int ret =strict_strtoul (buf,10 , &val); - -if (ret || val <1 || val >3 ) + ret =kstrtou8 (buf,10 , &val); +if (ret <0 ) +return ret; +if (val <1 || val >3 )return -EINVAL ;mutex_lock (&data->update_lock);
@@ -818,9 +822,11 @@ static ssize_t store_temp_target(struct device *dev,int nr = sensor_attr->index;unsigned long val;u8 target_mask; +int rv; -if (strict_strtoul (buf,10 , &val)) -return -EINVAL ; + rv =kstrtoul (buf,10 , &val); +if (rv <0 ) +return rv;mutex_lock (&data->update_lock); data->temp_target[nr] =TARGET_TEMP_TO_REG (val);
@@ -862,9 +868,11 @@ static ssize_t store_temp_tolerance(struct device *dev,u8 reg_idx =0 ;u8 val_shift =0 ;u8 keep_mask =0 ; +int rv; -if (strict_strtoul (buf,10 , &val)) -return -EINVAL ; + rv =kstrtoul (buf,10 , &val); +if (rv <0 ) +return rv;switch (nr) {case 0 :
drivers/hwmon/w83792d.c +1 -1
@@ -749,7 +749,7 @@ store_chassis_clear(struct device *dev, struct device_attribute *attr,unsigned long val;u8 reg; -if (strict_strtoul (buf,10 , &val) || val !=0 ) +if (kstrtoul (buf,10 , &val) || val !=0 )return -EINVAL ;mutex_lock (&data->update_lock);
drivers/hwmon/w83793.c +1 -1
@@ -450,7 +450,7 @@ store_chassis_clear(struct device *dev,unsigned long val;u8 reg; -if (strict_strtoul (buf,10 , &val) || val !=0 ) +if (kstrtoul (buf,10 , &val) || val !=0 )return -EINVAL ;mutex_lock (&data->update_lock);
drivers/hwmon/w83795.c +72 -37
228 lines not on this page · raw message
Signature · 1 line
1.7.3.4
PATCH 24/52 kstrtox: convert drivers/isdn/
In reply to Alexey Dobriyan--- drivers/isdn/gigaset/ev-layer.c | 25 +++++++++---------------- drivers/isdn/hysdn/hysdn_proclog.c | 11 ++++------- 2 files changed, 13 insertions(+), 23 deletions(-)
drivers/isdn/gigaset/ev-layer.c +9 -16
@@ -390,12 +390,12 @@ static const struct zsau_resp_t {*/ static int cid_of_response (char *s) { -unsigned long cid; +unsigned int cid;int rc;if (s[-1 ] !=';' )return 0 ;/* no CID separator */ - rc =strict_strtoul (s,10 , &cid); + rc =kstrtouint (s,10 , &cid);if (rc)return 0 ;/* CID not numeric */ if (cid <1 || cid >65535 )
@@ -566,27 +566,20 @@ void gigaset_handle_modem_response(struct cardstate *cs)case RT_ZCAU : event->parameter =-1 ;if (curarg +1 < params) { -unsigned long type, value; +u8 type, value; - i =strict_strtoul (argv[curarg++],16 , &type); - j =strict_strtoul (argv[curarg++],16 , &value); + i =kstrtou8 (argv[curarg++],16 , &type); + j =kstrtou8 (argv[curarg++],16 , &value); -if (i ==0 && type <256 && - j ==0 && value <256 ) +if (i ==0 && j ==0 ) event->parameter = (type <<8 ) | value; }else curarg = params -1 ;break ;case RT_NUMBER : - event->parameter =-1 ; -if (curarg < params) { -unsigned long res; -int rc; - - rc =strict_strtoul (argv[curarg++],10 , &res); -if (rc ==0 ) - event->parameter = res; - } +if (curarg >= params || +kstrtoint (argv[curarg++],10 , &event->parameter)) + event->parameter =-1 ;gig_dbg (DEBUG_EVENT ,"parameter==%d" , event->parameter);break ; }
drivers/isdn/hysdn/hysdn_proclog.c +4 -7
@@ -155,7 +155,6 @@ put_log_buffer(hysdn_card * card, char *cp)static ssize_t hysdn_log_write (struct file *file,const char __user *buf,size_t count,loff_t * off) { -unsigned long u =0 ;int rc;unsigned char valbuf[128 ];hysdn_card *card = file->private_data;
@@ -167,12 +166,10 @@ hysdn_log_write(struct file *file, const char __user *buf, size_t count, loff_t valbuf[count] =0 ;/* terminating 0 */ - rc =strict_strtoul (valbuf,0 , &u); - -if (rc ==0 ) { - card->debug_flags = u;/* remember debug flags */ -hysdn_addlog (card,"debug set to 0x%lx" , card->debug_flags); - } + rc =kstrtoul (valbuf,0 , &card->debug_flags); +if (rc <0 ) +return rc; +hysdn_addlog (card,"debug set to 0x%lx" , card->debug_flags);return (count); }/* hysdn_log_write */
Signature · 1 line
1.7.3.4
PATCH 27/52 kstrtox: convert drivers/md/
In reply to Alexey Dobriyan--- drivers/md/bitmap.c | 14 ++++---- drivers/md/dm-raid.c | 31 ++++++++++------- drivers/md/md.c | 86 +++++++++++++++++++++++++++++++++---------------- drivers/md/md.h | 2 +- drivers/md/raid5.c | 16 ++++++--- 5 files changed, 94 insertions(+), 55 deletions(-)
drivers/md/bitmap.c +7 -7
@@ -1885,10 +1885,8 @@ location_store(mddev_t *mddev, const char *buf, size_t len)return -EINVAL ; }else {int rv; -if (buf[0 ] =='+' ) - rv =strict_strtoll (buf+1 ,10 , &offset); -else - rv =strict_strtoll (buf,10 , &offset); + + rv =kstrtoll (buf,10 , &offset);if (rv)return rv;if (offset ==0 )
@@ -1943,7 +1941,7 @@ timeout_store(mddev_t *mddev, const char *buf, size_t len) {/* timeout can be set at any time */ unsigned long timeout; -int rv =strict_strtoul_scaled (buf, &timeout,4 ); +int rv =kstrtoul_scaled (buf, &timeout,4 );if (rv)return rv;
@@ -1984,7 +1982,9 @@ static ssize_t backlog_store(mddev_t *mddev, const char *buf, size_t len) {unsigned long backlog; -int rv =strict_strtoul (buf,10 , &backlog); +int rv; + + rv =kstrtoul (buf,10 , &backlog);if (rv)return rv;if (backlog >COUNTER_MAX )
@@ -2010,7 +2010,7 @@ chunksize_store(mddev_t *mddev, const char *buf, size_t len)unsigned long csize;if (mddev->bitmap)return -EBUSY ; - rv =strict_strtoul (buf,10 , &csize); + rv =kstrtoul (buf,10 , &csize);if (rv)return rv; if (csize < 512 ||
drivers/md/dm-raid.c +18 -13
@@ -254,12 +254,15 @@ static int parse_raid_params(struct raid_set *rs, char **argv,unsigned i, rebuild_cnt =0 ;unsigned long value;char *key; +int rv;/* * First, parse the in-order required arguments */ -if ((strict_strtoul (argv[0 ],10 , &value) <0 ) || - !is_power_of_2 (value) || (value <8 )) { + rv =kstrtoul (argv[0 ],10 , &value); +if (rv <0 ) +return rv; +if (!is_power_of_2 (value) || (value <8 )) { rs->ti->error ="Bad chunk size" ;return -EINVAL ; }
@@ -295,9 +298,10 @@ static int parse_raid_params(struct raid_set *rs, char **argv, } key = argv[i++]; -if (strict_strtoul (argv[i],10 , &value) <0 ) { + rv =kstrtoul (argv[i],10 , &value); +if (rv <0 ) { rs->ti->error ="Bad numerical argument given in raid params" ; -return -EINVAL ; +return rv; }if (!strcmp (key,"rebuild" )) {
@@ -410,10 +414,10 @@ static void raid_unplug(struct dm_target_callbacks *cb)*/ static int raid_ctr (struct dm_target *ti,unsigned argc,char **argv) { -int ret;struct raid_type *rt; -unsigned long num_raid_params, num_raid_devs; +unsigned int num_raid_params, num_raid_devs;struct raid_set *rs =NULL ; +int ret;/* Must have at least <raid_type> <#raid_params> */ if (argc <2 ) {
@@ -431,9 +435,10 @@ static int raid_ctr(struct dm_target *ti, unsigned argc, char **argv) argv++;/* number of RAID parameters */ -if (strict_strtoul (argv[0 ],10 , &num_raid_params) <0 ) { + ret =kstrtouint (argv[0 ],10 , &num_raid_params); +if (ret <0 ) { ti->error ="Cannot understand number of RAID parameters" ; -return -EINVAL ; +return ret; } argc--; argv++;
@@ -444,17 +449,17 @@ static int raid_ctr(struct dm_target *ti, unsigned argc, char **argv)return -EINVAL ; } -if ((strict_strtoul (argv[num_raid_params],10 , &num_raid_devs) <0 ) || - (num_raid_devs >=INT_MAX )) { + ret =kstrtouint (argv[num_raid_params],10 , &num_raid_devs); +if (ret <0 ) { ti->error ="Cannot understand number of raid devices" ; -return -EINVAL ; +return ret; } - rs =context_alloc (ti, rt, (unsigned )num_raid_devs); + rs =context_alloc (ti, rt, num_raid_devs);if (IS_ERR (rs))return PTR_ERR (rs); - ret =parse_raid_params (rs, argv, (unsigned )num_raid_params); + ret =parse_raid_params (rs, argv, num_raid_params);if (ret) goto bad;
drivers/md/md.c +58 -28
174 lines not on this page · raw message
drivers/md/md.h +1 -1
@@ -514,7 +514,7 @@ extern void md_set_array_sectors(mddev_t *mddev, sector_t array_sectors);extern int md_check_no_bitmap (mddev_t *mddev);extern int md_integrity_register (mddev_t *mddev);extern void md_integrity_add_rdev (mdk_rdev_t *rdev,mddev_t *mddev); -extern int strict_strtoul_scaled (const char *cp,unsigned long *res,int scale); +extern int kstrtoul_scaled (const char *cp,unsigned long *res,int scale);extern void restore_bitmap_write_access (struct file *file);extern void md_unplug (mddev_t *mddev);
drivers/md/raid5.c +10 -6
@@ -4614,7 +4614,7 @@ static ssize_t raid5_store_stripe_cache_size(mddev_t *mddev, const char *page, size_t len) {raid5_conf_t *conf = mddev->private; -unsigned long new; +unsigned int new;int err;if (len >=PAGE_SIZE )
@@ -4622,8 +4622,9 @@ raid5_store_stripe_cache_size(mddev_t *mddev, const char *page, size_t len)if (!conf)return -ENODEV ; -if (strict_strtoul (page,10 , &new)) -return -EINVAL ; + err =kstrtouint (page,10 , &new); +if (err <0 ) +return err; err =raid5_set_cache_size (mddev, new);if (err)return err;
@@ -4649,14 +4650,17 @@ static ssize_t raid5_store_preread_threshold(mddev_t *mddev, const char *page, size_t len) {raid5_conf_t *conf = mddev->private; -unsigned long new; +unsigned int new; +int rv; +if (len >=PAGE_SIZE )return -EINVAL ;if (!conf)return -ENODEV ; -if (strict_strtoul (page,10 , &new)) -return -EINVAL ; + rv =kstrtouint (page,10 , &new); +if (rv <0 ) +return rv;if (new > conf->max_nr_stripes)return -EINVAL ; conf->bypass_threshold = new;
Signature · 1 line
1.7.3.4
PATCH 30/52 kstrtox: convert drivers/mmc/
In reply to Alexey Dobriyan--- drivers/mmc/card/mmc_test.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/card/mmc_test.c +2 -2
@@ -2173,7 +2173,7 @@ static ssize_t mtf_test_write(struct file *file, const char __user *buf,struct mmc_card *card = (struct mmc_card *)sf->private;struct mmc_test_card *test;char lbuf[12 ]; -long testcase; +int testcase;if (count >=sizeof (lbuf))return -EINVAL ;
@@ -2182,7 +2182,7 @@ static ssize_t mtf_test_write(struct file *file, const char __user *buf,return -EFAULT ; lbuf[count] ='\0' ; -if (strict_strtol (lbuf,10 , &testcase)) +if (kstrtoint (lbuf,10 , &testcase))return -EINVAL ; test =kzalloc (sizeof (struct mmc_test_card ),GFP_KERNEL );
Signature · 1 line
1.7.3.4
PATCH 29/52 kstrtox: convert drivers/misc/
In reply to Alexey Dobriyan--- drivers/misc/ad525x_dpot.c | 2 +- drivers/misc/apds9802als.c | 7 ++- drivers/misc/apds990x.c | 45 +++++++++++++--------- drivers/misc/bh1770glc.c | 72 ++++++++++++++++++++++-------------- drivers/misc/bh1780gli.c | 4 +- drivers/misc/bmp085.c | 31 ++++++--------- drivers/misc/ep93xx_pwm.c | 33 ++++++++-------- drivers/misc/hmc6352.c | 7 ++- drivers/misc/isl29003.c | 28 ++++++++++---- drivers/misc/isl29020.c | 7 ++- drivers/misc/iwmc3200top/log.c | 76 ++++++++++++++++---------------------- drivers/misc/sgi-gru/gruprocfs.c | 7 ++- drivers/misc/ti_dac7512.c | 10 +++-- 13 files changed, 175 insertions(+), 154 deletions(-)
drivers/misc/ad525x_dpot.c +1 -1
@@ -472,7 +472,7 @@ static ssize_t sysfs_set_reg(struct device *dev, !test_bit(DPOT_RDAC_MASK & reg, data->otp_en_mask))return -EPERM ; - err =strict_strtoul (buf,10 , &value); + err =kstrtoul (buf,10 , &value);if (err)return err;
drivers/misc/apds9802als.c +4 -3
@@ -123,11 +123,12 @@ static ssize_t als_sensing_range_store(struct device *dev, {struct i2c_client *client =to_i2c_client (dev);struct als_data *data =i2c_get_clientdata (client); +unsigned int val;int ret_val; -unsigned long val; -if (strict_strtoul (buf,10 , &val)) -return -EINVAL ; + ret_val =kstrtouint (buf,10 , &val); +if (ret_val <0 ) +return ret_val;if (val <4096 ) val =1 ;
drivers/misc/apds990x.c +26 -19
89 lines not on this page · raw message
drivers/misc/bh1770glc.c +44 -28
145 lines not on this page · raw message
drivers/misc/bh1780gli.c +2 -2
@@ -103,10 +103,10 @@ static ssize_t bh1780_store_power_state(struct device *dev, {struct platform_device *pdev =to_platform_device (dev);struct bh1780_data *ddata =platform_get_drvdata (pdev); -unsigned long val; +int val;int error; - error =strict_strtoul (buf,0 , &val); + error =kstrtoint (buf,0 , &val);if (error)return error;
drivers/misc/bmp085.c +12 -19
@@ -86,7 +86,7 @@ struct bmp085_data {struct bmp085_calibration_data calibration;u32 raw_temperature;u32 raw_pressure; -unsigned char oversampling_setting; +u8 oversampling_setting;/* [0, 3] */ u32 last_temp_measurement;s32 b6;/* calculated temperature correction coefficient */ };
@@ -284,22 +284,13 @@ exit:* increase both. The datasheet gives on overview on how measurement time, * accuracy and noise correlate. */ -static void bmp085_set_oversampling (struct bmp085_data *data, -unsigned char oversampling) +static void bmp085_set_oversampling (struct bmp085_data *data,u8 oversampling) {if (oversampling >3 ) oversampling =3 ; data->oversampling_setting = oversampling; } -/* -* Returns the currently selected oversampling. Range: 0..3 -*/ -static unsigned char bmp085_get_oversampling (struct bmp085_data *data) -{ -return data->oversampling_setting; -} -/* sysfs callbacks */ static ssize_t set_oversampling(struct device *dev, struct device_attribute *attr,
@@ -307,13 +298,14 @@ static ssize_t set_oversampling(struct device *dev, {struct i2c_client *client =to_i2c_client (dev);struct bmp085_data *data =i2c_get_clientdata (client); -unsigned long oversampling; -int success =strict_strtoul (buf,10 , &oversampling); -if (success ==0 ) { -bmp085_set_oversampling (data, oversampling); -return count; - } -return success; +u8 oversampling; +int rv; + + rv =kstrtou8 (buf,10 , &oversampling); +if (rv <0 ) +return rv; +bmp085_set_oversampling (data, oversampling); +return count; } static ssize_t show_oversampling(struct device *dev,
@@ -321,7 +313,8 @@ static ssize_t show_oversampling(struct device *dev, {struct i2c_client *client =to_i2c_client (dev);struct bmp085_data *data =i2c_get_clientdata (client); -return sprintf (buf,"%u\n" ,bmp085_get_oversampling (data)); + +return sprintf (buf,"%hhu\n" , data->oversampling_setting); } static DEVICE_ATTR(oversampling, S_IWUSR | S_IRUGO, show_oversampling, set_oversampling);
drivers/misc/ep93xx_pwm.c +16 -17
@@ -149,9 +149,9 @@ static ssize_t ep93xx_pwm_set_freq(struct device *dev,long val;int err; - err =strict_strtol (buf,10 , &val); + err =kstrtol (buf,10 , &val);if (err) -return -EINVAL ; +return err;if (val ==0 ) {ep93xx_pwm_disable (pwm);
@@ -191,7 +191,7 @@ static ssize_t ep93xx_pwm_get_duty_percent(struct device *dev,struct platform_device *pdev =to_platform_device (dev);struct ep93xx_pwm *pwm =platform_get_drvdata (pdev); -return sprintf (buf,"%d\n" , pwm->duty_percent); +return sprintf (buf,"%u\n" , pwm->duty_percent); } static ssize_t ep93xx_pwm_set_duty_percent(struct device *dev,
@@ -199,21 +199,20 @@ static ssize_t ep93xx_pwm_set_duty_percent(struct device *dev, {struct platform_device *pdev =to_platform_device (dev);struct ep93xx_pwm *pwm =platform_get_drvdata (pdev); -long val; +u32 term; +unsigned int val;int err; - err =strict_strtol (buf,10 , &val); -if (err) + err =kstrtouint (buf,10 , &val); +if (err <0 ) +return err; +if (val >=100 )return -EINVAL ; -if (val >0 && val <100 ) { -u32 term =ep93xx_pwm_read_tc (pwm); -ep93xx_pwm_write_dc (pwm, ((term +1 ) * val /100 ) -1 ); - pwm->duty_percent = val; -return count; - } - -return -EINVAL ; + term =ep93xx_pwm_read_tc (pwm); +ep93xx_pwm_write_dc (pwm, ((term +1 ) * val /100 ) -1 ); + pwm->duty_percent = val; +return count; } static ssize_t ep93xx_pwm_get_invert(struct device *dev,
@@ -230,12 +229,12 @@ static ssize_t ep93xx_pwm_set_invert(struct device *dev, {struct platform_device *pdev =to_platform_device (dev);struct ep93xx_pwm *pwm =platform_get_drvdata (pdev); -long val; +int val;int err; - err =strict_strtol (buf,10 , &val); + err =kstrtoint (buf,10 , &val);if (err) -return -EINVAL ; +return err;if (val ==0 )ep93xx_pwm_normal (pwm);
drivers/misc/hmc6352.c +4 -3
@@ -43,11 +43,12 @@ static int compass_store(struct device *dev, const char *buf, size_t count, const char *map) {struct i2c_client *c =to_i2c_client (dev); +unsigned int val;int ret; -unsigned long val; -if (strict_strtoul (buf,10 , &val)) -return -EINVAL ; + ret =kstrtouint (buf,10 , &val); +if (ret <0 ) +return ret;if (val >=strlen (map))return -EINVAL ;mutex_lock (&compass_mutex);
drivers/misc/isl29003.c +20 -8
@@ -205,10 +205,13 @@ static ssize_t isl29003_store_range(struct device *dev, const char *buf, size_t count) {struct i2c_client *client =to_i2c_client (dev); -unsigned long val; +unsigned int val;int ret; -if ((strict_strtoul (buf,10 , &val) <0 ) || (val >3 )) + ret =kstrtouint (buf,10 , &val); +if (ret <0 ) +return ret; +if (val >3 )return -EINVAL ; ret =isl29003_set_range (client, val);
@@ -236,10 +239,13 @@ static ssize_t isl29003_store_resolution(struct device *dev, const char *buf, size_t count) {struct i2c_client *client =to_i2c_client (dev); -unsigned long val; +unsigned int val;int ret; -if ((strict_strtoul (buf,10 , &val) <0 ) || (val >3 )) + ret =kstrtouint (buf,10 , &val); +if (ret <0 ) +return ret; +if (val >3 )return -EINVAL ; ret =isl29003_set_resolution (client, val);
@@ -264,10 +270,13 @@ static ssize_t isl29003_store_mode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct i2c_client *client = to_i2c_client(dev); -unsigned long val; +unsigned int val;int ret; -if ((strict_strtoul (buf,10 , &val) <0 ) || (val >2 )) + ret =kstrtouint (buf,10 , &val); +if (ret <0 ) +return ret; +if (val >2 )return -EINVAL ; ret =isl29003_set_mode (client, val);
@@ -295,10 +304,13 @@ static ssize_t isl29003_store_power_state(struct device *dev, const char *buf, size_t count) {struct i2c_client *client =to_i2c_client (dev); -unsigned long val; +unsigned int val;int ret; -if ((strict_strtoul (buf,10 , &val) <0 ) || (val >1 )) + ret =kstrtouint (buf,10 , &val); +if (ret <0 ) +return ret; +if (val >1 )return -EINVAL ; ret =isl29003_set_power_state (client, val);
drivers/misc/isl29020.c +4 -3
@@ -87,11 +87,12 @@ static ssize_t als_sensing_range_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct i2c_client *client = to_i2c_client(dev); +unsigned int val;int ret_val; -unsigned long val; -if (strict_strtoul (buf,10 , &val)) -return -EINVAL ; + ret_val =kstrtouint (buf,10 , &val); +if (ret_val <0 ) +return ret_val;if (val <1 || val >64000 )return -EINVAL ;
drivers/misc/iwmc3200top/log.c +32 -44
146 lines not on this page · raw message
drivers/misc/sgi-gru/gruprocfs.c +4 -3
@@ -161,15 +161,16 @@ static ssize_t options_write(struct file *file, const char __user *userbuf, size_t count, loff_t *data) { char buf[20]; +int rv;if (count >=sizeof (buf))return -EINVAL ;if (copy_from_user (buf, userbuf, count))return -EFAULT ; buf[count] ='\0' ; -if (strict_strtoul (buf,0 , &gru_options)) -return -EINVAL ; - + rv =kstrtoul (buf,0 , &gru_options); +if (rv <0 ) +return rv;return count; }
drivers/misc/ti_dac7512.c +6 -4
@@ -31,11 +31,13 @@ static ssize_t dac7512_store_val(struct device *dev, const char *buf, size_t count) {struct spi_device *spi =to_spi_device (dev); -unsigned char tmp[2 ]; -unsigned long val; +u8 tmp[2 ]; +u16 val; +int rv; -if (strict_strtoul (buf,10 , &val) <0 ) -return -EINVAL ; + rv =kstrtou16 (buf,10 , &val); +if (rv <0 ) +return rv; tmp[0 ] = val >>8 ; tmp[1 ] = val &0xff ;
Signature · 1 line
1.7.3.4
PATCH 32/52 kstrtox: convert drivers/net/wireless/
In reply to Alexey Dobriyan--- drivers/net/wireless/ath/ath9k/debug.c | 22 ++++++---------- drivers/net/wireless/iwlwifi/iwl-agn.c | 36 ++++++++++++--------------- drivers/net/wireless/iwlwifi/iwl3945-base.c | 15 ++++------ drivers/net/wireless/libertas/mesh.c | 7 +++-- drivers/net/wireless/rtlwifi/base.c | 15 +++------- drivers/net/wireless/wl12xx/debugfs.c | 15 +++------- drivers/net/wireless/wl12xx/main.c | 6 +--- 7 files changed, 46 insertions(+), 70 deletions(-)
drivers/net/wireless/ath/ath9k/debug.c +8 -14
@@ -49,7 +49,6 @@ static ssize_t write_file_debug(struct file *file, const char __user *user_buf, {struct ath_softc *sc = file->private_data;struct ath_common *common =ath9k_hw_common (sc->sc_ah); -unsigned long mask;char buf[32 ];ssize_t len;
@@ -58,10 +57,8 @@ static ssize_t write_file_debug(struct file *file, const char __user *user_buf,return -EFAULT ; buf[len] ='\0' ; -if (strict_strtoul (buf,0 , &mask)) +if (kstrtoint (buf,0 , &common->debug_mask))return -EINVAL ; - - common->debug_mask = mask;return count; }
@@ -94,7 +91,7 @@ static ssize_t write_file_tx_chainmask(struct file *file, const char __user *use {struct ath_softc *sc = file->private_data;struct ath_common *common =ath9k_hw_common (sc->sc_ah); -unsigned long mask; +u8 mask;char buf[32 ];ssize_t len;
@@ -103,7 +100,7 @@ static ssize_t write_file_tx_chainmask(struct file *file, const char __user *usereturn -EFAULT ; buf[len] ='\0' ; -if (strict_strtoul (buf,0 , &mask)) +if (kstrtou8 (buf,0 , &mask))return -EINVAL ; common->tx_chainmask = mask;
@@ -137,7 +134,7 @@ static ssize_t write_file_rx_chainmask(struct file *file, const char __user *use {struct ath_softc *sc = file->private_data;struct ath_common *common =ath9k_hw_common (sc->sc_ah); -unsigned long mask; +u8 mask;char buf[32 ];ssize_t len;
@@ -146,7 +143,7 @@ static ssize_t write_file_rx_chainmask(struct file *file, const char __user *usereturn -EFAULT ; buf[len] ='\0' ; -if (strict_strtoul (buf,0 , &mask)) +if (kstrtou8 (buf,0 , &mask))return -EINVAL ; common->rx_chainmask = mask;
@@ -804,7 +801,6 @@ static ssize_t write_file_regidx(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { struct ath_softc *sc = file->private_data; -unsigned long regidx;char buf[32 ];ssize_t len;
@@ -813,10 +809,8 @@ static ssize_t write_file_regidx(struct file *file, const char __user *user_buf,return -EFAULT ; buf[len] ='\0' ; -if (strict_strtoul (buf,0 , ®idx)) +if (kstrtou32 (buf,0 , &sc->debug.regidx))return -EINVAL ; - - sc->debug.regidx = regidx;return count; }
@@ -847,7 +841,7 @@ static ssize_t write_file_regval(struct file *file, const char __user *user_buf, {struct ath_softc *sc = file->private_data;struct ath_hw *ah = sc->sc_ah; -unsigned long regval; +u32 regval;char buf[32 ];ssize_t len;
@@ -856,7 +850,7 @@ static ssize_t write_file_regval(struct file *file, const char __user *user_buf,return -EFAULT ; buf[len] ='\0' ; -if (strict_strtoul (buf,0 , ®val)) +if (kstrtou32 (buf,0 , ®val))return -EINVAL ;REG_WRITE_D (ah, sc->debug.regidx, regval);
drivers/net/wireless/iwlwifi/iwl-agn.c +16 -20
@@ -1463,19 +1463,16 @@ static ssize_t store_debug_level(struct device *d, const char *buf, size_t count) {struct iwl_priv *priv =dev_get_drvdata (d); -unsigned long val;int ret; - ret =strict_strtoul (buf,0 , &val); -if (ret) + ret =kstrtou32 (buf,0 , &priv->debug_level); +if (ret) {IWL_ERR (priv,"%s is not in hex or decimal form.\n" , buf); -else { - priv->debug_level = val; -if (iwl_alloc_traffic_mem (priv)) -IWL_ERR (priv, -"Not enough memory to generate traffic log\n" ); +return ret; } -return strnlen (buf, count); +if (iwl_alloc_traffic_mem (priv)) +IWL_ERR (priv,"Not enough memory to generate traffic log\n" ); +return count; } static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO,
@@ -1514,21 +1511,20 @@ static ssize_t store_tx_power(struct device *d, const char *buf, size_t count) {struct iwl_priv *priv =dev_get_drvdata (d); -unsigned long val; +u8 val;int ret; - ret =strict_strtoul (buf,10 , &val); -if (ret) + ret =kstrtou8 (buf,10 , &val); +if (ret) {IWL_INFO (priv,"%s is not in decimal form.\n" , buf); -else { - ret =iwl_set_tx_power (priv, val, false); -if (ret) -IWL_ERR (priv,"failed setting tx power (0x%d).\n" , - ret); -else - ret = count; +return ret; } -return ret; + ret =iwl_set_tx_power (priv, val, false); +if (ret) { +IWL_ERR (priv,"failed setting tx power (0x%d).\n" , ret); +return ret; + } +return count; } static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, show_tx_power, store_tx_power);
drivers/net/wireless/iwlwifi/iwl3945-base.c +6 -9
@@ -3444,19 +3444,16 @@ static ssize_t store_debug_level(struct device *d, const char *buf, size_t count) {struct iwl_priv *priv =dev_get_drvdata (d); -unsigned long val;int ret; - ret =strict_strtoul (buf,0 , &val); -if (ret) + ret =kstrtou32 (buf,0 , &priv->debug_level); +if (ret) {IWL_INFO (priv,"%s is not in hex or decimal form.\n" , buf); -else { - priv->debug_level = val; -if (iwl_alloc_traffic_mem (priv)) -IWL_ERR (priv, -"Not enough memory to generate traffic log\n" ); +return ret; } -return strnlen (buf, count); +if (iwl_alloc_traffic_mem (priv)) +IWL_ERR (priv,"Not enough memory to generate traffic log\n" ); +return count; } static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO,
drivers/net/wireless/libertas/mesh.c +4 -3
@@ -92,14 +92,15 @@ static ssize_t lbs_prb_rsp_limit_set(struct device *dev, {struct lbs_private *priv =to_net_dev (dev)->ml_priv;struct cmd_ds_mesh_access mesh_access; +u32 retry_limit;int ret; -unsigned long retry_limit;memset (&mesh_access,0 ,sizeof (mesh_access)); mesh_access.data[0 ] =cpu_to_le32 (CMD_ACT_SET ); -if (!strict_strtoul (buf,10 , &retry_limit)) -return -ENOTSUPP ; + ret =kstrtou32 (buf,10 , &retry_limit); +if (ret <0 ) +return ret;if (retry_limit >15 )return -ENOTSUPP ;
drivers/net/wireless/rtlwifi/base.c +5 -10
@@ -901,19 +901,14 @@ static ssize_t rtl_store_debug_level(struct device *d, {struct ieee80211_hw *hw =dev_get_drvdata (d);struct rtl_priv *rtlpriv =rtl_priv (hw); -unsigned long val;int ret; - ret =strict_strtoul (buf,0 , &val); -if (ret) { -printk (KERN_DEBUG "%s is not in hex or decimal form.\n" , buf); - }else { - rtlpriv->dbg.global_debuglevel = val; -printk (KERN_DEBUG "debuglevel:%x\n" , + ret =kstrtou32 (buf,0 , &rtlpriv->dbg.global_debuglevel); +if (ret <0 ) +return ret; +printk (KERN_DEBUG "debuglevel:%x\n" , rtlpriv->dbg.global_debuglevel); - } - -return strnlen (buf, count); +return count; } static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO,
drivers/net/wireless/wl12xx/debugfs.c +5 -10
@@ -261,27 +261,22 @@ static ssize_t gpio_power_write(struct file *file,unsigned long value;int ret; -mutex_lock (&wl->mutex); - len =min (count,sizeof (buf) -1 ); -if (copy_from_user (buf, user_buf, len)) { - ret = -EFAULT ; - goto out; - } +if (copy_from_user (buf, user_buf, len)) +return -EFAULT ; buf[len] ='\0' ; - ret =strict_strtoul (buf,0 , &value); + ret =kstrtoul (buf,0 , &value);if (ret <0 ) {wl1271_warning ("illegal value in gpio_power" ); - goto out; +return ret; } +mutex_lock (&wl->mutex);if (value)wl1271_power_on (wl);else wl1271_power_off (wl); - -out:mutex_unlock (&wl->mutex);return count; }
drivers/net/wireless/wl12xx/main.c +2 -4
@@ -2543,17 +2543,15 @@ static ssize_t wl1271_sysfs_store_bt_coex_state(struct device *dev,unsigned long res;int ret; - ret =strict_strtoul (buf,10 , &res); - + ret =kstrtoul (buf,10 , &res);if (ret <0 ) {wl1271_warning ("incorrect value written to bt_coex_mode" );return count; } + res = !!res;mutex_lock (&wl->mutex); - res = !!res; -if (res == wl->sg_enabled) goto out;
Signature · 1 line
1.7.3.4
PATCH 34/52 kstrtox: convert drivers/power/
In reply to Alexey Dobriyan--- drivers/power/pcf50633-charger.c | 4 ++-- drivers/power/power_supply_sysfs.c | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-)
drivers/power/pcf50633-charger.c +2 -2
@@ -191,7 +191,7 @@ static ssize_t set_usblim(struct device *dev,unsigned long ma;int ret; - ret =strict_strtoul (buf,10 , &ma); + ret =kstrtoul (buf,10 , &ma);if (ret)return -EINVAL ;
@@ -228,7 +228,7 @@ static ssize_t set_chglim(struct device *dev,if (!mbc->pcf->pdata->charger_reference_current_ma)return -ENODEV ; - ret =strict_strtoul (buf,10 , &ma); + ret =kstrtoul (buf,10 , &ma);if (ret)return -EINVAL ;
drivers/power/power_supply_sysfs.c +1 -5
@@ -107,15 +107,11 @@ static ssize_t power_supply_store_property(struct device *dev,struct power_supply *psy =dev_get_drvdata (dev);const ptrdiff_t off = attr - power_supply_attrs;union power_supply_propval value; -long long_val;/* TODO: support other types than int */ - ret =strict_strtol (buf,10 , &long_val); + ret =kstrtoint (buf,10 , &value.intval);if (ret <0 )return ret; - - value.intval = long_val; - ret = psy->set_property (psy, off, &value);if (ret <0 )return ret;
Signature · 1 line
1.7.3.4
PATCH 35/52 kstrtox: convert drivers/regulator/
In reply to Alexey Dobriyan--- drivers/regulator/virtual.c | 32 ++++++++++++++++++++------------ 1 files changed, 20 insertions(+), 12 deletions(-)
drivers/regulator/virtual.c +20 -12
@@ -118,10 +118,12 @@ static ssize_t set_min_uV(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) {struct virtual_consumer_data *data =dev_get_drvdata (dev); -long val; +int val; +int rv; -if (strict_strtol (buf,10 , &val) !=0 ) -return count; + rv =kstrtoint (buf,10 , &val); +if (rv <0 ) +return rv;mutex_lock (&data->lock);
@@ -144,10 +146,12 @@ static ssize_t set_max_uV(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) {struct virtual_consumer_data *data =dev_get_drvdata (dev); -long val; +int val; +int rv; -if (strict_strtol (buf,10 , &val) !=0 ) -return count; + rv =kstrtoint (buf,10 , &val); +if (rv <0 ) +return rv;mutex_lock (&data->lock);
@@ -170,10 +174,12 @@ static ssize_t set_min_uA(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) {struct virtual_consumer_data *data =dev_get_drvdata (dev); -long val; +int val; +int rv; -if (strict_strtol (buf,10 , &val) !=0 ) -return count; + rv =kstrtoint (buf,10 , &val); +if (rv <0 ) +return rv;mutex_lock (&data->lock);
@@ -196,10 +202,12 @@ static ssize_t set_max_uA(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) {struct virtual_consumer_data *data =dev_get_drvdata (dev); -long val; +int val; +int rv; -if (strict_strtol (buf,10 , &val) !=0 ) -return count; + rv =kstrtoint (buf,10 , &val); +if (rv <0 ) +return rv;mutex_lock (&data->lock);
Signature · 1 line
1.7.3.4
PATCH 37/52 kstrtox: convert drivers/scsi/
In reply to Alexey Dobriyan--- drivers/scsi/pmcraid.c | 2 +- drivers/scsi/scsi_sysfs.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/scsi/pmcraid.c +1 -1
@@ -4213,7 +4213,7 @@ static ssize_t pmcraid_store_log_level(struct pmcraid_instance *pinstance;unsigned long val; -if (strict_strtoul (buf,10 , &val)) +if (kstrtoul (buf,10 , &val))return -EINVAL ;/* log-level should be from 0 to 2 */ if (val >2 )
drivers/scsi/scsi_sysfs.c +5 -4
@@ -757,11 +757,12 @@ sdev_store_queue_ramp_up_period(struct device *dev, const char *buf, size_t count) {struct scsi_device *sdev =to_scsi_device (dev); -unsigned long period; - -if (strict_strtoul (buf,10 , &period)) -return -EINVAL ; +unsigned int period; +int rv; + rv =kstrtouint (buf,10 , &period); +if (rv <0 ) +return rv; sdev->queue_ramp_up_period =msecs_to_jiffies (period);return period; }
Signature · 1 line
1.7.3.4
PATCH 38/52 kstrtox: convert drivers/ssb/
In reply to Alexey Dobriyan--- drivers/ssb/sprom.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
drivers/ssb/sprom.c +4 -3
@@ -38,7 +38,6 @@ static int hex2sprom(u16 *sprom, const char *dump, size_t len, {char c, tmp[5 ] = {0 };int err, cnt =0 ; -unsigned long parsed;/* Strip whitespace at the end. */ while (len) {
@@ -52,12 +51,14 @@ static int hex2sprom(u16 *sprom, const char *dump, size_t len,return -EINVAL ;while (cnt < sprom_size_words) { +u16 parsed; +memcpy (tmp, dump,4 ); dump +=4 ; - err =strict_strtoul (tmp,16 , &parsed); + err =kstrtou16 (tmp,16 , &parsed);if (err)return err; - sprom[cnt++] =swab16 ((u16 )parsed); + sprom[cnt++] =swab16 (parsed); }return 0 ;
Signature · 1 line
1.7.3.4
PATCH 39/52 kstrtox: convert drivers/target/
In reply to Alexey Dobriyan--- drivers/target/target_core_alua.c | 28 ++++---- drivers/target/target_core_configfs.c | 102 ++++++++------------------ drivers/target/target_core_fabric_configfs.c | 13 ++-- drivers/target/target_core_file.c | 7 +- 4 files changed, 53 insertions(+), 97 deletions(-)
drivers/target/target_core_alua.c +14 -14
@@ -1714,10 +1714,10 @@ ssize_t core_alua_store_access_type(unsigned long tmp;int ret; - ret =strict_strtoul (page,0 , &tmp); + ret =kstrtoul (page,0 , &tmp);if (ret <0 ) {printk (KERN_ERR "Unable to extract alua_access_type\n" ); -return -EINVAL ; +return ret; }if ((tmp !=0 ) && (tmp !=1 ) && (tmp !=2 ) && (tmp !=3 )) { printk(KERN_ERR "Illegal value for alua_access_type:"
@@ -1752,10 +1752,10 @@ ssize_t core_alua_store_nonop_delay_msecs(unsigned long tmp;int ret; - ret =strict_strtoul (page,0 , &tmp); + ret =kstrtoul (page,0 , &tmp);if (ret <0 ) {printk (KERN_ERR "Unable to extract nonop_delay_msecs\n" ); -return -EINVAL ; +return ret; }if (tmp >ALUA_MAX_NONOP_DELAY_MSECS ) { printk(KERN_ERR "Passed nonop_delay_msecs: %lu, exceeds"
@@ -1783,10 +1783,10 @@ ssize_t core_alua_store_trans_delay_msecs(unsigned long tmp;int ret; - ret =strict_strtoul (page,0 , &tmp); + ret =kstrtoul (page,0 , &tmp);if (ret <0 ) {printk (KERN_ERR "Unable to extract trans_delay_msecs\n" ); -return -EINVAL ; +return ret; }if (tmp >ALUA_MAX_TRANS_DELAY_MSECS ) { printk(KERN_ERR "Passed trans_delay_msecs: %lu, exceeds"
@@ -1814,10 +1814,10 @@ ssize_t core_alua_store_preferred_bit(unsigned long tmp;int ret; - ret =strict_strtoul (page,0 , &tmp); + ret =kstrtoul (page,0 , &tmp);if (ret <0 ) {printk (KERN_ERR "Unable to extract preferred ALUA value\n" ); -return -EINVAL ; +return ret; }if ((tmp !=0 ) && (tmp !=1 )) {printk (KERN_ERR "Illegal value for preferred ALUA: %lu\n" , tmp);
@@ -1849,10 +1849,10 @@ ssize_t core_alua_store_offline_bit(if (!(lun->lun_sep))return -ENODEV ; - ret =strict_strtoul (page,0 , &tmp); + ret =kstrtoul (page,0 , &tmp);if (ret <0 ) {printk (KERN_ERR "Unable to extract alua_tg_pt_offline value\n" ); -return -EINVAL ; +return ret; }if ((tmp !=0 ) && (tmp !=1 )) { printk(KERN_ERR "Illegal value for alua_tg_pt_offline: %lu\n",
@@ -1888,10 +1888,10 @@ ssize_t core_alua_store_secondary_status(unsigned long tmp;int ret; - ret =strict_strtoul (page,0 , &tmp); + ret =kstrtoul (page,0 , &tmp);if (ret <0 ) {printk (KERN_ERR "Unable to extract alua_tg_pt_status\n" ); -return -EINVAL ; +return ret; } if ((tmp != ALUA_STATUS_NONE) && (tmp != ALUA_STATUS_ALTERED_BY_EXPLICT_STPG) &&
@@ -1921,10 +1921,10 @@ ssize_t core_alua_store_secondary_write_metadata(unsigned long tmp;int ret; - ret =strict_strtoul (page,0 , &tmp); + ret =kstrtoul (page,0 , &tmp);if (ret <0 ) {printk (KERN_ERR "Unable to extract alua_tg_pt_write_md\n" ); -return -EINVAL ; +return ret; }if ((tmp !=0 ) && (tmp !=1 )) { printk(KERN_ERR "Illegal value for alua_tg_pt_write_md:"
drivers/target/target_core_configfs.c +31 -71
195 lines not on this page · raw message
drivers/target/target_core_fabric_configfs.c +6 -7
@@ -190,7 +190,7 @@ static ssize_t target_fabric_mappedlun_store_write_protect(struct se_portal_group *se_tpg = se_nacl->se_tpg;unsigned long op; -if (strict_strtoul (page,0 , &op)) +if (kstrtoul (page,0 , &op))return -EINVAL ;if ((op !=1 ) && (op !=0 ))
@@ -285,7 +285,7 @@ static struct config_group *target_fabric_make_mappedlun(struct se_lun_acl *lacl;struct config_item *acl_ci;char *buf; -unsigned long mapped_lun; +unsigned int mapped_lun;int ret =0 ; acl_ci = &group->cg_item;
@@ -313,10 +313,9 @@ static struct config_group *target_fabric_make_mappedlun(* Determine the Mapped LUN value. This is what the SCSI Initiator * Port will actually see. */ -if (strict_strtoul (buf +4 ,0 , &mapped_lun) || mapped_lun >UINT_MAX ) { - ret = -EINVAL ; + ret =kstrtouint (buf +4 ,0 , &mapped_lun); +if (ret <0 ) goto out; - } lacl =core_dev_init_initiator_node_lun_acl (se_tpg, mapped_lun,config_item_name (acl_ci), &ret);
@@ -746,14 +745,14 @@ static struct config_group *target_fabric_make_lun(struct se_portal_group *se_tpg =container_of (group, struct se_portal_group, tpg_lun_group);struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf; -unsigned long unpacked_lun; +u32 unpacked_lun;if (strstr (name,"lun_" ) != name) {printk (KERN_ERR "Unable to locate \'_\" in" " \"lun_$LUN_NUMBER\"\n" );return ERR_PTR (-EINVAL ); } -if (strict_strtoul (name +4 ,0 , &unpacked_lun) || unpacked_lun >UINT_MAX ) +if (kstrtou32 (name +4 ,0 , &unpacked_lun))return ERR_PTR (-EINVAL ); lun =core_get_lun_from_tpg (se_tpg, unpacked_lun);
drivers/target/target_core_file.c +2 -5
@@ -545,12 +545,9 @@ static ssize_t fd_set_configfs_dev_params(break ;case Opt_fd_dev_size: arg_p =match_strdup (&args[0 ]); - ret =strict_strtoull (arg_p,0 , &fd_dev->fd_dev_size); -if (ret <0 ) { -printk (KERN_ERR "strict_strtoull() failed for" -" fd_dev_size=\n" ); + ret =kstrtoull (arg_p,0 , &fd_dev->fd_dev_size); +if (ret <0 ) goto out; - }printk (KERN_INFO "FILEIO: Referencing Size: %llu" " bytes\n" , fd_dev->fd_dev_size); fd_dev->fbd_flags |=FBDF_HAS_SIZE ;
Signature · 1 line
1.7.3.4
PATCH 41/52 kstrtox: convert drivers/video/
In reply to Alexey Dobriyan--- drivers/video/backlight/adp5520_bl.c | 13 +- drivers/video/backlight/adp8860_bl.c | 12 +- drivers/video/backlight/backlight.c | 4 +- drivers/video/backlight/s6e63m0.c | 2 +- drivers/video/fsl-diu-fb.c | 36 +++-- .../video/omap2/displays/panel-tpo-td043mtea1.c | 10 +- drivers/video/omap2/dss/display.c | 16 +- drivers/video/via/viafbdev.c | 155 ++++++++++++-------- drivers/video/wm8505fb.c | 2 +- 9 files changed, 152 insertions(+), 98 deletions(-)
drivers/video/backlight/adp5520_bl.c +8 -5
@@ -18,7 +18,7 @@ struct adp5520_bl {struct device *master;struct adp5520_backlight_platform_data *pdata;struct mutex lock; -unsigned long cached_daylight_max; +u8 cached_daylight_max;int id;int current_brightness; };
@@ -156,11 +156,11 @@ static ssize_t adp5520_store(struct device *dev, const char *buf, size_t count, int reg) {struct adp5520_bl *data =dev_get_drvdata (dev); -unsigned long val; +u8 val;int ret; - ret =strict_strtoul (buf,10 , &val); -if (ret) + ret =kstrtou8 (buf,10 , &val); +if (ret <0 )return ret;mutex_lock (&data->lock);
@@ -211,8 +211,11 @@ static ssize_t adp5520_bl_daylight_max_store(struct device *dev, const char *buf, size_t count) {struct adp5520_bl *data =dev_get_drvdata (dev); +int rv; -strict_strtoul (buf,10 , &data->cached_daylight_max); + rv =kstrtou8 (buf,10 , &data->cached_daylight_max); +if (rv <0 ) +return rv;return adp5520_store (dev, buf, count,ADP5520_DAYLIGHT_MAX ); } static DEVICE_ATTR(daylight_max, 0664, adp5520_bl_daylight_max_show,
drivers/video/backlight/adp8860_bl.c +7 -5
@@ -110,7 +110,7 @@ struct adp8860_bl {struct adp8860_led *led;struct adp8860_backlight_platform_data *pdata;struct mutex lock; -unsigned long cached_daylight_max; +u8 cached_daylight_max;int id;int revid;int current_brightness;
@@ -449,10 +449,10 @@ static ssize_t adp8860_store(struct device *dev, const char *buf, size_t count, int reg) {struct adp8860_bl *data =dev_get_drvdata (dev); -unsigned long val; +u8 val;int ret; - ret =strict_strtoul (buf,10 , &val); + ret =kstrtou8 (buf,10 , &val);if (ret)return ret;
@@ -502,7 +502,9 @@ static ssize_t adp8860_bl_l1_daylight_max_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct adp8860_bl *data = dev_get_drvdata(dev); -int ret =strict_strtoul (buf,10 , &data->cached_daylight_max); +int ret; + + ret =kstrtou8 (buf,10 , &data->cached_daylight_max);if (ret)return ret;
@@ -609,7 +611,7 @@ static ssize_t adp8860_bl_ambient_light_zone_store(struct device *dev,uint8_t reg_val;int ret; - ret =strict_strtoul (buf,10 , &val); + ret =kstrtoul (buf,10 , &val);if (ret)return ret;
drivers/video/backlight/backlight.c +2 -2
@@ -110,7 +110,7 @@ static ssize_t backlight_store_power(struct device *dev,struct backlight_device *bd =to_backlight_device (dev);unsigned long power; - rc =strict_strtoul (buf,0 , &power); + rc =kstrtoul (buf,0 , &power);if (rc)return rc;
@@ -144,7 +144,7 @@ static ssize_t backlight_store_brightness(struct device *dev,struct backlight_device *bd =to_backlight_device (dev);unsigned long brightness; - rc =strict_strtoul (buf,0 , &brightness); + rc =kstrtoul (buf,0 , &brightness);if (rc)return rc;
drivers/video/backlight/s6e63m0.c +1 -1
@@ -689,7 +689,7 @@ static ssize_t s6e63m0_sysfs_store_gamma_mode(struct device *dev,struct backlight_device *bd =NULL ;int brightness, rc; - rc =strict_strtoul (buf,0 , (unsigned long *)&lcd->gamma_mode); + rc =kstrtouint (buf,0 , &lcd->gamma_mode);if (rc <0 )return rc;
drivers/video/fsl-diu-fb.c +24 -12
@@ -182,7 +182,7 @@ static struct fb_videomode __devinitdata fsl_diu_mode_db[] = { };static char *fb_mode ="1024x768-32@60" ; -static unsigned long default_bpp =32 ; +static unsigned int default_bpp =32 ;static int monitor_port;#if defined(CONFIG_NOT_COHERENT_CACHE )
@@ -1455,13 +1455,15 @@ static void free_buf(struct device *dev, struct diu_addr *buf, u32 size,static ssize_t store_monitor (struct device *device,struct device_attribute *attr,const char *buf,size_t count) { -int old_monitor_port; -unsigned long val;struct fsl_diu_data *machine_data = container_of(attr, struct fsl_diu_data, dev_attr); +int old_monitor_port; +int val; +int rv; -if (strict_strtoul (buf,10 , &val)) -return 0 ; + rv =kstrtoint (buf,10 , &val); +if (rv <0 ) +return rv; old_monitor_port = machine_data->monitor_port; machine_data->monitor_port = diu_ops.set_sysfs_monitor_port (val);
@@ -1700,20 +1702,28 @@ static int fsl_diu_remove(struct platform_device *ofdev)static int __init fsl_diu_setup (char *options) {char *opt; -unsigned long val;if (!options || !*options)return 0 ;while ((opt =strsep (&options,"," )) !=NULL ) { +int rv; +if (!*opt)continue ;if (!strncmp (opt,"monitor=" ,8 )) { -if (!strict_strtoul (opt +8 ,10 , &val) && (val <=2 )) - monitor_port = val; +int val; + + rv =kstrtoint (opt +8 ,10 , &val); +if (rv <0 ) +return rv; +if (val <0 || val >2 ) +return -EINVAL ; + monitor_port = val; }else if (!strncmp (opt,"bpp=" ,4 )) { -if (!strict_strtoul (opt +4 ,10 , &val)) - default_bpp = val; + rv =kstrtouint (opt +4 ,10 , &default_bpp); +if (rv <0 ) +return rv; }else fb_mode = opt; }
@@ -1762,7 +1772,9 @@ static int __init fsl_diu_init(void)*/ if (fb_get_options ("fslfb" , &option))return -ENODEV ; -fsl_diu_setup (option); + ret =fsl_diu_setup (option); +if (ret <0 ) +return ret;#endif printk (KERN_INFO "Freescale DIU driver\n" );
@@ -1827,7 +1839,7 @@ MODULE_LICENSE("GPL");module_param_named (mode, fb_mode, charp,0 );MODULE_PARM_DESC (mode,"Specify resolution as \"<xres>x<yres>[-<bpp>][@<refresh>]\" " ); -module_param_named (bpp, default_bpp, ulong,0 ); +module_param_named (bpp, default_bpp, uint,0 );MODULE_PARM_DESC (bpp,"Specify bit-per-pixel if not specified mode" );module_param_named (monitor, monitor_port, int,0 ); MODULE_PARM_DESC(monitor,
drivers/video/omap2/displays/panel-tpo-td043mtea1.c +6 -4
@@ -147,7 +147,7 @@ static ssize_t tpo_td043_vmirror_store(struct device *dev,long val;int ret; - ret =strict_strtol (buf,0 , &val); + ret =kstrtol (buf,0 , &val);if (ret <0 )return ret;
@@ -172,11 +172,13 @@ static ssize_t tpo_td043_mode_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct tpo_td043_device *tpo_td043 = dev_get_drvdata(dev); -long val; +u8 val;int ret; - ret =strict_strtol (buf,0 , &val); -if (ret !=0 || val & ~7 ) + ret =kstrtou8 (buf,0 , &val); +if (ret <0 ) +return ret; +if (val & ~7 )return -EINVAL ; tpo_td043->mode = val;
drivers/video/omap2/dss/display.c +8 -8
@@ -262,21 +262,21 @@ static ssize_t display_wss_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { struct omap_dss_device *dssdev = to_dss_device(dev); -unsigned long wss; -int r; +u32 wss; +int rv;if (!dssdev->driver->get_wss || !dssdev->driver->set_wss)return -ENOENT ; -if (strict_strtoul (buf,0 , &wss)) -return -EINVAL ; - + rv =kstrtou32 (buf,0 , &wss); +if (rv <0 ) +return rv;if (wss >0xfffff )return -EINVAL ; - r = dssdev->driver->set_wss (dssdev, wss); -if (r) -return r; + rv = dssdev->driver->set_wss (dssdev, wss); +if (rv) +return rv;return size; }
drivers/video/via/viafbdev.c +95 -60
244 lines not on this page · raw message
drivers/video/wm8505fb.c +1 -1
@@ -154,7 +154,7 @@ static ssize_t contrast_store(struct device *dev,struct wm8505fb_info *fbi =to_wm8505fb_info (info);unsigned long tmp; -if (strict_strtoul (buf,10 , &tmp) || (tmp >0xff )) +if (kstrtoul (buf,10 , &tmp) || (tmp >0xff ))return -EINVAL ; fbi->contrast = tmp;
Signature · 1 line
1.7.3.4
PATCH 40/52 kstrtox: convert drivers/usb/
In reply to Alexey Dobriyan--- drivers/usb/gadget/storage_common.c | 7 ++++--- drivers/usb/host/ehci-dbg.c | 6 +++--- drivers/usb/serial/iuu_phoenix.c | 27 ++++++++++----------------- 3 files changed, 17 insertions(+), 23 deletions(-)
drivers/usb/gadget/storage_common.c +4 -3
@@ -713,8 +713,9 @@ static ssize_t fsg_store_ro(struct device *dev, struct device_attribute *attr,struct rw_semaphore *filesem =dev_get_drvdata (dev);unsigned long ro; -if (strict_strtoul (buf,2 , &ro)) -return -EINVAL ; + rc =kstrtoul (buf,2 , &ro); +if (rc <0 ) +return rc;/* * Allow the write-enable status to change only while the
@@ -740,7 +741,7 @@ static ssize_t fsg_store_nofua(struct device *dev,struct fsg_lun *curlun =fsg_lun_from_dev (dev);unsigned long nofua; -if (strict_strtoul (buf,2 , &nofua)) +if (kstrtoul (buf,2 , &nofua))return -EINVAL ;/* Sync data when switching from async mode to sync */
drivers/usb/host/ehci-dbg.c +3 -3
@@ -1000,7 +1000,7 @@ static ssize_t debug_lpm_write(struct file *file, const char __user *user_buf, buf[len -1 ] ='\0' ;if (strncmp (buf,"enable" ,5 ) ==0 ) { -if (strict_strtoul (buf +7 ,10 , &port)) +if (kstrtoul (buf +7 ,10 , &port))return -EINVAL ; params =ehci_readl (ehci, &ehci->caps->hcs_params);if (port >HCS_N_PORTS (params)) {
@@ -1018,7 +1018,7 @@ static ssize_t debug_lpm_write(struct file *file, const char __user *user_buf,printk (KERN_INFO "force enable LPM for port %lu\n" , port); }else if (strncmp (buf,"hird=" ,5 ) ==0 ) {unsigned long hird; -if (strict_strtoul (buf +5 ,16 , &hird)) +if (kstrtoul (buf +5 ,16 , &hird))return -EINVAL ;printk (KERN_INFO "setting hird %s %lu\n" , buf +6 , hird); temp =ehci_readl (ehci, &ehci->regs->command);
@@ -1026,7 +1026,7 @@ static ssize_t debug_lpm_write(struct file *file, const char __user *user_buf, temp |= hird <<24 ;ehci_writel (ehci, temp, &ehci->regs->command); }else if (strncmp (buf,"disable" ,7 ) ==0 ) { -if (strict_strtoul (buf +8 ,10 , &port)) +if (kstrtoul (buf +8 ,10 , &port))return -EINVAL ; params =ehci_readl (ehci, &ehci->caps->hcs_params);if (port >HCS_N_PORTS (params)) {
drivers/usb/serial/iuu_phoenix.c +10 -17
@@ -1227,23 +1227,16 @@ static ssize_t store_vcc_mode(struct device *dev, {struct usb_serial_port *port =to_usb_serial_port (dev);struct iuu_private *priv =usb_get_serial_port_data (port); -unsigned long v; - -if (strict_strtoul (buf,10 , &v)) { -dev_err (dev,"%s - vcc_mode: %s is not a unsigned long\n" , - __func__, buf); - goto fail_store_vcc_mode; - } - -dbg ("%s: setting vcc_mode = %ld" , __func__, v); - -if ((v !=3 ) && (v !=5 )) { -dev_err (dev,"%s - vcc_mode %ld is invalid\n" , __func__, v); - }else { -iuu_vcc_set (port, v); - priv->vcc = v; - } -fail_store_vcc_mode: +int v; +int rv; + + rv =kstrtoint (buf,10 , &v); +if (rv <0 ) +return rv; +if (v !=3 && v !=5 ) +return -EINVAL ; +iuu_vcc_set (port, v); + priv->vcc = v;return count; }
Signature · 1 line
1.7.3.4
PATCH 42/52 kstrtox: convert drivers/w1/
In reply to Alexey Dobriyan--- drivers/w1/w1.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/w1/w1.c +4 -4
@@ -233,10 +233,10 @@ static ssize_t w1_master_attribute_store_search(struct device * dev,struct device_attribute *attr, const char * buf, size_t count) { - long tmp; struct w1_master *md = dev_to_w1_master(dev); +int tmp; -if (strict_strtol (buf,0 , &tmp) == -EINVAL ) +if (kstrtoint (buf,0 , &tmp) <0 )return -EINVAL ;mutex_lock (&md->mutex);
@@ -265,10 +265,10 @@ static ssize_t w1_master_attribute_store_pullup(struct device *dev,struct device_attribute *attr, const char *buf, size_t count) { - long tmp; struct w1_master *md = dev_to_w1_master(dev); +int tmp; -if (strict_strtol (buf,0 , &tmp) == -EINVAL ) +if (kstrtoint (buf,0 , &tmp) <0 )return -EINVAL ;mutex_lock (&md->mutex);
Signature · 1 line
1.7.3.4
PATCH 44/52 kstrtox: convert net/
In reply to Alexey Dobriyan--- net/batman-adv/bat_sysfs.c | 69 ++++++++++++++++++++------------------- net/batman-adv/gateway_common.c | 4 +- net/bluetooth/hci_sysfs.c | 16 ++++---- net/dns_resolver/dns_key.c | 5 ++- net/mac80211/debugfs.c | 10 ++--- net/rfkill/core.c | 11 +++--- net/sunrpc/addr.c | 18 ++++------ net/sunrpc/auth.c | 6 ++-- net/sunrpc/xprtsock.c | 8 +++-- 9 files changed, 72 insertions(+), 75 deletions(-)
net/batman-adv/bat_sysfs.c +35 -34
@@ -150,36 +150,36 @@ static int store_uint_attr(char *buff, size_t count, struct net_device *net_dev, char *attr_name, unsigned int min, unsigned int max, atomic_t *attr) { - unsigned long uint_val; + unsigned int val;int ret; - ret =strict_strtoul (buff,10 , &uint_val); -if (ret) { + ret =kstrtouint (buff,10 , &val); +if (ret <0 ) {bat_info (net_dev,"%s: Invalid parameter received: %s\n" , attr_name, buff); -return -EINVAL ; +return ret; } -if (uint_val < min) { -bat_info (net_dev,"%s: Value is too small: %lu min: %u\n" , - attr_name, uint_val, min); +if (val < min) { +bat_info (net_dev,"%s: Value is too small: %u min: %u\n" , + attr_name, val, min);return -EINVAL ; } -if (uint_val > max) { -bat_info (net_dev,"%s: Value is too big: %lu max: %u\n" , - attr_name, uint_val, max); +if (val > max) { +bat_info (net_dev,"%s: Value is too big: %u max: %u\n" , + attr_name, val, max);return -EINVAL ; } -if (atomic_read (attr) == uint_val) +if (atomic_read (attr) == val)return count; -bat_info (net_dev,"%s: Changing from: %i to: %lu\n" , - attr_name,atomic_read (attr), uint_val); +bat_info (net_dev,"%s: Changing from: %i to: %u\n" , + attr_name,atomic_read (attr), val); -atomic_set (attr, uint_val); +atomic_set (attr, val);return count; }
@@ -211,32 +211,33 @@ static ssize_t show_vis_mode(struct kobject *kobj, struct attribute *attr, }static ssize_t store_vis_mode (struct kobject *kobj,struct attribute *attr, -char *buff,size_t count) +char *buf,size_t count) {struct net_device *net_dev =kobj_to_netdev (kobj);struct bat_priv *bat_priv =netdev_priv (net_dev); -unsigned long val; -int ret, vis_mode_tmp =-1 ; +unsigned int vis_mode_tmp; - ret =strict_strtoul (buff,10 , &val); +if (count >0 && buf[count -1 ] =='\n' ) + buf[count -1 ] ='\0' ; -if (((count ==2 ) && (!ret) && (val ==VIS_TYPE_CLIENT_UPDATE )) || - (strncmp (buff,"client" ,6 ) ==0 ) || - (strncmp (buff,"off" ,3 ) ==0 )) +if (strcmp (buf,"client" ) ==0 ||strcmp (buf,"off" ) ==0 ) vis_mode_tmp =VIS_TYPE_CLIENT_UPDATE ; - -if (((count ==2 ) && (!ret) && (val ==VIS_TYPE_SERVER_SYNC )) || - (strncmp (buff,"server" ,6 ) ==0 )) +else if (strcmp (buf,"server" ) ==0 ) vis_mode_tmp =VIS_TYPE_SERVER_SYNC ; - -if (vis_mode_tmp <0 ) { -if (buff[count -1 ] =='\n' ) - buff[count -1 ] ='\0' ; - -bat_info (net_dev, -"Invalid parameter for 'vis mode' setting received: " -"%s\n" , buff); -return -EINVAL ; +else { +unsigned int val; +int rv; + + rv =kstrtoint (buf,10 , &val); +if (rv <0 ) +return rv; +switch (val) { +case VIS_TYPE_CLIENT_UPDATE : +case VIS_TYPE_SERVER_SYNC : + vis_mode_tmp = val; +default : +return -EINVAL ; + } }if (atomic_read (&bat_priv->vis_mode) == vis_mode_tmp)
@@ -247,7 +248,7 @@ static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr, "client" : "server", vis_mode_tmp == VIS_TYPE_CLIENT_UPDATE ? "client" : "server"); -atomic_set (&bat_priv->vis_mode, (unsigned )vis_mode_tmp); +atomic_set (&bat_priv->vis_mode, vis_mode_tmp);return count; }
net/batman-adv/gateway_common.c +2 -2
@@ -96,7 +96,7 @@ static bool parse_gw_bandwidth(struct net_device *net_dev, char *buff, *tmp_ptr ='\0' ; } - ret =strict_strtoul (buff,10 , down); + ret =kstrtoul (buff,10 , down);if (ret) { bat_err(net_dev, "Download speed of gateway mode invalid: %s\n",
@@ -121,7 +121,7 @@ static bool parse_gw_bandwidth(struct net_device *net_dev, char *buff, *tmp_ptr ='\0' ; } - ret =strict_strtoul (slash_ptr +1 ,10 , up); + ret =kstrtoul (slash_ptr +1 ,10 , up);if (ret) {bat_err (net_dev, "Upload speed of gateway mode invalid: "
net/bluetooth/hci_sysfs.c +8 -8
@@ -277,9 +277,9 @@ static ssize_t show_idle_timeout(struct device *dev, struct device_attribute *atstatic ssize_t store_idle_timeout (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) {struct hci_dev *hdev =dev_get_drvdata (dev); -unsigned long val; +u32 val; -if (strict_strtoul (buf,0 , &val) <0 ) +if (kstrtou32 (buf,0 , &val) <0 )return -EINVAL ;if (val !=0 && (val <500 || val >3600000 ))
@@ -299,12 +299,12 @@ static ssize_t show_sniff_max_interval(struct device *dev, struct device_attribustatic ssize_t store_sniff_max_interval (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) {struct hci_dev *hdev =dev_get_drvdata (dev); -unsigned long val; +u16 val; -if (strict_strtoul (buf,0 , &val) <0 ) +if (kstrtou16 (buf,0 , &val) <0 )return -EINVAL ; -if (val <0x0002 || val >0xFFFE || val %2 ) +if (val ==0 || val %2 )return -EINVAL ;if (val < hdev->sniff_min_interval)
@@ -324,12 +324,12 @@ static ssize_t show_sniff_min_interval(struct device *dev, struct device_attribustatic ssize_t store_sniff_min_interval (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) {struct hci_dev *hdev =dev_get_drvdata (dev); -unsigned long val; +u16 val; -if (strict_strtoul (buf,0 , &val) <0 ) +if (kstrtou16 (buf,0 , &val) <0 )return -EINVAL ; -if (val <0x0002 || val >0xFFFE || val %2 ) +if (val ==0 || val %2 )return -EINVAL ;if (val > hdev->sniff_max_interval)
net/dns_resolver/dns_key.c +3 -2
@@ -62,7 +62,6 @@ static int dns_resolver_instantiate(struct key *key, const void *_data, size_t datalen) { struct user_key_payload *upayload; -unsigned long derrno;int ret;size_t result_len =0 ;const char *data = _data, *end, *opt;
@@ -113,11 +112,13 @@ dns_resolver_instantiate(struct key *key, const void *_data, size_t datalen)* that's to be recorded as the result in this key */ if (opt_nlen ==sizeof (DNS_ERRORNO_OPTION ) -1 &&memcmp (opt,DNS_ERRORNO_OPTION , opt_nlen) ==0 ) { +unsigned long derrno; +kdebug ("dns error number option" );if (opt_vlen <=0 ) goto bad_option_value; - ret =strict_strtoul (eq,10 , &derrno); + ret =kstrtoul (eq,10 , &derrno);if (ret <0 ) goto bad_option_value;
net/mac80211/debugfs.c +4 -6
@@ -186,7 +186,7 @@ static ssize_t uapsd_queues_write(struct file *file, size_t count, loff_t *ppos) { struct ieee80211_local *local = file->private_data; -unsigned long val; +unsigned int val;char buf[10 ];size_t len;int ret;
@@ -196,8 +196,7 @@ static ssize_t uapsd_queues_write(struct file *file,return -EFAULT ; buf[len] ='\0' ; - ret =strict_strtoul (buf,0 , &val); - + ret =kstrtouint (buf,0 , &val);if (ret)return -EINVAL ;
@@ -230,7 +229,7 @@ static ssize_t uapsd_max_sp_len_write(struct file *file, size_t count, loff_t *ppos) { struct ieee80211_local *local = file->private_data; -unsigned long val; +unsigned int val;char buf[10 ];size_t len;int ret;
@@ -240,8 +239,7 @@ static ssize_t uapsd_max_sp_len_write(struct file *file,return -EFAULT ; buf[len] ='\0' ; - ret =strict_strtoul (buf,0 , &val); - + ret =kstrtouint (buf,0 , &val);if (ret)return -EINVAL ;
net/rfkill/core.c +5 -6
@@ -638,17 +638,16 @@ static ssize_t rfkill_soft_store(struct device *dev, const char *buf, size_t count) { struct rfkill *rfkill = to_rfkill(dev); -unsigned long state; +unsigned int state;int err;if (!capable (CAP_NET_ADMIN ))return -EPERM ; - err =strict_strtoul (buf,0 , &state); + err =kstrtouint (buf,0 , &state);if (err)return err; - -if (state >1 ) +if (state >1 )return -EINVAL ;mutex_lock (&rfkill_global_mutex);
@@ -682,13 +681,13 @@ static ssize_t rfkill_state_store(struct device *dev, const char *buf, size_t count) { struct rfkill *rfkill = to_rfkill(dev); -unsigned long state; +int state;int err;if (!capable (CAP_NET_ADMIN ))return -EPERM ; - err =strict_strtoul (buf,0 , &state); + err =kstrtoint (buf,0 , &state);if (err)return err;
net/sunrpc/addr.c +7 -11
@@ -173,15 +173,15 @@ static int rpc_parse_scope_id(const char *buf, const size_t buflen, len = (buf + buflen) - delim -1 ; p =kstrndup (delim +1 , len,GFP_KERNEL );if (p) { -unsigned long scope_id =0 ;struct net_device *dev; +u32 scope_id; dev =dev_get_by_name (&init_net, p);if (dev !=NULL ) { scope_id = dev->ifindex;dev_put (dev); }else { -if (strict_strtoul (p,10 , &scope_id) ==0 ) { +if (kstrtou32 (p,10 , &scope_id) <0 ) {kfree (p);return 0 ; }
@@ -299,7 +299,7 @@ EXPORT_SYMBOL_GPL(rpc_sockaddr2uaddr);* @sap: buffer into which to plant socket address * @salen: size of buffer * -* @uaddr does not have to be '\0'-terminated, but strict_strtoul() and +* @uaddr does not have to be '\0'-terminated, but kstrto*() and * rpc_pton() require proper string termination to be successful. * * Returns the size of the socket address if successful; otherwise
@@ -309,7 +309,7 @@ size_t rpc_uaddr2sockaddr(const char *uaddr, const size_t uaddr_len, struct sockaddr *sap, const size_t salen) { char *c, buf[RPCBIND_MAXUADDRLEN + sizeof('\0')]; -unsigned long portlo, porthi; +u8 portlo, porthi;unsigned short port;if (uaddr_len >RPCBIND_MAXUADDRLEN )
@@ -321,21 +321,17 @@ size_t rpc_uaddr2sockaddr(const char *uaddr, const size_t uaddr_len, c =strrchr (buf,'.' );if (unlikely (c ==NULL ))return 0 ; -if (unlikely (strict_strtoul (c +1 ,10 , &portlo) !=0 )) -return 0 ; -if (unlikely (portlo >255 )) +if (unlikely (kstrtou8 (c +1 ,10 , &portlo) !=0 ))return 0 ; *c ='\0' ; c =strrchr (buf,'.' );if (unlikely (c ==NULL ))return 0 ; -if (unlikely (strict_strtoul (c +1 ,10 , &porthi) !=0 )) -return 0 ; -if (unlikely (porthi >255 )) +if (unlikely (kstrtou8 (c +1 ,10 , &porthi) !=0 ))return 0 ; - port = (unsigned short )((porthi <<8 ) | portlo); + port = (porthi <<8 ) | portlo; *c ='\0' ;if (rpc_pton (buf,strlen (buf), sap, salen) ==0 )
net/sunrpc/auth.c +3 -3
@@ -47,9 +47,9 @@ static int param_set_hashtbl_sz(const char *val, const struct kernel_param *kp)if (!val) goto out_inval; - ret =strict_strtoul (val,0 , &num); -if (ret == -EINVAL ) - goto out_inval; + ret =kstrtoul (val,0 , &num); +if (ret <0 ) +return ret; nbits =fls (num);if (num > (1U << nbits)) nbits++;
net/sunrpc/xprtsock.c +5 -3
@@ -2499,13 +2499,15 @@ static int param_set_uint_minmax(const char *val,const struct kernel_param *kp, unsigned int min, unsigned int max) { - unsigned long num; + unsigned int num;int ret;if (!val)return -EINVAL ; - ret =strict_strtoul (val,0 , &num); -if (ret == -EINVAL || num < min || num > max) + ret =kstrtouint (val,0 , &num); +if (ret <0 ) +return ret; +if (num < min || num > max)return -EINVAL ; *((unsigned int *)kp->arg) = num;return 0 ;
Signature · 1 line
1.7.3.4
PATCH 46/52 kstrtox: convert microblaze
In reply to Alexey Dobriyan--- arch/microblaze/kernel/traps.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/microblaze/kernel/traps.c +1 -1
@@ -27,7 +27,7 @@ static unsigned long kstack_depth_to_print; /* 0 == entire stack */static int __init kstack_setup (char *s) { -return !strict_strtoul (s,0 , &kstack_depth_to_print); +return !kstrtoul (s,0 , &kstack_depth_to_print); }__setup ("kstack=" , kstack_setup);
Signature · 1 line
1.7.3.4
PATCH 45/52 kstrtox: convert arm
In reply to Alexey DobriyanIn arch/arm/mach-omap2/board-omap3touchbook.c:
remove "tbr" parameter, it's unused.
--- arch/arm/mach-omap2/board-omap3touchbook.c | 11 ----------- arch/arm/mach-omap2/mux.c | 15 ++++++--------- arch/arm/mach-pxa/balloon3.c | 2 +- arch/arm/mach-pxa/viper.c | 3 +-- arch/arm/mach-s3c2412/mach-jive.c | 2 +- arch/arm/mach-ux500/mbox-db5500.c | 27 ++++++++------------------- arch/arm/mach-w90x900/cpu.c | 5 +++-- arch/arm/plat-omap/mcbsp.c | 4 ++-- 8 files changed, 22 insertions(+), 47 deletions(-)
arch/arm/mach-omap2/board-omap3touchbook.c +0 -11
@@ -62,8 +62,6 @@#define TB_BL_PWM_TIMER 9#define TB_KILL_POWER_GPIO 168 -static unsigned long touchbook_revision; -static struct mtd_partition omap3touchbook_nand_partitions[] = {/* All the partition sizes are listed in terms of NAND block size */ {
@@ -493,15 +491,6 @@ static void omap3_touchbook_poweroff(void)gpio_direction_output (TB_KILL_POWER_GPIO ,0 ); } -static int __init early_touchbook_revision (char *p) -{ -if (!p) -return 0 ; - -return strict_strtoul (p,10 , &touchbook_revision); -} -early_param ("tbr" , early_touchbook_revision); -static struct omap_musb_board_data musb_board_data = { .interface_type =MUSB_INTERFACE_ULPI , .mode =MUSB_OTG ,
arch/arm/mach-omap2/mux.c +6 -9
@@ -548,7 +548,7 @@ static ssize_t omap_mux_dbg_signal_write(struct file *file,char buf[OMAP_MUX_MAX_ARG_CHAR ];struct seq_file *seqf;struct omap_mux *m; -unsigned long val; +u16 val;int buf_size, ret;struct omap_mux_partition *partition;
@@ -561,13 +561,10 @@ static ssize_t omap_mux_dbg_signal_write(struct file *file,if (copy_from_user (buf, user_buf, buf_size))return -EFAULT ; - ret =strict_strtoul (buf,0x10 , &val); + ret =kstrtou16 (buf,0x10 , &val);if (ret <0 )return ret; -if (val >0xffff ) -return -EINVAL ; - seqf = file->private_data; m = seqf->private;
@@ -575,7 +572,7 @@ static ssize_t omap_mux_dbg_signal_write(struct file *file,if (!partition)return -ENODEV ; -omap_mux_write (partition, (u16 )val, m->reg_offset); +omap_mux_write (partition, val, m->reg_offset); *ppos += count;return count;
@@ -770,18 +767,18 @@ static void __init omap_mux_set_cmdline_signals(void)while ((token =strsep (&next_opt,"," )) !=NULL ) {char *keyval, *name; -unsigned long val; keyval = token; name =strsep (&keyval,"=" );if (name) { +u16 val;int res; - res =strict_strtoul (keyval,0x10 , &val); + res =kstrtou16 (keyval,0x10 , &val);if (res <0 )continue ; -omap_mux_init_signal (name, (u16 )val); +omap_mux_init_signal (name, val); } }
arch/arm/mach-pxa/balloon3.c +1 -1
@@ -91,7 +91,7 @@ int __init parse_balloon3_features(char *arg)if (!arg)return 0 ; -return strict_strtoul (arg,0 , &balloon3_features_present); +return kstrtoul (arg,0 , &balloon3_features_present); }early_param ("balloon3_features" , parse_balloon3_features);
arch/arm/mach-pxa/viper.c +1 -2
@@ -767,8 +767,7 @@ static unsigned long viper_tpm;static int __init viper_tpm_setup (char *str) { -strict_strtoul (str,10 , &viper_tpm); -return 1 ; +return !kstrtoul (str,10 , &viper_tpm); }__setup ("tpm=" , viper_tpm_setup);
arch/arm/mach-s3c2412/mach-jive.c +1 -1
@@ -240,7 +240,7 @@ static int __init jive_mtdset(char *options)if (options ==NULL || options[0 ] =='\0' )return 0 ; -if (strict_strtoul (options,10 , &set)) { +if (kstrtoul (options,10 , &set)) {printk (KERN_ERR "failed to parse mtdset=%s\n" , options);return 0 ; }
arch/arm/mach-ux500/mbox-db5500.c +8 -19
@@ -122,29 +122,18 @@ static ssize_t mbox_write_fifo(struct device *dev,const char *buf, size_t count) { - unsigned long mbox_mess; -unsigned long nbr_sends; -unsigned long i; -char int_buf[16 ]; -char *token; -char *val; - struct mbox *mbox = (struct mbox *) dev->platform_data; +unsigned int mbox_mess, nbr_sends; +unsigned int i; -strncpy ((char *) &int_buf, buf,sizeof (int_buf)); - token = (char *) &int_buf; - -/* Parse message */ - val =strsep (&token," " ); -if ((val ==NULL ) || (strict_strtoul (val,16 , &mbox_mess) !=0 )) - mbox_mess =0xDEADBEEF ; - - val =strsep (&token," " ); -if ((val ==NULL ) || (strict_strtoul (val,10 , &nbr_sends) !=0 )) +if (sscanf (buf,"%u %u" , &mbox_mess, &nbr_sends) !=2 ) { nbr_sends =1 ; +if (sscanf (buf,"%u" , &mbox_mess) !=1 ) +return -EINVAL ; + } -dev_dbg (dev,"Will write 0x%lX %ld times using data struct at 0x%X\n" , - mbox_mess, nbr_sends, (u32 ) mbox); +dev_dbg (dev,"Will write 0x%X %u times using data struct at %p\n" , + mbox_mess, nbr_sends, mbox);for (i =0 ; i < nbr_sends; i++)mbox_send (mbox, mbox_mess, true);
arch/arm/mach-w90x900/cpu.c +3 -2
@@ -170,12 +170,13 @@ static int __init nuc900_set_clkval(unsigned int cpufreq) }static int __init nuc900_set_cpufreq (char *str) { -unsigned long cpufreq, val; +unsigned int cpufreq, val;if (!*str)return 0 ; -strict_strtoul (str,0 , &cpufreq); +if (kstrtouint (str,0 , &cpufreq) <0 ) +return 0 ;nuc900_clock_source (NULL ,"ext" );
arch/arm/plat-omap/mcbsp.c +2 -2
@@ -1485,10 +1485,10 @@ static ssize_t prop##_store(struct device *dev, \ const char *buf, size_t size) \ { \struct omap_mcbsp *mcbsp =dev_get_drvdata (dev); \ -unsigned long val; \ +u16 val; \int status; \ \ - status =strict_strtoul (buf,0 , &val); \ + status =kstrtou16 (buf,0 , &val); \if (status) \return status; \ \
Signature · 1 line
1.7.3.4
PATCH 49/52 kstrtox: convert s390
In reply to Alexey Dobriyan--- arch/s390/kernel/ptrace.c | 8 +++-- arch/s390/kernel/vdso.c | 5 ++- drivers/s390/block/dasd_devmap.c | 20 +++++------ drivers/s390/char/sclp_async.c | 8 +++-- drivers/s390/cio/ccwgroup.c | 4 +- drivers/s390/cio/cmf.c | 9 +++-- drivers/s390/cio/css.c | 4 +- drivers/s390/cio/device.c | 6 ++-- drivers/s390/cio/qdio_debug.c | 6 ++- drivers/s390/net/qeth_l3_sys.c | 10 ++--- drivers/s390/scsi/zfcp_aux.c | 4 +- drivers/s390/scsi/zfcp_sysfs.c | 66 +++++++++++++++++++++++--------------- drivers/tty/hvc/hvc_iucv.c | 6 ++-- 13 files changed, 88 insertions(+), 68 deletions(-)
arch/s390/kernel/ptrace.c +5 -3
@@ -1143,12 +1143,14 @@ unsigned long regs_get_register(struct pt_regs *regs, unsigned int offset)int regs_query_register_offset (const char *name) { -unsigned long offset; +unsigned int offset; +int rv;if (!name || *name !='r' )return -EINVAL ; -if (strict_strtoul (name +1 ,10 , &offset)) -return -EINVAL ; + rv =kstrtouint (name +1 ,10 , &offset); +if (rv <0 ) +return rv;if (offset >=NUM_GPRS )return -EINVAL ;return offset;
arch/s390/kernel/vdso.c +3 -2
@@ -54,7 +54,6 @@ unsigned int __read_mostly vdso_enabled = 1;static int __init vdso_setup (char *s) { -unsigned long val;int rc; rc =0 ;
@@ -63,7 +62,9 @@ static int __init vdso_setup(char *s)else if (strncmp (s,"off" ,4 ) ==0 ) vdso_enabled =0 ;else { - rc =strict_strtoul (s,0 , &val); +unsigned long val; + + rc =kstrtoul (s,0 , &val); vdso_enabled = rc ?0 : !!val; }return !rc;
drivers/s390/block/dasd_devmap.c +9 -11
@@ -902,7 +902,7 @@ dasd_use_raw_store(struct device *dev, struct device_attribute *attr,if (IS_ERR (devmap))return PTR_ERR (devmap); -if ((strict_strtoul (buf,10 , &val) !=0 ) || val >1 ) +if (kstrtoul (buf,10 , &val) !=0 || val >1 )return -EINVAL ;spin_lock (&dasd_devmap_lock);
@@ -1159,20 +1159,18 @@ dasd_expires_store(struct device *dev, struct device_attribute *attr, {struct dasd_device *device;unsigned long val; +int rv; + + rv =kstrtoul (buf,10 , &val); +if (rv <0 ) +return rv; +if (val ==0 || val >DASD_EXPIRES_MAX ) +return -EINVAL ; device =dasd_device_from_cdev (to_ccwdev (dev));if (IS_ERR (device))return -ENODEV ; - -if ((strict_strtoul (buf,10 , &val) !=0 ) || - (val >DASD_EXPIRES_MAX ) || val ==0 ) { -dasd_put_device (device); -return -EINVAL ; - } - -if (val) - device->default_expires = val; - + device->default_expires = val;dasd_put_device (device);return count; }
drivers/s390/char/sclp_async.c +5 -3
@@ -67,7 +67,6 @@ static int proc_handler_callhome(struct ctl_table *ctl, int write, void __user *buffer, size_t *count, loff_t *ppos) { - unsigned long val; int len, rc;char buf[3 ];
@@ -81,13 +80,16 @@ static int proc_handler_callhome(struct ctl_table *ctl, int write,if (rc !=0 )return -EFAULT ; }else { +int val; + len = *count; rc =copy_from_user (buf, buffer,sizeof (buf));if (rc !=0 )return -EFAULT ; buf[sizeof (buf) -1 ] ='\0' ; -if (strict_strtoul (buf,0 , &val) !=0 ) -return -EINVAL ; + rc =kstrtoint (buf,0 , &val); +if (rc <0 ) +return rc;if (val !=0 && val !=1 )return -EINVAL ; callhome_enabled = val;
drivers/s390/cio/ccwgroup.c +2 -2
@@ -419,7 +419,7 @@ ccwgroup_online_store (struct device *dev, struct device_attribute *attr, const {struct ccwgroup_device *gdev;struct ccwgroup_driver *gdrv; -unsigned long value; +int value;int ret;if (!dev->driver)
@@ -431,7 +431,7 @@ ccwgroup_online_store (struct device *dev, struct device_attribute *attr, constif (!try_module_get (gdrv->owner))return -EINVAL ; - ret =strict_strtoul (buf,0 , &value); + ret =kstrtoint (buf,0 , &value);if (ret) goto out;
drivers/s390/cio/cmf.c +6 -3
@@ -1181,10 +1181,10 @@ static ssize_t cmb_enable_store(struct device *dev, size_t c) {struct ccw_device *cdev; +int val;int ret; -unsigned long val; - ret =strict_strtoul (buf,16 , &val); + ret =kstrtoint (buf,16 , &val);if (ret)return ret;
@@ -1197,8 +1197,11 @@ static ssize_t cmb_enable_store(struct device *dev,case 1 : ret =enable_cmf (cdev);break ; +default : + ret = -EINVAL ; } - +if (ret <0 ) +return ret;return c; }
drivers/s390/cio/css.c +2 -2
@@ -710,10 +710,10 @@ css_cm_enable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) {struct channel_subsystem *css =to_css (dev); +int val;int ret; -unsigned long val; - ret =strict_strtoul (buf,16 , &val); + ret =kstrtoint (buf,16 , &val);if (ret)return ret;mutex_lock (&css->mutex);
drivers/s390/cio/device.c +3 -3
@@ -536,8 +536,8 @@ static ssize_t online_store (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) {struct ccw_device *cdev =to_ccwdev (dev); -int force, ret; -unsigned long i; +int force, i; +int ret;if (!dev_fsm_final_state (cdev) && cdev->private->state !=DEV_STATE_DISCONNECTED )
@@ -555,7 +555,7 @@ static ssize_t online_store (struct device *dev, struct device_attribute *attr, ret =0 ; }else { force =0 ; - ret =strict_strtoul (buf,16 , &i); + ret =kstrtoint (buf,16 , &i); }if (ret) goto out;
drivers/s390/cio/qdio_debug.c +4 -2
@@ -187,7 +187,7 @@ static ssize_t qperf_seq_write(struct file *file, const char __user *ubuf,struct seq_file *seq = file->private_data;struct qdio_irq *irq_ptr = seq->private;struct qdio_q *q; -unsigned long val; +int val;char buf[8 ];int ret, i;
@@ -199,7 +199,7 @@ static ssize_t qperf_seq_write(struct file *file, const char __user *ubuf,return -EFAULT ; buf[count] =0 ; - ret =strict_strtoul (buf,10 , &val); + ret =kstrtoint (buf,10 , &val);if (ret <0 )return ret;
@@ -215,6 +215,8 @@ static ssize_t qperf_seq_write(struct file *file, const char __user *ubuf,case 1 : irq_ptr->perf_stat_enabled =1 ;break ; +default : +return -EINVAL ; }return count; }
drivers/s390/net/qeth_l3_sys.c +4 -6
@@ -355,8 +355,8 @@ static ssize_t qeth_l3_dev_sniffer_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct qeth_card *card = dev_get_drvdata(dev); -int rc =0 ; -unsigned long i; +int i; +int rc;if (!card)return -EINVAL ;
@@ -371,11 +371,9 @@ static ssize_t qeth_l3_dev_sniffer_store(struct device *dev, goto out; } - rc =strict_strtoul (buf,16 , &i); -if (rc) { - rc = -EINVAL ; + rc =kstrtoint (buf,16 , &i); +if (rc) goto out; - }switch (i) {case 0 : card->options.sniffer = i;
drivers/s390/scsi/zfcp_aux.c +2 -2
@@ -102,11 +102,11 @@ static void __init zfcp_init_device_setup(char *devstr)strncpy (busid, token,ZFCP_BUS_ID_SIZE ); token =strsep (&str,"," ); -if (!token ||strict_strtoull (token,0 , (unsigned long long *) &wwpn)) +if (!token ||kstrtou64 (token,0 , &wwpn)) goto err_out; token =strsep (&str,"," ); -if (!token ||strict_strtoull (token,0 , (unsigned long long *) &lun)) +if (!token ||kstrtou64 (token,0 , &lun)) goto err_out;kfree (str_saved);
drivers/s390/scsi/zfcp_sysfs.c +40 -26
122 lines not on this page · raw message
drivers/tty/hvc/hvc_iucv.c +3 -3
@@ -94,7 +94,7 @@ static void hvc_iucv_msg_complete(struct iucv_path *, struct iucv_message *);/* Kernel module parameter: use one terminal device as default */ -static unsigned long hvc_iucv_devices =1 ; +static unsigned int hvc_iucv_devices =1 ;/* Array of allocated hvc iucv tty lines... */ static struct hvc_iucv_private *hvc_iucv_table[MAX_HVC_IUCV_LINES ];
@@ -1227,7 +1227,7 @@ static int __init hvc_iucv_init(void) }if (hvc_iucv_devices >MAX_HVC_IUCV_LINES ) { -pr_err ("%lu is not a valid value for the hvc_iucv= " +pr_err ("%u is not a valid value for the hvc_iucv= " "kernel parameter\n" , hvc_iucv_devices); rc = -EINVAL ; goto out_error;
@@ -1328,7 +1328,7 @@ out_error:*/ static int __init hvc_iucv_config (char *val) { -return strict_strtoul (val,10 , &hvc_iucv_devices); +return kstrtouint (val,10 , &hvc_iucv_devices); }
Signature · 1 line
1.7.3.4
PATCH 51/52 kstrtox: convert x86
In reply to Alexey Dobriyan--- arch/x86/kernel/cpu/cpufreq/powernow-k8.c | 12 ++++++++---- arch/x86/kernel/cpu/intel_cacheinfo.c | 15 ++++++++------- arch/x86/kernel/cpu/mcheck/mce.c | 25 ++++++++++++++----------- arch/x86/kernel/cpu/mcheck/mce_amd.c | 12 ++++++++---- arch/x86/kvm/mmu_audit.c | 6 +++--- arch/x86/platform/uv/tlb_uv.c | 19 ++++++++++++------- drivers/platform/x86/classmate-laptop.c | 2 +- drivers/platform/x86/compal-laptop.c | 14 ++++++-------- 8 files changed, 60 insertions(+), 45 deletions(-)
arch/x86/kernel/cpu/cpufreq/powernow-k8.c +8 -4
@@ -1451,11 +1451,15 @@ static void cpb_toggle(bool t)static ssize_t store_cpb (struct cpufreq_policy *policy,const char *buf,size_t count) { -int ret = -EINVAL ; -unsigned long val =0 ; +int val; +int ret; - ret =strict_strtoul (buf,10 , &val); -if (!ret && (val ==0 || val ==1 ) && cpb_capable) + ret =kstrtoint (buf,10 , &val); +if (ret <0 ) +return ret; +if (val !=0 && val !=1 ) +return -EINVAL ; +if (cpb_capable)cpb_toggle (val);else return -EINVAL ;
arch/x86/kernel/cpu/intel_cacheinfo.c +8 -7
@@ -408,7 +408,7 @@ SHOW_CACHE_DISABLE(0) SHOW_CACHE_DISABLE(1)static void amd_l3_disable_index (struct amd_l3_cache *l3,int cpu, -unsigned slot,unsigned long idx) +unsigned slot,u32 idx) {int i;
@@ -447,12 +447,12 @@ static void amd_l3_disable_index(struct amd_l3_cache *l3, int cpu,* * @return: 0 on success, error status on failure */ -int amd_set_l3_disable_slot (struct amd_l3_cache *l3,int cpu,unsigned slot, -unsigned long index) +static int amd_set_l3_disable_slot (struct amd_l3_cache *l3,int cpu, +unsigned slot,u32 index) {int ret =0 ; -#define SUBCACHE_MASK (3UL << 20) +#define SUBCACHE_MASK (3U << 20)#define SUBCACHE_INDEX 0xfff/*
@@ -484,7 +484,7 @@ static ssize_t store_cache_disable(struct _cpuid4_info *this_leaf, const char *buf, size_t count, unsigned int slot) { - unsigned long val = 0; + u32 val;int cpu, err =0 ;if (!capable (CAP_SYS_ADMIN ))
@@ -496,8 +496,9 @@ static ssize_t store_cache_disable(struct _cpuid4_info *this_leaf, cpu =cpumask_first (to_cpumask (this_leaf->shared_cpu_map)); -if (strict_strtoul (buf,10 , &val) <0 ) -return -EINVAL ; + err =kstrtou32 (buf,10 , &val); +if (err <0 ) +return err; err =amd_set_l3_disable_slot (this_leaf->l3, cpu, slot, val);if (err) {
arch/x86/kernel/cpu/mcheck/mce.c +14 -11
@@ -1833,12 +1833,11 @@ static ssize_t show_bank(struct sys_device *s, struct sysdev_attribute *attr,static ssize_t set_bank (struct sys_device *s,struct sysdev_attribute *attr,const char *buf,size_t size) { -u64 new; +int rv; -if (strict_strtoull (buf,0 , &new) <0 ) -return -EINVAL ; - -attr_to_bank (attr)->ctl = new; + rv =kstrtou64 (buf,0 , &attr_to_bank (attr)->ctl); +if (rv <0 ) +return rv;mce_restart ();return size;
@@ -1871,10 +1870,12 @@ static ssize_t set_ignore_ce(struct sys_device *s,struct sysdev_attribute *attr, const char *buf, size_t size) { - u64 new; + unsigned long long new; +int rv; -if (strict_strtoull (buf,0 , &new) <0 ) -return -EINVAL ; + rv =kstrtoull (buf,0 , &new); +if (rv <0 ) +return rv;if (mce_ignore_ce ^ !!new) {if (new) {
@@ -1894,10 +1895,12 @@ static ssize_t set_cmci_disabled(struct sys_device *s,struct sysdev_attribute *attr, const char *buf, size_t size) { - u64 new; + unsigned long long new; +int rv; -if (strict_strtoull (buf,0 , &new) <0 ) -return -EINVAL ; + rv =kstrtoull (buf,0 , &new); +if (rv <0 ) +return rv;if (mce_cmci_disabled ^ !!new) {if (new) {
arch/x86/kernel/cpu/mcheck/mce_amd.c +8 -4
@@ -312,9 +312,11 @@ store_interrupt_enable(struct threshold_block *b, const char *buf, size_t size) {struct thresh_restart tr;unsigned long new; +int rv; -if (strict_strtoul (buf,0 , &new) <0 ) -return -EINVAL ; + rv =kstrtoul (buf,0 , &new); +if (rv <0 ) +return rv; b->interrupt_enable = !!new;
@@ -331,9 +333,11 @@ store_threshold_limit(struct threshold_block *b, const char *buf, size_t size) {struct thresh_restart tr;unsigned long new; +int rv; -if (strict_strtoul (buf,0 , &new) <0 ) -return -EINVAL ; + rv =kstrtoul (buf,0 , &new); +if (rv <0 ) +return rv;if (new >THRESHOLD_MAX ) new =THRESHOLD_MAX ;
arch/x86/kvm/mmu_audit.c +3 -3
@@ -275,12 +275,12 @@ static void mmu_audit_disable(void)static int mmu_audit_set (const char *val,const struct kernel_param *kp) { +int enable;int ret; -unsigned long enable; - ret =strict_strtoul (val,10 , &enable); + ret =kstrtoint (val,10 , &enable);if (ret <0 ) -return -EINVAL ; +return ret;switch (enable) {case 0 :
arch/x86/platform/uv/tlb_uv.c +12 -7
@@ -1028,21 +1028,22 @@ static ssize_t uv_ptc_proc_write(struct file *file, const char __user *user, size_t count, loff_t *data) { int cpu; -long input_arg; +int input_arg;char optstr[64 ];struct ptc_stats *stat; +int rv;if (count ==0 || count >sizeof (optstr))return -EINVAL ;if (copy_from_user (optstr, user, count))return -EFAULT ; optstr[count -1 ] ='\0' ; -if (strict_strtol (optstr,10 , &input_arg) <0 ) { -printk (KERN_DEBUG "%s is invalid\n" , optstr); -return -EINVAL ; - } + rv =kstrtoint (optstr,10 , &input_arg); +if (rv <0 ) +return rv; -if (input_arg ==0 ) { +switch (input_arg) { +case 0 :printk (KERN_DEBUG "# cpu: cpu number\n" );printk (KERN_DEBUG "Sender statistics:\n" ); printk(KERN_DEBUG
@@ -1110,11 +1111,15 @@ static ssize_t uv_ptc_proc_write(struct file *file, const char __user *user, "disable: number times use of the BAU was disabled\n");printk (KERN_DEBUG "enable: number times use of the BAU was re-enabled\n" ); - }else if (input_arg ==-1 ) { +break ; +case -1 :for_each_present_cpu (cpu) { stat = &per_cpu (ptcstats, cpu);memset (stat,0 ,sizeof (struct ptc_stats )); } +break ; +default : +return -EINVAL ; }return count;
drivers/platform/x86/classmate-laptop.c +1 -1
@@ -198,7 +198,7 @@ static ssize_t cmpc_accel_sensitivity_store(struct device *dev, inputdev =dev_get_drvdata (&acpi->dev); accel =dev_get_drvdata (&inputdev->dev); - r =strict_strtoul (buf,0 , &sensitivity); + r =kstrtoul (buf,0 , &sensitivity);if (r)return r;
drivers/platform/x86/compal-laptop.c +6 -8
@@ -421,13 +421,12 @@ static ssize_t pwm_enable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct compal_data *data = dev_get_drvdata(dev); -long val; +unsigned int val;int err; - err =strict_strtol (buf,10 , &val); + + err =kstrtouint (buf,10 , &val);if (err)return err; -if (val <0 ) -return -EINVAL ; data->pwm_enable = val;
@@ -459,13 +458,12 @@ static ssize_t pwm_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) {struct compal_data *data =dev_get_drvdata (dev); -long val; +u8 val;int err; - err =strict_strtol (buf,10 , &val); + + err =kstrtou8 (buf,10 , &val);if (err)return err; -if (val <0 || val >255 ) -return -EINVAL ; data->curr_pwm = val;
Signature · 1 line
1.7.3.4
PATCH 50/52 kstrtox: convert tile
In reply to Alexey Dobriyan--- arch/tile/kernel/setup.c | 15 ++++++++------- arch/tile/kernel/single_step.c | 4 +--- arch/tile/kernel/traps.c | 4 +--- arch/tile/mm/init.c | 9 +++------ 4 files changed, 13 insertions(+), 19 deletions(-)
arch/tile/kernel/setup.c +8 -7
@@ -101,8 +101,9 @@ unsigned long __initdata pci_reserve_end_pfn = -1U;static int __init setup_maxmem (char *str) { -long maxmem_mb; -if (str ==NULL ||strict_strtol (str,0 , &maxmem_mb) !=0 || +unsigned int maxmem_mb; + +if (str ==NULL ||kstrtouint (str,0 , &maxmem_mb) !=0 || maxmem_mb ==0 )return -EINVAL ;
@@ -117,16 +118,16 @@ early_param("maxmem", setup_maxmem);static int __init setup_maxnodemem (char *str) {char *endp; -long maxnodemem_mb, node; +unsigned int maxnodemem_mb, node; node = str ?simple_strtoul (str, &endp,0 ) :INT_MAX ;if (node >=MAX_NUMNODES || *endp !=':' || -strict_strtol (endp+1 ,0 , &maxnodemem_mb) !=0 ) +kstrtouint (endp+1 ,0 , &maxnodemem_mb) !=0 )return -EINVAL ; maxnodemem_pfn[node] = (maxnodemem_mb >> (HPAGE_SHIFT -20 )) << (HPAGE_SHIFT -PAGE_SHIFT ); -pr_info ("Forcing RAM used on node %ld to no more than %dMB\n" , +pr_info ("Forcing RAM used on node %u to no more than %uMB\n" , node, maxnodemem_pfn[node] >> (20 -PAGE_SHIFT ));return 0 ; }
@@ -147,9 +148,9 @@ early_param("isolnodes", setup_isolnodes);#ifdef CONFIG_PCI static int __init setup_pci_reserve (char * str) { -unsigned long mb; +unsigned int mb; -if (str ==NULL ||strict_strtoul (str,0 , &mb) !=0 || +if (str ==NULL ||kstrtouint (str,0 , &mb) !=0 || mb >3 *1024 )return -EINVAL ;
arch/tile/kernel/single_step.c +1 -3
@@ -36,10 +36,8 @@ int unaligned_printk;static int __init setup_unaligned_printk (char *str) { -long val; -if (strict_strtol (str,0 , &val) !=0 ) +if (kstrtoint (str,0 , &unaligned_printk) !=0 )return 0 ; - unaligned_printk = val;pr_info ("Printk for each unaligned data accesses is %s\n" , unaligned_printk ?"enabled" :"disabled" );return 1 ;
arch/tile/kernel/traps.c +1 -3
@@ -41,10 +41,8 @@ static int __init setup_unaligned_fixup(char *str)* will still parse the instruction, then fire a SIGBUS with * the correct address from inside the single_step code. */ -long val; -if (strict_strtol (str,0 , &val) !=0 ) +if (kstrtoint (str,0 , &unaligned_fixup) !=0 )return 0 ; - unaligned_fixup = val; pr_info("Fixups for unaligned data accesses are %s\n", unaligned_fixup >= 0 ? (unaligned_fixup ? "enabled" : "disabled") :
arch/tile/mm/init.c +3 -6
@@ -988,12 +988,9 @@ static long __write_once initfree = 1;/* Select whether to free (1) or mark unusable (0) the __init pages. */ static int __init set_initfree (char *str) { -long val; -if (strict_strtol (str,0 , &val)) { - initfree = val; -pr_info ("initfree: %s free init pages\n" , - initfree ?"will" :"won't" ); - } +if (kstrtoint (str,0 , &initfree) <0 ) +return 0 ; +pr_info ("initfree: %s free init pages\n" , initfree ?"will" :"won't" );return 1 ; }__setup ("initfree=" , set_initfree);
Signature · 1 line
1.7.3.4
PATCH 48/52 kstrtox: convert powerpc
In reply to Alexey Dobriyan--- arch/powerpc/kernel/setup_64.c | 6 +++--- arch/powerpc/kernel/vio.c | 4 ++-- arch/powerpc/platforms/pseries/dlpar.c | 4 ++-- arch/powerpc/platforms/pseries/mobility.c | 2 +- arch/powerpc/sysdev/fsl_85xx_l2ctlr.c | 8 ++++---- 5 files changed, 12 insertions(+), 12 deletions(-)
arch/powerpc/kernel/setup_64.c +3 -3
@@ -113,13 +113,13 @@ static void check_smt_enabled(void)else if (!strcmp (smt_enabled_cmdline,"off" )) smt_enabled_at_boot =0 ;else { -long smt; +int smt;int rc; - rc =strict_strtol (smt_enabled_cmdline,10 , &smt); + rc =kstrtoint (smt_enabled_cmdline,10 , &smt);if (!rc) smt_enabled_at_boot = -min (threads_per_core, (int )smt); +min (threads_per_core, smt); } }else { dn =of_find_node_by_path ("/options" );
arch/powerpc/kernel/vio.c +2 -2
@@ -946,10 +946,10 @@ static ssize_t viodev_cmo_desired_set(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct vio_dev *viodev = to_vio_dev(dev); -size_t new_desired; +unsigned long new_desired;int ret; - ret =strict_strtoul (buf,10 , &new_desired); + ret =kstrtoul (buf,10 , &new_desired);if (ret)return ret;
arch/powerpc/platforms/pseries/dlpar.c +2 -2
@@ -403,12 +403,12 @@ out:static ssize_t dlpar_cpu_probe (const char *buf,size_t count) {struct device_node *dn; -unsigned long drc_index; +u32 drc_index;char *cpu_name;int rc;cpu_hotplug_driver_lock (); - rc =strict_strtoul (buf,0 , &drc_index); + rc =kstrtou32 (buf,0 , &drc_index);if (rc) { rc = -EINVAL ; goto out;
arch/powerpc/platforms/pseries/mobility.c +1 -1
@@ -316,7 +316,7 @@ static ssize_t migrate_store(struct class *class, struct class_attribute *attr,u64 streamid;int rc; - rc =strict_strtoull (buf,0 , &streamid); + rc =kstrtou64 (buf,0 , &streamid);if (rc)return rc;
arch/powerpc/sysdev/fsl_85xx_l2ctlr.c +4 -4
@@ -32,9 +32,9 @@ struct mpc85xx_l2ctlr __iomem *l2ctlr;static long get_cache_sram_size (void ) { -unsigned long val; +unsigned int val; -if (!sram_size || (strict_strtoul (sram_size,0 , &val) <0 )) +if (!sram_size ||kstrtouint (sram_size,0 , &val) <0 )return -EINVAL ;return val;
@@ -42,9 +42,9 @@ static long get_cache_sram_size(void)static long get_cache_sram_offset (void ) { -unsigned long val; +unsigned int val; -if (!sram_offset || (strict_strtoul (sram_offset,0 , &val) <0 )) +if (!sram_offset ||kstrtouint (sram_offset,0 , &val) <0 )return -EINVAL ;return val;
Signature · 1 line
1.7.3.4
PATCH 47/52 kstrtox: convert mips
In reply to Alexey Dobriyan--- arch/mips/alchemy/devboards/pm.c | 6 ++---- arch/mips/alchemy/devboards/prom.c | 2 +- arch/mips/alchemy/gpr/init.c | 2 +- arch/mips/alchemy/mtx-1/init.c | 2 +- arch/mips/alchemy/xxs1500/init.c | 2 +- arch/mips/loongson/common/env.c | 3 +-- arch/mips/pci/ops-tx4927.c | 9 +++------ arch/mips/txx9/generic/setup.c | 4 +--- 8 files changed, 11 insertions(+), 19 deletions(-)
arch/mips/alchemy/devboards/pm.c +2 -4
@@ -158,12 +158,10 @@ static ssize_t db1x_pmattr_store(struct kobject *kobj,int tmp;if (ATTRCMP (timer_timeout)) { - tmp =strict_strtoul (instr,0 , &l); + tmp =kstrtoul (instr,0 , &db1x_pm_sleep_secs);if (tmp)return tmp; - db1x_pm_sleep_secs = l; - }else if (ATTRCMP (timer)) {if (instr[0 ] !='0' ) db1x_pm_wakemsk |=SYS_WAKEMSK_M2 ;
@@ -181,7 +179,7 @@ static ssize_t db1x_pmattr_store(struct kobject *kobj, } }else if (ATTRCMP (wakemsk)) { - tmp =strict_strtoul (instr,0 , &l); + tmp =kstrtoul (instr,0 , &l);if (tmp)return tmp;
arch/mips/alchemy/devboards/prom.c +1 -1
@@ -54,7 +54,7 @@ void __init prom_init(void)prom_init_cmdline (); memsize_str =prom_getenv ("memsize" ); -if (!memsize_str ||strict_strtoul (memsize_str,0 , &memsize)) +if (!memsize_str ||kstrtoul (memsize_str,0 , &memsize)) memsize =ALCHEMY_BOARD_DEFAULT_MEMSIZE ;add_memory_region (0 , memsize,BOOT_MEM_RAM );
arch/mips/alchemy/gpr/init.c +1 -1
@@ -53,7 +53,7 @@ void __init prom_init(void)if (!memsize_str) memsize =0x04000000 ;else -strict_strtoul (memsize_str,0 , &memsize); +kstrtoul (memsize_str,0 , &memsize);add_memory_region (0 , memsize,BOOT_MEM_RAM ); }
arch/mips/alchemy/mtx-1/init.c +1 -1
@@ -56,7 +56,7 @@ void __init prom_init(void)if (!memsize_str) memsize =0x04000000 ;else -strict_strtoul (memsize_str,0 , &memsize); +kstrtoul (memsize_str,0 , &memsize);add_memory_region (0 , memsize,BOOT_MEM_RAM ); }
arch/mips/alchemy/xxs1500/init.c +1 -1
@@ -54,7 +54,7 @@ void __init prom_init(void)if (!memsize_str) memsize =0x04000000 ;else -strict_strtoul (memsize_str,0 , &memsize); +kstrtoul (memsize_str,0 , &memsize);add_memory_region (0 , memsize,BOOT_MEM_RAM ); }
arch/mips/loongson/common/env.c +1 -2
@@ -29,9 +29,8 @@ unsigned long memsize, highmemsize;#define parse_even_earlier (res, option, p) \ do { \ - int ret; \ if (strncmp(option, (char *)p, strlen(option)) == 0) \ - ret = strict_strtol((char *)p + strlen(option"="), 10, &res); \ + kstrtol((char *)p + strlen(option"="), 10, &res); \ } while (0)void __init prom_init_env (void )
arch/mips/pci/ops-tx4927.c +3 -6
@@ -202,18 +202,15 @@ char *__devinit tx4927_pcibios_setup(char *str)unsigned long val;if (!strncmp (str,"trdyto=" ,7 )) { -if (strict_strtoul (str +7 ,0 , &val) ==0 ) - tx4927_pci_opts.trdyto = val; +kstrtou8 (str +7 ,0 , &tx4927_pci_opts.trdyto);return NULL ; }if (!strncmp (str,"retryto=" ,8 )) { -if (strict_strtoul (str +8 ,0 , &val) ==0 ) - tx4927_pci_opts.retryto = val; +kstrtou8 (str +8 ,0 , &tx4927_pci_opts.retryto);return NULL ; }if (!strncmp (str,"gbwc=" ,5 )) { -if (strict_strtoul (str +5 ,0 , &val) ==0 ) - tx4927_pci_opts.gbwc = val; +kstrtou16 (str +5 ,0 , &tx4927_pci_opts.gbwc);return NULL ; }return str;
arch/mips/txx9/generic/setup.c +1 -3
@@ -308,9 +308,7 @@ static void __init preprocess_cmdline(void) txx9_board_vec =find_board_byname (str +6 );continue ; }else if (strncmp (str,"masterclk=" ,10 ) ==0 ) { -unsigned long val; -if (strict_strtoul (str +10 ,10 , &val) ==0 ) - txx9_master_clock = val; +kstrtouint (str +10 ,10 , &txx9_master_clock);continue ; }else if (strcmp (str,"icdisable" ) ==0 ) { txx9_ic_disable =1 ;
Signature · 1 line
1.7.3.4
PATCH 43/52 kstrtox: convert sound/
In reply to Alexey Dobriyan--- sound/drivers/dummy.c | 2 +- sound/pci/hda/hda_hwdep.c | 10 ++++------ sound/pci/hda/patch_sigmatel.c | 7 ++----- sound/soc/codecs/wm8962.c | 4 ++-- sound/soc/soc-core.c | 6 +++--- 5 files changed, 12 insertions(+), 17 deletions(-)
sound/drivers/dummy.c +1 -1
@@ -953,7 +953,7 @@ static void dummy_proc_write(struct snd_info_entry *entry,if (i >=ARRAY_SIZE (fields))continue ;snd_info_get_str (item, ptr,sizeof (item)); -if (strict_strtoull (item,0 , &val)) +if (kstrtoull (item,0 , &val))continue ;if (fields[i].size ==sizeof (int )) *get_dummy_int_ptr (dummy, fields[i].offset) = val;
sound/pci/hda/hda_hwdep.c +4 -6
@@ -293,11 +293,11 @@ static ssize_t type##_store(struct device *dev, \ { \struct snd_hwdep *hwdep =dev_get_drvdata (dev); \struct hda_codec *codec = hwdep->private_data; \ -unsigned long val; \ -int err =strict_strtoul (buf,0 , &val); \ +int err; \ + \ + err =kstrtou32 (buf,0 , &codec->type); \if (err <0 ) \return err; \ - codec->type = val; \return count; \ }
@@ -699,9 +699,7 @@ static void parse_chip_name_mode(char *buf, struct hda_bus *bus, static void parse_##name##_mode(char *buf, struct hda_bus *bus, \struct hda_codec **codecp) \ { \ -unsigned long val; \ -if (!strict_strtoul (buf,0 , &val)) \ - (*codecp)->name = val; \ +kstrtou32 (buf,0 , &(*codecp)->name); \ }DEFINE_PARSE_ID_MODE (vendor_id);
sound/pci/hda/patch_sigmatel.c +2 -5
@@ -4194,16 +4194,13 @@ static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, int enable);static inline int get_int_hint (struct hda_codec *codec,const char *key, -int *valp) +unsigned int *val) {const char *p; p =snd_hda_get_hint (codec, key);if (p) { -unsigned long val; -if (!strict_strtoul (p,0 , &val)) { - *valp = val; +if (kstrtouint (p,0 , val) ==0 )return 1 ; - } }return 0 ; }
sound/soc/codecs/wm8962.c +2 -2
@@ -3501,10 +3501,10 @@ static ssize_t wm8962_beep_set(struct device *dev, const char *buf, size_t count) {struct wm8962_priv *wm8962 =dev_get_drvdata (dev); -long int time; +int time;int ret; - ret =strict_strtol (buf,10 , &time); + ret =kstrtoint (buf,10 , &time);if (ret !=0 )return ret;
sound/soc/soc-core.c +3 -3
@@ -151,7 +151,7 @@ static ssize_t pmdown_time_set(struct device *dev, container_of(dev, struct snd_soc_pcm_runtime, dev);int ret; - ret =strict_strtol (buf,10 , &rtd->pmdown_time); + ret =kstrtol (buf,10 , &rtd->pmdown_time);if (ret)return ret;
@@ -188,7 +188,7 @@ static ssize_t codec_reg_write_file(struct file *file,char buf[32 ];int buf_size;char *start = buf; -unsigned long reg, value; +u32 reg, value;int step =1 ;struct snd_soc_codec *codec = file->private_data;
@@ -207,7 +207,7 @@ static ssize_t codec_reg_write_file(struct file *file,return -EINVAL ;while (*start ==' ' ) start++; -if (strict_strtoul (start,16 , &value)) +if (kstrtou32 (start,16 , &value))return -EINVAL ;snd_soc_write (codec, reg, value);return buf_size;
Signature · 1 line
1.7.3.4
PATCH 36/52 kstrtox: convert drivers/rtc/
In reply to Alexey Dobriyan--- drivers/rtc/rtc-pcf2123.c | 23 +++++++++++------------ 1 files changed, 11 insertions(+), 12 deletions(-)
drivers/rtc/rtc-pcf2123.c +11 -12
@@ -87,13 +87,14 @@ static ssize_t pcf2123_show(struct device *dev, struct device_attribute *attr,struct spi_device *spi =to_spi_device (dev);struct pcf2123_sysfs_reg *r;u8 txbuf[1 ], rxbuf[1 ]; -unsigned long reg; +u8 reg;int ret; r = container_of(attr, struct pcf2123_sysfs_reg, attr); -if (strict_strtoul (r->name,16 , ®)) -return -EINVAL ; + ret =kstrtou8 (r->name,16 , ®); +if (ret <0 ) +return ret; txbuf[0 ] =PCF2123_READ | reg; ret =spi_write_then_read (spi, txbuf,1 , rxbuf,1 );
@@ -108,19 +109,17 @@ static ssize_t pcf2123_store(struct device *dev, struct device_attribute *attr,struct spi_device *spi =to_spi_device (dev);struct pcf2123_sysfs_reg *r;u8 txbuf[2 ]; -unsigned long reg; -unsigned long val; -int ret; r = container_of(attr, struct pcf2123_sysfs_reg, attr); -if (strict_strtoul (r->name,16 , ®) - ||strict_strtoul (buffer,10 , &val)) -return -EINVAL ; - - txbuf[0 ] =PCF2123_WRITE | reg; - txbuf[1 ] = val; + ret =kstrtou8 (r->name,16 , &txbuf[0 ]); +if (ret <0 ) +return ret; + txbuf[0 ] |=PCF2123_WRITE ; + ret =kstrtou8 (buffer,10 , &txbuf[1 ]); +if (ret <0 ) +return ret; ret =spi_write (spi, txbuf,sizeof (txbuf));if (ret <0 )return -EIO ;
Signature · 1 line
1.7.3.4
PATCH 33/52 kstrtox: convert drivers/pci/
In reply to Alexey Dobriyan--- drivers/pci/hotplug/fakephp.c | 2 +- drivers/pci/pci-sysfs.c | 45 ++++++++++++++++++++++------------------ 2 files changed, 26 insertions(+), 21 deletions(-)
drivers/pci/hotplug/fakephp.c +1 -1
@@ -49,7 +49,7 @@ static ssize_t legacy_store(struct kobject *kobj, struct attribute *attr,struct legacy_slot *slot =container_of (kobj,typeof (*slot), kobj);unsigned long val; -if (strict_strtoul (buf,0 , &val) <0 ) +if (kstrtoul (buf,0 , &val) <0 )return -EINVAL ;if (val)
drivers/pci/pci-sysfs.c +25 -20
108 lines not on this page · raw message
Signature · 1 line
1.7.3.4
PATCH 31/52 kstrtox: convert drivers/net/
In reply to Alexey Dobriyan--- drivers/net/can/at91_can.c | 9 +++------ drivers/net/can/janz-ican3.c | 5 +++-- drivers/net/can/slcan.c | 5 +---- drivers/net/can/softing/softing_main.c | 2 +- drivers/net/netxen/netxen_nic_main.c | 4 ++-- drivers/net/qlcnic/qlcnic_main.c | 4 ++-- drivers/net/stmmac/stmmac_main.c | 29 ++++++++++++++++------------- 7 files changed, 28 insertions(+), 30 deletions(-)
drivers/net/can/at91_can.c +3 -6
@@ -1079,9 +1079,8 @@ static ssize_t at91_sysfs_set_mb0_id(struct device *dev, {struct net_device *ndev =to_net_dev (dev);struct at91_priv *priv =netdev_priv (ndev); -unsigned long can_id; +u32 can_id;ssize_t ret; -int err;rtnl_lock ();
@@ -1090,11 +1089,9 @@ static ssize_t at91_sysfs_set_mb0_id(struct device *dev, goto out; } - err =strict_strtoul (buf,0 , &can_id); -if (err) { - ret = err; + ret =kstrtou32 (buf,0 , &can_id); +if (ret <0 ) goto out; - }if (can_id &CAN_EFF_FLAG ) can_id &=CAN_EFF_MASK |CAN_EFF_FLAG ;
drivers/net/can/janz-ican3.c +3 -2
@@ -1608,8 +1608,9 @@ static ssize_t ican3_sysfs_set_term(struct device *dev,unsigned long enable;int ret; -if (strict_strtoul (buf,0 , &enable)) -return -EINVAL ; + ret =kstrtoul (buf,0 , &enable); +if (ret <0 ) +return ret; ret =ican3_set_termination (mod, enable);if (ret)
drivers/net/can/slcan.c +1 -4
@@ -163,7 +163,6 @@ static void slc_bump(struct slcan *sl)struct sk_buff *skb;struct can_frame cf;int i, dlc_pos, tmp; -unsigned long ultmp;char cmd = sl->rbuff[0 ];if ((cmd !='t' ) && (cmd !='T' ) && (cmd !='r' ) && (cmd !='R' ))
@@ -181,11 +180,9 @@ static void slc_bump(struct slcan *sl) sl->rbuff[dlc_pos] =0 ;/* terminate can_id string */ -if (strict_strtoul (sl->rbuff+1 ,16 , &ultmp)) +if (kstrtou32 (sl->rbuff+1 ,16 , &cf.can_id))return ; - cf.can_id = ultmp; -if (!(cmd &0x20 ))/* NO tiny chars => extended frame format */ cf.can_id |=CAN_EFF_FLAG ;
drivers/net/can/softing/softing_main.c +1 -1
@@ -594,7 +594,7 @@ static ssize_t store_output(struct device *dev, struct device_attribute *attr,unsigned long val;int ret; - ret =strict_strtoul (buf,0 , &val); + ret =kstrtoul (buf,0 , &val);if (ret <0 )return ret; val &=0xFF ;
drivers/net/netxen/netxen_nic_main.c +2 -2
@@ -2503,7 +2503,7 @@ netxen_store_bridged_mode(struct device *dev,if (adapter->is_up !=NETXEN_ADAPTER_UP_MAGIC ) goto err_out; -if (strict_strtoul (buf,2 , &new)) +if (kstrtoul (buf,2 , &new)) goto err_out;if (!netxen_config_bridged_mode (adapter, !!new))
@@ -2542,7 +2542,7 @@ netxen_store_diag_mode(struct device *dev,struct netxen_adapter *adapter =dev_get_drvdata (dev);unsigned long new; -if (strict_strtoul (buf,2 , &new)) +if (kstrtoul (buf,2 , &new))return -EINVAL ;if (!!new != !!(adapter->flags &NETXEN_NIC_DIAG_ENABLED ))
drivers/net/qlcnic/qlcnic_main.c +2 -2
@@ -3192,7 +3192,7 @@ qlcnic_store_bridged_mode(struct device *dev,if (!test_bit (__QLCNIC_DEV_UP, &adapter->state)) goto err_out; -if (strict_strtoul (buf,2 , &new)) +if (kstrtoul (buf,2 , &new)) goto err_out;if (!adapter->nic_ops->config_bridged_mode (adapter, !!new))
@@ -3228,7 +3228,7 @@ qlcnic_store_diag_mode(struct device *dev,struct qlcnic_adapter *adapter =dev_get_drvdata (dev);unsigned long new; -if (strict_strtoul (buf,2 , &new)) +if (kstrtoul (buf,2 , &new))return -EINVAL ;if (!!new != !!(adapter->flags &QLCNIC_DIAG_ENABLED ))
drivers/net/stmmac/stmmac_main.c +16 -13
@@ -1955,31 +1955,34 @@ static int __init stmmac_cmdline_opt(char *str)if (!str || !*str)return -EINVAL ;while ((opt =strsep (&str,"," )) !=NULL ) { +int rv; +if (!strncmp (opt,"debug:" ,6 )) -strict_strtoul (opt +6 ,0 , (unsigned long *)&debug); + rv =kstrtoint (opt +6 ,0 , &debug);else if (!strncmp (opt,"phyaddr:" ,8 )) -strict_strtoul (opt +8 ,0 , (unsigned long *)&phyaddr); + rv =kstrtoint (opt +8 ,0 , &phyaddr);else if (!strncmp (opt,"dma_txsize:" ,11 )) -strict_strtoul (opt +11 ,0 , - (unsigned long *)&dma_txsize); + rv =kstrtoint (opt +11 ,0 , &dma_txsize);else if (!strncmp (opt,"dma_rxsize:" ,11 )) -strict_strtoul (opt +11 ,0 , - (unsigned long *)&dma_rxsize); + rv =kstrtoint (opt +11 ,0 , &dma_rxsize);else if (!strncmp (opt,"buf_sz:" ,7 )) -strict_strtoul (opt +7 ,0 , (unsigned long *)&buf_sz); + rv =kstrtoint (opt +7 ,0 , &buf_sz);else if (!strncmp (opt,"tc:" ,3 )) -strict_strtoul (opt +3 ,0 , (unsigned long *)&tc); + rv =kstrtoint (opt +3 ,0 , &tc);else if (!strncmp (opt,"watchdog:" ,9 )) -strict_strtoul (opt +9 ,0 , (unsigned long *)&watchdog); + rv =kstrtoint (opt +9 ,0 , &watchdog);else if (!strncmp (opt,"flow_ctrl:" ,10 )) -strict_strtoul (opt +10 ,0 , - (unsigned long *)&flow_ctrl); + rv =kstrtoint (opt +10 ,0 , &flow_ctrl);else if (!strncmp (opt,"pause:" ,6 )) -strict_strtoul (opt +6 ,0 , (unsigned long *)&pause); + rv =kstrtoint (opt +6 ,0 , &pause);#ifdef CONFIG_STMMAC_TIMER else if (!strncmp(opt, "tmrate:", 7)) -strict_strtoul (opt +7 ,0 , (unsigned long *)&tmrate); + rv =kstrtoint (opt +7 ,0 , &tmrate);#endif + else + rv = -EINVAL ; +if (rv <0 ) +return rv; }return 0 ; }
Signature · 1 line
1.7.3.4
PATCH 23/52 kstrtox: convert drivers/input/
In reply to Alexey Dobriyan--- drivers/input/input-polldev.c | 8 ++- drivers/input/keyboard/atkbd.c | 33 ++++++++++---- drivers/input/keyboard/lm8323.c | 20 ++++----- drivers/input/misc/adxl34x.c | 14 +++--- drivers/input/misc/ati_remote2.c | 31 +++++++------ drivers/input/mouse/elantech.c | 10 +--- drivers/input/mouse/hgpk.c | 18 +++++--- drivers/input/mouse/logips2pp.c | 8 +++- drivers/input/mouse/psmouse-base.c | 31 ++++++------- drivers/input/mouse/sentelic.c | 79 ++++++++++++++++++---------------- drivers/input/mouse/sentelic.h | 10 ++-- drivers/input/mouse/trackpoint.c | 19 +++++---- drivers/input/tablet/aiptek.c | 34 +++++++-------- drivers/input/touchscreen/ad7877.c | 16 ++++---- drivers/input/touchscreen/ad7879.c | 4 +- drivers/input/touchscreen/ads7846.c | 6 ++- 16 files changed, 182 insertions(+), 159 deletions(-)
drivers/input/input-polldev.c +5 -3
@@ -130,10 +130,12 @@ static ssize_t input_polldev_set_poll(struct device *dev, {struct input_polled_dev *polldev =dev_get_drvdata (dev);struct input_dev *input = polldev->input; -unsigned long interval; +unsigned int interval; +int rv; -if (strict_strtoul (buf,0 , &interval)) -return -EINVAL ; + rv =kstrtouint (buf,0 , &interval); +if (rv <0 ) +return rv;if (interval < polldev->poll_interval_min)return -EINVAL ;
drivers/input/keyboard/atkbd.c +23 -10
@@ -1305,7 +1305,7 @@ static ssize_t atkbd_show_extra(struct atkbd *atkbd, char *buf)static ssize_t atkbd_set_extra (struct atkbd *atkbd,const char *buf,size_t count) {struct input_dev *old_dev, *new_dev; -unsigned long value; +unsigned int value;int err;bool old_extra;unsigned char old_set;
@@ -1313,7 +1313,10 @@ static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t counif (!atkbd->write)return -EIO ; -if (strict_strtoul (buf,10 , &value) || value >1 ) + err =kstrtouint (buf,10 , &value); +if (err <0 ) +return err; +if (value >1 )return -EINVAL ;if (atkbd->extra != value) {
@@ -1389,11 +1392,14 @@ static ssize_t atkbd_show_scroll(struct atkbd *atkbd, char *buf)static ssize_t atkbd_set_scroll (struct atkbd *atkbd,const char *buf,size_t count) {struct input_dev *old_dev, *new_dev; -unsigned long value; +unsigned int value;int err;bool old_scroll; -if (strict_strtoul (buf,10 , &value) || value >1 ) + err =kstrtouint (buf,10 , &value); +if (err <0 ) +return err; +if (value >1 )return -EINVAL ;if (atkbd->scroll != value) {
@@ -1433,7 +1439,7 @@ static ssize_t atkbd_show_set(struct atkbd *atkbd, char *buf)static ssize_t atkbd_set_set (struct atkbd *atkbd,const char *buf,size_t count) {struct input_dev *old_dev, *new_dev; -unsigned long value; +int value;int err;unsigned char old_set;bool old_extra;
@@ -1441,7 +1447,10 @@ static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count)if (!atkbd->write)return -EIO ; -if (strict_strtoul (buf,10 , &value) || (value !=2 && value !=3 )) + err =kstrtoint (buf,10 , &value); +if (err <0 ) +return err; +if (value !=2 && value !=3 )return -EINVAL ;if (atkbd->set != value) {
@@ -1484,14 +1493,17 @@ static ssize_t atkbd_show_softrepeat(struct atkbd *atkbd, char *buf)static ssize_t atkbd_set_softrepeat (struct atkbd *atkbd,const char *buf,size_t count) {struct input_dev *old_dev, *new_dev; -unsigned long value; +unsigned int value;int err;bool old_softrepeat, old_softraw;if (!atkbd->write)return -EIO ; -if (strict_strtoul (buf,10 , &value) || value >1 ) + err =kstrtouint (buf,10 , &value); +if (err <0 ) +return err; +if (value >1 )return -EINVAL ;if (atkbd->softrepeat != value) {
@@ -1534,11 +1546,12 @@ static ssize_t atkbd_show_softraw(struct atkbd *atkbd, char *buf)static ssize_t atkbd_set_softraw (struct atkbd *atkbd,const char *buf,size_t count) {struct input_dev *old_dev, *new_dev; -unsigned long value; +unsigned int value;int err;bool old_softraw; -if (strict_strtoul (buf,10 , &value) || value >1 ) + err =kstrtouint (buf,10 , &value); +if (value >1 )return -EINVAL ;if (atkbd->softraw != value) {
drivers/input/keyboard/lm8323.c +8 -12
@@ -557,15 +557,10 @@ static ssize_t lm8323_pwm_store_time(struct device *dev,struct led_classdev *led_cdev =dev_get_drvdata (dev);struct lm8323_pwm *pwm =cdev_to_pwm (led_cdev);int ret; -unsigned long time; - - ret =strict_strtoul (buf,10 , &time); -/* Numbers only, please. */ -if (ret) -return -EINVAL ; - - pwm->fade_time = time; + ret =kstrtoint (buf,10 , &pwm->fade_time); +if (ret <0 ) +return ret;return strlen (buf); } static DEVICE_ATTR(time, 0644, lm8323_pwm_show_time, lm8323_pwm_store_time);
@@ -623,13 +618,14 @@ static ssize_t lm8323_set_disable(struct device *dev, const char *buf, size_t count) {struct lm8323_chip *lm =dev_get_drvdata (dev); +unsigned int kp_enabled;int ret; -unsigned long i; - - ret =strict_strtoul (buf,10 , &i); + ret =kstrtouint (buf,10 , &kp_enabled); +if (ret <0 ) +return ret;mutex_lock (&lm->lock); - lm->kp_enabled = !i; + lm->kp_enabled = !kp_enabled;mutex_unlock (&lm->lock);return count;
drivers/input/misc/adxl34x.c +7 -7
@@ -454,8 +454,8 @@ static ssize_t adxl34x_disable_store(struct device *dev,unsigned long val;int error; - error =strict_strtoul (buf,10 , &val); -if (error) + error =kstrtoul (buf,10 , &val); +if (error <0 )return error;mutex_lock (&ac->mutex);
@@ -543,7 +543,7 @@ static ssize_t adxl34x_rate_store(struct device *dev,unsigned long val;int error; - error =strict_strtoul (buf,10 , &val); + error =kstrtoul (buf,10 , &val);if (error)return error;
@@ -578,7 +578,7 @@ static ssize_t adxl34x_autosleep_store(struct device *dev,unsigned long val;int error; - error =strict_strtoul (buf,10 , &val); + error =kstrtoul (buf,10 , &val);if (error)return error;
@@ -622,13 +622,13 @@ static ssize_t adxl34x_write_store(struct device *dev, const char *buf, size_t count) {struct adxl34x *ac =dev_get_drvdata (dev); -unsigned long val; +u16 val;int error;/* * This allows basic ADXL register write access for debug purposes. */ - error =strict_strtoul (buf,16 , &val); + error =kstrtou16 (buf,16 , &val);if (error)return error;
@@ -639,7 +639,7 @@ static ssize_t adxl34x_write_store(struct device *dev,return count; } -static DEVICE_ATTR(write, 0664, NULL, adxl34x_write_store); +static DEVICE_ATTR(write, 0220, NULL, adxl34x_write_store);#endif static struct attribute *adxl34x_attributes[] = {
drivers/input/misc/ati_remote2.c +17 -14
@@ -41,14 +41,14 @@ static int ati_remote2_set_mask(const char *val,const struct kernel_param *kp, unsigned int max) { - unsigned long mask; + unsigned int mask;int ret;if (!val)return -EINVAL ; - ret =strict_strtoul (val,0 , &mask); -if (ret) + ret =kstrtouint (val,0 , &mask); +if (ret <0 )return ret;if (mask & ~max)
@@ -719,20 +719,21 @@ static ssize_t ati_remote2_store_channel_mask(struct device *dev,struct usb_device *udev =to_usb_device (dev);struct usb_interface *intf =usb_ifnum_to_if (udev,0 );struct ati_remote2 *ar2 =usb_get_intfdata (intf); -unsigned long mask; -int r; +unsigned int mask; +int rv; -if (strict_strtoul (buf,0 , &mask)) -return -EINVAL ; + rv =kstrtouint (buf,0 , &mask); +if (rv <0 ) +return rv;if (mask & ~ATI_REMOTE2_MAX_CHANNEL_MASK )return -EINVAL ; - r =usb_autopm_get_interface (ar2->intf[0 ]); -if (r) { + rv =usb_autopm_get_interface (ar2->intf[0 ]); +if (rv) {dev_err (&ar2->intf[0 ]->dev, -"%s(): usb_autopm_get_interface() = %d\n" , __func__, r); -return r; +"%s(): usb_autopm_get_interface() = %d\n" , __func__, rv); +return rv; }mutex_lock (&ati_remote2_mutex);
@@ -765,10 +766,12 @@ static ssize_t ati_remote2_store_mode_mask(struct device *dev,struct usb_device *udev =to_usb_device (dev);struct usb_interface *intf =usb_ifnum_to_if (udev,0 );struct ati_remote2 *ar2 =usb_get_intfdata (intf); -unsigned long mask; +unsigned int mask; +int rv; -if (strict_strtoul (buf,0 , &mask)) -return -EINVAL ; + rv =kstrtouint (buf,0 , &mask); +if (rv <0 ) +return rv;if (mask & ~ATI_REMOTE2_MAX_MODE_MASK )return -EINVAL ;
drivers/input/mouse/elantech.c +3 -7
@@ -517,16 +517,12 @@ static ssize_t elantech_set_int_attr(struct psmouse *psmouse,struct elantech_data *etd = psmouse->private;struct elantech_attr_data *attr = data;unsigned char *reg = (unsigned char *) etd + attr->field_offset; -unsigned long value; +u8 value;int err; - err =strict_strtoul (buf,16 , &value); -if (err) + err =kstrtou8 (buf,16 , &value); +if (err <0 )return err; - -if (value >0xff ) -return -EINVAL ; -/* Do we need to preserve some bits for version 2 hardware too? */ if (etd->hw_version ==1 ) {if (attr->reg ==0x10 )
drivers/input/mouse/hgpk.c +11 -7
@@ -787,11 +787,13 @@ static ssize_t hgpk_set_powered(struct psmouse *psmouse, void *data, const char *buf, size_t count) {struct hgpk_data *priv = psmouse->private; -unsigned long value; +unsigned int value;int err; - err =strict_strtoul (buf,10 , &value); -if (err || value >1 ) + err =kstrtouint (buf,10 , &value); +if (err <0 ) +return err; +if (value >1 )return -EINVAL ;if (value != priv->powered) {
@@ -879,11 +881,13 @@ static ssize_t hgpk_trigger_recal(struct psmouse *psmouse, void *data, const char *buf, size_t count) {struct hgpk_data *priv = psmouse->private; -unsigned long value; +unsigned int value;int err; - err =strict_strtoul (buf,10 , &value); -if (err || value !=1 ) + err =kstrtouint (buf,10 , &value); +if (err <0 ) +return err; +if (value !=1 )return -EINVAL ;/*
@@ -895,7 +899,7 @@ static ssize_t hgpk_trigger_recal(struct psmouse *psmouse, void *data,return count; } -__PSMOUSE_DEFINE_ATTR (recalibrate,S_IWUSR |S_IRUGO ,NULL , +__PSMOUSE_DEFINE_ATTR (recalibrate,S_IWUSR ,NULL , hgpk_trigger_recal_show, hgpk_trigger_recal, false);static void hgpk_disconnect (struct psmouse *psmouse)
drivers/input/mouse/logips2pp.c +6 -2
@@ -155,9 +155,13 @@ static ssize_t ps2pp_attr_show_smartscroll(struct psmouse *psmouse,static ssize_t ps2pp_attr_set_smartscroll (struct psmouse *psmouse,void *data,const char *buf,size_t count) { -unsigned long value; +unsigned int value; +int rv; -if (strict_strtoul (buf,10 , &value) || value >1 ) + rv =kstrtouint (buf,10 , &value); +if (rv <0 ) +return rv; +if (value >1 )return -EINVAL ;ps2pp_set_smartscroll (psmouse, value);
drivers/input/mouse/psmouse-base.c +14 -17
@@ -1546,16 +1546,11 @@ static ssize_t psmouse_show_int_attr(struct psmouse *psmouse, void *offset, charstatic ssize_t psmouse_set_int_attr (struct psmouse *psmouse,void *offset,const char *buf,size_t count) {unsigned int *field = (unsigned int *)((char *)psmouse + (size_t )offset); -unsigned long value; - -if (strict_strtoul (buf,10 , &value)) -return -EINVAL ; - -if ((unsigned int )value != value) -return -EINVAL ; - - *field = value; +int rv; + rv =kstrtouint (buf,10 , field); +if (rv <0 ) +return rv;return count; }
@@ -1660,22 +1655,24 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, costatic ssize_t psmouse_attr_set_rate (struct psmouse *psmouse,void *data,const char *buf,size_t count) { -unsigned long value; - -if (strict_strtoul (buf,10 , &value)) -return -EINVAL ; +unsigned int value; +int rv; + rv =kstrtouint (buf,10 , &value); +if (rv <0 ) +return rv; psmouse->set_rate (psmouse, value);return count; }static ssize_t psmouse_attr_set_resolution (struct psmouse *psmouse,void *data,const char *buf,size_t count) { -unsigned long value; - -if (strict_strtoul (buf,10 , &value)) -return -EINVAL ; +unsigned int value; +int rv; + rv =kstrtouint (buf,10 , &value); +if (rv <0 ) +return rv; psmouse->set_resolution (psmouse, value);return count; }
drivers/input/mouse/sentelic.c +42 -37
203 lines not on this page · raw message
drivers/input/mouse/sentelic.h +5 -5
@@ -66,17 +66,17 @@#ifdef __KERNEL__struct fsp_data { -unsigned char ver;/* hardware version */ -unsigned char rev;/* hardware revison */ -unsigned char buttons;/* Number of buttons */ +u8 ver;/* hardware version */ +u8 rev;/* hardware revison */ +u8 buttons;/* Number of buttons */ unsigned int flags;#define FSPDRV_FLAG_EN_OPC (0x001)/* enable on-pad clicking */ bool vscroll;/* Vertical scroll zone enabled */ bool hscroll;/* Horizontal scroll zone enabled */ -unsigned char last_reg;/* Last register we requested read from */ -unsigned char last_val; +u8 last_reg;/* Last register we requested read from */ +u8 last_val; };#ifdef CONFIG_MOUSE_PS2_SENTELIC
drivers/input/mouse/trackpoint.c +11 -8
@@ -89,13 +89,12 @@ static ssize_t trackpoint_set_int_attr(struct psmouse *psmouse, void *data,struct trackpoint_data *tp = psmouse->private;struct trackpoint_attr_data *attr = data;unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); -unsigned long value; +int rv; -if (strict_strtoul (buf,10 , &value) || value >255 ) -return -EINVAL ; - - *field = value; -trackpoint_write (&psmouse->ps2dev, attr->command, value); + rv =kstrtou8 (buf,10 , field); +if (rv <0 ) +return rv; +trackpoint_write (&psmouse->ps2dev, attr->command, *field);return count; }
@@ -115,9 +114,13 @@ static ssize_t trackpoint_set_bit_attr(struct psmouse *psmouse, void *data,struct trackpoint_data *tp = psmouse->private;struct trackpoint_attr_data *attr = data;unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); -unsigned long value; +u8 value; +int rv; -if (strict_strtoul (buf,10 , &value) || value >1 ) + rv =kstrtou8 (buf,10 , &value); +if (rv <0 ) +return rv; +if (value >1 )return -EINVAL ;if (attr->inverted)
drivers/input/tablet/aiptek.c +16 -18
@@ -1199,9 +1199,9 @@ static ssize_t store_tabletXtilt(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct aiptek *aiptek = dev_get_drvdata(dev); -long x; +int x; -if (strict_strtol (buf,10 , &x)) { +if (kstrtoint (buf,10 , &x)) {size_t len = buf[count -1 ] =='\n' ? count -1 : count;if (strncmp (buf,"disable" , len))
@@ -1241,9 +1241,9 @@ static ssize_t store_tabletYtilt(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct aiptek *aiptek = dev_get_drvdata(dev); -long y; +int y; -if (strict_strtol (buf,10 , &y)) { +if (kstrtoint (buf,10 , &y)) {size_t len = buf[count -1 ] =='\n' ? count -1 : count;if (strncmp (buf,"disable" , len))
@@ -1278,12 +1278,11 @@ static ssize_t store_tabletJitterDelay(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct aiptek *aiptek = dev_get_drvdata(dev); -long j; +int rv; -if (strict_strtol (buf,10 , &j)) -return -EINVAL ; - - aiptek->newSetting.jitterDelay = (int )j; + rv =kstrtoint (buf,10 , &aiptek->newSetting.jitterDelay); +if (rv <0 ) +return rv;return count; }
@@ -1307,12 +1306,11 @@ static ssize_t store_tabletProgrammableDelay(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct aiptek *aiptek = dev_get_drvdata(dev); -long d; +int rv; -if (strict_strtol (buf,10 , &d)) -return -EINVAL ; - - aiptek->newSetting.programmableDelay = (int )d; + rv =kstrtoint (buf,10 , &aiptek->newSetting.programmableDelay); +if (rv <0 ) +return rv;return count; }
@@ -1558,11 +1556,11 @@ static ssize_t store_tabletWheel(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct aiptek *aiptek = dev_get_drvdata(dev); -long w; - -if (strict_strtol (buf,10 , &w))return -EINVAL ; +int rv; - aiptek->newSetting.wheel = (int )w; + rv =kstrtoint (buf,10 , &aiptek->newSetting.wheel); +if (rv <0 ) +return rv;return count; }
drivers/input/touchscreen/ad7877.c +8 -8
@@ -489,8 +489,8 @@ static ssize_t ad7877_disable_store(struct device *dev,unsigned long val;int error; - error =strict_strtoul (buf,10 , &val); -if (error) + error =kstrtoul (buf,10 , &val); +if (error <0 )return error;if (val)
@@ -519,8 +519,8 @@ static ssize_t ad7877_dac_store(struct device *dev,unsigned long val;int error; - error =strict_strtoul (buf,10 , &val); -if (error) + error =kstrtoul (buf,10 , &val); +if (error <0 )return error;mutex_lock (&ts->mutex);
@@ -549,8 +549,8 @@ static ssize_t ad7877_gpio3_store(struct device *dev,unsigned long val;int error; - error =strict_strtoul (buf,10 , &val); -if (error) + error =kstrtoul (buf,10 , &val); +if (error <0 )return error;mutex_lock (&ts->mutex);
@@ -580,8 +580,8 @@ static ssize_t ad7877_gpio4_store(struct device *dev,unsigned long val;int error; - error =strict_strtoul (buf,10 , &val); -if (error) + error =kstrtoul (buf,10 , &val); +if (error <0 )return error;mutex_lock (&ts->mutex);
drivers/input/touchscreen/ad7879.c +2 -2
@@ -340,8 +340,8 @@ static ssize_t ad7879_disable_store(struct device *dev,unsigned long val;int error; - error =strict_strtoul (buf,10 , &val); -if (error) + error =kstrtoul (buf,10 , &val); +if (error <0 )return error;ad7879_toggle (ts, val);
drivers/input/touchscreen/ads7846.c +4 -2
@@ -590,9 +590,11 @@ static ssize_t ads7846_disable_store(struct device *dev, {struct ads7846 *ts =dev_get_drvdata (dev);unsigned long i; +int rv; -if (strict_strtoul (buf,10 , &i)) -return -EINVAL ; + rv =kstrtoul (buf,10 , &i); +if (rv <0 ) +return rv;if (i)ads7846_disable (ts);
Signature · 1 line
1.7.3.4
PATCH 28/52 kstrtox: convert drivers/mfd/
In reply to Alexey Dobriyan--- drivers/mfd/ab3100-core.c | 16 +++---------- drivers/mfd/ab3550-core.c | 48 +++++++++++++++-------------------------- drivers/mfd/ab8500-debugfs.c | 31 ++++++++------------------ 3 files changed, 32 insertions(+), 63 deletions(-)
drivers/mfd/ab3100-core.c +4 -12
@@ -497,7 +497,7 @@ static ssize_t ab3100_get_set_reg(struct file *file,char buf[32 ];ssize_t buf_size;int regp; -unsigned long user_reg; +u8 reg;int err;int i =0 ;
@@ -520,22 +520,19 @@ static ssize_t ab3100_get_set_reg(struct file *file,/* * Advance pointer to end of string then terminate * the register string. This is needed to satisfy -* the strict_strtoul() function. +* the kstrtou8() function. */ while ((i < buf_size) && (buf[i] !=' ' )) i++; buf[i] ='\0' ; - err =strict_strtoul (&buf[regp],16 , &user_reg); + err =kstrtou8 (&buf[regp],16 , ®);if (err)return err; -if (user_reg >0xff ) -return -EINVAL ;/* Either we read or we write a register here */ if (!priv->mode) {/* Reading */ -u8 reg = (u8 ) user_reg;u8 regvalue;ab3100_get_register_interruptible (ab3100, reg, ®value);
@@ -545,8 +542,6 @@ static ssize_t ab3100_get_set_reg(struct file *file, reg, regvalue); }else {int valp; -unsigned long user_value; -u8 reg = (u8 ) user_reg;u8 value;u8 regvalue;
@@ -563,13 +558,10 @@ static ssize_t ab3100_get_set_reg(struct file *file, i++; buf[i] ='\0' ; - err =strict_strtoul (&buf[valp],16 , &user_value); + err =kstrtou8 (&buf[valp],16 , &value);if (err)return err; -if (user_reg >0xff ) -return -EINVAL ; - value = (u8 ) user_value;ab3100_set_register_interruptible (ab3100, reg, value);ab3100_get_register_interruptible (ab3100, reg, ®value);
drivers/mfd/ab3550-core.c +18 -30
106 lines not on this page · raw message
drivers/mfd/ab8500-debugfs.c +10 -21
@@ -14,8 +14,8 @@#include <linux/mfd/abx500.h> #include <linux/mfd/ab8500.h> -static u32 debug_bank; -static u32 debug_address; +static u8 debug_bank; +static u8 debug_address;/** * struct ab8500_reg_range
@@ -430,9 +430,9 @@ static ssize_t ab8500_bank_write(struct file *file,return -EFAULT ; buf[buf_size] =0 ; - err =strict_strtoul (buf,0 , &user_bank); + err =kstrtoul (buf,0 , &user_bank);if (err) -return -EINVAL ; +return err;if (user_bank >=AB8500_NUM_BANKS ) {dev_err (dev,"debugfs error input > number of banks\n" );
@@ -458,10 +458,8 @@ static ssize_t ab8500_address_write(struct file *file,const char __user *user_buf, size_t count, loff_t *ppos) { - struct device *dev = ((struct seq_file *)(file->private_data))->private; char buf[32];int buf_size; -unsigned long user_address;int err;/* Get userspace string and assure termination */
@@ -470,14 +468,9 @@ static ssize_t ab8500_address_write(struct file *file,return -EFAULT ; buf[buf_size] =0 ; - err =strict_strtoul (buf,0 , &user_address); + err =kstrtou8 (buf,0 , &debug_address);if (err) -return -EINVAL ; -if (user_address >0xff ) { -dev_err (dev,"debugfs error input > 0xff\n" ); -return -EINVAL ; - } - debug_address = user_address; +return err;return buf_size; }
@@ -511,7 +504,7 @@ static ssize_t ab8500_val_write(struct file *file,struct device *dev = ((struct seq_file *)(file->private_data))->private;char buf[32 ];int buf_size; -unsigned long user_val; +u8 user_val;int err;/* Get userspace string and assure termination */
@@ -520,15 +513,11 @@ static ssize_t ab8500_val_write(struct file *file,return -EFAULT ; buf[buf_size] =0 ; - err =strict_strtoul (buf,0 , &user_val); + err =kstrtou8 (buf,0 , &user_val);if (err) -return -EINVAL ; -if (user_val >0xff ) { -dev_err (dev,"debugfs error input > 0xff\n" ); -return -EINVAL ; - } +return err; err =abx500_set_register_interruptible (dev, - (u8 )debug_bank, debug_address, (u8 )user_val); + (u8 )debug_bank, debug_address, user_val);if (err <0 ) {printk (KERN_ERR "abx500_set_reg failed %d, %d" , err, __LINE__);return -EINVAL ;
Signature · 1 line
1.7.3.4
PATCH 26/52 kstrtox: convert drivers/macintosh/
In reply to Alexey Dobriyan--- drivers/macintosh/ams/ams-input.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-)
drivers/macintosh/ams/ams-input.c +6 -3
@@ -116,10 +116,13 @@ static ssize_t ams_input_show_joystick(struct device *dev,static ssize_t ams_input_store_joystick (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) { -unsigned long enable; -int error =0 ; +unsigned int enable; +int error; -if (strict_strtoul (buf,0 , &enable) || enable >1 ) + error =kstrtouint (buf,0 , &enable); +if (error <0 ) +return error; +if (enable >1 )return -EINVAL ;mutex_lock (&ams_input_mutex);
Signature · 1 line
1.7.3.4
PATCH 25/52 kstrtox: convert drivers/leds/
In reply to Alexey Dobriyan--- drivers/leds/leds-bd2802.c | 10 +++++----- drivers/leds/leds-lp5521.c | 9 +++++---- drivers/leds/leds-lp5523.c | 11 ++++++----- drivers/leds/leds-netxbig.c | 2 +- drivers/leds/leds-ns2.c | 2 +- drivers/leds/leds-ss4200.c | 4 ++-- drivers/leds/ledtrig-backlight.c | 2 +- drivers/leds/ledtrig-gpio.c | 2 +- 8 files changed, 22 insertions(+), 20 deletions(-)
drivers/leds/leds-bd2802.c +5 -5
@@ -338,15 +338,15 @@ static ssize_t bd2802_store_reg##reg_addr(struct device *dev, \ struct device_attribute *attr, const char *buf, size_t count) \ { \ struct bd2802_led *led = i2c_get_clientdata(to_i2c_client(dev));\ -unsigned long val; \ +u8 val; \int ret; \if (!count) \return -EINVAL ; \ - ret =strict_strtoul (buf,16 , &val); \ + ret =kstrtou8 (buf,16 , &val); \if (ret) \return ret; \down_write (&led->rwsem); \ -bd2802_write_byte (led->client, reg_addr, (u8 ) val); \ +bd2802_write_byte (led->client, reg_addr, val); \up_write (&led->rwsem); \return count; \ } \
@@ -502,11 +502,11 @@ static ssize_t bd2802_store_##attr_name(struct device *dev, \ struct device_attribute *attr, const char *buf, size_t count) \ { \ struct bd2802_led *led = i2c_get_clientdata(to_i2c_client(dev));\ -unsigned long val; \ +unsigned int val; \int ret; \if (!count) \return -EINVAL ; \ - ret =strict_strtoul (buf,16 , &val); \ + ret =kstrtouint (buf,16 , &val); \if (ret) \return ret; \down_write (&led->rwsem); \
drivers/leds/leds-lp5521.c +5 -4
@@ -498,11 +498,12 @@ static ssize_t store_current(struct device *dev,struct led_classdev *led_cdev =dev_get_drvdata (dev);struct lp5521_led *led =cdev_to_led (led_cdev);struct lp5521_chip *chip =led_to_lp5521 (led); -ssize_t ret; -unsigned long curr; +u8 curr; +int ret; -if (strict_strtoul (buf,0 , &curr)) -return -EINVAL ; + ret =kstrtou8 (buf,0 , &curr); +if (ret <0 ) +return ret;if (curr > led->max_current)return -EINVAL ;
drivers/leds/leds-lp5523.c +6 -5
@@ -689,11 +689,12 @@ static ssize_t store_current(struct device *dev,struct led_classdev *led_cdev =dev_get_drvdata (dev);struct lp5523_led *led =cdev_to_led (led_cdev);struct lp5523_chip *chip =led_to_lp5523 (led); -ssize_t ret; -unsigned long curr; +u8 curr; +int ret; -if (strict_strtoul (buf,0 , &curr)) -return -EINVAL ; + ret =kstrtou8 (buf,0 , &curr); +if (ret <0 ) +return ret;if (curr > led->max_current)return -EINVAL ;
@@ -701,7 +702,7 @@ static ssize_t store_current(struct device *dev,mutex_lock (&chip->lock); ret =lp5523_write (chip->client,LP5523_REG_LED_CURRENT_BASE + led->chan_nr, - (u8 )curr); + curr);mutex_unlock (&chip->lock);if (ret <0 )
drivers/leds/leds-netxbig.c +1 -1
@@ -255,7 +255,7 @@ static ssize_t netxbig_led_sata_store(struct device *dev,int mode_val;int ret; - ret =strict_strtoul (buff,10 , &enable); + ret =kstrtoul (buff,10 , &enable);if (ret <0 )return ret;
drivers/leds/leds-ns2.c +1 -1
@@ -148,7 +148,7 @@ static ssize_t ns2_led_sata_store(struct device *dev,unsigned long enable;enum ns2_led_modes mode; - ret =strict_strtoul (buff,10 , &enable); + ret =kstrtoul (buff,10 , &enable);if (ret <0 )return ret;
drivers/leds/leds-ss4200.c +2 -2
@@ -457,9 +457,9 @@ static ssize_t nas_led_blink_store(struct device *dev, {int ret;struct led_classdev *led =dev_get_drvdata (dev); -unsigned long blink_state; +u32 blink_state; - ret =strict_strtoul (buf,10 , &blink_state); + ret =kstrtou32 (buf,10 , &blink_state);if (ret)return ret;
drivers/leds/ledtrig-backlight.c +1 -1
@@ -76,7 +76,7 @@ static ssize_t bl_trig_invert_store(struct device *dev,unsigned long invert;int ret; - ret =strict_strtoul (buf,10 , &invert); + ret =kstrtoul (buf,10 , &invert);if (ret <0 )return ret;
drivers/leds/ledtrig-gpio.c +1 -1
@@ -110,7 +110,7 @@ static ssize_t gpio_trig_inverted_store(struct device *dev,unsigned long inverted;int ret; - ret =strict_strtoul (buf,10 , &inverted); + ret =kstrtoul (buf,10 , &inverted);if (ret <0 )return ret;
Signature · 1 line
1.7.3.4
PATCH 22/52 kstrtox: convert drivers/infiniband/
In reply to Alexey Dobriyan--- drivers/infiniband/hw/nes/nes.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-)
drivers/infiniband/hw/nes/nes.c +5 -2
@@ -1132,12 +1132,15 @@ static ssize_t nes_show_wqm_quanta(struct device_driver *ddp, char *buf)static ssize_t nes_store_wqm_quanta (struct device_driver *ddp,const char *buf,size_t count) { -unsigned long wqm_quanta_value; +unsigned int wqm_quanta_value;u32 wqm_config1;u32 i =0 ;struct nes_device *nesdev; +int rv; -strict_strtoul (buf,0 , &wqm_quanta_value); + rv =kstrtouint (buf,0 , &wqm_quanta_value); +if (rv <0 ) +return rv;list_for_each_entry (nesdev, &nes_dev_list, list) {if (i == ee_flsh_adapter) { nesdev->nesadapter->wqm_quanta = wqm_quanta_value;
Signature · 1 line
1.7.3.4
PATCH 17/52 kstrtox: convert drivers/gpio/
In reply to Alexey Dobriyan--- drivers/gpio/gpiolib.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
drivers/gpio/gpiolib.c +6 -6
@@ -302,7 +302,7 @@ static ssize_t gpio_value_store(struct device *dev,else {long value; - status =strict_strtol (buf,0 , &value); + status =kstrtol (buf,0 , &value);if (status ==0 ) {if (test_bit (FLAG_ACTIVE_LOW , &desc->flags)) value = !value;
@@ -528,7 +528,7 @@ static ssize_t gpio_active_low_store(struct device *dev, }else {long value; - status =strict_strtol (buf,0 , &value); + status =kstrtol (buf,0 , &value);if (status ==0 ) status =sysfs_set_active_low (desc, dev, value !=0 ); }
@@ -606,10 +606,10 @@ static ssize_t export_store(struct class *class,struct class_attribute *attr, const char *buf, size_t len) { - long gpio; + unsigned int gpio;int status; - status =strict_strtol (buf,0 , &gpio); + status =kstrtouint (buf,0 , &gpio);if (status <0 ) goto done;
@@ -638,10 +638,10 @@ static ssize_t unexport_store(struct class *class,struct class_attribute *attr, const char *buf, size_t len) { - long gpio; + unsigned int gpio;int status; - status =strict_strtol (buf,0 , &gpio); + status =kstrtouint (buf,0 , &gpio);if (status <0 ) goto done;
Signature · 1 line
1.7.3.4
PATCH 16/52 kstrtox: convert drivers/edac/
In reply to Alexey Dobriyan--- drivers/edac/amd64_edac_inj.c | 135 +++++++++++++++++------------------------ drivers/edac/edac_mc_sysfs.c | 20 +++--- drivers/edac/i7core_edac.c | 41 +++++++------ drivers/edac/mce_amd_inj.c | 28 ++++----- 4 files changed, 101 insertions(+), 123 deletions(-)
drivers/edac/amd64_edac_inj.c +55 -80
@@ -16,21 +16,18 @@ static ssize_t amd64_inject_section_store(struct mem_ctl_info *mci, const char *data, size_t count) {struct amd64_pvt *pvt = mci->pvt_info; -unsigned long value; -int ret =0 ; - - ret =strict_strtoul (data,10 , &value); -if (ret != -EINVAL ) { - -if (value >3 ) { -amd64_warn ("%s: invalid section 0x%lx\n" , __func__, value); -return -EINVAL ; - } - - pvt->injection.section = (u32 ) value; -return count; +u32 value; +int ret; + + ret =kstrtou32 (data,10 , &value); +if (ret <0 ) +return ret; +if (value >3 ) { +amd64_warn ("%s: invalid section 0x%x\n" , __func__, value); +return -EINVAL ; } -return ret; + pvt->injection.section = value; +return count; }static ssize_t amd64_inject_word_show (struct mem_ctl_info *mci,char *buf)
@@ -49,21 +46,18 @@ static ssize_t amd64_inject_word_store(struct mem_ctl_info *mci, const char *data, size_t count) {struct amd64_pvt *pvt = mci->pvt_info; -unsigned long value; -int ret =0 ; - - ret =strict_strtoul (data,10 , &value); -if (ret != -EINVAL ) { - -if (value >8 ) { -amd64_warn ("%s: invalid word 0x%lx\n" , __func__, value); -return -EINVAL ; - } - - pvt->injection.word = (u32 ) value; -return count; +u32 value; +int ret; + + ret =kstrtou32 (data,10 , &value); +if (ret <0 ) +return ret; +if (value >8 ) { +amd64_warn ("%s: invalid word 0x%x\n" , __func__, value); +return -EINVAL ; } -return ret; + pvt->injection.word = value; +return count; }static ssize_t amd64_inject_ecc_vector_show (struct mem_ctl_info *mci,char *buf)
@@ -81,22 +75,19 @@ static ssize_t amd64_inject_ecc_vector_store(struct mem_ctl_info *mci, const char *data, size_t count) {struct amd64_pvt *pvt = mci->pvt_info; -unsigned long value; -int ret =0 ; - - ret =strict_strtoul (data,16 , &value); -if (ret != -EINVAL ) { - -if (value &0xFFFF0000 ) { -amd64_warn ("%s: invalid EccVector: 0x%lx\n" , +u32 value; +int ret; + + ret =kstrtou32 (data,16 , &value); +if (ret <0 ) +return ret; +if (value &0xFFFF0000 ) { +amd64_warn ("%s: invalid EccVector: 0x%x\n" , __func__, value); -return -EINVAL ; - } - - pvt->injection.bit_map = (u32 ) value; -return count; +return -EINVAL ; } -return ret; + pvt->injection.bit_map = value; +return count; }/*
@@ -107,29 +98,22 @@ static ssize_t amd64_inject_read_store(struct mem_ctl_info *mci, const char *data, size_t count) {struct amd64_pvt *pvt = mci->pvt_info; -unsigned long value;u32 section, word_bits; -int ret =0 ; - - ret =strict_strtoul (data,10 , &value); -if (ret != -EINVAL ) { -/* Form value to choose 16-byte section of cacheline */ - section =F10_NB_ARRAY_DRAM_ECC | -SET_NB_ARRAY_ADDRESS (pvt->injection.section); -pci_write_config_dword (pvt->F3,F10_NB_ARRAY_ADDR , section); +/* Form value to choose 16-byte section of cacheline */ + section =F10_NB_ARRAY_DRAM_ECC | +SET_NB_ARRAY_ADDRESS (pvt->injection.section); +pci_write_config_dword (pvt->F3,F10_NB_ARRAY_ADDR , section); - word_bits =SET_NB_DRAM_INJECTION_READ (pvt->injection.word, - pvt->injection.bit_map); + word_bits =SET_NB_DRAM_INJECTION_READ (pvt->injection.word, + pvt->injection.bit_map); -/* Issue 'word' and 'bit' along with the READ request */ -pci_write_config_dword (pvt->F3,F10_NB_ARRAY_DATA , word_bits); +/* Issue 'word' and 'bit' along with the READ request */ +pci_write_config_dword (pvt->F3,F10_NB_ARRAY_DATA , word_bits); -debugf0 ("section=0x%x word_bits=0x%x\n" , section, word_bits); +debugf0 ("section=0x%x word_bits=0x%x\n" , section, word_bits); -return count; - } -return ret; +return count; }/*
@@ -140,29 +124,22 @@ static ssize_t amd64_inject_write_store(struct mem_ctl_info *mci, const char *data, size_t count) {struct amd64_pvt *pvt = mci->pvt_info; -unsigned long value;u32 section, word_bits; -int ret =0 ; - - ret =strict_strtoul (data,10 , &value); -if (ret != -EINVAL ) { -/* Form value to choose 16-byte section of cacheline */ - section =F10_NB_ARRAY_DRAM_ECC | -SET_NB_ARRAY_ADDRESS (pvt->injection.section); -pci_write_config_dword (pvt->F3,F10_NB_ARRAY_ADDR , section); +/* Form value to choose 16-byte section of cacheline */ + section =F10_NB_ARRAY_DRAM_ECC | +SET_NB_ARRAY_ADDRESS (pvt->injection.section); +pci_write_config_dword (pvt->F3,F10_NB_ARRAY_ADDR , section); - word_bits =SET_NB_DRAM_INJECTION_WRITE (pvt->injection.word, - pvt->injection.bit_map); + word_bits =SET_NB_DRAM_INJECTION_WRITE (pvt->injection.word, + pvt->injection.bit_map); -/* Issue 'word' and 'bit' along with the READ request */ -pci_write_config_dword (pvt->F3,F10_NB_ARRAY_DATA , word_bits); +/* Issue 'word' and 'bit' along with the READ request */ +pci_write_config_dword (pvt->F3,F10_NB_ARRAY_DATA , word_bits); -debugf0 ("section=0x%x word_bits=0x%x\n" , section, word_bits); +debugf0 ("section=0x%x word_bits=0x%x\n" , section, word_bits); -return count; - } -return ret; +return count; }/*
@@ -197,17 +174,15 @@ struct mcidev_sysfs_attribute amd64_inj_attrs[] = { { .attr = { .name = "inject_write", - .mode = (S_IRUGO | S_IWUSR) + .mode = S_IWUSR, }, - .show = NULL, .store = amd64_inject_write_store, }, { .attr = { .name = "inject_read", - .mode = (S_IRUGO | S_IWUSR) + .mode = S_IWUSR, }, - .show = NULL, .store = amd64_inject_read_store, }, };
drivers/edac/edac_mc_sysfs.c +11 -9
@@ -48,16 +48,16 @@ int edac_mc_get_poll_msec(void)static int edac_set_poll_msec (const char *val,struct kernel_param *kp) { -long l; +unsigned int l;int ret;if (!val)return -EINVAL ; - ret =strict_strtol (val,0 , &l); -if (ret == -EINVAL || ((int )l != l)) -return -EINVAL ; - *((int *)kp->arg) = l; + ret =kstrtouint (val,0 , &l); +if (ret <0 ) +return ret; + *(unsigned int *)kp->arg = l;/* notify edac_mc engine to reset the poll period */ edac_mc_reset_delay_period (l);
@@ -448,14 +448,16 @@ static ssize_t mci_reset_counters_store(struct mem_ctl_info *mci,static ssize_t mci_sdram_scrub_rate_store (struct mem_ctl_info *mci,const char *data,size_t count) { -unsigned long bandwidth =0 ; +u32 bandwidth;int new_bw =0 ; +int rv;if (!mci->set_sdram_scrub_rate)return -EINVAL ; -if (strict_strtoul (data,10 , &bandwidth) <0 ) -return -EINVAL ; + rv =kstrtou32 (data,10 , &bandwidth); +if (rv <0 ) +return rv; new_bw = mci->set_sdram_scrub_rate (mci, bandwidth);if (new_bw >=0 ) {
@@ -463,7 +465,7 @@ static ssize_t mci_sdram_scrub_rate_store(struct mem_ctl_info *mci,return count; } -edac_printk (KERN_DEBUG ,EDAC_MC ,"Error setting scrub rate to: %lu\n" , bandwidth); +edac_printk (KERN_DEBUG ,EDAC_MC ,"Error setting scrub rate to: %u\n" , bandwidth);return -EINVAL ; }
drivers/edac/i7core_edac.c +22 -19
97 lines not on this page · raw message
drivers/edac/mce_amd_inj.c +13 -15
@@ -39,15 +39,13 @@ static ssize_t edac_inject_##reg##_store(struct kobject *kobj, \struct edac_mce_attr *attr, \ const char *data, size_t count)\ { \ - int ret = 0; \ -unsigned long value; \ + int ret; \ \ - ret =strict_strtoul (data,16 , &value); \ -if (ret <0 ) \ + ret =kstrtou64 (data,16 , &i_mce.reg); \ +if (ret <0 ) { \ printk(KERN_ERR "Error writing MCE " #reg " field.\n"); \ - \ - i_mce.reg = value; \ - \ +return ret; \ + } \return count; \ }
@@ -79,22 +77,22 @@ static ssize_t edac_inject_bank_store(struct kobject *kobj,struct edac_mce_attr *attr, const char *data, size_t count) { - int ret = 0; -unsigned long value; + u8 bank; +int ret; - ret =strict_strtoul (data,10 , &value); + ret =kstrtou8 (data,10 , &bank);if (ret <0 ) {printk (KERN_ERR "Invalid bank value!\n" ); -return -EINVAL ; +return ret; } -if (value >5 ) -if (boot_cpu_data.x86 !=0x15 || value >6 ) { -printk (KERN_ERR "Non-existant MCE bank: %lu\n" , value); +if (bank >5 ) +if (boot_cpu_data.x86 !=0x15 || bank >6 ) { +printk (KERN_ERR "Non-existant MCE bank: %hhu\n" , bank);return -EINVAL ; } - i_mce.bank = value; + i_mce.bank = bank;amd_decode_mce (NULL ,0 , &i_mce);
Signature · 1 line
1.7.3.4
PATCH 13/52 kstrtox: convert drivers/block/
In reply to Alexey Dobriyan--- drivers/block/osdblk.c | 10 ++-------- drivers/block/rbd.c | 8 +------- 2 files changed, 3 insertions(+), 15 deletions(-)
drivers/block/osdblk.c +2 -8
@@ -596,18 +596,12 @@ static ssize_t class_osdblk_remove(struct class *c, {struct osdblk_device *osdev =NULL ;int target_id, rc; -unsigned long ul;struct list_head *tmp; - rc =strict_strtoul (buf,10 , &ul); -if (rc) + rc =kstrtoint (buf,10 , &target_id); +if (rc <0 )return rc; -/* convert to int; abort if we lost anything in the conversion */ - target_id = (int ) ul; -if (target_id != ul) -return -EINVAL ; -/* remove object from list immediately */ mutex_lock_nested (&ctl_mutex,SINGLE_DEPTH_NESTING );
drivers/block/rbd.c +1 -7
@@ -1866,18 +1866,12 @@ static ssize_t rbd_remove(struct bus_type *bus, {struct rbd_device *rbd_dev =NULL ;int target_id, rc; -unsigned long ul;int ret = count; - rc =strict_strtoul (buf,10 , &ul); + rc =kstrtoint (buf,10 , &target_id);if (rc)return rc; -/* convert to int; abort if we lost anything in the conversion */ - target_id = (int ) ul; -if (target_id != ul) -return -EINVAL ; -mutex_lock_nested (&ctl_mutex,SINGLE_DEPTH_NESTING ); rbd_dev =__rbd_get_dev (target_id);
Signature · 1 line
1.7.3.4
PATCH 10/52 kstrtox: convert drivers/acpi/
In reply to Alexey Dobriyan--- drivers/acpi/acpi_pad.c | 27 ++++++++++++++++++--------- drivers/acpi/power_meter.c | 16 +++++++--------- 2 files changed, 25 insertions(+), 18 deletions(-)
drivers/acpi/acpi_pad.c +18 -9
@@ -284,9 +284,12 @@ static uint32_t acpi_pad_idle_cpus_num(void)static ssize_t acpi_pad_rrtime_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) { -unsigned long num; -if (strict_strtoul (buf,0 , &num)) -return -EINVAL ; +unsigned int num; +int rv; + + rv =kstrtouint (buf,0 , &num); +if (rv <0 ) +return rv;if (num <1 || num >=100 )return -EINVAL ;mutex_lock (&isolated_cpus_lock);
@@ -307,9 +310,12 @@ static DEVICE_ATTR(rrtime, S_IRUGO|S_IWUSR,static ssize_t acpi_pad_idlepct_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) { -unsigned long num; -if (strict_strtoul (buf,0 , &num)) -return -EINVAL ; +unsigned int num; +int rv; + + rv =kstrtouint (buf,0 , &num); +if (rv <0 ) +return rv;if (num <1 || num >=100 )return -EINVAL ;mutex_lock (&isolated_cpus_lock);
@@ -330,9 +336,12 @@ static DEVICE_ATTR(idlepct, S_IRUGO|S_IWUSR,static ssize_t acpi_pad_idlecpus_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) { -unsigned long num; -if (strict_strtoul (buf,0 , &num)) -return -EINVAL ; +unsigned int num; +int rv; + + rv =kstrtouint (buf,0 , &num); +if (rv <0 ) +return rv;mutex_lock (&isolated_cpus_lock);acpi_pad_idle_cpus (num);mutex_unlock (&isolated_cpus_lock);
drivers/acpi/power_meter.c +7 -9
@@ -166,12 +166,12 @@ static ssize_t set_avg_interval(struct device *dev,union acpi_object arg0 = {ACPI_TYPE_INTEGER };struct acpi_object_list args = {1 , &arg0 };int res; -unsigned long temp; +u64 temp;unsigned long long data;acpi_status status; - res =strict_strtoul (buf,10 , &temp); -if (res) + res =kstrtou64 (buf,10 , &temp); +if (res <0 )return res; if (temp > resource->caps.max_avg_interval ||
@@ -241,8 +241,8 @@ static ssize_t set_cap(struct device *dev, struct device_attribute *devattr,unsigned long long data;acpi_status status; - res =strict_strtoul (buf,10 , &temp); -if (res) + res =kstrtoul (buf,10 , &temp); +if (res <0 )return res; temp /=1000 ;
@@ -311,13 +311,11 @@ static ssize_t set_trip(struct device *dev, struct device_attribute *devattr,int res;unsigned long temp; - res =strict_strtoul (buf,10 , &temp); -if (res) + res =kstrtoul (buf,10 , &temp); +if (res <0 )return res; temp /=1000 ; -if (temp <0 ) -return -EINVAL ;mutex_lock (&resource->lock); resource->trip[attr->index -7 ] = temp;
Signature · 1 line
1.7.3.4
PATCH 6/52 kstrtox: convert security/
In reply to Alexey Dobriyan--- security/apparmor/lsm.c | 2 +- security/integrity/ima/ima_audit.c | 2 +- security/integrity/ima/ima_policy.c | 15 ++++----------- security/keys/encrypted.c | 8 +++++--- security/keys/trusted.c | 23 +++++++++++------------ security/selinux/hooks.c | 4 ++-- security/selinux/selinuxfs.c | 2 +- security/tomoyo/common.c | 8 +++++--- 8 files changed, 30 insertions(+), 34 deletions(-)
security/apparmor/lsm.c +1 -1
@@ -754,7 +754,7 @@ module_param_named(enabled, apparmor_enabled, aabool, S_IRUSR);static int __init apparmor_enabled_setup (char *str) {unsigned long enabled; -int error =strict_strtoul (str,0 , &enabled); +int error =kstrtoul (str,0 , &enabled);if (!error) apparmor_enabled = enabled ?1 :0 ;return 1 ;
security/integrity/ima/ima_audit.c +1 -1
@@ -24,7 +24,7 @@ static int __init ima_audit_setup(char *str) {unsigned long audit; -if (!strict_strtoul (str,0 , &audit)) +if (!kstrtoul (str,0 , &audit)) ima_audit = audit ?1 :0 ;return 1 ; }
security/integrity/ima/ima_policy.c +4 -11
@@ -278,7 +278,6 @@ static int ima_parse_rule(char *rule, struct ima_measure_rule_entry *entry)while ((p =strsep (&rule," \t" )) !=NULL ) {substring_t args[MAX_OPT_ARGS ];int token; -unsigned long lnum;if (result <0 )break ;
@@ -349,8 +348,7 @@ static int ima_parse_rule(char *rule, struct ima_measure_rule_entry *entry)break ; } - result =strict_strtoul (args[0 ].from,16 , - &entry->fsmagic); + result =kstrtoul (args[0 ].from,16 , &entry->fsmagic);if (!result) entry->flags |=IMA_FSMAGIC ;break ;
@@ -362,14 +360,9 @@ static int ima_parse_rule(char *rule, struct ima_measure_rule_entry *entry)break ; } - result =strict_strtoul (args[0 ].from,10 , &lnum); -if (!result) { - entry->uid = (uid_t ) lnum; -if (entry->uid != lnum) - result = -EINVAL ; -else - entry->flags |=IMA_UID ; - } + result =kstrtou32 (args[0 ].from,10 , &entry->uid); +if (!result) + entry->flags |=IMA_UID ;break ;case Opt_obj_user:ima_log_string (ab,"obj_user" , args[0 ].from);
security/keys/encrypted.c +5 -3
@@ -521,11 +521,13 @@ static struct encrypted_key_payload *encrypted_key_alloc(struct key *key,unsigned short datablob_len;unsigned short decrypted_datalen;unsigned int encrypted_datalen; -long dlen; +unsigned int dlen;int ret; - ret =strict_strtol (datalen,10 , &dlen); -if (ret <0 || dlen <MIN_DATA_SIZE || dlen >MAX_DATA_SIZE ) + ret =kstrtouint (datalen,10 , &dlen); +if (ret <0 ) +return ERR_PTR (ret); +if (dlen <MIN_DATA_SIZE || dlen >MAX_DATA_SIZE )return ERR_PTR (-EINVAL ); decrypted_datalen = dlen;
security/keys/trusted.c +11 -12
@@ -766,8 +766,6 @@ static int getoptions(char *c, struct trusted_key_payload *pay,char *p = c;int token;int res; -unsigned long handle; -unsigned long lock;while ((p =strsep (&c," \t" ))) {if (*p =='\0' || *p ==' ' || *p =='\t' )
@@ -782,11 +780,10 @@ static int getoptions(char *c, struct trusted_key_payload *pay,hex2bin (opt->pcrinfo, args[0 ].from, opt->pcrinfo_len);break ;case Opt_keyhandle: - res =strict_strtoul (args[0 ].from,16 , &handle); -if (res <0 ) -return -EINVAL ; opt->keytype = SEAL_keytype; - opt->keyhandle = handle; + res =kstrtou32 (args[0 ].from,16 , &opt->keyhandle); +if (res <0 ) +return res;break ;case Opt_keyauth:if (strlen (args[0 ].from) !=2 *SHA1_DIGEST_SIZE )
@@ -805,10 +802,9 @@ static int getoptions(char *c, struct trusted_key_payload *pay,return -EINVAL ;break ;case Opt_pcrlock: - res =strict_strtoul (args[0 ].from,10 , &lock); + res =kstrtoint (args[0 ].from,10 , &opt->pcrlock);if (res <0 ) -return -EINVAL ; - opt->pcrlock = lock; +return res;break ;default :return -EINVAL ;
@@ -827,7 +823,6 @@ static int datablob_parse(char *datablob, struct trusted_key_payload *p, struct trusted_key_options *o) {substring_t args[MAX_OPT_ARGS ]; -long keylen;int ret = -EINVAL ;int key_cmd;char *c;
@@ -838,13 +833,17 @@ static int datablob_parse(char *datablob, struct trusted_key_payload *p,return -EINVAL ; key_cmd =match_token (c, key_tokens, args);switch (key_cmd) { +unsigned int keylen; +case Opt_new:/* first argument is key size */ c =strsep (&datablob," \t" );if (!c)return -EINVAL ; - ret =strict_strtol (c,10 , &keylen); -if (ret <0 || keylen <MIN_KEY_SIZE || keylen >MAX_KEY_SIZE ) + ret =kstrtouint (c,10 , &keylen); +if (ret <0 ) +return ret; +if (keylen <MIN_KEY_SIZE || keylen >MAX_KEY_SIZE )return -EINVAL ; p->key_len = keylen; ret =getoptions (datablob, p, o);
security/selinux/hooks.c +2 -2
@@ -101,7 +101,7 @@ int selinux_enforcing;static int __init enforcing_setup (char *str) {unsigned long enforcing; -if (!strict_strtoul (str,0 , &enforcing)) +if (!kstrtoul (str,0 , &enforcing)) selinux_enforcing = enforcing ?1 :0 ;return 1 ; }
@@ -114,7 +114,7 @@ int selinux_enabled = CONFIG_SECURITY_SELINUX_BOOTPARAM_VALUE;static int __init selinux_enabled_setup (char *str) {unsigned long enabled; -if (!strict_strtoul (str,0 , &enabled)) +if (!kstrtoul (str,0 , &enabled)) selinux_enabled = enabled ?1 :0 ;return 1 ; }
security/selinux/selinuxfs.c +1 -1
@@ -50,7 +50,7 @@ unsigned int selinux_checkreqprot = CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE;static int __init checkreqprot_setup (char *str) {unsigned long checkreqprot; -if (!strict_strtoul (str,0 , &checkreqprot)) +if (!kstrtoul (str,0 , &checkreqprot)) selinux_checkreqprot = checkreqprot ?1 :0 ;return 1 ; }
security/tomoyo/common.c +5 -3
@@ -1091,14 +1091,16 @@ static int tomoyo_write_domain_profile(struct tomoyo_io_buffer *head)char *data = head->write_buf;char *cp =strchr (data,' ' );struct tomoyo_domain_info *domain; -unsigned long profile; +unsigned int profile; +int rv;if (!cp)return -EINVAL ; *cp ='\0' ; domain =tomoyo_find_domain (cp +1 ); -if (strict_strtoul (data,10 , &profile)) -return -EINVAL ; + rv =kstrtouint (data,10 , &profile); +if (rv <0 ) +return rv;if (domain && profile <TOMOYO_MAX_PROFILES && (tomoyo_profile_ptr[profile] || !tomoyo_policy_loaded)) domain->profile = (u8 ) profile;
Signature · 1 line
1.7.3.4
PATCH 3/52 kstrtox: convert kernel/trace/
In reply to Alexey Dobriyan--- kernel/trace/ftrace.c | 6 +++--- kernel/trace/ring_buffer.c | 2 +- kernel/trace/trace.c | 16 ++++++++-------- kernel/trace/trace_events.c | 8 ++++---- kernel/trace/trace_events_filter.c | 4 ++-- kernel/trace/trace_functions.c | 4 ++-- kernel/trace/trace_kprobe.c | 25 ++++++++++++------------- kernel/trace/trace_stack.c | 4 ++-- 8 files changed, 34 insertions(+), 35 deletions(-)
kernel/trace/ftrace.c +3 -3
@@ -747,7 +747,7 @@ ftrace_profile_write(struct file *filp, const char __user *ubuf, buf[cnt] =0 ; - ret =strict_strtoul (buf,10 , &val); + ret =kstrtoul (buf,10 , &val);if (ret <0 )return ret;
@@ -3053,7 +3053,7 @@ ftrace_pid_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *ppos) { char buf[64], *tmp; -long val; +int val;int ret;if (cnt >=sizeof (buf))
@@ -3072,7 +3072,7 @@ ftrace_pid_write(struct file *filp, const char __user *ubuf,if (strlen (tmp) ==0 )return 1 ; - ret =strict_strtol (tmp,10 , &val); + ret =kstrtoint (tmp,10 , &val);if (ret <0 )return ret;
kernel/trace/ring_buffer.c +1 -1
@@ -3972,7 +3972,7 @@ rb_simple_write(struct file *filp, const char __user *ubuf, buf[cnt] =0 ; - ret =strict_strtoul (buf,10 , &val); + ret =kstrtoul (buf,10 , &val);if (ret <0 )return ret;
kernel/trace/trace.c +8 -8
@@ -389,7 +389,7 @@ static int __init set_tracing_thresh(char *str)if (!str)return 0 ; - ret =strict_strtoul (str,0 , &threshhold); + ret =kstrtoul (str,0 , &threshhold);if (ret <0 )return 0 ; tracing_thresh = threshhold *1000 ;
@@ -2702,7 +2702,7 @@ tracing_ctrl_write(struct file *filp, const char __user *ubuf, buf[cnt] =0 ; - ret =strict_strtoul (buf,10 , &val); + ret =kstrtoul (buf,10 , &val);if (ret <0 )return ret;
@@ -2963,7 +2963,7 @@ tracing_max_lat_write(struct file *filp, const char __user *ubuf, buf[cnt] =0 ; - ret =strict_strtoul (buf,10 , &val); + ret =kstrtoul (buf,10 , &val);if (ret <0 )return ret;
@@ -3422,7 +3422,7 @@ tracing_entries_write(struct file *filp, const char __user *ubuf, buf[cnt] =0 ; - ret =strict_strtoul (buf,10 , &val); + ret =kstrtoul (buf,10 , &val);if (ret <0 )return ret;
@@ -4075,7 +4075,7 @@ trace_options_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *ppos) {struct trace_option_dentry *topt = filp->private_data; -unsigned long val; +unsigned int val;char buf[64 ];int ret;
@@ -4087,7 +4087,7 @@ trace_options_write(struct file *filp, const char __user *ubuf, size_t cnt, buf[cnt] =0 ; - ret =strict_strtoul (buf,10 , &val); + ret =kstrtouint (buf,10 , &val);if (ret <0 )return ret;
@@ -4137,7 +4137,7 @@ trace_options_core_write(struct file *filp, const char __user *ubuf, size_t cnt, {long index = (long )filp->private_data;char buf[64 ]; -unsigned long val; +unsigned int val;int ret;if (cnt >=sizeof (buf))
@@ -4148,7 +4148,7 @@ trace_options_core_write(struct file *filp, const char __user *ubuf, size_t cnt, buf[cnt] =0 ; - ret =strict_strtoul (buf,10 , &val); + ret =kstrtouint (buf,10 , &val);if (ret <0 )return ret;
kernel/trace/trace_events.c +4 -4
@@ -486,7 +486,7 @@ event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt, {struct ftrace_event_call *call = filp->private_data;char buf[64 ]; -unsigned long val; +int val;int ret;if (cnt >=sizeof (buf))
@@ -497,7 +497,7 @@ event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt, buf[cnt] =0 ; - ret =strict_strtoul (buf,10 , &val); + ret =kstrtoint (buf,10 , &val);if (ret <0 )return ret;
@@ -569,8 +569,8 @@ system_enable_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *ppos) {const char *system = filp->private_data; -unsigned long val;char buf[64 ]; +int val;ssize_t ret;if (cnt >=sizeof (buf))
@@ -581,7 +581,7 @@ system_enable_write(struct file *filp, const char __user *ubuf, size_t cnt, buf[cnt] =0 ; - ret =strict_strtoul (buf,10 , &val); + ret =kstrtoint (buf,10 , &val);if (ret <0 )return ret;
kernel/trace/trace_events_filter.c +2 -2
@@ -807,9 +807,9 @@ static int filter_add_pred(struct filter_parse_state *ps, fn = filter_pred_pchar; }else {if (field->is_signed) - ret =strict_strtoll (pred->regex.pattern,0 , &val); + ret =kstrtoll (pred->regex.pattern,0 , &val);else - ret =strict_strtoull (pred->regex.pattern,0 , &val); + ret =kstrtoull (pred->regex.pattern,0 , &val);if (ret) {parse_error (ps,FILT_ERR_ILLEGAL_INTVAL ,0 );return -EINVAL ;
kernel/trace/trace_functions.c +2 -2
@@ -354,8 +354,8 @@ ftrace_trace_onoff_callback(char *glob, char *cmd, char *param, int enable)* We use the callback data field (which is a pointer) * as our counter. */ - ret =strict_strtoul (number,0 , (unsigned long *)&count); -if (ret) + ret =kstrtoul (number,0 , (unsigned long *)&count); +if (ret <0 )return ret; out_reg:
kernel/trace/trace_kprobe.c +12 -13
@@ -684,9 +684,8 @@ static int split_symbol_offset(char *symbol, unsigned long *offset) tmp =strchr (symbol,'+' );if (tmp) { -/* skip sign because strict_strtol doesn't accept '+' */ - ret =strict_strtoul (tmp +1 ,0 , offset); -if (ret) + ret =kstrtoul (tmp,0 , offset); +if (ret <0 )return ret; *tmp ='\0' ; }else
@@ -715,8 +714,10 @@ static int parse_probe_vars(char *arg, const struct fetch_type *t,else ret = -EINVAL ; }else if (isdigit (arg[5 ])) { - ret =strict_strtoul (arg +5 ,10 , ¶m); -if (ret || param >PARAM_MAX_STACK ) + ret =kstrtoul (arg +5 ,10 , ¶m); +if (ret <0 ) +return ret; +if (param >PARAM_MAX_STACK ) ret = -EINVAL ;else { f->fn = t->fetch[FETCH_MTD_stack];
@@ -752,8 +753,8 @@ static int __parse_probe_arg(char *arg, const struct fetch_type *t,break ;case '@' :/* memory or symbol */ if (isdigit (arg[1 ])) { - ret =strict_strtoul (arg +1 ,0 , ¶m); -if (ret) + ret =kstrtoul (arg +1 ,0 , ¶m); +if (ret <0 )break ; f->fn = t->fetch[FETCH_MTD_memory]; f->data = (void *)param;
@@ -772,11 +773,9 @@ static int __parse_probe_arg(char *arg, const struct fetch_type *t,if (!tmp)break ; *tmp ='\0' ; - ret =strict_strtol (arg +1 ,0 , &offset); -if (ret) + ret =kstrtol (arg,0 , &offset); +if (ret <0 )break ; -if (arg[0 ] =='-' ) - offset = -offset; arg = tmp +1 ; tmp =strrchr (arg,')' );if (tmp) {
@@ -948,8 +947,8 @@ static int create_trace_probe(int argc, char **argv)return -EINVAL ; }/* an address specified */ - ret =strict_strtoul (&argv[1 ][0 ],0 , (unsigned long *)&addr); -if (ret) { + ret =kstrtoul (&argv[1 ][0 ],0 , (unsigned long *)&addr); +if (ret <0 ) {pr_info ("Failed to parse address.\n" );return ret; }
kernel/trace/trace_stack.c +2 -2
@@ -153,7 +153,7 @@ static ssize_t stack_max_size_write(struct file *filp, const char __user *ubuf, size_t count, loff_t *ppos) { - long *ptr = filp->private_data; + unsigned long *ptr = filp->private_data;unsigned long val, flags;char buf[64 ];int ret;
@@ -167,7 +167,7 @@ stack_max_size_write(struct file *filp, const char __user *ubuf, buf[count] =0 ; - ret =strict_strtoul (buf,10 , &val); + ret =kstrtoul (buf,10 , &val);if (ret <0 )return ret;
Signature · 1 line
1.7.3.4
lib/kstrtox.c line 3
Quoted 6 lines · Alexey Dobriyan
lib/kstrtox.c new file +3
-0@@ -0,0 +1,227 @@ +/* +* Convert integer string representation to an integer. +* If an integer doesn't fit into specified type, -E is returned.
Which -E? Currently it returns -EINVAL everywhere.
lib/kstrtox.c line 117
Quoted 10 lines
lib/kstrtox.c new file +10
-0+int _kstrtoul (const char *s,unsigned int base,unsigned long *res) +{ + unsigned long long tmp; + int rv; + + rv = kstrtoull(s, base, &tmp); + if (rv < 0) + return rv; + if (tmp != (unsigned long long)(unsigned long)tmp) + return -EINVAL;
-ERANGE for out-of-range?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Quoted 6 lines · Geert Uytterhoeven
Quoted 2 lines · Alexey Dobriyan
+ * Convert integer string representation to an integer.
+ * If an integer doesn't fit into specified type, -E is returned.Which -E? Currently it returns
-EINVALeverywhere.
Comment meant function follows 0/-E idiom for return value.
Quoted 4 lines
Quoted 2 lines
+ if (tmp != (unsigned long long)(unsigned long)tmp)
+ return-EINVAL;
-ERANGEfor out-of-range?
Hmm, interesting.
It should prevent -EINVAL hardcoding.
Borislav Petkov
maintainerRe: [PATCH 16/52] kstrtox: convert drivers/edac/
In reply to Alexey DobriyanOn Sat, Feb 05, 2011 at 04:20:19PM +0200, Alexey Dobriyan wrote:
Some kind of a boilerplate commit message is still better than none at all.
Quoted 26 lines
Signed-off-by Alexey Dobriyan <[email protected]>--- drivers/edac/amd64_edac_inj.c | 135 +++++++++++++++++------------------------ drivers/edac/edac_mc_sysfs.c | 20 +++--- drivers/edac/i7core_edac.c | 41 +++++++------ drivers/edac/mce_amd_inj.c | 28 ++++----- 4 files changed, 101 insertions(+), 123 deletions(-)drivers/edac/amd64_edac_inj.c +0
-9@@ -16,21 +16,18 @@ static ssize_t amd64_inject_section_store(struct mem_ctl_info *mci, const char *data, size_t count) {struct amd64_pvt *pvt = mci->pvt_info; -unsigned long value; -int ret =0 ; - - ret =strict_strtoul (data,10 , &value); -if (ret != -EINVAL ) { - -if (value >3 ) { -amd64_warn ("%s: invalid section 0x%lx\n" , __func__, value); -return -EINVAL ;
drivers/edac/amd64_edac_inj.c static ssize_t amd64_inject_section_store(struct mem_ctl_info *mci, · line 24
Quoted 10 lines
drivers/edac/amd64_edac_inj.c +6
-4- } - - pvt->injection.section = (u32 ) value; -return count; +u32 value; +int ret; + + ret =kstrtou32 (data,10 , &value); +if (ret <0 ) +return ret;
newline here
drivers/edac/amd64_edac_inj.c static ssize_t amd64_inject_section_store(struct mem_ctl_info *mci, · line 28
Quoted 4 lines
drivers/edac/amd64_edac_inj.c +3
-0+if (value >3 ) { +amd64_warn ("%s: invalid section 0x%x\n" , __func__, value); +return -EINVAL ; }
and here.
Quoted 19 lines
drivers/edac/amd64_edac_inj.c +2
-10-return ret; + pvt->injection.section = value; +return count; }static ssize_t amd64_inject_word_show (struct mem_ctl_info *mci,char *buf)@@ -49,21 +46,18 @@ static ssize_t amd64_inject_word_store(struct mem_ctl_info *mci, const char *data, size_t count) {struct amd64_pvt *pvt = mci->pvt_info; -unsigned long value; -int ret =0 ; - - ret =strict_strtoul (data,10 , &value); -if (ret != -EINVAL ) { - -if (value >8 ) { -amd64_warn ("%s: invalid word 0x%lx\n" , __func__, value); -return -EINVAL ;
drivers/edac/amd64_edac_inj.c static ssize_t amd64_inject_word_store(struct mem_ctl_info *mci, · line 54
Quoted 10 lines
drivers/edac/amd64_edac_inj.c +6
-4- } - - pvt->injection.word = (u32 ) value; -return count; +u32 value; +int ret; + + ret =kstrtou32 (data,10 , &value); +if (ret <0 ) +return ret;
newline
drivers/edac/amd64_edac_inj.c static ssize_t amd64_inject_word_store(struct mem_ctl_info *mci, · line 58
Quoted 4 lines
drivers/edac/amd64_edac_inj.c +3
-0+if (value >8 ) { +amd64_warn ("%s: invalid word 0x%x\n" , __func__, value); +return -EINVAL ; }
newline.
Quoted 14 lines
drivers/edac/amd64_edac_inj.c +2
-5-return ret; + pvt->injection.word = value; +return count; }static ssize_t amd64_inject_ecc_vector_show (struct mem_ctl_info *mci,char *buf)@@ -81,22 +75,19 @@ static ssize_t amd64_inject_ecc_vector_store(struct mem_ctl_info *mci, const char *data, size_t count) {struct amd64_pvt *pvt = mci->pvt_info; -unsigned long value; -int ret =0 ; - - ret =strict_strtoul (data,16 , &value);
drivers/edac/amd64_edac_inj.c static ssize_t amd64_inject_ecc_vector_store(struct mem_ctl_info *mci, · line 83
Quoted 10 lines
drivers/edac/amd64_edac_inj.c +6
-4-if (ret != -EINVAL ) { - -if (value &0xFFFF0000 ) { - amd64_warn("%s: invalid EccVector: 0x%lx\n", +u32 value; +int ret; + + ret =kstrtou32 (data,16 , &value); +if (ret <0 ) +return ret;
newline.
drivers/edac/amd64_edac_inj.c static ssize_t amd64_inject_ecc_vector_store(struct mem_ctl_info *mci, · line 99
Quoted 11 lines
drivers/edac/amd64_edac_inj.c +3
-6+if (value &0xFFFF0000 ) { +amd64_warn ("%s: invalid EccVector: 0x%x\n" , __func__, value); -return -EINVAL ; - } - - pvt->injection.bit_map = (u32 ) value; -return count; +return -EINVAL ; } -return ret;
newline
Quoted 6 lines
drivers/edac/amd64_edac_inj.c +2
-0+ pvt->injection.bit_map = value; +return count; }/*
drivers/edac/amd64_edac_inj.c static ssize_t amd64_inject_read_store(struct mem_ctl_info *mci, · line 115
Quoted 9 lines
drivers/edac/amd64_edac_inj.c +0
-5@@ -107,29 +98,22 @@ static ssize_t amd64_inject_read_store(struct mem_ctl_info *mci, const char *data, size_t count) {struct amd64_pvt *pvt = mci->pvt_info; -unsigned long value;u32 section, word_bits; -int ret =0 ; - - ret =strict_strtoul (data,10 , &value); -if (ret != -EINVAL ) {
Dropping those would mean that the injection read (and write) below would happen on any value written. Let's keep them and enforce a write of '1' to be only valid injection trigger like the rest of the /sysfs interfaces:
ret = kstrtou8(data, 10, &value); if (ret < 0) return ret; if (value != 1) return -EINVAL;
Quoted 31 lines
drivers/edac/amd64_edac_inj.c +10
-12-/* Form value to choose 16-byte section of cacheline */ - section =F10_NB_ARRAY_DRAM_ECC | -SET_NB_ARRAY_ADDRESS (pvt->injection.section); -pci_write_config_dword (pvt->F3,F10_NB_ARRAY_ADDR , section); +/* Form value to choose 16-byte section of cacheline */ + section =F10_NB_ARRAY_DRAM_ECC | +SET_NB_ARRAY_ADDRESS (pvt->injection.section); +pci_write_config_dword (pvt->F3,F10_NB_ARRAY_ADDR , section); - word_bits =SET_NB_DRAM_INJECTION_READ (pvt->injection.word, - pvt->injection.bit_map); + word_bits =SET_NB_DRAM_INJECTION_READ (pvt->injection.word, + pvt->injection.bit_map); -/* Issue 'word' and 'bit' along with the READ request */ -pci_write_config_dword (pvt->F3,F10_NB_ARRAY_DATA , word_bits); +/* Issue 'word' and 'bit' along with the READ request */ +pci_write_config_dword (pvt->F3,F10_NB_ARRAY_DATA , word_bits); -debugf0 ("section=0x%x word_bits=0x%x\n" , section, word_bits); +debugf0 ("section=0x%x word_bits=0x%x\n" , section, word_bits); -return count; - } -return ret; +return count; }/*
drivers/edac/amd64_edac_inj.c static ssize_t amd64_inject_write_store(struct mem_ctl_info *mci, · line 148
Quoted 9 lines
drivers/edac/amd64_edac_inj.c +0
-5@@ -140,29 +124,22 @@ static ssize_t amd64_inject_write_store(struct mem_ctl_info *mci, const char *data, size_t count) {struct amd64_pvt *pvt = mci->pvt_info; -unsigned long value;u32 section, word_bits; -int ret =0 ; - - ret =strict_strtoul (data,10 , &value); -if (ret != -EINVAL ) {
Same as above.
Quoted 31 lines
drivers/edac/amd64_edac_inj.c +10
-12-/* Form value to choose 16-byte section of cacheline */ - section =F10_NB_ARRAY_DRAM_ECC | -SET_NB_ARRAY_ADDRESS (pvt->injection.section); -pci_write_config_dword (pvt->F3,F10_NB_ARRAY_ADDR , section); +/* Form value to choose 16-byte section of cacheline */ + section =F10_NB_ARRAY_DRAM_ECC | +SET_NB_ARRAY_ADDRESS (pvt->injection.section); +pci_write_config_dword (pvt->F3,F10_NB_ARRAY_ADDR , section); - word_bits =SET_NB_DRAM_INJECTION_WRITE (pvt->injection.word, - pvt->injection.bit_map); + word_bits =SET_NB_DRAM_INJECTION_WRITE (pvt->injection.word, + pvt->injection.bit_map); -/* Issue 'word' and 'bit' along with the READ request */ -pci_write_config_dword (pvt->F3,F10_NB_ARRAY_DATA , word_bits); +/* Issue 'word' and 'bit' along with the READ request */ +pci_write_config_dword (pvt->F3,F10_NB_ARRAY_DATA , word_bits); -debugf0 ("section=0x%x word_bits=0x%x\n" , section, word_bits); +debugf0 ("section=0x%x word_bits=0x%x\n" , section, word_bits); -return count; - } -return ret; +return count; }/*
drivers/edac/amd64_edac_inj.c struct mcidev_sysfs_attribute amd64_inj_attrs[] = { · line 177
Quoted 5 lines
drivers/edac/amd64_edac_inj.c +1
-1@@ -197,17 +174,15 @@ struct mcidev_sysfs_attribute amd64_inj_attrs[] = { { .attr = { .name = "inject_write", - .mode = (S_IRUGO | S_IWUSR) + .mode = S_IWUSR,
This change is not mentioned anywhere, why do we need it?
drivers/edac/amd64_edac_inj.c struct mcidev_sysfs_attribute amd64_inj_attrs[] = { · line 184
Quoted 9 lines
drivers/edac/amd64_edac_inj.c +1
-2}, - .show = NULL, .store = amd64_inject_write_store, }, { .attr = { .name = "inject_read", - .mode = (S_IRUGO | S_IWUSR) + .mode = S_IWUSR,
ditto.
drivers/edac/amd64_edac_inj.c struct mcidev_sysfs_attribute amd64_inj_attrs[] = { · line 188
Quoted 5 lines
drivers/edac/amd64_edac_inj.c +0
-1}, - .show = NULL, .store = amd64_inject_read_store, }, };
Ok, provided the general change to kstrtoX is agreed upon, you can add my Acked-by to the AMD EDAC changes pending the issues above.
Thanks.
Signature · 2 lines
Regards/Gruss,
Boris.Re: [PATCH 16/52] kstrtox: convert drivers/edac/
Quoted 34 lines · Borislav Petkov
On Sat, Feb 05, 2011 at 04:20:19PM +0200, Alexey Dobriyan wrote:
Some kind of a boilerplate commit message is still better than none at all.
Quoted 30 lines
Signed-off-by Alexey Dobriyan <[email protected]>--- drivers/edac/amd64_edac_inj.c | 135 +++++++++++++++++------------------------ drivers/edac/edac_mc_sysfs.c | 20 +++--- drivers/edac/i7core_edac.c | 41 +++++++------ drivers/edac/mce_amd_inj.c | 28 ++++----- 4 files changed, 101 insertions(+), 123 deletions(-)drivers/edac/amd64_edac_inj.c +0
-13@@ -16,21 +16,18 @@ static ssize_t amd64_inject_section_store(struct mem_ctl_info *mci, const char *data, size_t count) {struct amd64_pvt *pvt = mci->pvt_info; -unsigned long value; -int ret =0 ; - - ret =strict_strtoul (data,10 , &value); -if (ret != -EINVAL ) { - -if (value >3 ) { -amd64_warn ("%s: invalid section 0x%lx\n" , __func__, value); -return -EINVAL ; - } - - pvt->injection.section = (u32 ) value; -return count;
Quoted 8 lines
drivers/edac/amd64_edac_inj.c static ssize_t amd64_inject_section_store(struct mem_ctl_info *mci, · line 24
Quoted 6 lines
drivers/edac/amd64_edac_inj.c +6
-0+u32 value; +int ret; + + ret =kstrtou32 (data,10 , &value); +if (ret <0 ) +return ret;newline here
A what? Why?
Quoted 5 lines
Quoted 5 lines
drivers/edac/amd64_edac_inj.c +0
-1@@ -107,29 +98,22 @@ static ssize_t amd64_inject_read_store(struct mem_ctl_info *mci, const char *data, size_t count) {struct amd64_pvt *pvt = mci->pvt_info; -unsigned long value;
Quoted 8 lines
drivers/edac/amd64_edac_inj.c static ssize_t amd64_inject_read_store(struct mem_ctl_info *mci, · line 115
Quoted 5 lines
drivers/edac/amd64_edac_inj.c +0
-4u32 section, word_bits; -int ret =0 ; - - ret =strict_strtoul (data,10 , &value); -if (ret != -EINVAL ) {Dropping those would mean that the injection read (and write) below would happen on any value written.
Yes, since the value written is unused, and all data were already written via other files.
Quoted 3 lines
Let's keep them and enforce a write
of '1' to be only valid injection trigger like the rest of the /sysfs interfaces:
Right now, any number will do, so in fact it'd be better to use kstrtoul().
Quoted 6 lines
ret = kstrtou8(data, 10, &value); if (ret < 0) return ret; if (value != 1) return -EINVAL;
Quoted 8 lines
drivers/edac/amd64_edac_inj.c struct mcidev_sysfs_attribute amd64_inj_attrs[] = { · line 177
Quoted 6 lines
drivers/edac/amd64_edac_inj.c +1
-1@@ -197,17 +174,15 @@ struct mcidev_sysfs_attribute amd64_inj_attrs[] = { { .attr = { .name = "inject_write", - .mode = (S_IRUGO | S_IWUSR) + .mode = S_IWUSR,This change is not mentioned anywhere, why do we need it?
File is write-only. I'll mention this in changelog.
Quoted 8 lines
Quoted 8 lines
drivers/edac/amd64_edac_inj.c +1
-2- .show = NULL, .store = amd64_inject_write_store, }, { .attr = { .name = "inject_read", - .mode = (S_IRUGO | S_IWUSR) + .mode = S_IWUSR,
Re: [PATCH 16/52] kstrtox: convert drivers/edac/
Quoted 44 lines · Alexey Dobriyan
Quoted 34 lines · Borislav Petkov
On Sat, Feb 05, 2011 at 04:20:19PM +0200, Alexey Dobriyan wrote:
Some kind of a boilerplate commit message is still better than none at all.
Quoted 30 lines
Signed-off-by Alexey Dobriyan <[email protected]>--- drivers/edac/amd64_edac_inj.c | 135 +++++++++++++++++------------------------ drivers/edac/edac_mc_sysfs.c | 20 +++--- drivers/edac/i7core_edac.c | 41 +++++++------ drivers/edac/mce_amd_inj.c | 28 ++++----- 4 files changed, 101 insertions(+), 123 deletions(-)drivers/edac/amd64_edac_inj.c +0
-13@@ -16,21 +16,18 @@ static ssize_t amd64_inject_section_store(struct mem_ctl_info *mci, const char *data, size_t count) {struct amd64_pvt *pvt = mci->pvt_info; -unsigned long value; -int ret =0 ; - - ret =strict_strtoul (data,10 , &value); -if (ret != -EINVAL ) { - -if (value >3 ) { -amd64_warn ("%s: invalid section 0x%lx\n" , __func__, value); -return -EINVAL ; - } - - pvt->injection.section = (u32 ) value; -return count;Quoted 8 lines
drivers/edac/amd64_edac_inj.c static ssize_t amd64_inject_section_store(struct mem_ctl_info *mci, · line 24
Quoted 6 lines
drivers/edac/amd64_edac_inj.c +6
-0+u32 value; +int ret; + + ret =kstrtou32 (data,10 , &value); +if (ret <0 ) +return ret;newline here
Quoted 1 line
A what? Why?
Hmm, let me see, better readability.
Quoted 15 lines
Quoted 14 lines
drivers/edac/amd64_edac_inj.c static ssize_t amd64_inject_read_store(struct mem_ctl_info *mci, · line 115
Quoted 11 lines
drivers/edac/amd64_edac_inj.c +0
-5@@ -107,29 +98,22 @@ static ssize_t amd64_inject_read_store(struct mem_ctl_info *mci, const char *data, size_t count) {struct amd64_pvt *pvt = mci->pvt_info; -unsigned long value;u32 section, word_bits; -int ret =0 ; - - ret =strict_strtoul (data,10 , &value); -if (ret != -EINVAL ) {Dropping those would mean that the injection read (and write) below would happen on any value written.
Quoted 8 lines
Yes, since the value written is unused, and all data were already written via other files.
Quoted 3 lines
Let's keep them and enforce a write
of '1' to be only valid injection trigger like the rest of the /sysfs interfaces:Right now, any number will do, so in fact it'd be better to use
kstrtoul().
Ok, let's accept only a "1" though.
Quoted 16 lines
Quoted 7 lines
ret = kstrtou8(data, 10, &value); if (ret < 0) return ret; if (value != 1) return -EINVAL;Quoted 8 lines
drivers/edac/amd64_edac_inj.c struct mcidev_sysfs_attribute amd64_inj_attrs[] = { · line 177
Quoted 6 lines
drivers/edac/amd64_edac_inj.c +1
-1@@ -197,17 +174,15 @@ struct mcidev_sysfs_attribute amd64_inj_attrs[] = { { .attr = { .name = "inject_write", - .mode = (S_IRUGO | S_IWUSR) + .mode = S_IWUSR,This change is not mentioned anywhere, why do we need it?
Quoted 1 line
File is write-only. I'll mention this in changelog.
Ok, actually, come to think of it, it would be even better if it would show what values are written to the injection registers so I'll supply ->show methods for them. You can drop this hunk changing file perms from your patch.
Thanks.
Signature · 8 lines
Regards/Gruss, Boris. Advanced Micro Devices GmbH Einsteinring 24, 85609 Dornach General Managers: Alberto Bozzo, Andrew Bowd Registration: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632
Michal Simek
maintainerRe: [PATCH 46/52] kstrtox: convert microblaze
In reply to Alexey DobriyanQuoted 1 line · Alexey Dobriyan
Signed-off-by Alexey Dobriyan <[email protected]>
you forget to CC me. I will test it.
Michal
Quoted 17 lines
--- arch/microblaze/kernel/traps.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)arch/microblaze/kernel/traps.c +1
-1@@ -27,7 +27,7 @@ static unsigned long kstack_depth_to_print; /* 0 == entire stack */static int __init kstack_setup (char *s) { -return !strict_strtoul (s,0 , &kstack_depth_to_print); +return !kstrtoul (s,0 , &kstack_depth_to_print); }__setup ("kstack=" , kstack_setup);
Signature · 4 lines
Michal Simek, Ing. (M.Eng) w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/ Microblaze U-BOOT custodian
Re: [40/52] kstrtox: convert drivers/usb/
In reply to Alexey DobriyanQuoted 4 lines · Alexey Dobriyan
Signed-off-by Alexey Dobriyan <[email protected]>---
drivers/usb/gadget/storage_common.c| 7 ++++---
I haven't notice your patch (wasn't sent to linux-usb?) and changed this file already -- patch is in Greg's tree.
Quoted 9 lines
drivers/usb/host/ehci-dbg.c | 6 +++--- drivers/usb/serial/iuu_phoenix.c | 27 ++++++++++----------------- 3 files changed, 17 insertions(+), 23 deletions(-)drivers/usb/gadget/storage_common.c +0
-0
drivers/usb/gadget/storage_common.c static ssize_t fsg_store_ro(struct device *dev, · line 720
Quoted 10 lines
drivers/usb/gadget/storage_common.c +3
-2@@ -713,8 +713,9 @@ static ssize_t fsg_store_ro(struct device *dev,struct device_attribute *attr, struct rw_semaphore *filesem = dev_get_drvdata(dev);unsigned long ro; -if (strict_strtoul (buf,2 , &ro)) -return -EINVAL ; + rc =kstrtoul (buf,2 , &ro); +if (rc <0 ) +return rc;/* * Allow the write-enable status to change only while the
Also, this is actually incorrect -- it zeroes rc which it should not do. I made the same mistake at first. ;)
Quoted 38 lines
drivers/usb/gadget/storage_common.c +1
-1@@ -740,7 +741,7 @@ static ssize_t fsg_store_nofua(struct device *dev,struct fsg_lun *curlun =fsg_lun_from_dev (dev);unsigned long nofua; -if (strict_strtoul (buf,2 , &nofua)) +if (kstrtoul (buf,2 , &nofua))return -EINVAL ;/* Sync data when switching from async mode to sync */ drivers/usb/host/ehci-dbg.c +2
-2@@ -1000,7 +1000,7 @@ static ssize_t debug_lpm_write(struct file *file,const char __user *user_buf, buf[len -1 ] ='\0' ;if (strncmp (buf,"enable" ,5 ) ==0 ) { -if (strict_strtoul (buf +7 ,10 , &port)) +if (kstrtoul (buf +7 ,10 , &port))return -EINVAL ; params =ehci_readl (ehci, &ehci->caps->hcs_params);if (port >HCS_N_PORTS (params)) {@@ -1018,7 +1018,7 @@ static ssize_t debug_lpm_write(struct file *file, const char __user *user_buf, printk(KERN_INFO "force enable LPM for port %lu\n", port); }else if (strncmp (buf,"hird=" ,5 ) ==0 ) {unsigned long hird; -if (strict_strtoul (buf +5 ,16 , &hird)) +if (kstrtoul (buf +5 ,16 , &hird))return -EINVAL ;printk (KERN_INFO "setting hird %s %lu\n" , buf +6 , hird);drivers/usb/host/ehci-dbg.c +1
-1temp =ehci_readl (ehci, &ehci->regs->command);@@ -1026,7 +1026,7 @@ static ssize_t debug_lpm_write(struct file *file,const char __user *user_buf, temp |= hird << 24;ehci_writel (ehci, temp, &ehci->regs->command); }else if (strncmp (buf,"disable" ,7 ) ==0 ) { -if (strict_strtoul (buf +8 ,10 , &port)) +if (kstrtoul (buf +8 ,10 , &port))return -EINVAL ; params =ehci_readl (ehci, &ehci->caps->hcs_params);
Quoted 1 line
if (port >
HCS_N_PORTS(params)) {
I'm wondering if we care about loosing the possible -ERANGE.
Signature · 4 lines
Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Michal "mina86" Nazarewicz (o o) ooo +-----<email/xmpp: [email protected]>-----ooO--(_)--Ooo--