leds: lm3642: remove warnings for bad strtol, cleanup gotos
Bad string from userspace is not worth printing warning on; gotos that just directly return are not good, plus a comment fix. Cc: jacek.anaszewski@gmail.com, linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, dmurphy@ti.com Signed-off-by: Pavel Machek <pavel@ucw.cz>
This commit is contained in:
Родитель
445da487f1
Коммит
867b682459
|
@ -106,7 +106,7 @@ static int lm3642_control(struct lm3642_chip_data *chip,
|
||||||
ret = regmap_read(chip->regmap, REG_FLAG, &chip->last_flag);
|
ret = regmap_read(chip->regmap, REG_FLAG, &chip->last_flag);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(chip->dev, "Failed to read REG_FLAG Register\n");
|
dev_err(chip->dev, "Failed to read REG_FLAG Register\n");
|
||||||
goto out;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chip->last_flag)
|
if (chip->last_flag)
|
||||||
|
@ -146,11 +146,11 @@ static int lm3642_control(struct lm3642_chip_data *chip,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return ret;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(chip->dev, "Failed to write REG_I_CTRL Register\n");
|
dev_err(chip->dev, "Failed to write REG_I_CTRL Register\n");
|
||||||
goto out;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chip->tx_pin)
|
if (chip->tx_pin)
|
||||||
|
@ -159,13 +159,12 @@ static int lm3642_control(struct lm3642_chip_data *chip,
|
||||||
ret = regmap_update_bits(chip->regmap, REG_ENABLE,
|
ret = regmap_update_bits(chip->regmap, REG_ENABLE,
|
||||||
MODE_BITS_MASK << MODE_BITS_SHIFT,
|
MODE_BITS_MASK << MODE_BITS_SHIFT,
|
||||||
opmode << MODE_BITS_SHIFT);
|
opmode << MODE_BITS_SHIFT);
|
||||||
out:
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* torch */
|
/* torch */
|
||||||
|
|
||||||
/* torch pin config for lm3642*/
|
/* torch pin config for lm3642 */
|
||||||
static ssize_t lm3642_torch_pin_store(struct device *dev,
|
static ssize_t lm3642_torch_pin_store(struct device *dev,
|
||||||
struct device_attribute *attr,
|
struct device_attribute *attr,
|
||||||
const char *buf, size_t size)
|
const char *buf, size_t size)
|
||||||
|
@ -178,7 +177,7 @@ static ssize_t lm3642_torch_pin_store(struct device *dev,
|
||||||
|
|
||||||
ret = kstrtouint(buf, 10, &state);
|
ret = kstrtouint(buf, 10, &state);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_strtoint;
|
return ret;
|
||||||
if (state != 0)
|
if (state != 0)
|
||||||
state = 0x01 << TORCH_PIN_EN_SHIFT;
|
state = 0x01 << TORCH_PIN_EN_SHIFT;
|
||||||
|
|
||||||
|
@ -186,16 +185,12 @@ static ssize_t lm3642_torch_pin_store(struct device *dev,
|
||||||
ret = regmap_update_bits(chip->regmap, REG_ENABLE,
|
ret = regmap_update_bits(chip->regmap, REG_ENABLE,
|
||||||
TORCH_PIN_EN_MASK << TORCH_PIN_EN_SHIFT,
|
TORCH_PIN_EN_MASK << TORCH_PIN_EN_SHIFT,
|
||||||
state);
|
state);
|
||||||
if (ret < 0)
|
if (ret < 0) {
|
||||||
goto out;
|
dev_err(chip->dev, "%s:i2c access fail to register\n", __func__);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
out:
|
|
||||||
dev_err(chip->dev, "%s:i2c access fail to register\n", __func__);
|
|
||||||
return ret;
|
|
||||||
out_strtoint:
|
|
||||||
dev_err(chip->dev, "%s: fail to change str to int\n", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static DEVICE_ATTR(torch_pin, S_IWUSR, NULL, lm3642_torch_pin_store);
|
static DEVICE_ATTR(torch_pin, S_IWUSR, NULL, lm3642_torch_pin_store);
|
||||||
|
@ -229,7 +224,7 @@ static ssize_t lm3642_strobe_pin_store(struct device *dev,
|
||||||
|
|
||||||
ret = kstrtouint(buf, 10, &state);
|
ret = kstrtouint(buf, 10, &state);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_strtoint;
|
return ret;
|
||||||
if (state != 0)
|
if (state != 0)
|
||||||
state = 0x01 << STROBE_PIN_EN_SHIFT;
|
state = 0x01 << STROBE_PIN_EN_SHIFT;
|
||||||
|
|
||||||
|
@ -237,16 +232,12 @@ static ssize_t lm3642_strobe_pin_store(struct device *dev,
|
||||||
ret = regmap_update_bits(chip->regmap, REG_ENABLE,
|
ret = regmap_update_bits(chip->regmap, REG_ENABLE,
|
||||||
STROBE_PIN_EN_MASK << STROBE_PIN_EN_SHIFT,
|
STROBE_PIN_EN_MASK << STROBE_PIN_EN_SHIFT,
|
||||||
state);
|
state);
|
||||||
if (ret < 0)
|
if (ret < 0) {
|
||||||
goto out;
|
dev_err(chip->dev, "%s:i2c access fail to register\n", __func__);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
out:
|
|
||||||
dev_err(chip->dev, "%s:i2c access fail to register\n", __func__);
|
|
||||||
return ret;
|
|
||||||
out_strtoint:
|
|
||||||
dev_err(chip->dev, "%s: fail to change str to int\n", __func__);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static DEVICE_ATTR(strobe_pin, S_IWUSR, NULL, lm3642_strobe_pin_store);
|
static DEVICE_ATTR(strobe_pin, S_IWUSR, NULL, lm3642_strobe_pin_store);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче