Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp666074rdb; Fri, 6 Oct 2023 15:14:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFrobET/GZEgk/jNRmxkrJ7NI71lDbsiymAUmsIcioJbAAP9m2u8SkN8pqhaset+z2Iv59a X-Received: by 2002:a17:90a:c08c:b0:276:b21a:9df3 with SMTP id o12-20020a17090ac08c00b00276b21a9df3mr9185084pjs.15.1696630487278; Fri, 06 Oct 2023 15:14:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696630487; cv=none; d=google.com; s=arc-20160816; b=qeCsuipWYHu1EY/ElecP9eRIhibg3XADA7ubkOuzVUaCW0eS0T1k9rP0f72HN84yrl AAp+TiZZpp7uXvqsuW1VXFctm5A2T7T0Fsn1QNNHNpYmtGBXeLDWx7FxfYSGWmynaAT7 zOr/ZmNz3aVAE/yU93Fv+j7zaIW4d75XB3A5kYgqOafm7F52cVhYI6/7Y5Ay9BjbvZTt 0y+/YphKy2C0UCSbsEzwyplzuRNkr8TS37qyVTyqGXoISsdc6kLtOLBqtfPsm+JDZVa3 eJAcjYJEkHPh3If+Yiaa8tDaNMX+5gRaiHgjrJ9T6PAPeN0rkMdYyUk6nhKLVRkQL7Yh Tqtg== 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=Qti7Kwj81qHM/etaR2hk1GyZRCJxyG+q5Re3Vl2xp6I=; fh=B/AtLyYC43B5KT2/bsvg559ulmfxosHNdAWML96pIrk=; b=tCPxRDb1q4BDRYPqzd5DlF6sTDeCYuD353LK4Nx2cH8eO/xka1TdvPIUuMlEurEas2 1/hpoyXNBCF1LSLsmMylNx3d3zo/UWsZI3yS1u3OIY6udBb3XP14CubuzoSYXXcAE/N8 hZxViet2F4+qZOZbqe4a8/Mqxry+nLRY6E868XqrDiovsT4utI30eoO9+LOmphyHKQeN Q8wKL+OU5orkFdLIkzzbGDrIH5kejhcOmlz9pwEYx0I2Iv9+L+W/6gwvVVIbb8nUiMwy FMsDm2a6tyqQ7gbav2weAeBQKueLOuWrhkbh4HmikhdHy+DqYawt6B1/CTpRILF5gUXb VHwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="lBmkwH/I"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id bv4-20020a17090af18400b0027744a9de69si6858671pjb.126.2023.10.06.15.14.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 15:14:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="lBmkwH/I"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id BCB5D802D2D4; Fri, 6 Oct 2023 15:14:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233594AbjJFWO2 (ORCPT + 99 others); Fri, 6 Oct 2023 18:14:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233397AbjJFWO1 (ORCPT ); Fri, 6 Oct 2023 18:14:27 -0400 Received: from mail-yw1-x1131.google.com (mail-yw1-x1131.google.com [IPv6:2607:f8b0:4864:20::1131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F2C9BE for ; Fri, 6 Oct 2023 15:14:26 -0700 (PDT) Received: by mail-yw1-x1131.google.com with SMTP id 00721157ae682-59bf1dde73fso31918347b3.3 for ; Fri, 06 Oct 2023 15:14:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696630466; x=1697235266; 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=Qti7Kwj81qHM/etaR2hk1GyZRCJxyG+q5Re3Vl2xp6I=; b=lBmkwH/ItZuVUWk6FvPdaztvI9Fq60egh8IXuulDjlwMbgxLSHg5JMAf0106GaIBYf jzejzeqn2sy4uZS57756h9yM+ciAQeTJaIqri7SOUht7/4sTXtcZ+DEpCTj3rZ4PNmuB Z4TsLLxRBIUXc61rURV3trLfasAe7h+GpoXKDPjtDpHRpLR27iwZR8fxhPPbPBcl1zOJ xNgZ/dn4Ao21osf5wK49btk+V4QjhtntN9Do17ZDyp59Di3P0/WuUnTxRyJ9niSnMLmE jjaPtcFkmf5xg5Z7DJ2BUq1y/U2HezutC86JhJUI58eAYqqiSe6CKpXKfjiC4ljZf8uL tNKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696630466; x=1697235266; 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=Qti7Kwj81qHM/etaR2hk1GyZRCJxyG+q5Re3Vl2xp6I=; b=lgHMa8X/BFmjGNZyvKnDwx0anIt9MOafEHdkQhNGONnmFuRqNEB3eOdD8kLJeppgcT gQAdmK6yd58D9r238dTDsmul/4FO3CMg61NfUgVMZPCB321mKKDD7SyW6McB8nunF+zX RxCxu5Jwey4yICqjHEfwjtWEctmZvM2QTlfVMZlM/muOH9UnPd9a6qTqFUvA/2tG9xBj lqUtBwUzUrY9IxpwGhQHGUmC/Ton76DWUjq3QuLltv1P83wCfqy7Y4M/FzacpRV/mDZz D2kDE9qi2w+BR/m7vkZ+ZXkRzgKwz4CBOEexYETfhEz+vGh9Xk3hR5Vtvg6A/PuTFrPV Br2w== X-Gm-Message-State: AOJu0YxOOawg4+wBc+EQNqx4jux7luqUCLwRDB5ry5tItKSXtBDciiWP nwyX/WBwXJ5q38SbmTTZAJ4HT2dWtSCThpYUj3Y6vl0c8GkJdftl23I= X-Received: by 2002:a81:a546:0:b0:592:5def:5c0d with SMTP id v6-20020a81a546000000b005925def5c0dmr10090456ywg.45.1696630465842; Fri, 06 Oct 2023 15:14:25 -0700 (PDT) MIME-Version: 1.0 References: <20231006115147.18559-1-brgl@bgdev.pl> In-Reply-To: <20231006115147.18559-1-brgl@bgdev.pl> From: Linus Walleij Date: Sat, 7 Oct 2023 00:14:14 +0200 Message-ID: Subject: Re: [RFC/RFT PATCH] gpiolib: reverse-assign the fwnode to struct gpio_chip To: Bartosz Golaszewski Cc: 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=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 howler.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 (howler.vger.email [0.0.0.0]); Fri, 06 Oct 2023 15:14:44 -0700 (PDT) X-Spam-Level: ** 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 in > all cases. > > Signed-off-by: Bartosz Golaszewski Acked-by: Linus Walleij because we want the code to work (rough consensus and running code) > - if (gc->fwnode) > + if (gc->fwnode) { > device_set_node(&gdev->dev, gc->fwnode); > - else if (gc->parent) > - device_set_node(&gdev->dev, dev_fwnode(gc->parent)); > + } else if (gc->parent) { > + parent_fwnode =3D dev_fwnode(gc->parent); > + device_set_node(&gdev->dev, parent_fwnode); > + gc->fwnode =3D parent_fwnode; 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. gc->of_node was the same duplicated before. 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? Yours, Linus Walleij