Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2881258ybl; Thu, 29 Aug 2019 14:25:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqyZF4e59yzitmGiUw0oloxuishcxpWPY1E6J/pCjdx++aNd8KbLuQD4fOV6WsDeLHo9Iujw X-Received: by 2002:aa7:9edc:: with SMTP id r28mr13683925pfq.219.1567113916764; Thu, 29 Aug 2019 14:25:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567113916; cv=none; d=google.com; s=arc-20160816; b=AJyyxoBVHxYtOjtm0J3NR+BONzifvqh4w0G+dMprTfJbPsb+6ujUfMavTJl5jAZb8z 7HK1/9LngldBtb30qS7UYwYHjzxT2SPyj6YPbAcvgNrqSppM9yVAwkacCbpUMbmvoSxL d0dQmsE99PT94PTZ5HAtlpWXblGBmi/gHO7K2wL2sST07cRGImVxuoxokXqCfToSDzu4 mo8My8TnnEy31eszI4SgFSon0Xce4b/8AAq5mHKrDhx4uSyovH1gaPOOGahKFYcwQpKR bkYcXF+t2mWmn0q1yTy7fqOV+JNjSgSuQ3pep67BJWt0GRXhjA+pXw2ME9CXJ1jCKbG4 qiFA== 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=KAMqX6Bnm9fr6I/Mm1st7UIpnBzr6otwne9Xfw+9h8Q=; b=P1jjLm7TmY0dzh1EgAuHVOPp+eWix1ldc5OY7L6MhMfDCLHuJps+/Pex9+8iOy0oRL g9UNtVztDF0PIVaiwCnhe1qtKdvge6XF8hDICJEOpEFcy7AC070pnP9B2+/6QeFVzjAM Kxhcb2jwcoSLBX4+26eu+PBa90ESbbw030+Rv+CdvGUTF4/XfvLQIU3NkvPiMHMBHtNa I2GsyNkaeOwlqIL8ag3U3rbvqfyCpuwcxKzBpcQRA/uznFYkyrInxtwoHgiCFQPUOGR3 7uU39cP/fS/7qgQ1lZU7yPI/j4j99YSpHMJO8jFyllJ+KucsmeVqhDbMa57gejddYeQo 17Uw== 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 q24si2855866pls.7.2019.08.29.14.25.01; Thu, 29 Aug 2019 14:25:16 -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 S1728121AbfH2VWw (ORCPT + 99 others); Thu, 29 Aug 2019 17:22:52 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:40022 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726661AbfH2VWv (ORCPT ); Thu, 29 Aug 2019 17:22:51 -0400 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id 206A0813B1; Thu, 29 Aug 2019 23:22:35 +0200 (CEST) Date: Thu, 29 Aug 2019 23:22:48 +0200 From: Pavel Machek To: Jacek Anaszewski Cc: Dan Murphy , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] leds: lm3532: Fix optional led-max-microamp prop error handling Message-ID: <20190829212247.GB32254@amd> References: <20190829191836.9648-1-dmurphy@ti.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="JP+T4n/bALQSJXh8" Content-Disposition: inline In-Reply-To: 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 --JP+T4n/bALQSJXh8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu 2019-08-29 22:04:18, Jacek Anaszewski wrote: > Hi Dan, >=20 > Thanks for the update. >=20 > On 8/29/19 9:18 PM, Dan Murphy wrote: > > Fix the error handling for the led-max-microamp property. > > Need to check if the property is present and then if it is > > retrieve the setting and its max boundary > >=20 > > Reported-by: Pavel Machek > > Signed-off-by: Dan Murphy > > --- > > drivers/leds/leds-lm3532.c | 14 +++++++++----- > > 1 file changed, 9 insertions(+), 5 deletions(-) > >=20 > > diff --git a/drivers/leds/leds-lm3532.c b/drivers/leds/leds-lm3532.c > > index c5cfd8e3f15f..13b4265fb85a 100644 > > --- a/drivers/leds/leds-lm3532.c > > +++ b/drivers/leds/leds-lm3532.c > > @@ -601,11 +601,15 @@ static int lm3532_parse_node(struct lm3532_data *= priv) > > goto child_out; > > } > > =20 > > - ret =3D fwnode_property_read_u32(child, "led-max-microamp", > > - &led->full_scale_current); > > - > > - if (led->full_scale_current > LM3532_FS_CURR_MAX) > > - led->full_scale_current =3D LM3532_FS_CURR_MAX; > > + if (fwnode_property_present(child, "led-max-microamp")) { > > + if (fwnode_property_read_u32(child, "led-max-microamp", > > + &led->full_scale_current)) > > + dev_err(&priv->client->dev, > > + "Failed getting led-max-microamp\n"); > > + > > + if (led->full_scale_current > LM3532_FS_CURR_MAX) > > + led->full_scale_current =3D LM3532_FS_CURR_MAX; >=20 > One more nit: we have min() macro in kernel.h for such things. Actually, I believe this one is okay. min() would be also good, but improvement is not that big, as it still duplicates the argument. led->full_scale_current =3D min(led->full_scale_current, LM3532_FS_CURR_MAX) Best regards, Pavel --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --JP+T4n/bALQSJXh8 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAl1oQicACgkQMOfwapXb+vLL0ACcCBhnti0Tj6RaCErhjosQccHu 1wgAn2LJseuLFr6KxEU60hGF0abLzOIV =dlY+ -----END PGP SIGNATURE----- --JP+T4n/bALQSJXh8--