Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

misc: replace strict_strtoul() with kstrtoul()

The usage of strict_strtoul() is not preferred, because
strict_strtoul() is obsolete. Thus, kstrtoul() should be
used.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jingoo Han and committed by
Greg Kroah-Hartman
f7b41276 4cd5773a

+153 -82
+1 -1
drivers/misc/ad525x_dpot.c
··· 470 470 !test_bit(DPOT_RDAC_MASK & reg, data->otp_en_mask)) 471 471 return -EPERM; 472 472 473 - err = strict_strtoul(buf, 10, &value); 473 + err = kstrtoul(buf, 10, &value); 474 474 if (err) 475 475 return err; 476 476
+3 -2
drivers/misc/apds9802als.c
··· 126 126 int ret_val; 127 127 unsigned long val; 128 128 129 - if (strict_strtoul(buf, 10, &val)) 130 - return -EINVAL; 129 + ret_val = kstrtoul(buf, 10, &val); 130 + if (ret_val) 131 + return ret_val; 131 132 132 133 if (val < 4096) 133 134 val = 1;
+24 -13
drivers/misc/apds990x.c
··· 696 696 { 697 697 struct apds990x_chip *chip = dev_get_drvdata(dev); 698 698 unsigned long value; 699 + int ret; 699 700 700 - if (strict_strtoul(buf, 0, &value)) 701 - return -EINVAL; 701 + ret = kstrtoul(buf, 0, &value); 702 + if (ret) 703 + return ret; 702 704 703 705 chip->lux_calib = value; 704 706 ··· 761 759 unsigned long value; 762 760 int ret; 763 761 764 - if (strict_strtoul(buf, 0, &value)) 765 - return -EINVAL; 762 + ret = kstrtoul(buf, 0, &value); 763 + if (ret) 764 + return ret; 766 765 767 766 mutex_lock(&chip->mutex); 768 767 ret = apds990x_set_arate(chip, value); ··· 816 813 { 817 814 struct apds990x_chip *chip = dev_get_drvdata(dev); 818 815 unsigned long value; 816 + int ret; 819 817 820 - if (strict_strtoul(buf, 0, &value)) 821 - return -EINVAL; 818 + ret = kstrtoul(buf, 0, &value); 819 + if (ret) 820 + return ret; 822 821 823 822 mutex_lock(&chip->mutex); 824 823 ··· 897 892 static ssize_t apds990x_set_lux_thresh(struct apds990x_chip *chip, u32 *target, 898 893 const char *buf) 899 894 { 900 - int ret = 0; 901 895 unsigned long thresh; 896 + int ret; 902 897 903 - if (strict_strtoul(buf, 0, &thresh)) 904 - return -EINVAL; 898 + ret = kstrtoul(buf, 0, &thresh); 899 + if (ret) 900 + return ret; 905 901 906 902 if (thresh > APDS_RANGE) 907 903 return -EINVAL; ··· 963 957 { 964 958 struct apds990x_chip *chip = dev_get_drvdata(dev); 965 959 unsigned long value; 960 + int ret; 966 961 967 - if (strict_strtoul(buf, 0, &value)) 968 - return -EINVAL; 962 + ret = kstrtoul(buf, 0, &value); 963 + if (ret) 964 + return ret; 969 965 970 966 if ((value > APDS_RANGE) || (value == 0) || 971 967 (value < APDS_PROX_HYSTERESIS)) ··· 998 990 { 999 991 struct apds990x_chip *chip = dev_get_drvdata(dev); 1000 992 unsigned long value; 993 + int ret; 1001 994 1002 - if (strict_strtoul(buf, 0, &value)) 1003 - return -EINVAL; 995 + ret = kstrtoul(buf, 0, &value); 996 + if (ret) 997 + return ret; 998 + 1004 999 if (value) { 1005 1000 pm_runtime_get_sync(dev); 1006 1001 mutex_lock(&chip->mutex);
+38 -21
drivers/misc/bh1770glc.c
··· 651 651 unsigned long value; 652 652 ssize_t ret; 653 653 654 - if (strict_strtoul(buf, 0, &value)) 655 - return -EINVAL; 654 + ret = kstrtoul(buf, 0, &value); 655 + if (ret) 656 + return ret; 656 657 657 658 mutex_lock(&chip->mutex); 658 659 if (value) { ··· 727 726 { 728 727 struct bh1770_chip *chip = dev_get_drvdata(dev); 729 728 unsigned long value; 729 + int ret; 730 730 731 - if (strict_strtoul(buf, 0, &value)) 732 - return -EINVAL; 731 + ret = kstrtoul(buf, 0, &value); 732 + if (ret) 733 + return ret; 733 734 734 735 mutex_lock(&chip->mutex); 735 736 /* Assume no proximity. Sensor will tell real state soon */ ··· 827 824 { 828 825 struct bh1770_chip *chip = dev_get_drvdata(dev); 829 826 unsigned long value; 827 + int ret; 830 828 831 - if (strict_strtoul(buf, 0, &value)) 832 - return -EINVAL; 829 + ret = kstrtoul(buf, 0, &value); 830 + if (ret) 831 + return ret; 833 832 834 833 mutex_lock(&chip->mutex); 835 834 chip->prox_rate_threshold = bh1770_prox_rate_validate(value); ··· 845 840 { 846 841 struct bh1770_chip *chip = dev_get_drvdata(dev); 847 842 unsigned long value; 843 + int ret; 848 844 849 - if (strict_strtoul(buf, 0, &value)) 850 - return -EINVAL; 845 + ret = kstrtoul(buf, 0, &value); 846 + if (ret) 847 + return ret; 851 848 852 849 mutex_lock(&chip->mutex); 853 850 chip->prox_rate = bh1770_prox_rate_validate(value); ··· 872 865 unsigned long value; 873 866 int ret; 874 867 875 - if (strict_strtoul(buf, 0, &value)) 876 - return -EINVAL; 868 + ret = kstrtoul(buf, 0, &value); 869 + if (ret) 870 + return ret; 871 + 877 872 if (value > BH1770_PROX_RANGE) 878 873 return -EINVAL; 879 874 ··· 902 893 { 903 894 struct bh1770_chip *chip = dev_get_drvdata(dev); 904 895 unsigned long value; 896 + int ret; 905 897 906 - if (strict_strtoul(buf, 0, &value)) 907 - return -EINVAL; 898 + ret = kstrtoul(buf, 0, &value); 899 + if (ret) 900 + return ret; 908 901 909 902 if (value > BH1770_PROX_MAX_PERSISTENCE) 910 903 return -EINVAL; ··· 929 918 { 930 919 struct bh1770_chip *chip = dev_get_drvdata(dev); 931 920 unsigned long value; 921 + int ret; 932 922 933 - if (strict_strtoul(buf, 0, &value)) 934 - return -EINVAL; 923 + ret = kstrtoul(buf, 0, &value); 924 + if (ret) 925 + return ret; 935 926 936 927 if (value > BH1770_PROX_RANGE) 937 928 return -EINVAL; ··· 976 963 unsigned long value; 977 964 u32 old_calib; 978 965 u32 new_corr; 966 + int ret; 979 967 980 - if (strict_strtoul(buf, 0, &value)) 981 - return -EINVAL; 968 + ret = kstrtoul(buf, 0, &value); 969 + if (ret) 970 + return ret; 982 971 983 972 mutex_lock(&chip->mutex); 984 973 old_calib = chip->lux_calib; ··· 1027 1012 unsigned long rate_hz; 1028 1013 int ret, i; 1029 1014 1030 - if (strict_strtoul(buf, 0, &rate_hz)) 1031 - return -EINVAL; 1015 + ret = kstrtoul(buf, 0, &rate_hz); 1016 + if (ret) 1017 + return ret; 1032 1018 1033 1019 for (i = 0; i < ARRAY_SIZE(lux_rates_hz) - 1; i++) 1034 1020 if (rate_hz >= lux_rates_hz[i]) ··· 1063 1047 static ssize_t bh1770_set_lux_thresh(struct bh1770_chip *chip, u16 *target, 1064 1048 const char *buf) 1065 1049 { 1066 - int ret = 0; 1067 1050 unsigned long thresh; 1051 + int ret; 1068 1052 1069 - if (strict_strtoul(buf, 0, &thresh)) 1070 - return -EINVAL; 1053 + ret = kstrtoul(buf, 0, &thresh); 1054 + if (ret) 1055 + return ret; 1071 1056 1072 1057 if (thresh > BH1770_LUX_RANGE) 1073 1058 return -EINVAL;
+1 -1
drivers/misc/bh1780gli.c
··· 107 107 unsigned long val; 108 108 int error; 109 109 110 - error = strict_strtoul(buf, 0, &val); 110 + error = kstrtoul(buf, 0, &val); 111 111 if (error) 112 112 return error; 113 113
+6 -4
drivers/misc/carma/carma-fpga-program.c
··· 830 830 unsigned long val; 831 831 int ret; 832 832 833 - if (strict_strtoul(buf, 0, &val)) 834 - return -EINVAL; 833 + ret = kstrtoul(buf, 0, &val); 834 + if (ret) 835 + return ret; 835 836 836 837 if (val) { 837 838 ret = fpga_enable_power_supplies(priv); ··· 860 859 unsigned long val; 861 860 int ret; 862 861 863 - if (strict_strtoul(buf, 0, &val)) 864 - return -EINVAL; 862 + ret = kstrtoul(buf, 0, &val); 863 + if (ret) 864 + return ret; 865 865 866 866 /* We can't have an image writer and be programming simultaneously */ 867 867 if (mutex_lock_interruptible(&priv->lock))
+2 -2
drivers/misc/carma/carma-fpga.c
··· 1002 1002 unsigned long enable; 1003 1003 int ret; 1004 1004 1005 - ret = strict_strtoul(buf, 0, &enable); 1005 + ret = kstrtoul(buf, 0, &enable); 1006 1006 if (ret) { 1007 1007 dev_err(priv->dev, "unable to parse enable input\n"); 1008 - return -EINVAL; 1008 + return ret; 1009 1009 } 1010 1010 1011 1011 /* protect against concurrent enable/disable */
+3 -2
drivers/misc/hmc6352.c
··· 46 46 int ret; 47 47 unsigned long val; 48 48 49 - if (strict_strtoul(buf, 10, &val)) 50 - return -EINVAL; 49 + ret = kstrtoul(buf, 10, &val); 50 + if (ret) 51 + return ret; 51 52 if (val >= strlen(map)) 52 53 return -EINVAL; 53 54 mutex_lock(&compass_mutex);
+20 -4
drivers/misc/isl29003.c
··· 208 208 unsigned long val; 209 209 int ret; 210 210 211 - if ((strict_strtoul(buf, 10, &val) < 0) || (val > 3)) 211 + ret = kstrtoul(buf, 10, &val); 212 + if (ret) 213 + return ret; 214 + 215 + if (val > 3) 212 216 return -EINVAL; 213 217 214 218 ret = isl29003_set_range(client, val); ··· 243 239 unsigned long val; 244 240 int ret; 245 241 246 - if ((strict_strtoul(buf, 10, &val) < 0) || (val > 3)) 242 + ret = kstrtoul(buf, 10, &val); 243 + if (ret) 244 + return ret; 245 + 246 + if (val > 3) 247 247 return -EINVAL; 248 248 249 249 ret = isl29003_set_resolution(client, val); ··· 275 267 unsigned long val; 276 268 int ret; 277 269 278 - if ((strict_strtoul(buf, 10, &val) < 0) || (val > 2)) 270 + ret = kstrtoul(buf, 10, &val); 271 + if (ret) 272 + return ret; 273 + 274 + if (val > 2) 279 275 return -EINVAL; 280 276 281 277 ret = isl29003_set_mode(client, val); ··· 310 298 unsigned long val; 311 299 int ret; 312 300 313 - if ((strict_strtoul(buf, 10, &val) < 0) || (val > 1)) 301 + ret = kstrtoul(buf, 10, &val); 302 + if (ret) 303 + return ret; 304 + 305 + if (val > 1) 314 306 return -EINVAL; 315 307 316 308 ret = isl29003_set_power_state(client, val);
+4 -2
drivers/misc/isl29020.c
··· 90 90 int ret_val; 91 91 unsigned long val; 92 92 93 - if (strict_strtoul(buf, 10, &val)) 94 - return -EINVAL; 93 + ret_val = kstrtoul(buf, 10, &val); 94 + if (ret_val) 95 + return ret_val; 96 + 95 97 if (val < 1 || val > 64000) 96 98 return -EINVAL; 97 99
+4 -2
drivers/misc/lis3lv02d/lis3lv02d.c
··· 831 831 { 832 832 struct lis3lv02d *lis3 = dev_get_drvdata(dev); 833 833 unsigned long rate; 834 + int ret; 834 835 835 - if (strict_strtoul(buf, 0, &rate)) 836 - return -EINVAL; 836 + ret = kstrtoul(buf, 0, &rate); 837 + if (ret) 838 + return ret; 837 839 838 840 lis3lv02d_sysfs_poweron(lis3); 839 841 if (lis3lv02d_set_odr(lis3, rate))
+4 -8
drivers/misc/sgi-gru/gruprocfs.c
··· 160 160 static ssize_t options_write(struct file *file, const char __user *userbuf, 161 161 size_t count, loff_t *data) 162 162 { 163 - char buf[20]; 163 + int ret; 164 164 165 - if (count >= sizeof(buf)) 166 - return -EINVAL; 167 - if (copy_from_user(buf, userbuf, count)) 168 - return -EFAULT; 169 - buf[count] = '\0'; 170 - if (strict_strtoul(buf, 0, &gru_options)) 171 - return -EINVAL; 165 + ret = kstrtoul_from_user(userbuf, count, 0, &gru_options); 166 + if (ret) 167 + return ret; 172 168 173 169 return count; 174 170 }
+39 -18
drivers/misc/spear13xx_pcie_gadget.c
··· 316 316 struct spear_pcie_gadget_config *config, 317 317 const char *buf, size_t count) 318 318 { 319 - if (strict_strtoul(buf, 0, &config->requested_msi)) 320 - return -EINVAL; 319 + int ret; 320 + 321 + ret = kstrtoul(buf, 0, &config->requested_msi); 322 + if (ret) 323 + return ret; 324 + 321 325 if (config->requested_msi > 32) 322 326 config->requested_msi = 32; 323 327 ··· 334 330 { 335 331 struct pcie_app_reg __iomem *app_reg = config->va_app_base; 336 332 ulong en; 333 + int ret; 337 334 338 - if (strict_strtoul(buf, 0, &en)) 339 - return -EINVAL; 335 + ret = kstrtoul(buf, 0, &en); 336 + if (ret) 337 + return ret; 340 338 341 339 if (en) 342 340 writel(readl(&app_reg->app_ctrl_0) | (1 << SYS_INT_ID), ··· 357 351 struct pcie_app_reg __iomem *app_reg = config->va_app_base; 358 352 ulong vector; 359 353 u32 ven_msi; 354 + int ret; 360 355 361 - if (strict_strtoul(buf, 0, &vector)) 362 - return -EINVAL; 356 + ret = kstrtoul(buf, 0, &vector); 357 + if (ret) 358 + return ret; 363 359 364 360 if (!config->configured_msi) 365 361 return -EINVAL; ··· 403 395 const char *buf, size_t count) 404 396 { 405 397 ulong id; 398 + int ret; 406 399 407 - if (strict_strtoul(buf, 0, &id)) 408 - return -EINVAL; 400 + ret = kstrtoul(buf, 0, &id); 401 + if (ret) 402 + return ret; 409 403 410 404 spear_dbi_write_reg(config, PCI_VENDOR_ID, 2, id); 411 405 ··· 430 420 const char *buf, size_t count) 431 421 { 432 422 ulong id; 423 + int ret; 433 424 434 - if (strict_strtoul(buf, 0, &id)) 435 - return -EINVAL; 425 + ret = kstrtoul(buf, 0, &id); 426 + if (ret) 427 + return ret; 436 428 437 429 spear_dbi_write_reg(config, PCI_DEVICE_ID, 2, id); 438 430 ··· 455 443 ulong size; 456 444 u32 pos, pos1; 457 445 u32 no_of_bit = 0; 446 + int ret; 458 447 459 - if (strict_strtoul(buf, 0, &size)) 460 - return -EINVAL; 448 + ret = kstrtoul(buf, 0, &size); 449 + if (ret) 450 + return ret; 451 + 461 452 /* min bar size is 256 */ 462 453 if (size <= 0x100) 463 454 size = 0x100; ··· 505 490 { 506 491 struct pcie_app_reg __iomem *app_reg = config->va_app_base; 507 492 ulong address; 493 + int ret; 508 494 509 - if (strict_strtoul(buf, 0, &address)) 510 - return -EINVAL; 495 + ret = kstrtoul(buf, 0, &address); 496 + if (ret) 497 + return ret; 511 498 512 499 address &= ~(config->bar0_size - 1); 513 500 if (config->va_bar0_address) ··· 535 518 const char *buf, size_t count) 536 519 { 537 520 ulong offset; 521 + int ret; 538 522 539 - if (strict_strtoul(buf, 0, &offset)) 540 - return -EINVAL; 523 + ret = kstrtoul(buf, 0, &offset); 524 + if (ret) 525 + return ret; 541 526 542 527 if (offset % 4) 543 528 return -EINVAL; ··· 568 549 const char *buf, size_t count) 569 550 { 570 551 ulong data; 552 + int ret; 571 553 572 - if (strict_strtoul(buf, 0, &data)) 573 - return -EINVAL; 554 + ret = kstrtoul(buf, 0, &data); 555 + if (ret) 556 + return ret; 574 557 575 558 if (!config->va_bar0_address) 576 559 return -ENOMEM;
+4 -2
drivers/misc/ti_dac7512.c
··· 33 33 struct spi_device *spi = to_spi_device(dev); 34 34 unsigned char tmp[2]; 35 35 unsigned long val; 36 + int ret; 36 37 37 - if (strict_strtoul(buf, 10, &val) < 0) 38 - return -EINVAL; 38 + ret = kstrtoul(buf, 10, &val); 39 + if (ret) 40 + return ret; 39 41 40 42 tmp[0] = val >> 8; 41 43 tmp[1] = val & 0xff;