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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51965C433F5 for ; Tue, 5 Apr 2022 20:48:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233744AbiDEUo3 (ORCPT ); Tue, 5 Apr 2022 16:44:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383966AbiDEPOv (ORCPT ); Tue, 5 Apr 2022 11:14:51 -0400 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::222]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CCB157B08; Tue, 5 Apr 2022 06:28:32 -0700 (PDT) Received: (Authenticated sender: clement.leger@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 709324000D; Tue, 5 Apr 2022 13:28:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1649165311; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qnhE1fGjUafmBC+KaTBnXvOD8ef7wgKM3WFEC0Tf58Q=; b=PNZNMPwtfLbDvJj2rr5VXgbxaCGxcXBVC+gZHBtIAYoLT4hU6bhMpirHr8gz34mNJXLwRO 6LDLtXVpQnIuL7joOzxx9Ymx88UJvXp25mqd5+1fwpkfq9LPc28eaU0N05kaOwcWtbuWmk GiTNuRJji7YMiyuTKfkrzQ+z3IpmfDY/JtMPHS4AI82mAnxjTgra4Kc/vf8XNy2XPyhn4G +R377fFgzWK/qsqrQV4FhwQeZHFkMf9ok4VSgKwai8hmm2ocIWz0Z7N3wOY3gDfIsP4wdc 1+jboRxEU1Fhwg8JYtN+22rUVhqpabxaS2J78OFowBUg/dKrZYmIvsQQdPdskw== Date: Tue, 5 Apr 2022 15:27:02 +0200 From: =?UTF-8?B?Q2zDqW1lbnQgTMOpZ2Vy?= To: "Rafael J. Wysocki" Cc: Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , Wolfram Sang , Peter Rosin , Rob Herring , Frank Rowand , Len Brown , Hans de Goede , Thomas Petazzoni , Alexandre Belloni , Allan Nielsen , Linux Kernel Mailing List , ACPI Devel Maling List , linux-i2c , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" Subject: Re: [PATCH v3 3/9] device property: add index argument to property_read_string_array() callback Message-ID: <20220405152702.50ba516d@fixe.home> In-Reply-To: References: <20220325113148.588163-1-clement.leger@bootlin.com> <20220325113148.588163-4-clement.leger@bootlin.com> <20220328162812.16deac92@fixe.home> Organization: Bootlin X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Le Tue, 5 Apr 2022 15:22:51 +0200, "Rafael J. Wysocki" a =C3=A9crit : > On Mon, Mar 28, 2022 at 4:29 PM Cl=C3=A9ment L=C3=A9ger wrote: > > > > Le Fri, 25 Mar 2022 16:30:45 +0200, > > Andy Shevchenko a =C3=A9crit : > > =20 > > > > pointer =3D property_entry_find(props, propname, length); > > > > if (IS_ERR(pointer)) > > > > return PTR_ERR(pointer); =20 > > > =20 > > > > + if (index >=3D array_len) > > > > + return -ENODATA; =20 > > > > > > I was about to ask if we can check this before the > > > property_entry_find() call, but realized that in such case it will > > > shadow possible errors due to wrong or absent property. =20 > > > > I think you are actually right, the check can be done after > > property_entry_count_elems_of_size() since it already checks for the > > property to be present. I'll move that check. > > =20 > > > > > > ... > > > =20 > > > > - of_property_read_string_array(node, propname, val, > > > > nval) : > > > > + of_property_read_string_array_index(node, > > > > propname, val, nval, > > > > + index) : =20 > > > > > > Dunno about the style there, but I think it can be one line. =20 > > > > Seems like the complete file is strictly applying the 80 columns rules > > so I thought it was better to keep it like this. However, I think the > > ternary oeprator is not really readable with such split. =20 >=20 > So FWIW I would entirely change it to >=20 > if (!val) > return of_property_count_strings(node, propname); >=20 > return of_property_read_string_array_index(node, propname, val, >=20 > nval, index); >=20 > which IMO would be way easier to read. Hi Rafael, Agreed, this is way more readable. I'll modify that. Thanks, --=20 Cl=C3=A9ment L=C3=A9ger, Embedded Linux and Kernel engineer at Bootlin https://bootlin.com