Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp688728yba; Mon, 1 Apr 2019 14:50:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqw2o7HmFLkksBgqt4l5iz78Bf/lkWkqHA5kym7mf9m00TJ7XPeAmBzUJH5I7EcuJUY7Hd5/ X-Received: by 2002:a62:ab14:: with SMTP id p20mr66727103pff.23.1554155407921; Mon, 01 Apr 2019 14:50:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554155407; cv=none; d=google.com; s=arc-20160816; b=GzxbfDt7zR6PuXmHZ5fs4f9JhHSQELpAoxAxjCdOPXFUeQz8st9NHJrTj/1RsTl1eS Gz5/NuNcI/s6yFWOYIJovEMY2Hjx/0HVq3qpcqRZHGev7qYQi9O5jvy69M5xVBCqU/tk d+slFd8SsjV2P75JINw6BjfxauXBVVu8fbAyOk1bu0jx8q5zRdO0Wc6NBH9/mFJzufON 1RKr4C+vICHfsRPztvcTSz8CzQQaN6/cPm/Gm5lV6IMHxgP4YKvNoZR/2r5MdFSIRntV a1ZtJq7r6S+cpln8J9VMZe1gsI7lUSw61WMfb0PZRxpjpGegRzCiOaFEswW9Kc/3YBN6 Tp2g== 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=oAAwV2F4yL3MJSa2jrm5Gbs43WWnmYeRi7aInl1MZts=; b=snFhM5PLUKsw9YDGibd1DB6BY1bJMvfwDpgV65KbBtdCQBlzqh2Zsn6jx9pHOf5zCf 5/iGmNngcOklZnwKyP5TNxfodCn5jjQHJPNOBAsyKp2nzFmB+fMrnGGHar9Q7c+4NOZD +8e/ct/CE4hKKw/hK7CcZSRBgL/DEpYkCOEcohiWRNr6N/aXsqUCSHMws6kP6BtrYnlR hzTDX/3RpEluFNDs3icuifXjWD95jjll41iiIqHrEqsgTBOkulGQOfjauHzdt/3sgjzj VfZRM57f2FkkYy6erU2sbv/Ed00hsvgIXkgnWZkDS21jD67DUqsTWfYH0DacveMhZ+ad 1v5g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j133si9692339pgc.543.2019.04.01.14.49.52; Mon, 01 Apr 2019 14:50:07 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726968AbfDAVsx (ORCPT + 99 others); Mon, 1 Apr 2019 17:48:53 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:56564 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726269AbfDAVsv (ORCPT ); Mon, 1 Apr 2019 17:48:51 -0400 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id 7661F803E9; Mon, 1 Apr 2019 23:48:40 +0200 (CEST) Date: Mon, 1 Apr 2019 23:48:47 +0200 From: Pavel Machek To: Brian Masney Cc: lee.jones@linaro.org, daniel.thompson@linaro.org, jingoohan1@gmail.com, robh+dt@kernel.org, jacek.anaszewski@gmail.com, mark.rutland@arm.com, b.zolnierkie@samsung.com, dri-devel@lists.freedesktop.org, linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fbdev@vger.kernel.org, dmurphy@ti.com, jonathan@marek.ca Subject: Re: [PATCH v2 3/3] backlight: lm3630a: add device tree supprt Message-ID: <20190401214847.GE14681@amd> References: <20190401103034.21062-1-masneyb@onstation.org> <20190401103034.21062-4-masneyb@onstation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="DqhR8hV3EnoxUkKN" Content-Disposition: inline In-Reply-To: <20190401103034.21062-4-masneyb@onstation.org> 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 --DqhR8hV3EnoxUkKN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon 2019-04-01 06:30:34, Brian Masney wrote: > Add device tree support to the lm3630a driver and allow configuring > independently on both banks the mapping mode (linear or exponential), > initial and maximum LED brightness. >=20 > Driver was tested on a LG Nexus 5 (hammerhead) phone. >=20 > Signed-off-by: Brian Masney > --- > drivers/video/backlight/lm3630a_bl.c | 69 ++++++++++++++++++++++++++++ > 1 file changed, 69 insertions(+) >=20 > diff --git a/drivers/video/backlight/lm3630a_bl.c b/drivers/video/backlig= ht/lm3630a_bl.c > index ef2553f452ca..96fbc1273dda 100644 > --- a/drivers/video/backlight/lm3630a_bl.c > +++ b/drivers/video/backlight/lm3630a_bl.c > @@ -35,6 +35,9 @@ > #define REG_MAX 0x50 > =20 > #define INT_DEBOUNCE_MSEC 10 > + > +#define LM3630A_MAX_SOURCES 2 > + > struct lm3630a_chip { > struct device *dev; > struct delayed_work work; > @@ -364,6 +367,64 @@ static const struct regmap_config lm3630a_regmap =3D= { > .max_register =3D REG_MAX, > }; > =20 > +static void lm3630a_parse_dt(struct lm3630a_chip *pchip) > +{ > + u32 sources[LM3630A_MAX_SOURCES], val; > + struct device_node *child_node; > + int num_sources, ret, i; > + bool linear; > + > + for_each_available_child_of_node(pchip->dev->of_node, child_node) { > + num_sources =3D of_property_count_u32_elems(child_node, > + "led-sources"); > + if (num_sources < 0) > + continue; > + > + if (num_sources > LM3630A_MAX_SOURCES) > + num_sources =3D LM3630A_MAX_SOURCES; > + > + ret =3D of_property_read_u32_array(child_node, "led-sources", > + sources, num_sources); > + if (ret) { > + dev_err(pchip->dev, > + "Error parsing led-sources node: %d\n", ret); > + return; > + } > + > + linear =3D of_property_read_bool(child_node, > + "ti,linear-mapping-mode"); > + > + for (i =3D 0; i < num_sources; i++) { > + if (sources[i] =3D=3D 0) > + pchip->pdata->leda_ctrl =3D linear ? > + LM3630A_LEDA_ENABLE_LINEAR : > + LM3630A_LEDA_ENABLE; > + else if (sources[i] =3D=3D 1) > + pchip->pdata->ledb_ctrl =3D linear ? > + LM3630A_LEDB_ENABLE_LINEAR : > + LM3630A_LEDB_ENABLE; This makes my head spin. So ... we can have multiple LEDs, each can have up to two sources.. and the settings are really per source, not per LED. But you do not test for overlaps. What prevents me from having foo { led_sources =3D <0>; ti,linear-mapping-mode; } bar { led_sources =3D <0>; } (I.e. conflicting settings for a source?) Plus I do not see parsing of led labels etc... > + ret =3D of_property_read_u32(child_node, > + "default-brightness", &val); > + if (!ret) { > + if (sources[i] =3D=3D 0) > + pchip->pdata->leda_init_brt =3D val; > + else if (sources[i] =3D=3D 1) > + pchip->pdata->ledb_init_brt =3D val; > + } > + > + ret =3D of_property_read_u32(child_node, "max-brightness", > + &val); > + if (!ret) { > + if (sources[i] =3D=3D 0) > + pchip->pdata->leda_max_brt =3D val; > + else if (sources[i] =3D=3D 1) > + pchip->pdata->ledb_max_brt =3D val; > + } > + } > + }; Extra ";" > +} > + > static int lm3630a_probe(struct i2c_client *client, > const struct i2c_device_id *id) > { > @@ -405,6 +466,7 @@ static int lm3630a_probe(struct i2c_client *client, > pdata->ledb_init_brt =3D LM3630A_MAX_BRIGHTNESS; > } > pchip->pdata =3D pdata; > + lm3630a_parse_dt(pchip); I'd expect abort if we are using dt and dt parsing fails. Pavel --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --DqhR8hV3EnoxUkKN Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlyihz8ACgkQMOfwapXb+vIE4ACeMdpxk/6BCAiO8WWDcfB5Tl89 7EgAnRM1tWG7/UUqMYrJeinnXGnd24zj =Su8z -----END PGP SIGNATURE----- --DqhR8hV3EnoxUkKN--