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 4882BEB8FD8 for ; Wed, 6 Sep 2023 14:16:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240492AbjIFOQN (ORCPT ); Wed, 6 Sep 2023 10:16:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230435AbjIFOQM (ORCPT ); Wed, 6 Sep 2023 10:16:12 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2E4910CC; Wed, 6 Sep 2023 07:16:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694009769; x=1725545769; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=0VcmV16fT8VmJAsdObBcJuWeG66DH8vv5hB7iUtf9Fk=; b=Pkdeh21jdhUaBzLo2BBA95Zwm5kTX4I1WB8tNbtHulHLFrhZ1PFi8fl+ 0sNdSDqRweXeC2+M5/0stoZ4cDLJQYQHtATSL4K9fenStYtRnnBOzxOAr DhXgqTWFl2E3aQZGJ7AiVCxZhhowiyugJbS3Yk/zPwi/c0TNkqoPRW/pq yBTRLdg6i9VAFgZjlf3tBHJzw1TeTn+xmAnZsCmYZtekHHHYavpYCeHXb XmVxq2JOzgX7rQxJOhw+/DrkO5H5diFDA5IQ7kM/SRzfF0ANn/c85Yh55 SyRln+tDpGWH5BM2DLh0s0TtfA+gecrpeNDgS0gE0fifAVl0usdPeSoqT Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10825"; a="441051172" X-IronPort-AV: E=Sophos;i="6.02,232,1688454000"; d="scan'208";a="441051172" 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230905185309.131295-5-brgl@bgdev.pl> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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