@@ -419,20 +419,13 @@ static ssize_t ab8500_bank_write(struct file *file,
419419 size_t count , loff_t * ppos )
420420{
421421 struct device * dev = ((struct seq_file * )(file -> private_data ))-> private ;
422- char buf [32 ];
423- int buf_size ;
424422 unsigned long user_bank ;
425423 int err ;
426424
427425 /* Get userspace string and assure termination */
428- buf_size = min (count , (sizeof (buf ) - 1 ));
429- if (copy_from_user (buf , user_buf , buf_size ))
430- return - EFAULT ;
431- buf [buf_size ] = 0 ;
432-
433- err = strict_strtoul (buf , 0 , & user_bank );
426+ err = kstrtoul_from_user (user_buf , count , 0 , & user_bank );
434427 if (err )
435- return - EINVAL ;
428+ return err ;
436429
437430 if (user_bank >= AB8500_NUM_BANKS ) {
438431 dev_err (dev , "debugfs error input > number of banks\n" );
@@ -441,7 +434,7 @@ static ssize_t ab8500_bank_write(struct file *file,
441434
442435 debug_bank = user_bank ;
443436
444- return buf_size ;
437+ return count ;
445438}
446439
447440static int ab8500_address_print (struct seq_file * s , void * p )
@@ -459,26 +452,20 @@ static ssize_t ab8500_address_write(struct file *file,
459452 size_t count , loff_t * ppos )
460453{
461454 struct device * dev = ((struct seq_file * )(file -> private_data ))-> private ;
462- char buf [32 ];
463- int buf_size ;
464455 unsigned long user_address ;
465456 int err ;
466457
467458 /* Get userspace string and assure termination */
468- buf_size = min (count , (sizeof (buf ) - 1 ));
469- if (copy_from_user (buf , user_buf , buf_size ))
470- return - EFAULT ;
471- buf [buf_size ] = 0 ;
472-
473- err = strict_strtoul (buf , 0 , & user_address );
459+ err = kstrtoul_from_user (user_buf , count , 0 , & user_address );
474460 if (err )
475- return - EINVAL ;
461+ return err ;
462+
476463 if (user_address > 0xff ) {
477464 dev_err (dev , "debugfs error input > 0xff\n" );
478465 return - EINVAL ;
479466 }
480467 debug_address = user_address ;
481- return buf_size ;
468+ return count ;
482469}
483470
484471static int ab8500_val_print (struct seq_file * s , void * p )
@@ -509,20 +496,14 @@ static ssize_t ab8500_val_write(struct file *file,
509496 size_t count , loff_t * ppos )
510497{
511498 struct device * dev = ((struct seq_file * )(file -> private_data ))-> private ;
512- char buf [32 ];
513- int buf_size ;
514499 unsigned long user_val ;
515500 int err ;
516501
517502 /* Get userspace string and assure termination */
518- buf_size = min (count , (sizeof (buf )- 1 ));
519- if (copy_from_user (buf , user_buf , buf_size ))
520- return - EFAULT ;
521- buf [buf_size ] = 0 ;
522-
523- err = strict_strtoul (buf , 0 , & user_val );
503+ err = kstrtoul_from_user (user_buf , count , 0 , & user_val );
524504 if (err )
525- return - EINVAL ;
505+ return err ;
506+
526507 if (user_val > 0xff ) {
527508 dev_err (dev , "debugfs error input > 0xff\n" );
528509 return - EINVAL ;
@@ -534,7 +515,7 @@ static ssize_t ab8500_val_write(struct file *file,
534515 return - EINVAL ;
535516 }
536517
537- return buf_size ;
518+ return count ;
538519}
539520
540521static const struct file_operations ab8500_bank_fops = {
0 commit comments