Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1630086ybp; Wed, 9 Oct 2019 17:49:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqziPOD8FIhCukK7Z9mrX583TZqqZKeAjtu3gdHtwVY5f+e4J02rMRGnYTrX4psIE4Cnqrzp X-Received: by 2002:aa7:d045:: with SMTP id n5mr5618182edo.24.1570668581252; Wed, 09 Oct 2019 17:49:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570668581; cv=none; d=google.com; s=arc-20160816; b=cJQvU9vlDLKtZWkOTbbI3xkqDwtZYOXL46+cRDo368ItzDwh01R9kThbhhmc/eUG/X qwlNTCJh6hNsuIQ2TQl97qSQr2PoPK+UCE2LWcY1WUSAhPOZ62OCUuLp7e95UUeXUDEs XH83qKVdX4oxmfH7zh+dYgcAyEdGDcZkGC/a2RnsJvjrgsc2m64/Pn65Vd7JxKjoVimw 7leEMsyAmye9AKjPN3PFmKLYAMZ5dz7kXtkNr1zU1sQOtLWf7hzQsNpMhEeL1gFgVzTK e5aJ9UlTCDQiUNxuxMdg7+YDSOEqFm2h0CADatOMCPiMGthiBjwa6SZqrI66V0jCNmsX qKNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=W4tgg+8rfTzgD3XxaYrq0SPR4ta7PyHqmlPUxUiR0C8=; b=ok5PlD8VAPS5TbN+dpIzmE7pNBAYlygZL6ILAypZ/NtojnYWwXf7Hd59YqRsqPy40r 3QH0tDK3pb/6to8vetB1fUdL545CdMcaDiqAqz/e/beQLVjAnsoc3BMYlThKfR+D1t9O 6uNx4B2xx4Ezehc3azYZ9AIph8vEDoYWJ6ABXzfC9E6Z26C3mZPqEajb/0rZjQj6HiuF NJRlc9VP+EDeNGm5hE6Hyg3ygowTcdJYqrGcSGK+TYPH1YBOAVHEYBVuKOeoYE/etSzo l4iKqzF4Vs2kiP4/PWKcGdAIIMjDiSZcM3zqgVIIHW0r4LoXCRgpMj2i7a1rhKMFyeYW dfrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=g1jDm8Sd; 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 l16si2108083ejx.141.2019.10.09.17.49.18; Wed, 09 Oct 2019 17:49:41 -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=g1jDm8Sd; 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 S1732609AbfJJAry (ORCPT + 99 others); Wed, 9 Oct 2019 20:47:54 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:41574 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731834AbfJJAry (ORCPT ); Wed, 9 Oct 2019 20:47:54 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id x9A0lpnB119594; Wed, 9 Oct 2019 19:47:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1570668471; bh=W4tgg+8rfTzgD3XxaYrq0SPR4ta7PyHqmlPUxUiR0C8=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=g1jDm8Sd+4vvRpKgKsmFynIxJWukTjmBehsVA3ptUdFWBLoTJx+u7M1vLvqdgK3KH WbtqytmXgkvn8IS9lVvJMbWwXYz/TvOiyReVOZc0L3QStKl24evA7xq+1M3CIodheM oacgCccnHIX8pDfQQ7aOJ8misTbe0tr8/FdRjIxk= Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x9A0lp3H086691 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 9 Oct 2019 19:47:51 -0500 Received: from DFLE107.ent.ti.com (10.64.6.28) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Wed, 9 Oct 2019 19:47:47 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE107.ent.ti.com (10.64.6.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Wed, 9 Oct 2019 19:47:47 -0500 Received: from [10.250.65.13] (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id x9A0loHH006322; Wed, 9 Oct 2019 19:47:50 -0500 Subject: Re: [PATCH v11 12/16] leds: lp55xx: Add multicolor framework support to lp55xx To: Jacek Anaszewski , CC: , References: <20191008204800.19870-1-dmurphy@ti.com> <20191008204800.19870-13-dmurphy@ti.com> <1f0ac6f3-a822-84f0-d398-2f16751c3b1b@gmail.com> From: Dan Murphy Message-ID: Date: Wed, 9 Oct 2019 19:47:31 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <1f0ac6f3-a822-84f0-d398-2f16751c3b1b@gmail.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US 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 Jacek On 10/9/19 5:04 PM, Jacek Anaszewski wrote: > Dan, > > On 10/8/19 10:47 PM, Dan Murphy wrote: >> Add multicolor framework support for the lp55xx family. >> >> Signed-off-by: Dan Murphy >> --- >> drivers/leds/Kconfig | 1 + >> drivers/leds/leds-lp55xx-common.c | 176 +++++++++++++++++++--- >> drivers/leds/leds-lp55xx-common.h | 11 ++ >> include/linux/platform_data/leds-lp55xx.h | 5 + >> 4 files changed, 169 insertions(+), 24 deletions(-) >> > [...] >> >> +static int lp5xx_parse_common_child(struct device_node *np, >> + struct lp55xx_led_config *cfg, >> + int chan_num, bool is_multicolor, >> + int color_num) >> +{ >> + u32 led_number; >> + int ret; >> + >> + of_property_read_string(np, "chan-name", >> + &cfg[chan_num].name); >> + of_property_read_u8(np, "led-cur", >> + &cfg[chan_num].led_current); >> + of_property_read_u8(np, "max-cur", >> + &cfg[chan_num].max_current); >> + >> + ret = of_property_read_u32(np, "reg", &led_number); >> + if (ret) >> + return ret; >> + >> + if (led_number < 0 || led_number > 6) >> + return -EINVAL; >> + >> + if (is_multicolor) >> + cfg[chan_num].color_component[color_num].output_num = >> + led_number; >> + else >> + cfg[chan_num].chan_nr = led_number; >> + >> + return 0; >> +} >> + >> +static int lp5xx_parse_channel_child(struct device_node *np, >> + struct lp55xx_led_config *cfg, >> + int child_number) >> +{ >> + struct device_node *child; >> + int channel_color; >> + int num_colors = 0; >> + u32 color_id; >> + int ret; >> + >> + cfg[child_number].default_trigger = >> + of_get_property(np, "linux,default-trigger", NULL); >> + >> + ret = of_property_read_u32(np, "color", &channel_color); >> + if (ret) >> + channel_color = ret; >> + >> + >> + if (channel_color == LED_COLOR_ID_MULTI) { >> + for_each_child_of_node(np, child) { >> + ret = lp5xx_parse_common_child(child, cfg, >> + child_number, true, >> + num_colors); >> + if (ret) >> + return ret; >> + >> + ret = of_property_read_u32(child, "color", &color_id); >> + if (ret) >> + return ret; >> + >> + cfg[child_number].color_component[num_colors].color_id = >> + color_id; >> + set_bit(color_id, &cfg[child_number].available_colors); >> + num_colors++; >> + } >> + >> + cfg[child_number].num_colors = num_colors; >> + } else { >> + return lp5xx_parse_common_child(np, cfg, child_number, false, >> + num_colors); >> + } >> + >> + return 0; >> +} >> + >> struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev, >> struct device_node *np) >> { >> @@ -546,6 +678,7 @@ struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev, >> struct lp55xx_led_config *cfg; >> int num_channels; >> int i = 0; >> + int ret; >> >> pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); >> if (!pdata) >> @@ -565,14 +698,9 @@ struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev, >> pdata->num_channels = num_channels; >> >> for_each_child_of_node(np, child) { >> - cfg[i].chan_nr = i; >> - >> - of_property_read_string(child, "chan-name", &cfg[i].name); >> - of_property_read_u8(child, "led-cur", &cfg[i].led_current); >> - of_property_read_u8(child, "max-cur", &cfg[i].max_current); >> - cfg[i].default_trigger = >> - of_get_property(child, "linux,default-trigger", NULL); >> - >> + ret = lp5xx_parse_channel_child(child, cfg, i); >> + if (ret) >> + return ERR_PTR(-EINVAL); >> i++; >> } >> >> diff --git a/drivers/leds/leds-lp55xx-common.h b/drivers/leds/leds-lp55xx-common.h >> index 783ed5103ce5..55d420f704d1 100644 >> --- a/drivers/leds/leds-lp55xx-common.h >> +++ b/drivers/leds/leds-lp55xx-common.h >> @@ -12,6 +12,10 @@ >> #ifndef _LEDS_LP55XX_COMMON_H >> #define _LEDS_LP55XX_COMMON_H >> >> +#include >> + >> +#define LP55XX_MAX_GROUPED_CHAN 4 >> + >> enum lp55xx_engine_index { >> LP55XX_ENGINE_INVALID, >> LP55XX_ENGINE_1, >> @@ -109,6 +113,9 @@ struct lp55xx_device_config { >> /* access brightness register */ >> int (*brightness_fn)(struct lp55xx_led *led); >> >> + /* access specific brightness register */ >> + int (*color_intensity_fn)(struct lp55xx_led *led); >> + >> /* current setting function */ >> void (*set_led_current) (struct lp55xx_led *led, u8 led_current); >> >> @@ -159,6 +166,8 @@ struct lp55xx_chip { >> * struct lp55xx_led >> * @chan_nr : Channel number >> * @cdev : LED class device >> + * @mc_cdev : Multi color class device >> + * @color_component : Multi color LED map information >> * @led_current : Current setting at each led channel >> * @max_current : Maximun current at each led channel >> * @brightness : Brightness value >> @@ -167,6 +176,8 @@ struct lp55xx_chip { >> struct lp55xx_led { >> int chan_nr; >> struct led_classdev cdev; >> + struct led_classdev_mc mc_cdev; >> + struct led_mc_color_conversion color_component[LP55XX_MAX_GROUPED_CHAN]; >> u8 led_current; >> u8 max_current; >> u8 brightness; >> diff --git a/include/linux/platform_data/leds-lp55xx.h b/include/linux/platform_data/leds-lp55xx.h >> index 96a787100fda..1e7a25ed9a87 100644 >> --- a/include/linux/platform_data/leds-lp55xx.h >> +++ b/include/linux/platform_data/leds-lp55xx.h >> @@ -12,6 +12,8 @@ >> #ifndef _LEDS_LP55XX_H >> #define _LEDS_LP55XX_H >> >> +#include >> + >> /* Clock configuration */ >> #define LP55XX_CLOCK_AUTO 0 >> #define LP55XX_CLOCK_INT 1 >> @@ -23,6 +25,9 @@ struct lp55xx_led_config { >> u8 chan_nr; >> u8 led_current; /* mA x10, 0 if led is not connected */ >> u8 max_current; >> + int num_colors; >> + unsigned long available_colors; >> + struct led_mc_color_conversion color_component[LED_COLOR_ID_MAX]; > I can't see why the array length can't be LP55XX_MAX_GROUPED_CHAN here > too. You're indexing it with num_colors counter and not with color_id. Ack Dan