From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3DD836E477; Tue, 24 Feb 2026 09:43:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771926227; cv=none; b=cpNvwfg/s4eKIq92Jk2CZmlLi6dgxwdsIjyPYtTcdcT49jSLg8QsEjVOH8wJ/Si2qIEr1fQkb4jcquxc40z8Z2kS8BEc6v6MIHQm6nGhuX/DDG2KJ1yUOsmwEkUToqr3Czb0A6K/rOl0XgoJa2w1RncGp6H3105EsHlRyDjWPuw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771926227; c=relaxed/simple; bh=26QMdg0hEVO6yJPDPsExraWWw+rvU+ntty1r2FB2pfs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dcBzEJ4nQ4sjybbYBBph/PZajhP/hzIMJkNXMDBDWUsi/HfiQYLfxYth0h2FviHl8b1Kf9087mlgt6g4yp0b44MKf1UWRs15QBuRhH/oZJTNH/qB/5q2O7piXS1HsNVrVMCqOnB9iJ0XWabUataCxG8OT268UeNkwa8aRHUC32o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Yd4Iq+F/; arc=none smtp.client-ip=198.175.65.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Yd4Iq+F/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1771926226; x=1803462226; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=26QMdg0hEVO6yJPDPsExraWWw+rvU+ntty1r2FB2pfs=; b=Yd4Iq+F/BgaYrvIIOdTDGyM4q71q8G7cBgjuiwEFEAUUSdqaRJ7cFQqZ w/Ov4C8DEjhVbmJK40ZSu1pZNB1gYcbHjE1OpwN1Fk5h1WGWErTtC8c85 v5U4nh24GZZXcPb3ifQCbvkczd0aVKV+k875G5EpoHYuTuJiEQBFOtyXL 3nlBvQNPmgPxfbOauNtfL1rdCdZlb3WN3ZlYcNwvQEcK3tf/J4cp/XrOe 0/HBEorwLk5/H+YVYjEzbxMXttg0nRFm1L7Pp+Mh3w2teb8FMCPov2gI6 G5qos4d8kE30KVZnVuLQnLW3WWCCjQeo849Sl9RTtffeRX5Xlqgs/X9E4 A==; X-CSE-ConnectionGUID: yu71uJsERP+NVVMrfhOFFg== X-CSE-MsgGUID: OwlX9kcGSsGiqXxIX4N/YA== X-IronPort-AV: E=McAfee;i="6800,10657,11710"; a="72640380" X-IronPort-AV: E=Sophos;i="6.21,308,1763452800"; d="scan'208";a="72640380" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Feb 2026 01:43:45 -0800 X-CSE-ConnectionGUID: LInzymtYRXqIKLfPflPCbw== X-CSE-MsgGUID: wjJlLgC0TFOUWcphC7T1LQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,308,1763452800"; d="scan'208";a="246430905" Received: from egrumbac-mobl6.ger.corp.intel.com (HELO localhost) ([10.245.244.146]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Feb 2026 01:43:41 -0800 Date: Tue, 24 Feb 2026 11:43:39 +0200 From: Andy Shevchenko To: Sakari Ailus Cc: Bartosz Golaszewski , "Rafael J. Wysocki" , Bartosz Golaszewski , Greg Kroah-Hartman , Danilo Krummrich , Linus Walleij , Dmitry Torokhov , Daniel Scally , Heikki Krogerus , Len Brown , driver-core@lists.linux.dev, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org Subject: Re: [PATCH v2 2/2] gpiolib: match secondary fwnode too in gpio_device_find_by_fwnode() Message-ID: References: <20260223-device-match-secondary-fwnode-v2-0-966c00c9eeeb@oss.qualcomm.com> <20260223-device-match-secondary-fwnode-v2-2-966c00c9eeeb@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo On Tue, Feb 24, 2026 at 10:56:16AM +0200, Sakari Ailus wrote: > On Tue, Feb 24, 2026 at 09:47:57AM +0100, Bartosz Golaszewski wrote: > > On Mon, Feb 23, 2026 at 11:07 PM Sakari Ailus > > wrote: ... > > > > > > static int gpio_chip_match_by_fwnode(struct gpio_chip *gc, const void *fwnode) > > > > > > { > > > > > > - return device_match_fwnode(&gc->gpiodev->dev, fwnode); > > > > > > + struct device *dev = &gc->gpiodev->dev; > > > > > > + struct fwnode_handle *node = dev_fwnode(dev); > > > > > > + > > > > > > + if (IS_ERR(fwnode)) > > > > > > + return 0; > > > > > > + > > > > > > + if (device_match_fwnode(dev, fwnode)) > > > > > > > > > > Could device_match_fwnode() match secondary fwnode as well? > > > > > > > > In the previous discussion on this, Andy was against doing that due to > > > > the concern that it might introduce subtle bugs, which I agree with. > > > > > > Could you elaborate or provide an example? I believe you ask me. Okay, the sophisticated case I have in mind is the intel_quark_i2c_gpio.c which provides a GPIO device with a list of children. First of all, it seems broken as it rewrites the secondary link for the I²C device. (Which makes me think that we need to have a copy of the [primary] fwnode in the children devices of MFD, but I don't know how to refcount that properly). The gpiolib-acpi-core.c has a matching function via ACPI_HANDLE(). So it might be not affected by this. What I don't know is USB Type-C and USB DWC3 code where it's much more complicated. And I'm not in a position to state that the change won't affect those. > > > The function has some 27 users although few are individual drivers. > > > > > > My understanding is that we only have the secondary fwnode for being able > > > to attach objects from different backend to the same node. The fwnode API > > > in the meantime generally tries to hide the existence of the secondary > > > fwnode; a rewrite (which ideally would have happened perhaps a few years > > > ago?) would probably make the fwnode a linked list instead so we'd lose > > > that secondary pointer in the process. > > > > It already is a (singly) linked list. Ideally it would be a > > With two entries at most. There is no technical limitation based on the data type. > > doubly-linked list moved into struct device with struct fwnode_handle > > having no concept of primary and secondary nodes. > > I'd think we had that list in struct fwnode_handle, which will still > represent nodes. But let's see the details when someone gets to implement > it. :-) In the case above single or double linked list doesn't solve the issue of the corrupted (parent) fwnode. We need also to have a siblings list so it looks more like a tree. -- With Best Regards, Andy Shevchenko