Since this value is only used in device probe, don't store it in private structure. Simply parse the value and set it. Signed-off-by: Marek Behún <marek.behun@xxxxxx> Cc: H. Nikolaus Schaller <hns@xxxxxxxxxxxxx> Cc: Grant Feng <von81@xxxxxxx> --- drivers/leds/leds-is31fl319x.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/leds/leds-is31fl319x.c b/drivers/leds/leds-is31fl319x.c index 595112958617e..8e3e02d959989 100644 --- a/drivers/leds/leds-is31fl319x.c +++ b/drivers/leds/leds-is31fl319x.c @@ -65,7 +65,6 @@ struct is31fl319x_chip { struct i2c_client *client; struct regmap *regmap; struct mutex lock; - u32 audio_gain_db; struct is31fl319x_led { struct is31fl319x_chip *chip; @@ -198,6 +197,18 @@ static int is31fl319x_parse_max_current(struct device *dev, u32 *aggregated) return 0; } +static u32 is31fl319x_parse_audio_gain(struct device *dev) +{ + u32 result; + + if (!of_property_read_u32(dev_of_node(dev), "audio-gain-db", &result)) + result = min(result, IS31FL319X_AUDIO_GAIN_DB_MAX); + else + result = 0; + + return result;; +} + static int is31fl319x_parse_child_dt(const struct device *dev, const struct device_node *child, struct is31fl319x_led *led) @@ -271,12 +282,6 @@ static int is31fl319x_parse_dt(struct device *dev, led->configured = true; } - is31->audio_gain_db = 0; - ret = of_property_read_u32(np, "audio-gain-db", &is31->audio_gain_db); - if (!ret) - is31->audio_gain_db = min(is31->audio_gain_db, - IS31FL319X_AUDIO_GAIN_DB_MAX); - return 0; put_child_node: @@ -346,6 +351,7 @@ static int is31fl319x_probe(struct i2c_client *client, struct is31fl319x_chip *is31; struct device *dev = &client->dev; struct gpio_desc *shutdown_gpio; + u32 audio_gain_db; int err; int i = 0; u32 aggregated_led_microamp; @@ -405,9 +411,11 @@ static int is31fl319x_probe(struct i2c_client *client, goto free_mutex; } + audio_gain_db = is31fl319x_parse_audio_gain(dev); + regmap_write(is31->regmap, IS31FL319X_CONFIG2, is31fl319x_microamp_to_cs(dev, aggregated_led_microamp) | - is31fl319x_db_to_gain(is31->audio_gain_db)); + is31fl319x_db_to_gain(audio_gain_db)); for (i = 0; i < is31->cdef->num_leds; i++) { struct is31fl319x_led *led = &is31->leds[i]; -- 2.26.2