Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1223451imm; Wed, 8 Aug 2018 13:00:48 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxue9KTCodnZ5Qb1N692Q/EmWLQV+rIkfiC1NWgkSItbcamJt6hXbdu6pAkKXME+CobRUZW X-Received: by 2002:a62:2bc8:: with SMTP id r191-v6mr4348913pfr.164.1533758448082; Wed, 08 Aug 2018 13:00:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533758448; cv=none; d=google.com; s=arc-20160816; b=QEz8oRu8WVya1+dkUaGFp1Z6QL7ipu6kg6N3AfcQ2s3Rf8kZ8Nm4dwnbVfXgCSaj+w 9rhvCq8o1tNiGTxreFFLQu+ZvIcK3lVyGZK6RSE3X4nYo8QlOoLbBqPUyFW4ThSykJ2e WGlt6b1oMnMOXAxDDsNJWy1wtpKJxOlbt2D4G5EFdVsyvV4BT7zQAWlJhfWgpjlqaFQW 9YjzX/gCtEQlyjCG8k7G2j2glQ6TQkQzC3V195fDV8bAq62mZ/Gfo3HLqOMwhmbPVrvO Wep9McOZAnBjGbB8W8NqN0sn6CHUIgaBdtRniPkniA9ONGvDnxyGIZ8TFQq5PFFV/noO yN1Q== 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:arc-authentication-results; bh=KVNvA0wQTkzn6f7OONKZWSMnf2XYiEgZREbSqF6xv4Q=; b=jXrASxrsA5HUaYOQoVnuY1a7txGXJlMxrqtznGpAXCgpT7X7X4u0YMLfHyvtizm3yd FBDWt65cdYxiFuOOAlhd+ds9Qzer2mGT5ziZqz1z8lBfgBGVjT3q03lgMQxAKXr4tbdD 27t045AykMIeOWjhK+OucaKZ9fVnoKGksOTw8U0bCwwn6um3SLMPNjW5VIsdv73BfLDA a/+mqGI12tW91rM2/5clJwTw4UFwdmgYFqJJq3iz4PTOeeDm14qpnmT1qyt/vKSvsSGG rJzw8aSR3zsLegyw45rq1qkVY9AOWX5U0nZUOvYOCsL3UOZgq2U/CCcmGjInwYJJOYQm yc4w== 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 s2-v6si4020906pgc.447.2018.08.08.13.00.33; Wed, 08 Aug 2018 13:00:48 -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 S1731179AbeHHWUZ (ORCPT + 99 others); Wed, 8 Aug 2018 18:20:25 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:38327 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729703AbeHHWUZ (ORCPT ); Wed, 8 Aug 2018 18:20:25 -0400 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id 906958064C; Wed, 8 Aug 2018 21:59:09 +0200 (CEST) Date: Wed, 8 Aug 2018 21:59:09 +0200 From: Pavel Machek To: Dan Murphy Cc: robh+dt@kernel.org, jacek.anaszewski@gmail.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org Subject: Re: [PATCH v2 2/2] leds: lm3697: Introduce the lm3697 driver Message-ID: <20180808195909.GC20912@amd> References: <20180807160442.8937-1-dmurphy@ti.com> <20180807160442.8937-2-dmurphy@ti.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="RIYY1s2vRbPFwWeW" Content-Disposition: inline In-Reply-To: <20180807160442.8937-2-dmurphy@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 --RIYY1s2vRbPFwWeW Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > Introduce the lm3697 LED driver for > backlighting and display. >=20 > Datasheet location: > http://www.ti.com/lit/ds/symlink/lm3697.pdf >=20 > Signed-off-by: Dan Murphy > + > +#define LM3697_HVLED1_2_3_A 0 > +#define LM3697_HVLED1_B_HVLED2_3_A 1 > +#define LM3697_HVLED2_B_HVLED1_3_A 2 > +#define LM3697_HVLED1_2_B_HVLED3_A 3 > +#define LM3697_HVLED3_B_HVLED1_2_A 4 > +#define LM3697_HVLED1_3_B_HVLED2_A 5 > +#define LM3697_HVLED1_A_HVLED2_3_B 6 > +#define LM3697_HVLED1_2_3_B 7 That's rather long and verbose way to describe a bitmap, right? > +static const struct regmap_config lm3697_regmap_config =3D { > + .reg_bits =3D 8, > + .val_bits =3D 8, > + > + .max_register =3D LM3697_CTRL_ENABLE, > + .reg_defaults =3D lm3697_reg_defs, > + .num_reg_defaults =3D ARRAY_SIZE(lm3697_reg_defs), > + .cache_type =3D REGCACHE_RBTREE, > +}; Is rbtree good idea? You don't have that many registers. > +static int lm3697_init(struct lm3697 *priv) > +{ > + int ret; > + =2E... > + regmap_write(priv->regmap, LM3697_RESET, LM3697_SW_RESET); No error checking required here? > + if (priv->control_bank_config < LM3697_HVLED1_2_3_A || > + priv->control_bank_config > LM3697_HVLED1_2_3_B) { > + dev_err(&priv->client->dev, "Control bank configuration is out of rang= e\n"); > + ret =3D -EINVAL; > + goto out; > + } > + > + device_for_each_child_node(priv->dev, child) { > + led =3D &priv->leds[i]; > + > + ret =3D fwnode_property_read_u32(child, "reg", &led->control_bank); > + if (ret) { > + dev_err(&priv->client->dev, "reg DT property missing\n"); > + goto child_out; > + } > + > + fwnode_property_read_string(child, "linux,default-trigger", > + &led->led_dev.default_trigger); > + > + ret =3D fwnode_property_read_string(child, "label", &name); > + if (ret) > + snprintf(led->label, sizeof(led->label), > + "%s::", priv->client->name); > + else > + snprintf(led->label, sizeof(led->label), > + "%s:%s", priv->client->name, name); > + > + > + led->priv =3D priv; > + led->led_dev.name =3D led->label; > + led->led_dev.brightness_set_blocking =3D lm3697_brightness_set; > + > + ret =3D devm_led_classdev_register(priv->dev, &led->led_dev); > + if (ret) { > + dev_err(&priv->client->dev, "led register err: %d\n", ret); > + goto child_out; > + } > + > + if (priv->control_bank_config =3D=3D LM3697_HVLED1_2_3_A || > + priv->control_bank_config =3D=3D LM3697_HVLED1_2_3_B) > + goto child_out; This checks if we have just one bank, I see it. Should it also check the led actually uses the correct bank? > + i++; > + fwnode_handle_put(child); > + } > + > +child_out: > + fwnode_handle_put(child); Is not the fwnode_handle_put() done twice for non-error case? > + ret =3D lm3697_init(led); > + if (ret) > + return ret; > + > + return ret; > +} The if is not needed here. > +static int lm3697_remove(struct i2c_client *client) > +{ > + struct lm3697 *led =3D i2c_get_clientdata(client); > + int ret; > + > + ret =3D regmap_update_bits(led->regmap, LM3697_CTRL_ENABLE, > + LM3697_CTRL_A_B_EN, 0); > + if (ret) { > + dev_err(&led->client->dev, "Failed to disable regulator\n"); > + return ret; Misleading, this does nothing with regulators. Pavel --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --RIYY1s2vRbPFwWeW Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAltrS40ACgkQMOfwapXb+vL+tgCfWiL4OedfDaGO5nplfYMJD/P5 Ph0AoLvOkyCnWOFDRqOxI/NCkQr1vKOl =UFS0 -----END PGP SIGNATURE----- --RIYY1s2vRbPFwWeW--