Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6869437pxv; Fri, 30 Jul 2021 04:37:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdP+IzXeZnzyH8GQhXyL1Vvz+tz4HqfasY4cdauceJz5k8jXu5kEhUHSbxqG1OOnEMhZUP X-Received: by 2002:a17:906:3e02:: with SMTP id k2mr2062528eji.479.1627645045363; Fri, 30 Jul 2021 04:37:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627645045; cv=none; d=google.com; s=arc-20160816; b=vnfkRSWsAbL9ytJFfgmzN68AdQabTe/T+WGQP3HYcZFgpcyTO/Wx7ucq+I99VuQa6b 4VpOpQLL/K2b2AG20EIxj56BEPMUPxeM4a37t1iCHaz9Ta2OEs0qE3OWwMv87xD8mrgl 5/S7qv8Ofyd/I69l82WMeqh+/V9oWx3m1TCMLSYOImYuAJG07t7s2EvPpvw784JTo74c fldSX+/8+9tN6u0wVWrX5lMNWFTWkjkVos46+8b9mvA8XtXDNz9VkdqfDa9kMQCjLKkC zFEBMwBXIccUhHnXq5yflDGeP2OzYdpDg1tIAYaMexDsherSLPYTvOXgDbA9hznlR8Mb qm2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=SR1xkUzOXOHCJfsRMFHIAGNy4B5TzprR01dnm4a9jUc=; b=my2oqG+E+7/MzEJAk/AsT7Et5oMlOzTLVdMcvqPDnzvUdjnZ86Za/bCUSJp0VriAlv SimdprFWkkjdAQJczfeZ2vKdVD74e6rhW3AnrkiHhHp8cF/mkKMJLXymfZhtbuGSZRIo WT/z6ca5aMKNiDBwovlsQUNQXS0BjZBCkFGCLizNesQ5bOi/+JBmyCTXayOsLDWz6d69 eLPNIs4Tn339EA+g16r/8D21JWgqkIcQhIz7poHLSYyoWNjZPmuNsuTEM03/DNMG+0u3 CgrYlfmJDYpOUkmEKFg0FopDjBiIfWcbV8ZdNdZfL5P5Fxjk+KZuGveadYw3XUc2BrJ1 cxWQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f21si1398240edf.129.2021.07.30.04.36.50; Fri, 30 Jul 2021 04:37:25 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238601AbhG3Lep (ORCPT + 99 others); Fri, 30 Jul 2021 07:34:45 -0400 Received: from mga18.intel.com ([134.134.136.126]:63437 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230157AbhG3Lep (ORCPT ); Fri, 30 Jul 2021 07:34:45 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10060"; a="200288228" X-IronPort-AV: E=Sophos;i="5.84,281,1620716400"; d="scan'208";a="200288228" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2021 04:34:39 -0700 X-IronPort-AV: E=Sophos;i="5.84,281,1620716400"; d="scan'208";a="500478875" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2021 04:34:38 -0700 Received: from andy by smile with local (Exim 4.94.2) (envelope-from ) id 1m9Qmd-003N12-Nh; Fri, 30 Jul 2021 14:34:31 +0300 Date: Fri, 30 Jul 2021 14:34:31 +0300 From: Andy Shevchenko To: Daniel Scally Cc: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, rafael@kernel.org, laurent.pinchart@ideasonboard.com Subject: Re: [PATCH 1/2] device property: Check fwnode->secondary in fwnode_graph_get_next_endpoint() Message-ID: References: <20210722201929.3585671-1-djrscally@gmail.com> <20210722201929.3585671-2-djrscally@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 23, 2021 at 02:04:59PM +0100, Daniel Scally wrote: > > On 23/07/2021 13:32, Andy Shevchenko wrote: > > On Thu, Jul 22, 2021 at 09:19:28PM +0100, Daniel Scally wrote: > >> Sensor drivers often check for an endpoint to make sure that they're > >> connected to a consuming device like a CIO2 during .probe(). Some of > >> those endpoints might be in the form of software_nodes assigned as > >> a secondary to the device's fwnode_handle. Account for this possibility > >> in fwnode_graph_get_next_endpoint() to avoid having to do it in the > >> sensor drivers themselves. > > ... > > > >> + ep = fwnode_call_ptr_op(parent, graph_get_next_endpoint, prev); > >> + > >> + if (IS_ERR_OR_NULL(ep) && !IS_ERR_OR_NULL(parent) && > >> + !IS_ERR_OR_NULL(parent->secondary)) > > Nit-pick, I would put it like: > > > > if (!IS_ERR_OR_NULL(parent->secondary) && !IS_ERR_OR_NULL(parent) && > > IS_ERR_OR_NULL(ep)) > > > > or > > > > if (IS_ERR_OR_NULL(ep) && > > !IS_ERR_OR_NULL(parent->secondary) && !IS_ERR_OR_NULL(parent)) > > > > for the sake of logical split. > > > OK; I'll do the second one, feel like it's better to have ep as the > first check. Fine, but also I have just noticed that parent should be checked before parent->secondary. Something like this if (IS_ERR_OR_NULL(ep) && !IS_ERR_OR_NULL(parent) && IS_ERR_OR_NULL(parent->secondary)) > >> + ep = fwnode_graph_get_next_endpoint(parent->secondary, NULL); -- With Best Regards, Andy Shevchenko