Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3522048pxj; Mon, 24 May 2021 08:34:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeBKqVeCBLG0q1LsKhNdFA0ofYU464O0Mj6fM0PYIaf+klLpLUTUUTB34qj21uJQx7nTwA X-Received: by 2002:a50:ec91:: with SMTP id e17mr26825667edr.228.1621870494035; Mon, 24 May 2021 08:34:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621870494; cv=none; d=google.com; s=arc-20160816; b=o3cU3f5gnxUo1MMOx8YsUBZm6dgJ4yHVQnq7f8HsFZrMaI/C1e77wa+ld+B0ma+uIi riLFGJk911iMqwosgkYtoP9iUzeUDpR08Huqu4lSXFBvebEVoh22TP+5Ek6EOOf02Yak qq4uMh2ogqRtZE4unyYx72LBe8wsWMq5CXms0OLLY66mS5V2P40MQfyOfxFfoVBo8AMM fWCs1+VRhbwROpEw4e43/7QyUAwzW9Sd1eoinnVXUgOcTDTok2/6nlar/9cf4ZtyXE1l p6gIbBF4E5R7RUKGilE3/aBER6d/QZ1oZlaSfUZ1ReEaXYOY3nQ80eZzEc0jceen56IL i2WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=5MVM5bUeOBcoLoP3W/nxVP4OlAB5bSPoQyJKgckUz8I=; b=IKGNwP/0bF/4ggUmrdBVasw4nE/840aK1q0iy14GaxiNQc1xZSN12U1Hd9ZXZGi+tP yTh2z0UmlpQ10IPdRKhCAO0kfpqmaxXAh8Xit9nEUjOLu/T8P2hTiuMZam0+U6tQK6ri ZNXLItuY4lnDm3eMg7OkPp6aKhe5nf6XnNOv5bymnqRVf3UJ5aD9Jea6uNWkcOtMtCHf OdAmd8OUoK8mfKTr+VC/SYU+RJq0z9qGobQmiHqnA3vawnuBGaXAbDLbxook1MV4RX+Z 2NaLL9pOrkyIpSO5SwOMGeyyx1FCELHouO8JOaEi769ZASv+2oUU1sdUexj20gaFB9yD 6uAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@svanheule.net header.s=mail1707 header.b=Hmt76Wx3; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=svanheule.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id du16si8061656ejc.38.2021.05.24.08.34.31; Mon, 24 May 2021 08:34: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; dkim=pass header.i=@svanheule.net header.s=mail1707 header.b=Hmt76Wx3; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=svanheule.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232762AbhEXPcm (ORCPT + 99 others); Mon, 24 May 2021 11:32:42 -0400 Received: from polaris.svanheule.net ([84.16.241.116]:35130 "EHLO polaris.svanheule.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233026AbhEXPcD (ORCPT ); Mon, 24 May 2021 11:32:03 -0400 Received: from [IPv6:2a02:a03f:eafb:ee01:cbcc:e481:3e58:4db1] (unknown [IPv6:2a02:a03f:eafb:ee01:cbcc:e481:3e58:4db1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: sander@svanheule.net) by polaris.svanheule.net (Postfix) with ESMTPSA id A19BD202FF0; Mon, 24 May 2021 17:30:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svanheule.net; s=mail1707; t=1621870231; 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=5MVM5bUeOBcoLoP3W/nxVP4OlAB5bSPoQyJKgckUz8I=; b=Hmt76Wx3Cn2CJMDd4/vkYSZjhlGEll5naZ+AkO0EURp37WRFFvQgim6ZFQ9EwiPDGmags3 9IVFxsG7TCrGSMhThwoJqgjp6kUCbMxUh+izP9iLsySTh6L4HlF4cSVzDh9GnNVz+7A0gK mljJApeRhSZdiANKVcKSfEIdont1J8KcgVi+VZSb0c2bg6dT9CZ5rz7rOhHIaPKz6cWFzL W3hSGYMlsEL69aXJbGeHVpeVLKo83eir9rdGsR9qG8Jny63q5YiU+sG4RhERTY6zZWhlaS gJ4XQNgGMnrTHGCCWRdNnF6poHSTG3O2HKB8ORb6fnv68ZRApU7NliM3KXQ+2Q== Message-ID: <867b81680fdf3076e8ce3fbc2dc36247d8e724a8.camel@svanheule.net> Subject: Re: [PATCH v3 6/6] leds: Add support for RTL8231 LED scan matrix From: Sander Vanheule To: Andy Shevchenko Cc: Pavel Machek , Rob Herring , Lee Jones , Mark Brown , Greg Kroah-Hartman , "Rafael J . Wysocki" , Michael Walle , Linus Walleij , Bartosz Golaszewski , Linux LED Subsystem , devicetree , "open list:GPIO SUBSYSTEM" , Andrew Lunn , Linux Kernel Mailing List Date: Mon, 24 May 2021 17:30:30 +0200 In-Reply-To: References: <213ab7580a1d3229d32f7aac67bf4e828612153a.1621809029.git.sander@svanheule.net> <08375439546c04d32b158c20fb59446c3bbafb46.camel@svanheule.net> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.4 (3.38.4-1.fc33) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2021-05-24 at 15:47 +0300, Andy Shevchenko wrote: > On Mon, May 24, 2021 at 3:04 PM Sander Vanheule wrote: > > On Mon, 2021-05-24 at 13:24 +0300, Andy Shevchenko wrote: > > > On Mon, May 24, 2021 at 1:34 AM Sander Vanheule > > > wrote: > > ... > > > > > +       if (ret != 2) > > > > +               return -ENODEV; > > > > > > I would say -EINVAL, but -ENODEV is similarly okay. > > > > Any specific reason you think EINVAL is more appropriate than ENODEV? > > My logic is that the initial values (from resource provider) are incorrect. > But as I said, I'm fine with either. Ok, that makes sense. Actually, I'm already using "address invalid" in the error messages when reading the address fails, so I'll change to EINVAL for consistency. > > > > > +       int err; > > > > > > ret or err? Be consistent across a single driver. > > > > I had first used 'err' for both fwnode_property_count_u32() and > > fwnode_property_read_u32_array(). The former returns "actual count or error > > code", while the latter is only "error code". And I found it weird to read > > the > > code as "does error code equal 2", if I used 'err' as variable name. > > > > I've split this up: > >  * addr_count for fwnode_property_count_u32's result > >  * err for fwnode_property_read_u32_array's result > > > > Since addr_count is only used before err is touched, I guess the compiler > > will > > optimize this out anyway? > > Usually we do this pattern (and it seems you missed the point, name of > variable is ret in some functions and err in the rest): > > err /* ret */ = foo(); > if (err < 0) >   return err; > count = err; I had only used 'ret' specifically in this one function, because I didn't like "if (err != 2)" (and I apparently decided that I disliked that more than the inconsistency introduced by using 'ret'). I'll stick to calling the variable 'err', and change the clause to (err != ARRAY_SIZE(addr)) to make it more obvious that 2 isn't just some random return value. Best, Sander