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 X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8EC60C47087 for ; Mon, 24 May 2021 16:05:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7607561376 for ; Mon, 24 May 2021 16:05:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236316AbhEXQGo (ORCPT ); Mon, 24 May 2021 12:06:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237797AbhEXQFk (ORCPT ); Mon, 24 May 2021 12:05:40 -0400 Received: from polaris.svanheule.net (polaris.svanheule.net [IPv6:2a00:c98:2060:a004:1::200]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72E20C061345 for ; Mon, 24 May 2021 08:30:33 -0700 (PDT) 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-leds@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