--- zzzz-none-000/linux-3.10.107/drivers/misc/bh1770glc.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/misc/bh1770glc.c 2021-02-04 17:41:59.000000000 +0000 @@ -651,8 +651,9 @@ unsigned long value; ssize_t ret; - if (strict_strtoul(buf, 0, &value)) - return -EINVAL; + ret = kstrtoul(buf, 0, &value); + if (ret) + return ret; mutex_lock(&chip->mutex); if (value) { @@ -726,9 +727,11 @@ { struct bh1770_chip *chip = dev_get_drvdata(dev); unsigned long value; + int ret; - if (strict_strtoul(buf, 0, &value)) - return -EINVAL; + ret = kstrtoul(buf, 0, &value); + if (ret) + return ret; mutex_lock(&chip->mutex); /* Assume no proximity. Sensor will tell real state soon */ @@ -824,9 +827,11 @@ { struct bh1770_chip *chip = dev_get_drvdata(dev); unsigned long value; + int ret; - if (strict_strtoul(buf, 0, &value)) - return -EINVAL; + ret = kstrtoul(buf, 0, &value); + if (ret) + return ret; mutex_lock(&chip->mutex); chip->prox_rate_threshold = bh1770_prox_rate_validate(value); @@ -840,9 +845,11 @@ { struct bh1770_chip *chip = dev_get_drvdata(dev); unsigned long value; + int ret; - if (strict_strtoul(buf, 0, &value)) - return -EINVAL; + ret = kstrtoul(buf, 0, &value); + if (ret) + return ret; mutex_lock(&chip->mutex); chip->prox_rate = bh1770_prox_rate_validate(value); @@ -865,8 +872,10 @@ unsigned long value; int ret; - if (strict_strtoul(buf, 0, &value)) - return -EINVAL; + ret = kstrtoul(buf, 0, &value); + if (ret) + return ret; + if (value > BH1770_PROX_RANGE) return -EINVAL; @@ -893,9 +902,11 @@ { struct bh1770_chip *chip = dev_get_drvdata(dev); unsigned long value; + int ret; - if (strict_strtoul(buf, 0, &value)) - return -EINVAL; + ret = kstrtoul(buf, 0, &value); + if (ret) + return ret; if (value > BH1770_PROX_MAX_PERSISTENCE) return -EINVAL; @@ -918,9 +929,11 @@ { struct bh1770_chip *chip = dev_get_drvdata(dev); unsigned long value; + int ret; - if (strict_strtoul(buf, 0, &value)) - return -EINVAL; + ret = kstrtoul(buf, 0, &value); + if (ret) + return ret; if (value > BH1770_PROX_RANGE) return -EINVAL; @@ -963,9 +976,11 @@ unsigned long value; u32 old_calib; u32 new_corr; + int ret; - if (strict_strtoul(buf, 0, &value)) - return -EINVAL; + ret = kstrtoul(buf, 0, &value); + if (ret) + return ret; mutex_lock(&chip->mutex); old_calib = chip->lux_calib; @@ -1012,8 +1027,9 @@ unsigned long rate_hz; int ret, i; - if (strict_strtoul(buf, 0, &rate_hz)) - return -EINVAL; + ret = kstrtoul(buf, 0, &rate_hz); + if (ret) + return ret; for (i = 0; i < ARRAY_SIZE(lux_rates_hz) - 1; i++) if (rate_hz >= lux_rates_hz[i]) @@ -1047,11 +1063,12 @@ static ssize_t bh1770_set_lux_thresh(struct bh1770_chip *chip, u16 *target, const char *buf) { - int ret = 0; unsigned long thresh; + int ret; - if (strict_strtoul(buf, 0, &thresh)) - return -EINVAL; + ret = kstrtoul(buf, 0, &thresh); + if (ret) + return ret; if (thresh > BH1770_LUX_RANGE) return -EINVAL; @@ -1168,7 +1185,7 @@ struct bh1770_chip *chip; int err; - chip = kzalloc(sizeof *chip, GFP_KERNEL); + chip = devm_kzalloc(&client->dev, sizeof *chip, GFP_KERNEL); if (!chip) return -ENOMEM; @@ -1181,8 +1198,7 @@ if (client->dev.platform_data == NULL) { dev_err(&client->dev, "platform data is mandatory\n"); - err = -EINVAL; - goto fail1; + return -EINVAL; } chip->pdata = client->dev.platform_data; @@ -1207,24 +1223,24 @@ chip->regs[0].supply = reg_vcc; chip->regs[1].supply = reg_vleds; - err = regulator_bulk_get(&client->dev, - ARRAY_SIZE(chip->regs), chip->regs); + err = devm_regulator_bulk_get(&client->dev, + ARRAY_SIZE(chip->regs), chip->regs); if (err < 0) { dev_err(&client->dev, "Cannot get regulators\n"); - goto fail1; + return err; } err = regulator_bulk_enable(ARRAY_SIZE(chip->regs), chip->regs); if (err < 0) { dev_err(&client->dev, "Cannot enable regulators\n"); - goto fail2; + return err; } usleep_range(BH1770_STARTUP_DELAY, BH1770_STARTUP_DELAY * 2); err = bh1770_detect(chip); if (err < 0) - goto fail3; + goto fail0; /* Start chip */ bh1770_chip_on(chip); @@ -1235,14 +1251,14 @@ if (chip->lux_corr == 0) { dev_err(&client->dev, "Improper correction values\n"); err = -EINVAL; - goto fail3; + goto fail0; } if (chip->pdata->setup_resources) { err = chip->pdata->setup_resources(); if (err) { err = -EINVAL; - goto fail3; + goto fail0; } } @@ -1250,7 +1266,7 @@ &bh1770_attribute_group); if (err < 0) { dev_err(&chip->client->dev, "Sysfs registration failed\n"); - goto fail4; + goto fail1; } /* @@ -1266,22 +1282,18 @@ if (err) { dev_err(&client->dev, "could not get IRQ %d\n", client->irq); - goto fail5; + goto fail2; } regulator_bulk_disable(ARRAY_SIZE(chip->regs), chip->regs); return err; -fail5: +fail2: sysfs_remove_group(&chip->client->dev.kobj, &bh1770_attribute_group); -fail4: +fail1: if (chip->pdata->release_resources) chip->pdata->release_resources(); -fail3: +fail0: regulator_bulk_disable(ARRAY_SIZE(chip->regs), chip->regs); -fail2: - regulator_bulk_free(ARRAY_SIZE(chip->regs), chip->regs); -fail1: - kfree(chip); return err; } @@ -1305,8 +1317,6 @@ pm_runtime_disable(&client->dev); pm_runtime_set_suspended(&client->dev); - regulator_bulk_free(ARRAY_SIZE(chip->regs), chip->regs); - kfree(chip); return 0; } @@ -1348,7 +1358,7 @@ } #endif -#ifdef CONFIG_PM_RUNTIME +#ifdef CONFIG_PM static int bh1770_runtime_suspend(struct device *dev) { struct i2c_client *client = container_of(dev, struct i2c_client, dev); @@ -1386,7 +1396,6 @@ static struct i2c_driver bh1770_driver = { .driver = { .name = "bh1770glc", - .owner = THIS_MODULE, .pm = &bh1770_pm_ops, }, .probe = bh1770_probe,