From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,TVD_PH_BODY_ACCOUNTS_POST, TVD_PH_BODY_META_ALL,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 235FFC433E1 for ; Mon, 13 Jul 2020 13:36:08 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E53232072D for ; Mon, 13 Jul 2020 13:36:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="g1+hyDkT"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ti.com header.i=@ti.com header.b="V7s0ufhy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E53232072D Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=ti.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=sSFRcosgCDciowhP8QKTPnZUamKTSa+/rgZQjQiwyKY=; b=g1+hyDkTdNYZFzHmDBPFvtqgI KJQIu/yx8p/ATuiUfIGHv7qbKNGsq0XiKNnmx90gBAbTIFu4JkjGiztkw+4zFv2MiQ1CHzdcR8+Lp +9iJwfgo/euZFCrOiXGFuIDsw9KLiugzoX9q2R2gUGTnIl41q3Xrjd+RPP5iH0dlqgJLbQhh9r4ak LBiFf6E/1dpdyBTiHBwazizA3K5jgzGIE5S7CG0t5NjlNhIoDnWaK3uIXT4GRwNP+lEnY7ik6eurI quhfBhY4ti+Ep5ClMQHjJk0RYG7BD6MuUbknvrbZ1w9U5oxETDzpOaguKpCqXLpuIZMEecRqIsOmh Ws96Mn4/A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1juybb-0002a9-0D; Mon, 13 Jul 2020 13:34:51 +0000 Received: from fllv0016.ext.ti.com ([198.47.19.142]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1juybX-0002YJ-Cx for linux-arm-kernel@lists.infradead.org; Mon, 13 Jul 2020 13:34:49 +0000 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 06DDYicE008834; Mon, 13 Jul 2020 08:34:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1594647284; bh=luXMMPErLS31mqgSXoK+p/1sP1jJ1sb3mbiOyr1b5Iw=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=V7s0ufhyzBePXtngza29y1zjt/bPy+SxICXzO3SIp/JiqaZvESJnK65MR6szglv6x ofpljnczLz7ECHvFNUUOtnGXjVpSVOL6KlP2fZS/2g8bn8c5lHRfEsJwJ2+myQwdnM zi6JTCSw9uP/Le5B0x4KroCCwZSvZnklT/Km4o4A= Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 06DDYiYm066629 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 13 Jul 2020 08:34:44 -0500 Received: from DLEE100.ent.ti.com (157.170.170.30) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Mon, 13 Jul 2020 08:34:43 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Mon, 13 Jul 2020 08:34:43 -0500 Received: from [10.250.32.229] (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 06DDYh1h042399; Mon, 13 Jul 2020 08:34:43 -0500 Subject: Re: [PATCH v29 03/16] leds: multicolor: Introduce a multicolor class definition To: Pavel Machek References: <20200622185919.2131-1-dmurphy@ti.com> <20200622185919.2131-4-dmurphy@ti.com> <20200711155734.GA21726@amd> From: Dan Murphy Message-ID: Date: Mon, 13 Jul 2020 08:34:43 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200711155734.GA21726@amd> Content-Language: en-US X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200713_093447_609820_C086AC19 X-CRM114-Status: GOOD ( 24.00 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robh@kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, jacek.anaszewski@gmail.com, linux-leds@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Pavel Thanks for the review On 7/11/20 10:57 AM, Pavel Machek wrote: > Hi! > >> Introduce a multicolor class that groups colored LEDs >> within a LED node. >> +What: /sys/class/leds//multi_intensity >> +Date: March 2020 >> +KernelVersion: 5.8 >> +Contact: Dan Murphy >> +Description: read/write >> + Intensity level for the LED color within an array of integers. > ? "This file contains array of integers". OK > >> + The intensities for each color must be entered based on the >> + multi_index array. > This does not make sense to me. "Order of components is described by > the multi_index array"? > >> The max_intensity should not exceed > "max_intensity" -> "maximum intensity"? OK > >> + /sys/class/leds//max_brightness. >> +Multicolor Class Brightness Control >> +=================================== >> +The multicolor class framework will calculate each monochrome LEDs intensity. > ? This is redundant and will be removed. > >> +static ssize_t multi_intensity_store(struct device *dev, >> + struct device_attribute *intensity_attr, >> + const char *buf, size_t size) >> +{ >> + struct led_classdev *led_cdev = dev_get_drvdata(dev); >> + struct led_classdev_mc *mcled_cdev = lcdev_to_mccdev(led_cdev); >> + int nrchars, offset = 0; >> + int intensity_value[LED_COLOR_ID_MAX]; >> + int i; >> + ssize_t ret; >> + >> + mutex_lock(&led_cdev->led_access); >> + >> + for (i = 0; i < mcled_cdev->num_colors; i++) { >> + ret = sscanf(buf + offset, "%i%n", >> + &intensity_value[i], &nrchars); >> + if (ret != 1) { >> + dev_dbg(led_cdev->dev, >> + "Incorrect number of LEDs expected %i values intensity was not applied\n", >> + mcled_cdev->num_colors); >> + ret = -EINVAL; >> + goto err_out; >> + } >> + offset += nrchars; >> + } >> + >> + /* account for the space at the end of the buffer */ >> + offset++; > space? I'd expect \n there. And it would be good to verify it is > indeed \n, so that for example "0 0 0b" is not accepted. It is a new line the comment is incorrect I can remove the comment or update the comment to account for the new line > Please remove the dev_dbg()s that can be triggered by userspace. We > don't want users spamming the logs. Removed > >> +static ssize_t multi_intensity_show(struct device *dev, >> + struct device_attribute *intensity_attr, >> + char *buf) >> +{ >> + struct led_classdev *led_cdev = dev_get_drvdata(dev); >> + struct led_classdev_mc *mcled_cdev = lcdev_to_mccdev(led_cdev); >> + int len = 0; >> + int i; >> + >> + for (i = 0; i < mcled_cdev->num_colors; i++) { >> + len += sprintf(buf + len, "%d", >> + mcled_cdev->subled_info[i].intensity); >> + len += sprintf(buf + len, " "); > We should not really put " " before newline. OK I will fix that. >> +static ssize_t multi_index_show(struct device *dev, >> + struct device_attribute *multi_index_attr, >> + char *buf) >> +{ >> + for (i = 0; i < mcled_cdev->num_colors; i++) { >> + index = mcled_cdev->subled_info[i].color_index; >> + len += sprintf(buf + len, "%s", led_colors[index]); >> + len += sprintf(buf + len, " "); >> + } > We should not really put " " before newline. > >> +{ >> + struct led_classdev *led_cdev; >> + >> + if (!mcled_cdev) >> + return -EINVAL; >> + >> + if (!mcled_cdev->num_colors) >> + return -EINVAL; > It is plain int, so you may want to check for <= 0? Or maybe make it > unsigned? ok >> +MODULE_LICENSE("GPL v2"); > If your legal department allows that, GPL v2+ would be preffered > (globally). OK > >> +struct mc_subled { >> + int color_index; >> + int brightness; >> + int intensity; >> + int channel; >> +}; >> + >> +struct led_classdev_mc { >> + /* led class device */ >> + struct led_classdev led_cdev; >> + int num_colors; >> + >> + struct mc_subled *subled_info; >> +}; > Would some "unsigned"s make sense here to cut number of corner cases? I made these unsigned. Dan > > Best regards, > Pavel _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel