Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp820903rdb; Sat, 7 Oct 2023 00:04:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGz0qcDvoWTOiLK/WezWE/LaYp8oE5cnWploxGl0EwyLx3wwGaW63SULGLcgGQg52Qs4vKJ X-Received: by 2002:a17:902:a40f:b0:1c8:7800:a241 with SMTP id p15-20020a170902a40f00b001c87800a241mr8930726plq.0.1696662281768; Sat, 07 Oct 2023 00:04:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696662281; cv=none; d=google.com; s=arc-20160816; b=VgOTD/8p3S7tjAl3jRwDyPyCjOSd7ZLsvN68o/5y5KsAzmJbW3oIno6QHOUKlrmLt0 8wXYiP4pEOvSuFA6GF4OI77EUhTuAnuDrb2+CdXlO4DeEQh80FTNQfwLexMtDWeQYuA5 +Y7HDTHDEEYpIxveR8krkQsSM1LEwv1F1K43czTXk2Of8dAcvZHDoHC+f0DXyW4stenq 34PSLP4me6+pOHlcXDiVtnyvJuT7iALOyLwEDGoxNw0VdalbM+WtcveEfzgWgwSG5F5O ZEMWbeg78XK3wjMUL1BoVf+NTJ2Kbo9utw8G7qE75AoKAmwyWadrVj4HQJSdfcpRrf2z ee2Q== 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=EZVQpme/Czd5/VYAsQPo4BoFaas9BoftbCjcn0zFcSw=; fh=MmZe3YaxDSZUixne8N7sm/NginetnAkm48ih4p6NetU=; b=qgHuIPV2xapUhErEu5Vq6YKz/nlf7f8XDzG39GX9S3kV7EEzPKlYscQx3g16HYJc57 H2Th83aHhJKcOhLz0VUzOlWK4ppeAhfVc781ghYbS/7QBQuykN44DqwbhrjL7wSp97a9 9RphxPjTAOLj1s5QVAEumzb40dCK/H9VQ1HOMwnBOls7sqB5LlshCNgqPCO14tNSBQt/ HCm0KQSgr2tJ+xYSNNmGz9e55uT/7KbH9+EXAEBw5++I2J5EzzrV+mihJhNaSytA3Jdi Rj3bHnKN/1/mJB2LvMgkOD2JLlVLc5YSovtCpRVwXteUF3xQfL+4L1tJKXEFOzac57ej 2Xmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hTRSVczn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id o18-20020a170902d4d200b001a6f0eab385si5766241plg.55.2023.10.07.00.04.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Oct 2023 00:04:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hTRSVczn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 77A0880A49A2; Sat, 7 Oct 2023 00:04:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343629AbjJGHE0 (ORCPT + 99 others); Sat, 7 Oct 2023 03:04:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343578AbjJGHEY (ORCPT ); Sat, 7 Oct 2023 03:04:24 -0400 Received: from mail-oi1-x22c.google.com (mail-oi1-x22c.google.com [IPv6:2607:f8b0:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72420BD; Sat, 7 Oct 2023 00:04:23 -0700 (PDT) Received: by mail-oi1-x22c.google.com with SMTP id 5614622812f47-3ae65e8eb45so1953303b6e.1; Sat, 07 Oct 2023 00:04:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696662262; x=1697267062; 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=EZVQpme/Czd5/VYAsQPo4BoFaas9BoftbCjcn0zFcSw=; b=hTRSVcznJYi1i4XDYx3+tVSmKH/Pu5jUsfxKuHPcR7FeVHjjhy3fAxQP7M5WMEAbbb RfXKozW0yZv6ena1ZD0BLPAifHEz/0V6bVLbrmLyC64SRQc/IbJYGS6gf1VR9KF0ssez rdqVzaZkQCFfD0o/kNX/rSdWcxWIh9T4ghUUDEBNhkwVUNws+5WOY8xQNqthVusj3dWN bWKI++Uss43e0Qxr5LxqX9vlaAIJE44vhVd2QEcMCMAA9RaSwy08AFT2g2SVxfR3d2Oc I+/0AWdVRRPtD2B0CQqVMdinWoZnaCJUeWQXyXOfQdiOhNQsUScOrFz+6kFXac20W1HN Alug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696662262; x=1697267062; 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=EZVQpme/Czd5/VYAsQPo4BoFaas9BoftbCjcn0zFcSw=; b=shLzKtL+mzh6SCKbZUgWhBZwNpEp/olI6HK550t9oBvmhlCxRx3/fRCsRAWhRWdLE4 7VTLZ6CyE0T1mSRz/Z1ZYuR6DAqT0u1yFuNicXWOuW4G13xxHX5qHHTvEcZnKjYtC2fA XuYJOiSzGMl8uJU1PgBSlnes9ESapSNLZcvcBp+ryqk9YUEiIW3wO/ig/0dNgWaHw9Ed RZbwmL4dtcHs0TMk7NgJDUqClNW1PBUIgmuCEOKtI+MQ+YxQYjoa5KHbxTHFA2an1jA3 j+emHvHISJ8vMrBm0jd41ueLHlI7tNSH/wDFIgrUFXxvBWaDoJTelKN/XiYBSc6mKBxf abxw== X-Gm-Message-State: AOJu0YwhXn8ev9Iznb430st828HI1efl4rLq3ioZxQEEBI3718eA5Gp5 5gSG/l5eLkOYrIgPfStjdp7b/j6eNiTEsfVHFaU= X-Received: by 2002:aca:2810:0:b0:3ad:fdfb:d384 with SMTP id 16-20020aca2810000000b003adfdfbd384mr9676137oix.53.1696662262569; Sat, 07 Oct 2023 00:04:22 -0700 (PDT) MIME-Version: 1.0 References: <20231006115147.18559-1-brgl@bgdev.pl> In-Reply-To: From: Andy Shevchenko Date: Sat, 7 Oct 2023 10:03:45 +0300 Message-ID: Subject: Re: [RFC/RFT PATCH] gpiolib: reverse-assign the fwnode to struct gpio_chip To: Linus Walleij Cc: Bartosz Golaszewski , Andy Shevchenko , 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=3.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 groat.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 (groat.vger.email [0.0.0.0]); Sat, 07 Oct 2023 00:04:39 -0700 (PDT) X-Spam-Level: ** On Sat, Oct 7, 2023 at 1:14=E2=80=AFAM Linus Walleij wrote: > On Fri, Oct 6, 2023 at 1:51=E2=80=AFPM Bartosz Golaszewski wrote: > > > 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. 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. > > > > Signed-off-by: Bartosz Golaszewski > > Acked-by: Linus Walleij > > because we want the code to work (rough consensus and running code) > > The core of the crux is that we have > information duplication with a reference to the fwnode in two > places. One in gdev->dev and one in gc->fwnode. No, we don't. We have plenty of drivers that have gc->fwnode =3D=3D NULL, which means that it is shared with the parent device. ... > A gdev is created for each gpio_chip so in my naive brain we could > get rid of gc->fwnode and only have the one inside gdev->dev? > +/- some helpful getters/setters if need be. > > Or what am I thinking wrong here? That would work I think. But I'm definitely against this change. It is the way to nowhere. We should really be quite strict about fwnode and do NOT assign the gc one behind the provider's back. If something is not working in this scenario, that should be fixed and not with a hack like this. --=20 With Best Regards, Andy Shevchenko