Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp559291rwb; Fri, 7 Oct 2022 00:30:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4590KhaI6HiOta0Ib3rvUB0tG/69i7KNtFRrdDWvfjOI0+roJuC+4q1uSzTkpTHHEHjrgA X-Received: by 2002:aa7:c60a:0:b0:458:d707:117 with SMTP id h10-20020aa7c60a000000b00458d7070117mr3360968edq.258.1665127823730; Fri, 07 Oct 2022 00:30:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665127823; cv=none; d=google.com; s=arc-20160816; b=PZILr3GhHexKE4pvhpcNS5fxOqw1GtkgIQuHm++BnabDdf8FJMxS0FBElI/lcSUDLw I2HkZ5Qusq6tNJiwQlPhiNccwFYucjkKCh4HEMu7Xi0REWjzJTxBqUROJho177SVAP9a H0mH4sn802yEvSq0P4QbkkZjZh0v3B8n5CISh3fh7JMG6wWM/CMcqMHnU9OxXzNteP45 ex7ydVXBGYGccmQYqfeyzLPsD8LOEMqUNR6r+uhVIMQpvwht1J6zNhcHLI2oGiiE8YBM gMomhJR7vZh0Zqh8H0J/HEJDd8ZMP+wxntZWrwQNxGBvodcvHgEdPctafVChqyNLbRSV /+ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=Pf/UzjHviED3BfnLk9xH+M7SGOLpsPXdFn77CT77kbE=; b=VIqh4YjhnVHO9VkllAEijKcmFBabYm5O0n3m6V9hZEJz8iKKbE0q0Ylst6iaYquiM+ VjLVjK6pFxknl2oaAnpq2W97ENGEpgpjRL6nPtIOtLxz/TSp4wrP4aPKLEUb8J86Jwtx FMHH4bnDE8IEFXlEzLhXtzrdvsEmD+xrpAKS40MRTAbG2+m+tVVvNPuuy36+TtcTgx4A vwv2EdFhx26+5lzNhV/AwMwXff7wAXC7YSAaUaG0dYdqLzBmEe1tLChs3d79WlWA8u9Q rZ/Xvaw4jn9e+XNQUdaDjJOL/MvSwg6XYB7kKKI3Rb7QVPCHe1/cPuJXragkUxDbPH/p vtFg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gb27-20020a170907961b00b007839293c32fsi663685ejc.423.2022.10.07.00.29.54; Fri, 07 Oct 2022 00:30:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229494AbiJGGea (ORCPT + 99 others); Fri, 7 Oct 2022 02:34:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229459AbiJGGe1 (ORCPT ); Fri, 7 Oct 2022 02:34:27 -0400 X-Greylist: delayed 272 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 06 Oct 2022 23:34:26 PDT Received: from smtpout1.mo3004.mail-out.ovh.net (smtpout1.mo3004.mail-out.ovh.net [79.137.123.219]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28997112A95; Thu, 6 Oct 2022 23:34:25 -0700 (PDT) Received: from pro2.mail.ovh.net (unknown [10.108.16.48]) by mo3004.mail-out.ovh.net (Postfix) with ESMTPS id 939F12430FC; Fri, 7 Oct 2022 06:34:24 +0000 (UTC) Received: from [192.168.1.41] (88.161.25.233) by DAG1EX1.emp2.local (172.16.2.1) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Fri, 7 Oct 2022 08:34:24 +0200 Message-ID: <6d3d2dfd-4d44-c91a-2145-bae624926259@traphandler.com> Date: Fri, 7 Oct 2022 08:34:23 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [RESEND PATCH v3 4/4] leds: Add a multicolor LED driver to group monochromatic LEDs Content-Language: en-US To: Andy Shevchenko CC: , , , , , , , , , , References: <20220917081339.3354075-1-jjhiblot@traphandler.com> <20220917081339.3354075-5-jjhiblot@traphandler.com> From: Jean-Jacques Hiblot In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [88.161.25.233] X-ClientProxiedBy: DAG8EX2.emp2.local (172.16.2.82) To DAG1EX1.emp2.local (172.16.2.1) X-Ovh-Tracer-Id: 14443044004980013335 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvfedrfeeiiedguddutdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefkffggfgfuvfevfhfhjggtgfhisehtkeertddtfeejnecuhfhrohhmpeflvggrnhdqlfgrtghquhgvshcujfhisghlohhtuceojhhjhhhisghlohhtsehtrhgrphhhrghnughlvghrrdgtohhmqeenucggtffrrghtthgvrhhnpedvfeekudegkeeuuedvueeuveejffdtvdethfelkefhfefftdetteffiefgvddtieenucfkpheptddrtddrtddrtddpkeekrdduiedurddvhedrvdeffeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhhouggvpehsmhhtphhouhhtpdhhvghlohepphhrohdvrdhmrghilhdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomhepjhhjhhhisghlohhtsehtrhgrphhhrghnughlvghrrdgtohhmpdhnsggprhgtphhtthhopedupdhrtghpthhtohepshhhrgesphgvnhhguhhtrhhonhhigidruggvpdfovfetjfhoshhtpehmoheftddtge X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 17/09/2022 10:37, Andy Shevchenko wrote: > On Sat, Sep 17, 2022 at 11:14 AM Jean-Jacques Hiblot > wrote: >> By allowing to group multiple monochrome LED into multicolor LEDs, >> all involved LEDs can be controlled in-sync. This enables using effects >> using triggers, etc. > ... > >> +config LEDS_GRP_MULTICOLOR >> + tristate "Multi-color LED grouping support" >> + help >> + This option enables support for monochrome LEDs that are >> + grouped into multicolor LEDs. > What will be the module name in case of "m" choice? > > ... > >> + struct led_mcg_priv *priv = >> + container_of(mc_cdev, struct led_mcg_priv, mc_cdev); > One line? > > ... > >> + /* >> + * Scale the intensity according the max brightness of the >> + * monochromatic LED > Usually we put a grammar period at the end of sentences in multi-line comments. > >> + */ > ... > >> + actual_led_brightness = DIV_ROUND_CLOSEST( >> + mono->max_brightness * mc_cdev->subled_info[i].brightness, >> + mc_cdev->led_cdev.max_brightness); > Can you fix an indentation, so it won't leave the line ending by open > parenthesis? I believe with the help of a temporary variable it can be > easily achieved. Could be done but I have no good name for the variable and I think it would just make things harder to understand. In that form I think it is clear that this is a cross-multiplication. > > ... > >> + for (;;) { >> + struct led_classdev *led_cdev; >> + led_cdev = devm_of_led_get(dev, count); > Why _of_ variant? Please, make this OF independent since it's > pretending to cover not only OF-based systems. This is not OF independent. It could be, but that will wait until someone needs it. I don't know much about ACPI and have no hardware to test it on. I'll add the missingĀ  dependency on OF in the Kconfig. > > >> + if (IS_ERR(led_cdev)) { >> + /* Reached the end of the list ? */ >> + if (PTR_ERR(led_cdev) == -ENOENT) >> + break; > Looks like the above needs an _optional() variant > >> + return dev_err_probe(dev, PTR_ERR(led_cdev), >> + "Unable to get led #%d", count); >> + } > ... > >> + priv->monochromatics = devm_krealloc(dev, priv->monochromatics, >> + count * sizeof(*priv->monochromatics), >> + GFP_KERNEL); > This needs at minimum to use one of the helpers from overflow.h, > ideally you may implement devm_krealloc_array() as a suitable wrapper > for that. > >> + if (!priv->monochromatics) >> + return -ENOMEM; > ... > >> + subled = devm_kzalloc(dev, count * sizeof(*subled), GFP_KERNEL); > NIH devm_kcalloc() > >> + if (!subled) >> + return -ENOMEM; > -- > With Best Regards, > Andy Shevchenko