Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp373379rdb; Fri, 6 Oct 2023 06:15:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGe++RGSlphRKxc6Y3goN49au4y1jk3XldasoqURR3bbDTCucJkhr28U9p/mbbv4AlNdvur X-Received: by 2002:a05:6a20:1454:b0:16b:c22c:f99c with SMTP id a20-20020a056a20145400b0016bc22cf99cmr1683444pzi.32.1696598115392; Fri, 06 Oct 2023 06:15:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696598115; cv=none; d=google.com; s=arc-20160816; b=p/f4HS9Y4tqc4fhruEhZIZ92NaGzNdiNlc/hK3jF9NncWbHtmGwcIZ3dg76GrD7FvZ dWq6aHT3JkEDQuisaRoqK5fL+exHgP/qybGrxokDriB5MGCYcIPiJXl4l93Rz7Oz4vFI Pxo6+sxmwq4zhDxTQ8qFcCTyGiVGGklgiDqw3MSB4qDWEdlmegM3DnbNR/LpdXGw862q JjqKxcaVH3Q80d2oP5HPszpG18nXSd8CIrliAf4qXSkBRPSDCPnW3vY9dfGJ0q98+M5z Sb3lz6U9T2Sna2sl//tUuKQqFU+6xHVVj5yW4cPildfE7fFhlsRqUXqRoidQfcUpS7as Heig== 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=wUti7mTwrGb1G371LxWTd5pKSwX0v7TrjR7xHAFvGt4=; fh=8zzPHVF/p9r0cc6oSFRH8dycuoc95V92ffiysEQGGYk=; b=Gwr4GbKbTdDLNnUxy8sJKdtuY2N2Xt1TZlVTmW59AAXpDTzb6Z/2ydDzIUGfaFZ3FQ 4Rs6+gkqb2YKmAWpDSxwXueSnWrHnovnH764QvWEQtOUpw0GVawskqF5TryvpuBOlA8c FfqEedhysFCx+1BQ5s9yaamE1GKJ3Cf/cB3yhL7a710L+mqHkcUP0GVnUDz3CKSNgMuP /tGYf3z/Esz1CXXMZ1w4fxo2KQCtHzv7/HGzAGE6EnQ+w1gGzMx/8B0dbcxUDwFNAVv3 bBx8YTzrt9/vnF02SPVJ1k4PzYYMo85CZuRrJXVGMktzOt4pi5av/WK+ERCEu08YQ6Tj odHw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id e7-20020a056a001a8700b0069100a207c2si1503480pfv.300.2023.10.06.06.15.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 06:15:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 54D4D80267E4; Fri, 6 Oct 2023 06:15:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232362AbjJFNPH (ORCPT + 99 others); Fri, 6 Oct 2023 09:15:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232342AbjJFNPF (ORCPT ); Fri, 6 Oct 2023 09:15:05 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F97EA6; Fri, 6 Oct 2023 06:15:04 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6600,9927,10855"; a="383639098" X-IronPort-AV: E=Sophos;i="6.03,204,1694761200"; d="scan'208";a="383639098" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Oct 2023 06:15:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10855"; a="781655164" X-IronPort-AV: E=Sophos;i="6.03,204,1694761200"; d="scan'208";a="781655164" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga008.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Oct 2023 06:15:00 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.97-RC1) (envelope-from ) id 1qokfS-00000003IrP-0WWv; Fri, 06 Oct 2023 16:14:58 +0300 Date: Fri, 6 Oct 2023 16:14:57 +0300 From: Andy Shevchenko To: Bartosz Golaszewski Cc: Linus Walleij , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Dipen Patel , Bartosz Golaszewski Subject: Re: [RFC/RFT PATCH] gpiolib: reverse-assign the fwnode to struct gpio_chip Message-ID: References: <20231006115147.18559-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231006115147.18559-1-brgl@bgdev.pl> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_SOFTFAIL 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 06 Oct 2023 06:15:14 -0700 (PDT) On Fri, Oct 06, 2023 at 01:51:47PM +0200, Bartosz Golaszewski wrote: > From: Bartosz Golaszewski > > struct gpio_chip is not only used to carry the information needed to > set-up a GPIO device but is also used in all GPIOLIB callbacks and is > passed to the matching functions of lookup helpers. > > In that last case, it is currently impossible to match a GPIO device by > fwnode unless it was explicitly assigned to the chip in the provider > code. That's expected behaviour. > If the fwnode is taken from the parent device, the pointer in > struct gpio_chip will remain NULL. > If we have a parent device but gc->fwnode was not assigned by the > provider, let's assign it ourselves so that lookup by fwnode can work in > all cases. I don't think this is a good change. We paper over the real issue where we and callers need to understand what they are looking for. ... > This is something that Dipen reported with one of the tegra drivers where > a GPIO lookup by fwnode does not work because the fwnode pointer in struct > gpio_chip is NULL. This patch addresses this use-case. I am not sure I understand the problem here. All these should have been addressed already, no? So, the GPIOLIB should use dev_fwnode(&gdev->dev) inside it, outside it the GPIO drivers are free to use gc->fwnode as long as they understand the lifetime of the respective object. -- With Best Regards, Andy Shevchenko