Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp753249pxk; Thu, 17 Sep 2020 15:35:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFVb5JoYB8RLkre4KsiCc3pfqJ5W6eRAtIg0NVJxZIhNVWrN5Y3qPrePTl0+/kQdW4taIO X-Received: by 2002:a17:906:6007:: with SMTP id o7mr34490529ejj.550.1600382129337; Thu, 17 Sep 2020 15:35:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600382129; cv=none; d=google.com; s=arc-20160816; b=JgdshKSCvPljZAWd3kVwAizea7C8IPUZpaRH1ykBwHdx2g1WGPXMlaTLQJznqYyg1v dm7kGNzo+/GseG7GdDe0Yq7i+Sbz9W49vKGRrHtOSEo5RudSjzJyJ7y3erOgGOUdapk0 WEwQ9bPZqYGwNm1tg+QoAoUbf09tm9gRjjczcCTPhPzsk0ied1vwvJtaVDqi9Zk+TnYT FUZfVuN8FcKVY932+1fTiLvtEH2UfUzZrNEtqzOI/DhIpp3xu87e84l8lXKxuSG5oObt PHmZzvn1OqnUeMwH0STMJ0ydhI28oGWxwCoclx8bAjOKMFtPZ5UletzCFc9t5CfysVYL Q5Sw== 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=zRRHRklJSmj75T3tS9OOhhjTKbVsU48ROVpGaI6CvuI=; b=L5Ix32VfFzX2FPlPbftI6ICfnMSpesAO+jaJRjiQl9tX6CYKEKxJjtcICrPrlrzJv8 TYAJkkhaTNwRiscOj5KAf/KW6XupSlqzBWL7je75nH9M1cCfNBkYAxbxvfObxYyFxO+W Af9Zj53gEep6UVEcsvjNONZK1rC4EbB/9f1NjVfKwWwFimVc2iJMugNMT0qmjUyrEoE9 kNYUDz7juJKmqRB/YWXfjFHmROuwVSGvzLpFBqamDJqfdyHr7nQKX5A+kaY2oP3mWPW4 N5yjoMfPFaIrTjmekiguXztXSwuaw9lKsqMWe5ockIKWbHNpAiEVuzpgyu9X4cmtPAJA YLIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nic.cz header.s=default header.b=pEXzLZri; 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 t15si763696edr.122.2020.09.17.15.35.05; Thu, 17 Sep 2020 15:35:29 -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=pEXzLZri; 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 S1726326AbgIQWeF (ORCPT + 99 others); Thu, 17 Sep 2020 18:34:05 -0400 Received: from mail.nic.cz ([217.31.204.67]:35610 "EHLO mail.nic.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726154AbgIQWeC (ORCPT ); Thu, 17 Sep 2020 18:34:02 -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 AEFE3140AAB; Fri, 18 Sep 2020 00:33:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600382035; bh=wpYWIMFLHHEQHY3szNAZh0Xlv5s2DPdwZfaOXl2xbtY=; h=From:To:Date; b=pEXzLZridMTS9MO6S1TGAIiEovytcB8dr3+gIuKJX9bER3qLnUTY3q3fbYs0KIt/x uW5o05gkXp9niUsrOLEPvN3Gi96S1Za6T10Ex6Ll44vIWkwLe8iZ7mngwE1tlghIrI /W0MY7PMwOrKKsTI4K1TH/jCdbyY7/THJwp4XsGM= 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?= Subject: [PATCH leds v2 14/50] leds: lm3697: use struct led_init_data when registering Date: Fri, 18 Sep 2020 00:33:02 +0200 Message-Id: <20200917223338.14164-15-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 By using struct led_init_data when registering we do not need to parse `label` DT property. Moreover `label` is deprecated and if it is not present but `color` and `function` are, LED core will compose a name from these properties instead. Previously if the `label` DT property was not present, the code composed name for the LED in the form "parent_name::" For backwards compatibility we therefore set init_data->default_label = ":"; so that the LED will not get a different name if `label` property is not present. Signed-off-by: Marek BehĂșn Cc: Dan Murphy --- drivers/leds/leds-lm3697.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/leds/leds-lm3697.c b/drivers/leds/leds-lm3697.c index 5d14f3d2220af..479776ac36c35 100644 --- a/drivers/leds/leds-lm3697.c +++ b/drivers/leds/leds-lm3697.c @@ -194,7 +194,6 @@ static int lm3697_probe_dt(struct lm3697 *priv) { struct fwnode_handle *child = NULL; struct lm3697_led *led; - const char *name; int control_bank; size_t i = 0; int ret = -EINVAL; @@ -214,6 +213,8 @@ static int lm3697_probe_dt(struct lm3697 *priv) priv->regulator = NULL; device_for_each_child_node(priv->dev, child) { + struct led_init_data init_data = {}; + ret = fwnode_property_read_u32(child, "reg", &control_bank); if (ret) { dev_err(&priv->client->dev, "reg property missing\n"); @@ -271,20 +272,17 @@ static int lm3697_probe_dt(struct lm3697 *priv) fwnode_property_read_string(child, "linux,default-trigger", &led->led_dev.default_trigger); - ret = fwnode_property_read_string(child, "label", &name); - if (ret) - snprintf(led->label, sizeof(led->label), - "%s::", priv->client->name); - else - snprintf(led->label, sizeof(led->label), - "%s:%s", priv->client->name, name); + init_data.fwnode = child; + init_data.devicename = priv->client->name; + /* for backwards compatibility if `label` is not present */ + init_data.default_label = ":"; led->priv = priv; - led->led_dev.name = led->label; led->led_dev.max_brightness = led->lmu_data.max_brightness; led->led_dev.brightness_set_blocking = lm3697_brightness_set; - ret = devm_led_classdev_register(priv->dev, &led->led_dev); + ret = devm_led_classdev_register_ext(priv->dev, &led->led_dev, + &init_data); if (ret) { dev_err(&priv->client->dev, "led register err: %d\n", ret); -- 2.26.2