Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp754299pxk; Thu, 17 Sep 2020 15:37:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpOzqxSZ5lZi8mZ1derWKPdPY5d8o5b3VwnT3xsIFR0oUoyBM8hMM5IOO3H6OhdOwV5r1N X-Received: by 2002:a17:906:f9d3:: with SMTP id lj19mr32681917ejb.346.1600382259000; Thu, 17 Sep 2020 15:37:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600382258; cv=none; d=google.com; s=arc-20160816; b=nB3RAWI6Y2EEI7gwEQmITa73Ugs34/xHFSbtK9IFqZTTQTCu8+RhW/3W/56PJf09DA K/7UdBRIamQcD30SdJi4B6GmbucgDFfTAvC+ZWMjIdY9oLQ2ClWrkVXQZmU54tbhY2sn WFq+WsmCwU88ZMh2xp2t9BFOWRIZKGvm3mikciycTFwF0rxkHsSI2nHKkkwO9T/HPB5Y AzoS1BunxBOfNDTe+j+rtXVYn95nLGvqoQOzPq7P4M4QditSBNr0Sg4+xlFNl7spwA9a d5XCqMnKbjYyapM8H9Ece/ogPt8Ub3YQDsbQTa8ZdodixQG9Y/uTp9JZ+y3nxKAdJxO6 SP9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=H9TcBKLYZluR8MZLudGuKuWo9XIvkFJ7Vb+EZ4P4H5k=; b=aarjb1disBuWVcOI8MFdhONbwk0AtMFVddIOciLnFBqEwXPMO3QQDEsg0bRszexR9a YksSgdthLCmAZQP4GA9UA6pCELCW2E9+AETOEW1QoBYIYrkX3ybgOQ3+MxXv8lSkE+qa axRhHpwtK4mSE9Ijekom7W8znlhZFtxkbzyFXh68keY+Fu+bMIQyyS1Dp8NHLIBiMdSy WTlApU5g016UgyEdvZYrecmc+OanoM8LbA5urNVz3Zdq/n+cHGZiNs6qZX0Tbe1IIV/Y lsFOx1shRSwNRNCHoHfk5252suf5ZApprS9/QbrWj/rkzelghNca/DA6Y47QegrIRyc5 +/kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nic.cz header.s=default header.b=m6Sfyn2a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nic.cz Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j23si875405ejm.736.2020.09.17.15.37.14; Thu, 17 Sep 2020 15:37:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nic.cz header.s=default header.b=m6Sfyn2a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nic.cz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726421AbgIQWeO (ORCPT + 99 others); Thu, 17 Sep 2020 18:34:14 -0400 Received: from mail.nic.cz ([217.31.204.67]:35854 "EHLO mail.nic.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726218AbgIQWeK (ORCPT ); Thu, 17 Sep 2020 18:34:10 -0400 Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 33054142042; Fri, 18 Sep 2020 00:33:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600382038; bh=jF62DFUspv0dwhNKqUBBbK3qw4wrbt7E6Hsa+iFaoe8=; h=From:To:Date; b=m6Sfyn2abv80e1kfOUaIwNcxcQf0ylGoG7T9u365XHENPoMRa+zu65SqI7D11w0i1 xh/E5dXaog285nnBl3FxOqt0ItDodJTbyuQ16YyRpZjLp20QaCzyaM1yotB7MIn93z QhNiFimnDpDnyXMpyUfkGCGqJkApriTN4N8kJk7I= From: =?UTF-8?q?Marek=20Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?UTF-8?q?Ond=C5=99ej=20Jirman?= , linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, =?UTF-8?q?Marek=20Beh=C3=BAn?= , "H . Nikolaus Schaller" , Grant Feng Subject: [PATCH leds v2 27/50] leds: is31fl319x: don't store audio gain value, simply set it Date: Fri, 18 Sep 2020 00:33:15 +0200 Message-Id: <20200917223338.14164-28-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917223338.14164-1-marek.behun@nic.cz> References: <20200917223338.14164-1-marek.behun@nic.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.nic.cz X-Spam-Status: No, score=0.00 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: H. Nikolaus Schaller Cc: Grant Feng --- 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