Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3870937ybz; Tue, 28 Apr 2020 01:44:54 -0700 (PDT) X-Google-Smtp-Source: APiQypLNBDK9jHzzXw7I2mrWFd7cixp1pi4v5OCSyzVhjCyoOnCjczqEP4AFL7cdtt097qOYXbYI X-Received: by 2002:a17:906:6811:: with SMTP id k17mr1521285ejr.351.1588063494334; Tue, 28 Apr 2020 01:44:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588063494; cv=none; d=google.com; s=arc-20160816; b=NxzqmeiyshYT4f67RYbEIuQunDXD44VKMDY7ipZ4eOEnkZmorvuuVFxzjrWMNUGS6i BOyxOKE7UT1c1kS2yclR9/rmK5T17vF80xpKQj2w2O/0mXlqNNp4SOeJocB7aJkjIZpQ GUbSfiVmOhNsFjONFGaJifp3ShTwL5Hw4l7sMQwxUsDzfLlxSNMMw52j0UNEVbokjvKz bNu2fLyziLhHhqqTMMGGNO6k+EDvy9Q6irA9waypZnLDCXHMVUhb7nyaxnxl9PxGoTy2 w3k7l+4+7LV+a4SFjswlKrKRKrnlAvUw2lus6J5FfGSqL+ytenIKtsiaqIeXzfSYhFrQ Dv0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Oj+LNc2CmIA2aMqblrYgozcXw4ZbO6lUbDhdkKCIovg=; b=edoqpOGutiC3fRpV3qAnaLboIiVS+1g8n7XaItfI40FtqVdIC1jtfzzEd6Bp0euNvg yPeft5PwoMUzyA3WHCr1iwHp45uNO0Ikst8fbYQ90AnfjZAUXpqljNW9k4iXu8lpfxEj eNrRflxJWIsNbHCwSvHQxOpgMMi9Z2CnNiIOWam2MNXJ0vn85CR2Mhc++rf60gILYLaA IaFu5W3ZSaEwabmKd/R4VW5WY/v5T0vs7ZlA0+xzo3uyIpw45Fy4pqwZO0hWfVrKpo+R iBZaxN2st3pAN4PhwEU6Csx+j5YjPTe4hUH0myKsbzPI/LwvmhSV4EkZcmsYoyj7hFGw 5nuw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i7si1133280edj.520.2020.04.28.01.44.31; Tue, 28 Apr 2020 01:44:54 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726930AbgD1ImD (ORCPT + 99 others); Tue, 28 Apr 2020 04:42:03 -0400 Received: from jabberwock.ucw.cz ([46.255.230.98]:35332 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726904AbgD1ImC (ORCPT ); Tue, 28 Apr 2020 04:42:02 -0400 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 872151C0263; Tue, 28 Apr 2020 10:42:00 +0200 (CEST) Date: Tue, 28 Apr 2020 10:41:59 +0200 From: Pavel Machek To: Dan Murphy Cc: jacek.anaszewski@gmail.com, linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v20 03/17] leds: multicolor: Introduce a multicolor class definition Message-ID: <20200428084159.GB20640@amd> References: <20200423155524.13971-1-dmurphy@ti.com> <20200423155524.13971-4-dmurphy@ti.com> <20200425202306.GA23926@amd> <80e20291-0ff2-87e6-8f93-2f37f588b148@ti.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="St7VIuEGZ6dlpu13" Content-Disposition: inline In-Reply-To: <80e20291-0ff2-87e6-8f93-2f37f588b148@ti.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --St7VIuEGZ6dlpu13 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > >>+cat /sys/class/leds/multicolor:status/multi_led_index > >>+green blue red > >Hmm. We should really make sure LEDs are ordered as "red green > >blue". Yes, userspace should support any order, but... >=20 > Ordering is not guaranteed since it is based on the DT ordering. I don't > think we can mandate that these LEDs be put in order in the DT. >=20 > Besides the framework and the device driver do not care what color is whe= re > only the user space needs to care.=A0 The FW and device driver only care = about > the brightness, intensity and channel. Ok, lets keep it like this. > >>+ offset +=3D nrchars; > >>+ } > >This checks for "not enough" intensities. Do we need check for "too > >many" intensities? >=20 > We ignore anything greater then mcled_cdev->num_colors.=A0 So if this is = set > to 3 we only read the first 3 values. >=20 > So we cannot read more then what is set by the DT. Please make it return an error if extra values are passed in. > >>+static ssize_t multi_led_intensity_show(struct device *dev, > >>+ struct device_attribute *intensity_attr, > >>+ char *buf) > >>+{ > >>+ struct led_classdev *led_cdev =3D dev_get_drvdata(dev); > >>+ struct led_classdev_mc *mcled_cdev =3D lcdev_to_mccdev(led_cdev); > >>+ int len =3D 0; > >>+ int i; > >>+ > >>+ for (i =3D 0; i < mcled_cdev->num_colors; i++) > >>+ len +=3D sprintf(buf + len, "%d ", > >>+ mcled_cdev->multicolor_info[i].color_led_intensity); > >>+ > >>+ len +=3D sprintf(buf + len, "%s", "\n"); > >This will result in extra " " before end of line. > > > >Please don't use "%s", "\n" to add single character. "\n" would be enoug= h. > Ack changed to just sprintf(buf + len, "\n"); Also note the extra space before end of line. Best regards, Pavel --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --St7VIuEGZ6dlpu13 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAl6n7FcACgkQMOfwapXb+vKdZACeLXsQXKtIiAtVWXrLbVqG9bx9 HyMAoIjtZeQ2xZ/fsOYK/KPl/KmmnrSC =HSyV -----END PGP SIGNATURE----- --St7VIuEGZ6dlpu13--