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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3E7E2EE14A5 for ; Wed, 6 Sep 2023 15:31:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DZ/BFDJu8ZK5LKc+vrVFhB9ejMPV+K+6SdXszfqCyGc=; b=VMKlZulSw6pWVP +g5LGLnuGNHSS8lFz6Gkup3j0LWBQ4OPw67PDncI+0R1zfqLwVzDPsAyG2rWX9Aj0H35IyutLdnuR VVqVz5bjwzAhM4sVmy8l/Vecs8s0VA1cw7uZDg9mPT8/h8yAKJoRPddoui4aQVxfT2Uu1888uix40 7RbpFsxhDb/Ld++KGeDbxHx/8axNBPdYQ9hL8e1QkYSxsm3OKhdBFJtwIECEsqU1N+Gj38yNpKvRZ +7czOFh5x1RPxFVNhQWNlT+sOzoxqRJ8anbn9FbxKBkGJz/mibe/PtakbOot5zsVWTbyvcNrZ3xfF UrWTzhdvsmgZEbt0nvKw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qduUn-00AOzy-1f; Wed, 06 Sep 2023 15:31:09 +0000 Received: from mgamail.intel.com ([134.134.136.31]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qdtKE-00AD4N-19 for linux-arm-kernel@lists.infradead.org; Wed, 06 Sep 2023 14:16:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694009770; x=1725545770; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=0VcmV16fT8VmJAsdObBcJuWeG66DH8vv5hB7iUtf9Fk=; b=FK7FcV8wjiA5o761O6vlXFNKX1JGJguHCjFcW8CjRcZUdhNCbtguh6N1 PRcnrJc8WwkDtRhuViSyoqp+fKxK9Ri9eDUWpDO4EJ1tdRfbKlhQt1LlE JPSyQ6zWM50PLP4Eno8ljNdsJ99D5wdif5DTRtm4qGMTGVGtT5ZHqfTFR ilHIKjp4/S00dJncqRfIesBqib1Aozrqg6tmfaBJZrXEtPnGKA874aSJe 9kCpXaQujdrnJNRB9mqm7HTQQLRtAUjEzSJQbs+4sa6Hb6UuORiIvLcIW nlyylUa2lHqyK9am4KTeG2T3/qTaMjQqvzNFOoYUk4j2S+dyAjBaDAiU4 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10825"; a="441051170" X-IronPort-AV: E=Sophos;i="6.02,232,1688454000"; d="scan'208";a="441051170" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2023 07:16:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10825"; a="735072513" X-IronPort-AV: E=Sophos;i="6.02,232,1688454000"; d="scan'208";a="735072513" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga007.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2023 07:16:03 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1qdtK3-006xcz-1V; Wed, 06 Sep 2023 17:15:59 +0300 Date: Wed, 6 Sep 2023 17:15:59 +0300 From: Andy Shevchenko To: Bartosz Golaszewski Cc: Aaro Koskinen , Janusz Krzysztofik , Tony Lindgren , Russell King , Mika Westerberg , Linus Walleij , Dipen Patel , Thierry Reding , Jonathan Hunter , Hans de Goede , Mark Gross , linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, timestamp@lists.linux.dev, linux-tegra@vger.kernel.org, platform-driver-x86@vger.kernel.org, Bartosz Golaszewski Subject: Re: [PATCH 04/21] gpiolib: provide gpio_device_get_desc() Message-ID: References: <20230905185309.131295-1-brgl@bgdev.pl> <20230905185309.131295-5-brgl@bgdev.pl> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230905185309.131295-5-brgl@bgdev.pl> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230906_071610_438235_3F2E5694 X-CRM114-Status: GOOD ( 18.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Sep 05, 2023 at 08:52:52PM +0200, Bartosz Golaszewski wrote: > From: Bartosz Golaszewski > > Getting the GPIO descriptor directly from the gpio_chip struct is > dangerous as we don't take the reference to the underlying GPIO device. > In order to start working towards removing gpiochip_get_desc(), let's > provide a safer variant that works with an existing reference to struct > gpio_device. ... > +/** > + * gpio_device_get_desc() - get the GPIO descriptor corresponding to the given > + * hardware number for this GPIO device > + * @gdev: GPIO device to get the descriptor from > + * @hwnum: hardware number of the GPIO for this chip > + * > + * Returns: > + * A pointer to the GPIO descriptor or ``ERR_PTR(-EINVAL)`` if no GPIO exists The known constants can be referenced as %EINVAL. > + * in the given chip for the specified hardware number or ``ERR_PTR(-ENODEV)`` Ditto. > + * if the underlying chip already vanished. > + * > + * The reference count of struct gpio_device is *NOT* increased like when the > + * GPIO is being requested for exclusive usage. It's up to the caller to make > + * sure the GPIO device will stay alive together with the descriptor returned > + * by this function. > + */ -- With Best Regards, Andy Shevchenko _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel