Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2410177imu; Tue, 6 Nov 2018 14:10:19 -0800 (PST) X-Google-Smtp-Source: AJdET5dhXxOejh++1tvAnSXmcQ2xKH8tr9DrR454+OBvuSp6EqEvAz5kHK4Wgf5mf/zsetflAeVU X-Received: by 2002:a17:902:930b:: with SMTP id bc11-v6mr28756193plb.101.1541542219427; Tue, 06 Nov 2018 14:10:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541542219; cv=none; d=google.com; s=arc-20160816; b=f+1bjAosXz3zJ6MUjmv0OunzfOhOX31UMJPl+PUjsPrMFbHNsJ1kB+wab11v7uvF1T 8MPO98HHqSU7KzKdC7Kil2f+mQ0Cd7FRU9DueWBWxzR358g6Xc+k2Z66HdMYRYzitgMn lXmcDrx9TGrAnT3GBiXrBMEoMInoPFMHUPtuW1M9mhVlto9TI3qxJ1Fv7NfpYn2r7L0T SEb82TmKVeRykf1KF9TObsAtLqfaAywhc6rq0nF6Xm0HlE3eacJBc2iYumZq9eFAUPbR 1qJulIxrxoERXlBsIJJ1GizQv/S6gdLsrtc4PHJmZzzov1IRnpLYSViin4OysILh/KQa wwbQ== 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=80S6lsb77TIUbOpcZGo7NUjWXITG+ozK8mtMIY4nfd4=; b=W1LTrgm6bLI5wUF5B1nDC2yDBR5QRv6wqoKrEzXP/ECn9wKtmKFvS5xnJeJPAt6K6o CbiUWsqeul0QKEr6spEW79Dsyf6PEPYPDEBk56UD9f/GjVvEzvJIrKvj+EWSPxyhHVL9 z6z2EhxxtkzxuYwQFJZyfVhEcOVLoDNr+AJrJJ8c4ZvFZYVhvquzB/q5yefStJ57qA1U E5p+X3LfKLOGhgwbXJgflTK1fXtJwslexAj+ZNB+3YS6ocB3qCT85fKokbhoXIi+ihad gcNsF3XYt5pFCPL0U5qgW1mxKo/G5MtsInW6yOY+s90CcmdQchTE4sAEvxUHEeTp+Svr 0h+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=spev2DJ0; 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 d9si14721918pgb.105.2018.11.06.14.10.04; Tue, 06 Nov 2018 14:10:19 -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=spev2DJ0; 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 S2388740AbeKGHff (ORCPT + 99 others); Wed, 7 Nov 2018 02:35:35 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:35069 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388240AbeKGHfe (ORCPT ); Wed, 7 Nov 2018 02:35:34 -0500 Received: by mail-lj1-f194.google.com with SMTP id x85-v6so12958916ljb.2; Tue, 06 Nov 2018 14:08:10 -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=80S6lsb77TIUbOpcZGo7NUjWXITG+ozK8mtMIY4nfd4=; b=spev2DJ0JJR82/qxqq0psarE48yyJPAMEARxfqn42J/QMvcMwSbWODxLUQisbGLiUQ fWn9Jgpd02kXIlojcut4MEANW+cndlosJaZaAgYl5xjdUaevQu1vOPFP8tBxYDzSXDpP XIKGzN+msKdQavm0fuYuoV7/8ughWqqEQTvsdcW1vYnE5L/bVjVbu3lFKQiDcDKn5Q6X Uez15jayGCHgRLqUS/RPUP0FBr40P4O4dCJfaoTW3+rcrttHQN45dIekgUovZ164l3VY hmGntTLq/rLdTGfRb13yK+nSnjzm4WNyHOPx7vSN6iuHlNiFB/g17Jp9LQXepbauNDfv ovZA== 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=80S6lsb77TIUbOpcZGo7NUjWXITG+ozK8mtMIY4nfd4=; b=aqVI9Dn6CPqR7+6BGK/afhmYcVp1HPDaBpJogyt1uNfY60pbBjMEzp/FyBm8LuEquc CeARFvbGdn5iKzUE7lCvmKS6Mozp7dvLYE1SU+BnYIP2Oc0yc+o5CYnjKK4X9NlNGRfL esywECTUMr9429p9TOPLviDdliw82Ak/vtN+BdNnKgKR9vD0grY2QkqJYI1wNbeLAsaz dusCcbl3Nn2W6gNiR/bOzI5PIysm7JTxIzzlOHtPGTvZsUOl5BhI//hzPXcMYyrq23B8 9jl12IEvqPrhFStHoVCdb/8AsOhDABBq9ATwwik8hSBU9r7kaRYP8C4b7IFYk4vddG6/ kh4g== X-Gm-Message-State: AGRZ1gK8Av7s2wKtcFGCTadmCNWq2yNF9BY/hmNiitcJZdYNVXh3zKmI t59eTRIJ/A0Cphwf9iuc9c3mp+7OaS4= X-Received: by 2002:a2e:5418:: with SMTP id i24-v6mr19801579ljb.51.1541542089786; Tue, 06 Nov 2018 14:08:09 -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.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Nov 2018 14:08:09 -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, Dan Murphy Subject: [PATCH 14/24] leds: lm3601x: Use led_compose_name() Date: Tue, 6 Nov 2018 23:07:22 +0100 Message-Id: <1541542052-10081-15-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: Dan Murphy --- drivers/leds/leds-lm3601x.c | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/drivers/leds/leds-lm3601x.c b/drivers/leds/leds-lm3601x.c index 081aa71..91ea652 100644 --- a/drivers/leds/leds-lm3601x.c +++ b/drivers/leds/leds-lm3601x.c @@ -10,7 +10,6 @@ #include #include #include -#include #define LM3601X_LED_IR 0x0 #define LM3601X_LED_TORCH 0x1 @@ -90,8 +89,6 @@ struct lm3601x_led { struct regmap *regmap; struct mutex lock; - char led_name[LED_MAX_NAME_SIZE]; - unsigned int flash_timeout; unsigned int last_flag; @@ -322,10 +319,24 @@ static const struct led_flash_ops flash_ops = { .fault_get = lm3601x_flash_fault_get, }; -static int lm3601x_register_leds(struct lm3601x_led *led) +static int lm3601x_register_leds(struct lm3601x_led *led, + struct fwnode_handle *fwnode) { struct led_classdev *led_cdev; struct led_flash_setting *setting; + struct led_init_data init_data = { fwnode }; + char *mode_name; + int ret; + + if (led->led_mode == LM3601X_LED_TORCH) + mode_name = "torch"; + else + mode_name = "infrared"; + + ret = led_compose_name(fwnode, led->client->name, mode_name, + init_data.name); + if (ret < 0) + return ret; led->fled_cdev.ops = &flash_ops; @@ -342,20 +353,20 @@ static int lm3601x_register_leds(struct lm3601x_led *led) setting->val = led->flash_current_max; led_cdev = &led->fled_cdev.led_cdev; - led_cdev->name = led->led_name; led_cdev->brightness_set_blocking = lm3601x_brightness_set; led_cdev->max_brightness = DIV_ROUND_UP(led->torch_current_max, LM3601X_TORCH_REG_DIV); led_cdev->flags |= LED_DEV_CAP_FLASH; - return led_classdev_flash_register(&led->client->dev, &led->fled_cdev); + return led_classdev_flash_register_ext(&led->client->dev, + &led->fled_cdev, &init_data); } -static int lm3601x_parse_node(struct lm3601x_led *led) +static int lm3601x_parse_node(struct lm3601x_led *led, + struct fwnode_handle **fwnode) { struct fwnode_handle *child = NULL; int ret = -ENODEV; - const char *name; child = device_get_next_child_node(&led->client->dev, child); if (!child) { @@ -376,17 +387,6 @@ static int lm3601x_parse_node(struct lm3601x_led *led) goto out_err; } - ret = fwnode_property_read_string(child, "label", &name); - if (ret) { - if (led->led_mode == LM3601X_LED_TORCH) - name = "torch"; - else - name = "infrared"; - } - - snprintf(led->led_name, sizeof(led->led_name), - "%s:%s", led->client->name, name); - ret = fwnode_property_read_u32(child, "led-max-microamp", &led->torch_current_max); if (ret) { @@ -411,6 +411,8 @@ static int lm3601x_parse_node(struct lm3601x_led *led) goto out_err; } + *fwnode = child; + out_err: fwnode_handle_put(child); return ret; @@ -419,6 +421,7 @@ static int lm3601x_parse_node(struct lm3601x_led *led) static int lm3601x_probe(struct i2c_client *client) { struct lm3601x_led *led; + struct fwnode_handle *fwnode; int ret; led = devm_kzalloc(&client->dev, sizeof(*led), GFP_KERNEL); @@ -428,7 +431,7 @@ static int lm3601x_probe(struct i2c_client *client) led->client = client; i2c_set_clientdata(client, led); - ret = lm3601x_parse_node(led); + ret = lm3601x_parse_node(led, &fwnode); if (ret) return -ENODEV; @@ -442,7 +445,7 @@ static int lm3601x_probe(struct i2c_client *client) mutex_init(&led->lock); - return lm3601x_register_leds(led); + return lm3601x_register_leds(led, fwnode); } static int lm3601x_remove(struct i2c_client *client) -- 2.1.4