Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp586389rdb; Fri, 6 Oct 2023 12:08:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IExdtRjzex/HAEXPwW1CmvViZbe1ZxCpcE6Jx4t4JK2b114cJiy9oxdOCFcet1ZJRiMzKl7 X-Received: by 2002:a05:6a00:13a3:b0:693:4552:cd6a with SMTP id t35-20020a056a0013a300b006934552cd6amr10392818pfg.16.1696619299866; Fri, 06 Oct 2023 12:08:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696619299; cv=none; d=google.com; s=arc-20160816; b=wRIgul4vm/lmZYu3L69WYm6jtviIucxMgHTjMx0IobxjmNHybv7g/VxY1THKhnBi1V zBcgSVBX64JEumogbvKPToRg5No4otU5/N9AF6Lqty3eki4qA6efNY3BjC+jqs26NYiu VuxBMHElA9hRyn2I5PPJCe6R418ZqrQwMPRw2RIXLaoV0N0Rq+O2aLsw0h1INJDWN8ut Ydt+G/QRFqGFs3Niv6Qg9NlK88PtR75HnM7oMZarmBe5IAT9alJK0axrVTl47SVbLK6h zKCls719FliLRlmAB4/aB5RcqiFg4eHUpDufgoEaQEGbOr05Ccr6DXgRjA1aUtMWMoFs xmYQ== 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=zxlLhkoj1Kmhin2Qlx3Q+WrvoF0R0Cb9Ja4Y1YVu+4c=; fh=DdYqE1ZUvFfH+rdiovq4I3rjmRz4OFtnmkHAPd6Y/CY=; b=eJTJqYE8bqjj1P6V8180b5Ux6DAqKw+IpgikKf8CkHbaMZ6Y2nEUVv2tifJpJ1ZnCs my99is1B4Q71mUHC6XqY18ej2L8fBaC71sIplxzdmXWmkLfdX3zkb40fiMdwdkSZWqLG 17mmOlP+booeov718OIiYjMkhugZA6JWg4TePtLaK/oBAoNRuYfILErBnWengP4TuUz3 /vdPS/wdYigjpaZDrWwsCqdtxt3gfPlD1Bww+Q3YeBse4/z99swSxmEn/0l1jwwgsicL vE7qPmI7EM56qaQLfgixHVPbRN9dsyqIoDQZvO+YIIfBdn/2IB5Wv5/D91vRp6bKioAw UfSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=TLDxoEpd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id l184-20020a6388c1000000b00537c6c285a0si4266343pgd.167.2023.10.06.12.08.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 12:08:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=TLDxoEpd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id B037D8032EE3; Fri, 6 Oct 2023 12:08:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233356AbjJFTIK (ORCPT + 99 others); Fri, 6 Oct 2023 15:08:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233363AbjJFTII (ORCPT ); Fri, 6 Oct 2023 15:08:08 -0400 Received: from mail-vs1-xe2f.google.com (mail-vs1-xe2f.google.com [IPv6:2607:f8b0:4864:20::e2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EB0CAB for ; Fri, 6 Oct 2023 12:08:06 -0700 (PDT) Received: by mail-vs1-xe2f.google.com with SMTP id ada2fe7eead31-45274236ef6so1193984137.3 for ; Fri, 06 Oct 2023 12:08:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1696619285; x=1697224085; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=zxlLhkoj1Kmhin2Qlx3Q+WrvoF0R0Cb9Ja4Y1YVu+4c=; b=TLDxoEpd1VVzP2mVNHKHE5dptEcJRqLnM8p/qOjD0CgPHt51KMoCLmd5kw1nzxcSWY yJNamVcOdDvcSGyjnliAn82Ky8Y63Z7IabIObEorEe9cIogWLZ5e8bP74QFLqjkg4zip FWFgfyWxf7PcJNAMeDQYPxhUyVWyF3a1+5qlbHHghJK1W0r6kuLePkF6M8lrdzk5exmd aJYstLDJ8Qew+l0SINgLx4F5p+FbNjYLrp8WZ8UWXpiDr3wyd1fbvCjXICu7wQ4yx+mW wGy0ug/gFbcSwavz4gXMQlt8USDnpXJGytFLgsbM1rnu62QUaby5f8/hTqK9NTnA+o8j 4gxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696619285; x=1697224085; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zxlLhkoj1Kmhin2Qlx3Q+WrvoF0R0Cb9Ja4Y1YVu+4c=; b=wKukhDmytubN4H/LoUey8C9ellS7qlW2fE3hGw1toU4sNp2D8xnoKaC49ioDpwV7cA isCTQYtxIg8wvJoomsKHxeYU5Vqn+uVE+7JHQ+1f8DyZBnk0f0A8KOHFGR1fb2tDDenE YVtLjnm7oPwDeIqMb00bwjf42NJr9EEEj3hBqecxcNhkDdarzsXRtd02LV7IJ8OGB5X0 ZtJlTLfmRhYFCwo4E1Qr92v1bv3yiFhqykhxhfAVaoCwEAV4xzqUfjDJ/wKEqvkIO9vu u95qZhxlV1SsAFOpgV0LfWJAghgnZrpAI+p08IkuZ9fnzCfAp5lOOhyafVHSLN6fZNlw 1uZw== X-Gm-Message-State: AOJu0YxiubQ86vwn3ukPhZtjprMMAyIZkp958LOn7Yo4wCcWLaymUB+U qBJh89VS7GTkPRcnAGcXMXWhbgUnnL1yF4KKIzwRLpGBMgt8BGDF X-Received: by 2002:a67:fdd0:0:b0:454:2d1e:6ced with SMTP id l16-20020a67fdd0000000b004542d1e6cedmr9726691vsq.27.1696619285327; Fri, 06 Oct 2023 12:08:05 -0700 (PDT) MIME-Version: 1.0 References: <20231006115147.18559-1-brgl@bgdev.pl> In-Reply-To: From: Bartosz Golaszewski Date: Fri, 6 Oct 2023 21:07:54 +0200 Message-ID: Subject: Re: [RFC/RFT PATCH] gpiolib: reverse-assign the fwnode to struct gpio_chip To: Andy Shevchenko Cc: Linus Walleij , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Dipen Patel , Bartosz Golaszewski Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=2.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_SBL_CSS, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Fri, 06 Oct 2023 12:08:17 -0700 (PDT) X-Spam-Level: ** On Fri, Oct 6, 2023 at 3:15=E2=80=AFPM Andy Shevchenko wr= ote: > > 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. > Is it though? We now have a GPIO device that represents a piece of physical hardware that has an fwnode assigned and the associated GPIO chip (tied to that device) that has none. How is that logical? It's not coherent. I'm not surprised users of that code will be confused - like Dipen in this case. Bart > > 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 i= n > > 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 whe= re > > a GPIO lookup by fwnode does not work because the fwnode pointer in str= uct > > 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 > >