Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp116774pxf; Wed, 24 Mar 2021 23:08:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxd/5TFfBaIJjWNbXj+Bf/R7vU/Vj4mJwb/MujUJxQAKcttGV+uAZ5IDhz/QI6fv3HZbGjl X-Received: by 2002:a17:906:1fd6:: with SMTP id e22mr7714082ejt.481.1616652536109; Wed, 24 Mar 2021 23:08:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616652536; cv=none; d=google.com; s=arc-20160816; b=l7SjL0eYQqS1FLVi24KnVBg+CPQSk8/vFQR4herc8OtbS43edrnU1pBqtJb2s4Yjfj doGW0utLVZE+/TAb6CU8PYl01ajQ2Lw6lt21T90qoS2jUa8sVvTRxFMkqqhzCFuo5BX+ PWOhMy8SFLZUB9wDrSYxYBrTtRCK8Ej0FV8SziKgO0kqYQjfl3+6v1DdNGoeKo+YhdPn Ec2BU1CQkxoSI8YPdb1jDNshwiOdc+efN41Zbgr7805oDOzx1SU3PSzOwrtZjyRecEnD ePbVX9bZ0mvm4ih65w590qjrNtwvxxjGxjdUl//9HFXyxTSUCtExcK2soA0nql4dMET6 2kAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:references:message-id:date :thread-index:thread-topic:subject:cc:to:from:dkim-signature; bh=KgAikQLc0a+uXf9MpMW7lcoLMvJvsmQiWu5c216iOEU=; b=uBud+ISKgIdGKHpKkdFDakRFRHaTdFgcP4gICg9aw6xU3TAGTJSUhawPfaQDx/o5EY MPw50g+IZO+4sPjGBj9qTvhdZUlJSMKTascztBQkBE3EbH8sIhmsYVmfLiB9LI9KkOr0 OPoM4Kfvu7GF2L38rau6WOmex27N043ehOXoMlINrGpgL7A0a+VOUbtUvGPxxDzLvj5r q6AgeCvHLe/GW8jw+NG9+GbQTZBzIlYK74RSmdE34C9nQph0yS5Ka2UBnfLoyovplClY bx3kskueP0ZSsILosH/w6pEv/JlcnYBZMV47zB3OfHtvubREVbJD1c+FMm97MZkO4Pp4 BvaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=YkOnfD8c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jz16si3477867ejb.586.2021.03.24.23.08.33; Wed, 24 Mar 2021 23:08:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=YkOnfD8c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229738AbhCYGEz (ORCPT + 99 others); Thu, 25 Mar 2021 02:04:55 -0400 Received: from smtp1.axis.com ([195.60.68.17]:37558 "EHLO smtp1.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229533AbhCYGEp (ORCPT ); Thu, 25 Mar 2021 02:04:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1616652285; x=1648188285; h=from:to:cc:subject:date:message-id:references: content-transfer-encoding:mime-version; bh=KgAikQLc0a+uXf9MpMW7lcoLMvJvsmQiWu5c216iOEU=; b=YkOnfD8ctxMyXt5arXrn2Ev3sDRIHh4iGKvg0wX9O++uVdI5o5n+IwGU yPoZklOVTmytyHClVO+72rsSO0za4Ljg8HP0i0BwhFTDhaPQkF3HcoZri DQV4jHS7BxQQ5jZmPumWtsG1vM1/2Ift4SbcSVoS8T1hlb16GdKVSHH4h EnoeFLyn672Gssjq/WNV3WNgoiGlIrR8sFUeSwL9FyfcXdu4Cfb8uMz0E is68ketGT7/Ztq62AJuPi8UxdvT6ypTRGfF0z0cFreLwTQNmqwJdT/Vu4 TpuyUPeWMQfaxLD1YKyloDQxuvJF49hdfGK9TQDzyUAMfPdobW2yyv9pl Q==; From: Hermes Zhang To: Marek Behun , Hermes Zhang CC: "pavel@ucw.cz" , "dmurphy@ti.com" , "robh+dt@kernel.org" , "linux-leds@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "lkml@axis.com" , kernel Subject: Re: [PATCH 1/2] leds: leds-multi-gpio: Add multiple GPIOs LED driver Thread-Topic: [PATCH 1/2] leds: leds-multi-gpio: Add multiple GPIOs LED driver Thread-Index: AQHXIINVpz7s49aciUujD1l9rQIjiw== Date: Thu, 25 Mar 2021 06:04:43 +0000 Message-ID: <7ea3f7e6ea7a464fa4bb59b94857a755@XBOX01.axis.com> References: <20210324075631.5004-1-chenhui.zhang@axis.com> <20210324075631.5004-2-chenhui.zhang@axis.com> <20210324103431.4b945915@thinkpad> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.0.5.60] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Marek,=0A= =0A= On 3/24/21 5:34 PM, Marek Behun wrote:=0A= >> +#include =0A= >> +#include =0A= >> +#include =0A= >> +#include =0A= >> +#include =0A= >> +#include =0A= >> +#include =0A= >> +#include =0A= >> +#include =0A= >> +#include =0A= >> +#include =0A= > Why do you include slab.h?=0A= Yeah, I will clean it in next commit.=0A= >> +=0A= >> +=0A= >> +static void multi_gpio_led_set(struct led_classdev *led_cdev,=0A= >> + enum led_brightness value)=0A= >> +{=0A= >> + struct multi_gpio_led_priv *priv;=0A= >> + int idx;=0A= >> +=0A= >> + DECLARE_BITMAP(values, MAX_GPIO_NUM);=0A= >> +=0A= >> + priv =3D container_of(led_cdev, struct multi_gpio_led_priv, cdev);=0A= >> +=0A= >> + idx =3D (value - LED_OFF) * priv->nr_states / (LED_FULL + 1);=0A= > LED_FULL / LED_OFF are deprecated, don't use them.=0A= =0A= Then could I use just 0 (instead LED_OFF) and led_cdev->max_brightness=0A= =0A= (instead of LED_FULL) here? The idea here is map the states defined in dts= =0A= =0A= to the full brightness range.=0A= =0A= > +=0A= > + priv->nr_states =3D ret;=0A= > + priv->states =3D devm_kzalloc(dev, sizeof(*priv->states) * priv->nr_sta= tes, GFP_KERNEL);=0A= > + if (!priv->states)=0A= > + return -ENOMEM;=0A= > +=0A= > + ret =3D of_property_read_u8_array(node, "led-states", priv->states, pri= v->nr_states);=0A= > + if (ret)=0A= > + return ret;=0A= > +=0A= > + priv->cdev.max_brightness =3D LED_FULL;=0A= > ???? max_brightness is not 255 (=3D LED_FULL). max_brightness must be=0A= > derived from the led-states property.=0A= =0A= Yeah, I will fix this. the max-brightness should for the whole LED,=0A= right? So=0A= =0A= it will at same level with led-states.=0A= =0A= =0A= =0A=