Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp783949pxp; Sat, 5 Mar 2022 19:23:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJyo2aTILYnZjhmac+a1XgFqTjkrCSdIBJfsIxp71RLtZEP3RQCZE1EPSyMGR8ppbedEac1U X-Received: by 2002:a17:906:2646:b0:6d5:d889:c92b with SMTP id i6-20020a170906264600b006d5d889c92bmr4610304ejc.696.1646536987443; Sat, 05 Mar 2022 19:23:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646536987; cv=none; d=google.com; s=arc-20160816; b=g1eth/wVyNHeW3d2TIj1cpfWzsXG66sQcaiVad60ZtgVyQTfbEfQb65INpCqbKiGKn 8LzWDaEsQuMVkIu//Nw0m6NC19dphf5lzMYZR6q0b4t18S6x1Vnk17kQzZp/hPUOwTA0 Pk+0bOskDIhuaMPSlukpA4Bl06Eh8YGc9XHQ+Rq97mY8uvInKH5n3sfKbGz/jI5x0Tg+ BQT2FfvI45GLWih/vxVBnGJ3xdcJFfd1bk4MYh2rc9p1tmOa2yceyVwDAlXxsuL1Sgwn HTDfOAFwaKAzDMEB1cEadMp0HsKQtSc4sD8KmIAKEKm+v7Cgrcy92+vAB5lFBQ0IQ/Ji UCLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Zc9mq6hVzaRjLQEcIpq3l9xbumYlszQ9nEQAPa0hcT8=; b=HBNbUMB8Vyawdg1pPKCqNsCHYyAmwtCIF5jueMGjXhnORA3bUWIugoF722/4m3Yiow dvFaHSOmJcWNo0eG8YwyjuiJPIpsuvOexIIFntObiPrJKN/mdzjSoaKKmLVLSLTy4Z4d 6JcqqpLp0FadJK7jzxV4apkvAgWIVrydJJfdV8xVt51PS4G+FpGJnS7izNvLTYkHlUo8 G/TJHIY7woOvs6iPApussP5ndThyrHi/izdKVLIrP5GXKQm/zLMSj6gIa2SmXVVqiuIB ci4IbOtxSxLv5RjfOK0o6EKphPqNc+7Qcw5D92zuHL6mdKcuUimIKZHmqT0D9jnH+Nya qLyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=oHhI9Cdw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id du11-20020a17090772cb00b006daa62dc420si5940859ejc.848.2022.03.05.19.22.44; Sat, 05 Mar 2022 19:23:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=oHhI9Cdw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232478AbiCEVsQ (ORCPT + 99 others); Sat, 5 Mar 2022 16:48:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229805AbiCEVsO (ORCPT ); Sat, 5 Mar 2022 16:48:14 -0500 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1948C5006F; Sat, 5 Mar 2022 13:47:24 -0800 (PST) Received: by mail-ej1-x629.google.com with SMTP id d10so24359232eje.10; Sat, 05 Mar 2022 13:47:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=Zc9mq6hVzaRjLQEcIpq3l9xbumYlszQ9nEQAPa0hcT8=; b=oHhI9CdwIKIw2V5EkezeDZLy6C5w9JYFVa6xwIFz5MSTTcKDxIR/6ndolTmQVuAPYc HVRi+EuEcQua0Y86dEOI4Dh87rPQpRzdjAG+O3yoYfdk7loWFPanTTIr0FyLu+FqfShx zoKc+NvB8RAhJ2//hEv7+lUTdnMMhAmgGNX6BGW/PTVtBC7XfX8z8xFVrayXoND87nHj zq9soUmiBcMvZN8JG6QBLev9nL57pfl5a48kt4LDEolaUoTKL24klZmL3ApEwz+PT7ct 1kj3TmgHza99hG9ihY/9dxxJhetsF3V504VM8byVhyVsEoewUQ7nDdo9iIrvBZO9rRV8 q+2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=Zc9mq6hVzaRjLQEcIpq3l9xbumYlszQ9nEQAPa0hcT8=; b=8BM8HHClB1vemR18PLfkgJ2VJ+fmLCm6Tr0jDctxPnBJTk6pg/q1wI1LIaBqbpizA3 YqG788rUw8cKq0HnmCrnm/6uCqrCBHH8xN/EGGToNA9BKsr6jaVE6F2QFEShLSecc8pv z2kL3NLWtDsLf/Ipqx7Qjbsy4y70ty/wUh4v5NkHwbvW/guNYLgVzZC95NEqXHICYLr+ 3buD2yZRO0gRtOavjIuyhw3pioefkvPNegrrd9v5dWUdv3bLf+YW3soZa2hWubJ3AS6E muI9jqclMt+TjO9pdQqkBjmroCY+UpG3lLVws8InGfIdmao9wqmCEtKk3sEgBWbvwj1T xDfQ== X-Gm-Message-State: AOAM530QvfwUeDF7FYsnX0DtE4tL9R3rpIgHT7iujpYIEwjG76WAhh+F iY1DA+2cmzuPys4ipnLrs4oqI6L/x+ogfMqDZWE= X-Received: by 2002:a17:907:728b:b0:6da:97db:b66d with SMTP id dt11-20020a170907728b00b006da97dbb66dmr3928537ejc.636.1646516842576; Sat, 05 Mar 2022 13:47:22 -0800 (PST) MIME-Version: 1.0 References: <20220304173256.39059-1-andriy.shevchenko@linux.intel.com> <8afcf0b81f78ffdda8bcac5f0fd1d4c40dc4f8d6.camel@gmail.com> In-Reply-To: <8afcf0b81f78ffdda8bcac5f0fd1d4c40dc4f8d6.camel@gmail.com> From: Andy Shevchenko Date: Sat, 5 Mar 2022 23:46:46 +0200 Message-ID: Subject: Re: [PATCH v2 1/1] device property: Allow error pointer to be passed to fwnode APIs To: =?UTF-8?B?TnVubyBTw6E=?= Cc: Andy Shevchenko , "Rafael J. Wysocki" , ACPI Devel Maling List , Linux Kernel Mailing List , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J. Wysocki" , Len Brown , =?UTF-8?B?TnVubyBTw6E=?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Mar 5, 2022 at 10:28 PM Nuno S=C3=A1 wrote: > > On Fri, 2022-03-04 at 19:32 +0200, Andy Shevchenko wrote: > > Some of the fwnode APIs might return an error pointer instead of NULL > > or valid fwnode handle. The result of such API call may be considered > > optional and hence the test for it is usually done in a form of > > > > fwnode =3D fwnode_find_reference(...); > > if (IS_ERR_OR_NULL(fwnode)) > > ...error handling... > > > > Nevertheless the resulting fwnode may have bumped reference count and > > hence caller of the above API is obliged to call fwnode_handle_put(). > > Since fwnode may be not valid either as NULL or error pointer the > > check > > has to be performed there. This approach uglifies the code and adds > > a point of making a mistake, i.e. forgetting about error point case. > > > > To prevent this allow error pointer to be passed to the fwnode APIs. ... > > ret =3D fwnode_call_int_op(fwnode, property_read_string_array, > > propname, > > val, nval); > > - if (ret =3D=3D -EINVAL && !IS_ERR_OR_NULL(fwnode) && > > - !IS_ERR_OR_NULL(fwnode->secondary)) > > + if (ret =3D=3D -EINVAL && !IS_ERR_OR_NULL(fwnode->secondary)) > > ret =3D fwnode_call_int_op(fwnode->secondary, > > property_read_string_array, > > Isn't !IS_ERR_OR_NULL(fwnode->secondary)) redundant? AFAIU, > fwnode_call_int_op() will already check the fwnode and only call the op > if the pointer is valid... It will shadow the error code, but it seems currently it's the same error c= ode. So, the question here is if we hide something important with that change. I dunno what is the best approach here (esp. taking into account that this is a fix), but ideally we should open code those macros to avoid double test for fwnode being valid. Because it seems that validation of fwnode and validation of the operation of the fwnode are orthogonal and here we mix them. I made this way for the sake of easier backporting and kicking off a discussion (as you already did). TL;DR: I think the introduction of the macros was a controversial move, for which I see pros and cons. --=20 With Best Regards, Andy Shevchenko