From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5266CC83F2C for ; Mon, 4 Sep 2023 09:00:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347307AbjIDI7H (ORCPT ); Mon, 4 Sep 2023 04:59:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236003AbjIDI7F (ORCPT ); Mon, 4 Sep 2023 04:59:05 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 157D518C; Mon, 4 Sep 2023 01:58:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1693817939; x=1725353939; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=W7fo/oErm2qTTpiwFnbFqLwIaJ6SfixvCi/d8bot2KQ=; b=XDLgGvSKKjNIurgWbOILdcDGKzWRemOp83ASvunv5S2qnpBgWm7th1im 8z0AW8gQlusLWmr/BfDlkFQRP/WP7b69GOhip1XKVAaVM+AHQ8rB/f6La RkNNrnCNsxKFOXc2teGzVudoYSFBMPLqlwjTy735FU0T3Tm8L9NSKWBOo g1RU8AP1QdVDyEu/y08jAgcRmeawGoNMYj/Z8NWMZ+waxIXNIfxZbKQQm i+q9SPemd3Y8HQR+vRi9mSupgmxZrgcFbMGwlOF1h9JaurrMQX/bamzjn RDUW3YAqYKRvE7MgtXsTya/8QnjtSamMDmHcrtZov1rkf+y/uQSnb58Ja w==; X-IronPort-AV: E=McAfee;i="6600,9927,10822"; a="379269245" X-IronPort-AV: E=Sophos;i="6.02,225,1688454000"; d="scan'208";a="379269245" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2023 01:58:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10822"; a="740679273" X-IronPort-AV: E=Sophos;i="6.02,225,1688454000"; d="scan'208";a="740679273" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga002.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2023 01:58:55 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1qd5Q4-006NZP-2P; Mon, 04 Sep 2023 11:58:52 +0300 Date: Mon, 4 Sep 2023 11:58:52 +0300 From: Andy Shevchenko To: Bartosz Golaszewski Cc: Linus Walleij , Kent Gibson , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: Re: [PATCH] gpio: sim: don't fiddle with GPIOLIB private members Message-ID: References: <20230901183240.102701-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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Sep 02, 2023 at 04:40:05PM +0200, Bartosz Golaszewski wrote: > On Fri, Sep 1, 2023 at 11:10 PM Andy Shevchenko > wrote: > > On Fri, Sep 01, 2023 at 08:32:40PM +0200, Bartosz Golaszewski wrote: ... > > > -static void gpio_sim_free(struct gpio_chip *gc, unsigned int offset) > > > > Why is this? > > Dunno, some git shenanigans? Time to use --patience then? ... > > > - /* Used by sysfs and configfs callbacks. */ > > > - dev_set_drvdata(&gc->gpiodev->dev, chip); > > > + /* Used by sysfs callbacks. */ > > > + dev_set_drvdata(swnode->dev, chip); > > > > dev pointer of firmware node is solely for dev links. Is it the case here? > > Seems to me you luckily abuse it. > > I don't think so. If anything we have a helper in the form of > get_dev_from_fwnode() but it takes reference to the device while we > don't need it - we know it'll be there because we created it. > > This information (struct device of the GPIO device) can also be > retrieved by iterating over the device children of the top platform > device and comparing their fwnodes against the one we got passed down > from probe() but it's just so many extra steps. > > Or we can have a getter in gpio/driver.h for that but I don't want to > expose another interface is we can simply use the fwnode. dev pointer in the fwnode strictly speaking is optional. No-one, except its solely user, should rely on it (its presence and lifetime). -- With Best Regards, Andy Shevchenko