From patchwork Mon Jul 2 18:12:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 140845 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp247696ljj; Mon, 2 Jul 2018 11:12:55 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdE/cZrO+PS3Hr7DWntAXyXUbWqRH36C7oQLsVe3cMqhIcng3R1MOcyLlTo6owepRSidJnX X-Received: by 2002:a62:9849:: with SMTP id q70-v6mr12689262pfd.178.1530555175678; Mon, 02 Jul 2018 11:12:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530555175; cv=none; d=google.com; s=arc-20160816; b=rvDwoTQe2aGeK5eE07U0pZkgNLMIlI4KFHw7FqS0nSASySJsZB0Df/BCEiS96J/Xjh Yv7XDzOHMYMC1QxWOlFt/h6gdP/jW3dA0ZbhwXLo+y21lyZF0IHEpPY6A0HaacNi+3Z+ Z+RgERiic2AszlHIzKIdv/bvFcWXFPP6+G5CUh6oRD3br11nUIE22I2s5fdi/sFtyYDs q8FFve5SMML0niDIGFCmocWmzpNaLpwDj2rahKoPczZX89XznhBOn7MDPqUZsyVtWnaD GD5tee0ykRoqBSxHD8e0fMbeXZQLkkaqs/lFa/3H24vD6gbRU+UQnd4cNrZ6Pp7bNdrC uFAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=8dSTKhrLAxjwZbEM0vByHtuyhwXB+A2b0Dnf/FadgIg=; b=d0SgL+JjhHm3ru6S9tbkhKJXvLGBxGus9MARHLXFCd6ZoDw/oTK6EANeTzDb5H1RjJ FAG6hOSKw/eBv24FSlgHCe8V0arQgBrFTHg5Y7eFPfpFJKsg+2WcYAf1n3EiR1U0JrYj WRloa/RWb3fjRVAXDl+5KGKFlVH5qoDa9sB1Un3tTV+FKMSpf25hhf7K2D90i7Onsy/i /ldt/hpD8E+fHcAwfJi4ngI/GKl4ii7pcAqDl+2Y2CwzGH48I5dENVgw+bsxIrLP7Mqr z8mTvOmqXRTPRqezLnffUqcxTTMjyRykcj/cxh25kktiOFTtJTVNfXtOunpq4C4Q78Au fczQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=EAlBGgGk; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b135-v6si12663627pga.51.2018.07.02.11.12.55; Mon, 02 Jul 2018 11:12:55 -0700 (PDT) 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=@ti.com header.s=ti-com-17Q1 header.b=EAlBGgGk; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932097AbeGBSMy (ORCPT + 31 others); Mon, 2 Jul 2018 14:12:54 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:47298 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753155AbeGBSMY (ORCPT ); Mon, 2 Jul 2018 14:12:24 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id w62ICJUB021213; Mon, 2 Jul 2018 13:12:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1530555139; bh=8dSTKhrLAxjwZbEM0vByHtuyhwXB+A2b0Dnf/FadgIg=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=EAlBGgGkC+KthjIrb+AlFH4EtYaezRbNkTuu04J8xqGjnKJce/RBE8TYaUzn8mpV9 maVKVCyPQTQkleTpkdainFNiFNaZJ9TeI3HVx2kzxTMw01dWomgdIgg2x0DnoA6TGN mqA+HxwctKqENVzismaqu/G9zmEoOAYvW2inaunw= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w62ICJa9025277; Mon, 2 Jul 2018 13:12:19 -0500 Received: from DLEE115.ent.ti.com (157.170.170.26) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Mon, 2 Jul 2018 13:12:18 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Mon, 2 Jul 2018 13:12:18 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w62ICIYH017666; Mon, 2 Jul 2018 13:12:18 -0500 Received: from localhost (a0272616local-lt.dhcp.ti.com [172.22.180.30]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id w62ICIx02911; Mon, 2 Jul 2018 13:12:18 -0500 (CDT) From: Dan Murphy To: , , , CC: , , , Dan Murphy Subject: [PATCH 2/4] leds: lm3692x: Change DT calls to fwnode calls Date: Mon, 2 Jul 2018 13:12:14 -0500 Message-ID: <20180702181216.19660-2-dmurphy@ti.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20180702181216.19660-1-dmurphy@ti.com> References: <20180702181216.19660-1-dmurphy@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Update the code to use the fwnode calls as opposed to ARM DT node api's. This allows the device to be used with either DT configurations or ACPI definitions. Signed-off-by: Dan Murphy --- drivers/leds/leds-lm3692x.c | 38 ++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) -- 2.17.0.582.gccdcbd54c diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c index 1a06d8c97789..ade4abfceb46 100644 --- a/drivers/leds/leds-lm3692x.c +++ b/drivers/leds/leds-lm3692x.c @@ -267,30 +267,15 @@ static int lm3692x_init(struct lm3692x_led *led) static int lm3692x_probe(struct i2c_client *client, const struct i2c_device_id *id) { - int ret; + struct fwnode_handle *child = NULL; struct lm3692x_led *led; - struct device_node *np = client->dev.of_node; - struct device_node *child_node; const char *name; + int ret; led = devm_kzalloc(&client->dev, sizeof(*led), GFP_KERNEL); if (!led) return -ENOMEM; - for_each_available_child_of_node(np, child_node) { - led->led_dev.default_trigger = of_get_property(child_node, - "linux,default-trigger", - NULL); - - ret = of_property_read_string(child_node, "label", &name); - if (!ret) - snprintf(led->label, sizeof(led->label), - "%s:%s", id->name, name); - else - snprintf(led->label, sizeof(led->label), - "%s::backlight_cluster", id->name); - }; - led->enable_gpio = devm_gpiod_get_optional(&client->dev, "enable", GPIOD_OUT_LOW); if (IS_ERR(led->enable_gpio)) { @@ -323,6 +308,25 @@ static int lm3692x_probe(struct i2c_client *client, if (ret) return ret; + child = device_get_next_child_node(&led->client->dev, child); + if (!child) { + dev_err(&led->client->dev, "No LED Child node\n"); + return ret; + } + + 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::", led->client->name); + else + snprintf(led->label, sizeof(led->label), + "%s:%s", led->client->name, name); + + led->led_dev.dev->of_node = to_of_node(child); + ret = devm_led_classdev_register(&client->dev, &led->led_dev); if (ret) { dev_err(&client->dev, "led register err: %d\n", ret);