From patchwork Sun Sep 20 00:25:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255363 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D430FC43469 for ; Sun, 20 Sep 2020 00:25:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8B81F20E65 for ; Sun, 20 Sep 2020 00:25:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="XA1b/JGm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726806AbgITAZF (ORCPT ); Sat, 19 Sep 2020 20:25:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726817AbgITAZF (ORCPT ); Sat, 19 Sep 2020 20:25:05 -0400 Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E578C061755 for ; Sat, 19 Sep 2020 17:25:05 -0700 (PDT) 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 0CEC2140A99; Sun, 20 Sep 2020 02:25:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600561503; bh=wCHcJGOtTztFA3VOpQ+2gTSFQn1wILFtTiwAsFMseXo=; h=From:To:Date; b=XA1b/JGmt8WHZqy9C3PtK0j2/evis1YQgP7LJHMfa9s56+2dImvGPQUSJFooDlmuS IUDxX3We3NdHw6I+rid6OoO6M0zk3QWbrAisyqFzoYQtfoZaXUmKFcwEk83EGPIZTY tRuT61lSkb6i/PJAGkOp1R9ZSM56cssxTLTjSrRQ= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?Ma?= =?utf-8?q?rek_Beh=C3=BAn?= , Peter Meerwald , Ricardo Ribalda , Zahari Petkov Subject: [PATCH leds 7/7] leds: pca963x: use struct led_init_data when registering Date: Sun, 20 Sep 2020 02:25:00 +0200 Message-Id: <20200920002500.5851-8-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200920002500.5851-1-marek.behun@nic.cz> References: <20200920002500.5851-1-marek.behun@nic.cz> MIME-Version: 1.0 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-leds@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 "pca963x:%d:%.2x:%u" For backwards compatibility we therefore set init_data->default_label to this value so that the LED will not get a different name if `label` property is not present, nor are `color` and `function`. Signed-off-by: Marek BehĂșn Cc: Peter Meerwald Cc: Ricardo Ribalda Cc: Zahari Petkov --- drivers/leds/leds-pca963x.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c index 5083ccce1a519..00aecd67e3483 100644 --- a/drivers/leds/leds-pca963x.c +++ b/drivers/leds/leds-pca963x.c @@ -289,8 +289,6 @@ static int pca963x_register_leds(struct i2c_client *client, struct pca963x_led *led = chip->leds; struct device *dev = &client->dev; struct fwnode_handle *child; - const char *name; - char label[64]; bool hw_blink; s32 mode2; u32 reg; @@ -323,6 +321,9 @@ static int pca963x_register_leds(struct i2c_client *client, return ret; device_for_each_child_node(dev, child) { + struct led_init_data init_data = {}; + char default_label[32]; + ret = fwnode_property_read_u32(child, "reg", ®); if (ret || reg >= chipdef->n_leds) { dev_err(dev, "Invalid 'reg' property for node %pfw\n", @@ -331,23 +332,21 @@ static int pca963x_register_leds(struct i2c_client *client, goto err; } - ret = fwnode_property_read_string(child, "label", &name); - if (!fwnode_property_read_string(child, "label", &name)) - snprintf(label, sizeof(label), "pca963x:%s", name); - else - snprintf(label, sizeof(label), "pca963x::"); - - fwnode_property_read_string(child, "linux,default-trigger", - &led->led_cdev.default_trigger); - led->led_num = reg; led->chip = chip; - led->led_cdev.name = label; led->led_cdev.brightness_set_blocking = pca963x_led_set; if (hw_blink) led->led_cdev.blink_set = pca963x_blink_set; - ret = devm_led_classdev_register(dev, &led->led_cdev); + init_data.fwnode = child; + /* for backwards compatibility */ + init_data.devicename = "pca963x"; + snprintf(default_label, sizeof(default_label), "%d:%.2x:%u", + client->adapter->nr, client->addr, reg); + init_data.default_label = default_label; + + ret = devm_led_classdev_register_ext(dev, &led->led_cdev, + &init_data); if (ret) { dev_err(dev, "Failed to register LED for node %pfw\n", child);