Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2409314imu; Tue, 6 Nov 2018 14:09:28 -0800 (PST) X-Google-Smtp-Source: AJdET5f3hi1B/ysw//82lqR3V1+attVthV7L4muZo9CLW+UEwFqoxiPJNnpDbQ+iryvfJcqMdrdg X-Received: by 2002:a62:15c7:: with SMTP id 190-v6mr14463405pfv.213.1541542168087; Tue, 06 Nov 2018 14:09:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541542167; cv=none; d=google.com; s=arc-20160816; b=qe5QHLUF0GHLmC7mhtXItLq+vIetSHEJGzY/EfcToyir3h1R/D00bnVH2Ic9sE6YfX hh6IW/JmkDFfX9MppPgxOZi+FPFuKkvt1DQwa2scD6k8hGwVU+gw21uSP+n57W4vdqE1 +sEYyD5XceUQOwTFQ6n2GxtiX5qiu3OmWvHglSA+U9lFG1st8DnhK4CICTMc3wFBDR9y cfM9WsUt0A2lL1Jai5N0BBWTcl6jCyCUGZetAgIPsNX8CaqJ30tW8u73v5jnh4VE/va6 vKYqH7LRuZPbsmnC/zzPMjw9WQP6eR6KttYJw1e9TaDNQQqd+oYsba2kgqO7lzrHCxNl tVCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=LJ6SOaj7NyIQapLj64p4Wg1aYkRzp9U5EfWFNYR9Uko=; b=CJnozp7wesBMa5YTn6MVnAaFRVVwRlmeBM+NeCHkBGeufanIdZT3I/y0x3G1pOXxq1 kEyBes9LMTC1sO+NrXuPY07asxYpPBtwO7iU2T0jbN97WhNp0ZT9j9L0hFPiohmgMBuS OHK0OhvFs7PkMdLen01dZB6gfoeN7onFDYGAHQ+ZXXjwWJ2azzhWes53vdbUjVCYGUWW HdWTHmVJAwOnNnnp4MweuqKRGHP3y+nYwgB2EKXH1UFEwbynjmicUZBf7+2bv33dZH1z g8QPjsDICJG5KnUIFUb8o0zjgue7Ql4RPARomyiWOeSJ3kFDvztaoq1e7Bww4DufRfIM F17A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hgpJnqKG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r85si6316433pgr.429.2018.11.06.14.09.12; Tue, 06 Nov 2018 14:09:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hgpJnqKG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389035AbeKGHft (ORCPT + 99 others); Wed, 7 Nov 2018 02:35:49 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:46500 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388991AbeKGHfs (ORCPT ); Wed, 7 Nov 2018 02:35:48 -0500 Received: by mail-lj1-f193.google.com with SMTP id v15-v6so4298369ljh.13; Tue, 06 Nov 2018 14:08:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LJ6SOaj7NyIQapLj64p4Wg1aYkRzp9U5EfWFNYR9Uko=; b=hgpJnqKGcwdresOJpu7asQFIcCaG6k3KNVBPUzoOm9EecRK9LPqNLZOFs/FcysKpcq c9AQOeHsogJG/0lF61iFZf7Gc4jqYG7oNCoXo1D+o8q8X9yY9CqhDMlkGdTRUg6tNO4E 2zgVM2SU8+wLISuNSefNHFYig7I4mCU/S+I56Pvwl1vel32WGrxlHY5yQ5SlZwUw56Pq 2pSLZTS0xxB+fVZEsMbbXJrAKGsOTzMvYoCb+wmDeStDdmSlpL2YDnK31rjb4EOZPymw 2dxD2CSiYSrvBK2bf4EqZM20lkuQlLFgJ3K9HKnqJwOjk+ddqQvEUxORYTGWwtgQ9QYf la7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LJ6SOaj7NyIQapLj64p4Wg1aYkRzp9U5EfWFNYR9Uko=; b=W4sZE/cK07qphLLYStUqNlPbRRmsb3zZDItzYY1cNCNnCaOAtb9MgD04QcmLaPug6s A8D5+41CcHU5uIVFAiJ5POD8RZH+ACwGzU8a5YB17UMt7qWI0aXO5ncF4x/yB/8cyzgn 5fy5z+S6dQeAAxS1k0S5det+6HIBgcgsbF0sUkD9I13avezDA7T2N25BwcuwtZ8JteLe rzEG6lo/UHU72ZkuPgbpzVTNpVbVFabB6lxG/yytSMcDvUxXKMzht/iaei/sFgqsMvH8 +0lx1e3wGKsfl6OBFqrVJMuSZYnBIrdbmRue7KELN778nT7TCmVBrhvCNbQupOjLl9MP 757A== X-Gm-Message-State: AGRZ1gKozfxcnQVQGdi9dN2zOLo0RNmg43iAMg1eNnUz6iIKUskagBzn 0WSvCWovOtggpAcbEhwBGSrKi+0SfMU= X-Received: by 2002:a2e:1bc5:: with SMTP id c66-v6mr17690038ljf.96.1541542104360; Tue, 06 Nov 2018 14:08:24 -0800 (PST) Received: from i4790k.home (bgp86.neoplus.adsl.tpnet.pl. [83.28.79.86]) by smtp.gmail.com with ESMTPSA id c20sm3185654lfj.67.2018.11.06.14.08.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Nov 2018 14:08:23 -0800 (PST) From: Jacek Anaszewski To: linux-leds@vger.kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, pavel@ucw.cz, robh@kernel.org, jacek.anaszewski@gmail.com, Linus Walleij Subject: [PATCH 22/24] leds: gpio: Use led_compose_name() Date: Tue, 6 Nov 2018 23:07:30 +0100 Message-Id: <1541542052-10081-23-git-send-email-jacek.anaszewski@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1541542052-10081-1-git-send-email-jacek.anaszewski@gmail.com> References: <1541542052-10081-1-git-send-email-jacek.anaszewski@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Switch to using generic LED support for composing LED class device name. Signed-off-by: Jacek Anaszewski Cc: Linus Walleij --- drivers/leds/leds-gpio.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c index c87fbd3..69a3cde 100644 --- a/drivers/leds/leds-gpio.c +++ b/drivers/leds/leds-gpio.c @@ -77,11 +77,19 @@ static int gpio_blink_set(struct led_classdev *led_cdev, static int create_gpio_led(const struct gpio_led *template, struct gpio_led_data *led_dat, struct device *parent, - struct device_node *np, gpio_blink_set_t blink_set) + struct fwnode_handle *fwnode, gpio_blink_set_t blink_set) { + struct led_init_data init_data = { fwnode }; int ret, state; - led_dat->cdev.name = template->name; + if (template->name) { + led_dat->cdev.name = template->name; + } else { + ret = led_compose_name(fwnode, NULL, NULL, init_data.name); + if (ret) + return ret; + } + led_dat->cdev.default_trigger = template->default_trigger; led_dat->can_sleep = gpiod_cansleep(led_dat->gpiod); if (!led_dat->can_sleep) @@ -112,7 +120,8 @@ static int create_gpio_led(const struct gpio_led *template, if (ret < 0) return ret; - return devm_led_classdev_register(parent, &led_dat->cdev); + return devm_led_classdev_register_ext(parent, &led_dat->cdev, + &init_data); } struct gpio_leds_priv { @@ -145,15 +154,6 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev) struct gpio_led_data *led_dat = &priv->leds[priv->num_leds]; struct gpio_led led = {}; const char *state = NULL; - struct device_node *np = to_of_node(child); - - ret = fwnode_property_read_string(child, "label", &led.name); - if (ret && IS_ENABLED(CONFIG_OF) && np) - led.name = np->name; - if (!led.name) { - fwnode_handle_put(child); - return ERR_PTR(-EINVAL); - } led.gpiod = devm_fwnode_get_gpiod_from_child(dev, NULL, child, GPIOD_ASIS, @@ -183,12 +183,11 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev) if (fwnode_property_present(child, "panic-indicator")) led.panic_indicator = 1; - ret = create_gpio_led(&led, led_dat, dev, np, NULL); + ret = create_gpio_led(&led, led_dat, dev, child, NULL); if (ret < 0) { fwnode_handle_put(child); return ERR_PTR(ret); } - led_dat->cdev.dev->of_node = np; priv->num_leds++; } -- 2.1.4