From patchwork Fri Oct 24 10:57:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 39426 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C706124026 for ; Fri, 24 Oct 2014 10:57:30 +0000 (UTC) Received: by mail-wg0-f72.google.com with SMTP id l18sf519901wgh.7 for ; Fri, 24 Oct 2014 03:57:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=EHbNTxAhSOPCZUGQOFCdjm8OrTvnWFRnjaCCpJz5aac=; b=lHIrsA15QEyzdh4OqgnRBwsZOXKiZE8PdVpno/icwK4WzO6YxH3Z/ec8qLR86bY07O MbuOmrHrV0JH0vkmyjs2jc6RWGgy3rLjjYBhkDvPtsbppxvNu0GzsLcSJKED4PLzDZRd QpxM8oKuFfetaZVYKW3auno9cdLT7B2GrdQS4omH75SvXlpJvXYIKV1D1ujkCgDO09YL lL3nu9Iqtw16ScUXRRZ8cmtVdLXg6D23t9tg3fr7nGEWg/UkcvTurHc7c4iLi1N88Lt2 /DMoC5vzOOGtfvsmlLJXrJ+e/vo1uMAfX9fyo0Gthn0wqQf5g8mydYjaSGHJEkkfSZ7e qftA== X-Gm-Message-State: ALoCoQlU9cMf0fOsQ3f35NNoBpuLYvf6wsF8y67bw7c5gEtLoVXybPLgaNh5QCTRQi+qMzMdHLvi X-Received: by 10.112.99.72 with SMTP id eo8mr2289824lbb.7.1414148249958; Fri, 24 Oct 2014 03:57:29 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.8.194 with SMTP id t2ls405853laa.14.gmail; Fri, 24 Oct 2014 03:57:29 -0700 (PDT) X-Received: by 10.152.29.41 with SMTP id g9mr2446826lah.83.1414148249601; Fri, 24 Oct 2014 03:57:29 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id y9si6472005lbr.1.2014.10.24.03.57.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 24 Oct 2014 03:57:29 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by mail-la0-f52.google.com with SMTP id hz20so2395197lab.39 for ; Fri, 24 Oct 2014 03:57:29 -0700 (PDT) X-Received: by 10.152.87.98 with SMTP id w2mr3533925laz.27.1414148249393; Fri, 24 Oct 2014 03:57:29 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp405467lbz; Fri, 24 Oct 2014 03:57:28 -0700 (PDT) X-Received: by 10.68.236.137 with SMTP id uu9mr3856786pbc.98.1414148247652; Fri, 24 Oct 2014 03:57:27 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id jx1si3932662pbd.97.2014.10.24.03.57.27 for ; Fri, 24 Oct 2014 03:57:27 -0700 (PDT) Received-SPF: none (google.com: linux-leds-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756504AbaJXK50 (ORCPT ); Fri, 24 Oct 2014 06:57:26 -0400 Received: from mail-wi0-f169.google.com ([209.85.212.169]:60542 "EHLO mail-wi0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756497AbaJXK5Z (ORCPT ); Fri, 24 Oct 2014 06:57:25 -0400 Received: by mail-wi0-f169.google.com with SMTP id q5so846972wiv.0 for ; Fri, 24 Oct 2014 03:57:24 -0700 (PDT) X-Received: by 10.194.122.104 with SMTP id lr8mr4102945wjb.64.1414148244329; Fri, 24 Oct 2014 03:57:24 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id ga7sm1619023wic.5.2014.10.24.03.57.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Oct 2014 03:57:23 -0700 (PDT) From: Linus Walleij To: Bryan Wu , Richard Purdie Cc: linux-leds@vger.kernel.org, Linus Walleij Subject: [PATCH 2/2] leds: syscon: handle multiple syscon instances Date: Fri, 24 Oct 2014 12:57:19 +0200 Message-Id: <1414148239-13016-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.9.3 Sender: linux-leds-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-leds@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linus.walleij@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Currently the syscon LED driver will only handle LEDs on the first syscon found in the system. But there can be several of them, so augment the driver to traverse all syscon nodes and check for syscon LEDs on them. Signed-off-by: Linus Walleij --- drivers/leds/leds-syscon.c | 67 +++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/drivers/leds/leds-syscon.c b/drivers/leds/leds-syscon.c index e0ccfc872c2f..6896e2d9ba58 100644 --- a/drivers/leds/leds-syscon.c +++ b/drivers/leds/leds-syscon.c @@ -66,39 +66,13 @@ static void syscon_led_set(struct led_classdev *led_cdev, dev_err(sled->cdev.dev, "error updating LED status\n"); } -static const struct of_device_id syscon_match[] = { - { .compatible = "syscon", }, - {}, -}; - -static int __init syscon_leds_init(void) +static int __init syscon_leds_spawn(struct device_node *np, + struct device *dev, + struct regmap *map) { - const struct of_device_id *devid; - struct device_node *np; struct device_node *child; - struct regmap *map; - struct platform_device *pdev; - struct device *dev; int ret; - np = of_find_matching_node_and_match(NULL, syscon_match, - &devid); - if (!np) - return -ENODEV; - - map = syscon_node_to_regmap(np); - if (IS_ERR(map)) - return PTR_ERR(map); - - /* - * If the map is there, the device should be there, we allocate - * memory on the syscon device's behalf here. - */ - pdev = of_find_device_by_node(np); - if (!pdev) - return -ENODEV; - dev = &pdev->dev; - for_each_available_child_of_node(np, child) { struct syscon_led *sled; const char *state; @@ -146,7 +120,6 @@ static int __init syscon_leds_init(void) if (ret < 0) return ret; } - } sled->cdev.brightness_set = syscon_led_set; @@ -156,7 +129,39 @@ static int __init syscon_leds_init(void) dev_info(dev, "registered LED %s\n", sled->cdev.name); } + return 0; +} + +static int __init syscon_leds_init(void) +{ + struct device_node *np; + + for_each_of_allnodes(np) { + struct platform_device *pdev; + struct regmap *map; + int ret; + + if (!of_device_is_compatible(np, "syscon")) + continue; + + map = syscon_node_to_regmap(np); + if (IS_ERR(map)) { + pr_err("error getting regmap for syscon LEDs\n"); + continue; + } + + /* + * If the map is there, the device should be there, we allocate + * memory on the syscon device's behalf here. + */ + pdev = of_find_device_by_node(np); + if (!pdev) + return -ENODEV; + ret = syscon_leds_spawn(np, &pdev->dev, map); + if (ret) + dev_err(&pdev->dev, "could not spawn syscon LEDs\n"); + } - return 0; + return 0; } device_initcall(syscon_leds_init);