Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp831975rdb; Sat, 7 Oct 2023 00:40:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHdOmfR8tzC3PvtMSsMBaV3CcHcVPRkQgNGiMe/iH98PU3qH1cvPq2ahmxiV1OpOvfi+EEf X-Received: by 2002:a05:6a00:1a92:b0:690:bdda:7c35 with SMTP id e18-20020a056a001a9200b00690bdda7c35mr11528977pfv.1.1696664434944; Sat, 07 Oct 2023 00:40:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696664434; cv=none; d=google.com; s=arc-20160816; b=q0jnFfMyXtifHY3QArL+6eORtWs6aJoxTirSSS2vPpb49epoVQU1yJDOh6uLz8o8pW QejPmPPL4IFHbQTnatOfIZmNwi7p6nIIfQ508sxrHFodDu494XeIBO2vLa0ov+twJjuk TbEch5enaJahu9fYjQiDhXPajLOe1XpnOoYuGsjyku+xovobljCJzw9hshhwK09S4qub 4d1NHiB2xRECGZ9XMY2P8sXMYVVZItb7CYipmJEN23J2kQs/3KSfDuU5T06ASYkU8UfL ZoV+3Xx6waPq3pAkpnEN0c1i0hL7pzKvlgOtoNj0kdbExmHdRcngKMSbr3tH3D2dDHGp G6Ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=kr4X2Glt7ojcrpUvAgx3Algpp7Vi2HDvhb7TfvIzcs4=; fh=TM4rogEc0ruu3iKpudcQ1Fo7htn3cxAl0dmUSA+11E4=; b=HN5sD/tkkEDMQl02P3dcvv5NcEHpEz3pH9B85ywRtmQszIiKWiA4ePmQlnVecM0uen Stzfuvom3FlTflLhMBJyMx3Yi6+Fd0kgtfNELKAtvu0ncc7lnOZdp54WAvHx7vPvqBgP 7cMlG2+qasD6y5Dx6fsFg/EKoZOYWdV8jea2aXCAYQOn40OZEVE77uF0ed/J5QP++Dox 4wWwhMqrIZlmf+iCUUo7Jr24TOoSuvnhm4OyQ3qH/ddqDLlXpGuMyWX6HtzTyMiHd2+K wnlZkinC9ZLBa9Fyqxa8Ot1M3g1+gVu+7x38YEUBlPmxUreJH1h2VHZ4cSnBjeiq2Ocw 94jA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id j22-20020aa78016000000b0068a3c575900si2907187pfi.84.2023.10.07.00.40.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Oct 2023 00:40:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 92FB780AD26C; Sat, 7 Oct 2023 00:40:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343692AbjJGHj6 (ORCPT + 99 others); Sat, 7 Oct 2023 03:39:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343611AbjJGHj4 (ORCPT ); Sat, 7 Oct 2023 03:39:56 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B36DBD; Sat, 7 Oct 2023 00:39:55 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6600,9927,10855"; a="448101647" X-IronPort-AV: E=Sophos;i="6.03,205,1694761200"; d="scan'208";a="448101647" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Oct 2023 00:39:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10855"; a="729118298" X-IronPort-AV: E=Sophos;i="6.03,205,1694761200"; d="scan'208";a="729118298" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga006.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Oct 2023 00:39:53 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.97-RC1) (envelope-from ) id 1qp1ug-00000003Xq6-18l2; Sat, 07 Oct 2023 10:39:50 +0300 Date: Sat, 7 Oct 2023 10:39:50 +0300 From: Andy Shevchenko To: Linus Walleij Cc: Bartosz Golaszewski , 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=2.6 required=5.0 tests=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 fry.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 (fry.vger.email [0.0.0.0]); Sat, 07 Oct 2023 00:40:25 -0700 (PDT) X-Spam-Level: ** On Sat, Oct 07, 2023 at 12:22:01AM +0200, Linus Walleij wrote: > On Fri, Oct 6, 2023 at 9:08 PM Bartosz Golaszewski wrote: > > I don't see any good reason for it not having the fwnode assigned. > > User calling gpio_device_find() will have to jump through hoops in > > order to match the device by fwnode > > Yeah I would add > > struct fwnode_handle *gpiochip_get_fwnode(struct gpio_chip *gc) > { > return dev_fwnode(&gc->gpiodev->dev); > } > > so it's easy for external users to get the fwnode if they really need it. > This and a few more changes and we can drop gc->fwnode altogether > can't we? This would work, but the problem here is to understand which fwnode (semantically) the caller wants to use. One is the GPIO device's, and the other is what provider explicitly assigned. Currently the latter case is transparent in a sense that GPIO device will get the same fwnode as GPIO chip submitted by the provider. Internally GPIOLIB must use GPIO device fwnode and rely only on it. Externally it depends. Basically it's provider's business to know if it is safe to use gc->fwnode or not and when. -- With Best Regards, Andy Shevchenko