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 0ECD2E7849A for ; Mon, 2 Oct 2023 09:42:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236184AbjJBJmU (ORCPT ); Mon, 2 Oct 2023 05:42:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230506AbjJBJmQ (ORCPT ); Mon, 2 Oct 2023 05:42:16 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31BDDA7; Mon, 2 Oct 2023 02:42:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696239733; x=1727775733; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=SWeFo/AW06duwWAYJncQ5ko3aVNmWFyeSa2D5HzoNmg=; b=P84uRqLFrwsm6iMK7QMMWqP3tK15BgZb6gV7ZF4EnqUaAQfl2jWLcbov EQlD3G9hwiTqEpXOXek/c5L7M2P0btCjSJK84QmlzRJLnomhvs7Fbp/1h 4lJ9cbhyrzFN8iuf2LtBKAsrMcxQQGbq05HlRBldb9ZVjaujczZBafcwO 0Yt9XUOEghR0i/bvlldYg2fEE2ZDXnXs6a1ACGCB0gfxPN1syaRobkrJQ 8K6J+7/1nQ9U1qgJqJHF4sOsQwgWKehRac4l+vhYKswk0u6NGO0a8mxxf w0J79rdDX/ho3KbEOEeXB8jQY1LTcQe4fQB7rFvfLrx5oZL5MqohWdNYI Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10850"; a="381494535" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="381494535" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Oct 2023 02:42:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10850"; a="744064474" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="744064474" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga007.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Oct 2023 02:42:10 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.97-RC0) (envelope-from ) id 1qnFRH-000000027d5-2bzu; Mon, 02 Oct 2023 12:42:07 +0300 Date: Mon, 2 Oct 2023 12:42:07 +0300 From: Andy Shevchenko To: Bartosz Golaszewski Cc: Linus Walleij , Mika Westerberg , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Bartosz Golaszewski Subject: Re: [PATCH v4 03/11] gpiolib: provide gpio_device_find() Message-ID: References: <20230927142931.19798-1-brgl@bgdev.pl> <20230927142931.19798-4-brgl@bgdev.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230927142931.19798-4-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 Wed, Sep 27, 2023 at 04:29:23PM +0200, Bartosz Golaszewski wrote: > From: Bartosz Golaszewski > > gpiochip_find() is wrong and its kernel doc is misleading as the > function doesn't return a reference to the gpio_chip but just a raw > pointer. The chip itself is not guaranteed to stay alive, in fact it can > be deleted at any point. Also: other than GPIO drivers themselves, > nobody else has any business accessing gpio_chip structs. > > Provide a new gpio_device_find() function that returns a real reference > to the opaque gpio_device structure that is guaranteed to stay alive for > as long as there are active users of it. ... > struct gpio_chip *gpiochip_find(void *data, > int (*match)(struct gpio_chip *gc, > +struct gpio_device *gpio_device_find(void *data, > + int (*match)(struct gpio_chip *gc, > + void *data)) Why not typedef int (*gpio_chip_match_fn)(struct gpio_chip *gc, void *data); ? -- With Best Regards, Andy Shevchenko