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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A4EDE81DF5 for ; Fri, 6 Oct 2023 13:15:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232357AbjJFNPG (ORCPT ); Fri, 6 Oct 2023 09:15:06 -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 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org 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