Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp431953pxu; Sun, 22 Nov 2020 13:54:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJxxwZsvYjWDaP+cjoMIZLsJKcagF9PyeN8/BuTRMeIw8qxapdZyWRIZR6jVw6jfEcMHn8lX X-Received: by 2002:a17:906:174f:: with SMTP id d15mr26160842eje.15.1606082042839; Sun, 22 Nov 2020 13:54:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606082042; cv=none; d=google.com; s=arc-20160816; b=U9gW6EP+PKBQxZWl4zdGNRKJxKKrhDN8T3rPu2/DU5Awu4pijNTrAlCtlDcHkvWY1r nzLXhJqw31F23a57fKBAsJe8zgWRLwXKmKaZC6POvzT3Sv35q/IdZItKRalYj4R6Dz5m E2AezQVZxcxnKayX32co6vobSXMrZNZWIgWaqdSbqP+FD5oYwbiyreZzm8D/9sNSMKvm PFZ9ELZoUMTf6lQe/DoUNS5iJtr6E9OaV0RAUeju5TDRW8BcU6DEo0qVdlEDn/Ea2KDf iFH0bFRNSmgKcYF9D2gQQewjDgWBaJa2OawU6QvQudcJ3rtlUw1RYgHThNbpPIFCH356 tXMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=+kGNoLLnyvYj54sIYNg+yEQxr8OU1H3KIfMv0EVZHNc=; b=VwdOmQOK6TRrsTo7w7wu3h5O+BZw9Eft8DDt+fklPp445CsWfBpcGf93Yu6hu8snut cu6HDDIv5K7MefJO2/knBKMSThe/6+jKMqUJjf0BQlxrLPvSWGHfMC7hY2dCEVOnI3Vc jokApbZk/qQr+xwIHX8ILK7P9zMHvDPAlMvu3+eOZJi9cjoR3kbz/breKvMM4nUtZ5E+ co6VO/ueReK3wf6g+PaJlk5x7lA0h24FK2QThTqlYpAIafYaSbJqeXD4iwxTbLO1nVVr /P5m6gGN1Yl2rj68kXqziKP+oxouLUO6sOBbmflS+AD15U+xQBNuXkJlM26snY7rshQR cvSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gAPL0Zd0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id df12si5616305edb.5.2020.11.22.13.53.40; Sun, 22 Nov 2020 13:54:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gAPL0Zd0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726512AbgKVVtK (ORCPT + 99 others); Sun, 22 Nov 2020 16:49:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726339AbgKVVtK (ORCPT ); Sun, 22 Nov 2020 16:49:10 -0500 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46477C0613CF; Sun, 22 Nov 2020 13:49:10 -0800 (PST) Received: by mail-pf1-x443.google.com with SMTP id v12so13023047pfm.13; Sun, 22 Nov 2020 13:49:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+kGNoLLnyvYj54sIYNg+yEQxr8OU1H3KIfMv0EVZHNc=; b=gAPL0Zd0tcbTyPHShleI5QTPJM5FZ8BZeX/kKAVCiMn6xPLCNzqV4Bv+1hj0wPmP0e bEYviEFF22VqkLh0zJ0/qqyNjH2Nw940qoYeADdw6FZURkBBv40r1e9vq2WWM2auqRgs XFyhC5bc3cfagFkKLuc5l1Y1/bckw8yQFauK7GeTWVaMa7fWJPy8ufX1sFl/OgjbpjWa rpU3Lg+n/0ItdLcX3gz36lFPlT/yjYJ2W80K2t1j/3/LauvAFyOCEL6/5OnzM24vnvfH sttEq/Bd34zpVetEXIvwgYN2FJWENbEf7i2q8WGtSsTMxalQBaxW2uzBQlT1b5XWB8oo lzDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+kGNoLLnyvYj54sIYNg+yEQxr8OU1H3KIfMv0EVZHNc=; b=Y3e9yqcuHoVLKIzkt5DTU/1p/cv+a/puLnPVkwt/Bn+ONpoofUk4eY3AwTYdPUnw/x n/xha4Tq+vMseAj+XnnA0f6xA3tlQKW1l0DRjcz1ubsMz1qglu0ZDGOEmmFLFfJpxwE1 RsepUcnCt6I3OzL+tXsrpBkhTnr49AzLxZZqa2eO2iTqb/dCmPA0rw/6/y+9aRo1xRkT Cl8oNoB6Kq7hjLGU+c852HpkGs34a4AfXDkcKLVt7movs0A5Fhi/x4aiHKPXWpNARtJc 3NFSk3NNm8ho39lhnwEQVai5flvtdGby0O41A/vF4fwk/PI39xo47GOy8oEWc23rSROR DZ/w== X-Gm-Message-State: AOAM530V1XlU7P2bQeSGnLGv7c5iHEjvHf6bpQjWqNybX+IRo8iHOwhY ynDLePnPgGTE6+T1i3VnaeD1E5vXfW099fKcQb8K76iMK+fFm7O4 X-Received: by 2002:a62:55c6:0:b029:197:f982:e980 with SMTP id j189-20020a6255c60000b0290197f982e980mr4549251pfb.40.1606081749791; Sun, 22 Nov 2020 13:49:09 -0800 (PST) MIME-Version: 1.0 References: <20201122092548.61979-1-gnurou@gmail.com> In-Reply-To: From: Andy Shevchenko Date: Sun, 22 Nov 2020 23:48:52 +0200 Message-ID: Subject: Re: [PATCH] Documentation: gpio: fix typo and unclear legacy API section To: Alexandre Courbot Cc: Linus Walleij , Bartosz Golaszewski , Jonathan Corbet , "open list:GPIO SUBSYSTEM" , Linux Documentation List , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Nov 22, 2020 at 11:31 AM Alexandre Courbot wrote: > > On Sun, Nov 22, 2020 at 6:25 PM Alexandre Courbot wrote: > > > > The "Interacting With the Legacy GPIO Subsystem" of the documentation > > was unclear at best, and even included a sentence that seems to say the > > opposite of what it should say about the lifetime of the return value of > > the conversion functions. > > > > Try to clarify things a bit and hopefully make that section more > > readable. > > > > Signed-off-by: Alexandre Courbot > > Realized after sending this should also have a > > Reported-by: Andy Shevchenko > > Apologies for the omission Andy! NP And perhaps BugLink: https://stackoverflow.com/q/64455505/2511795 > > > --- > > Documentation/driver-api/gpio/consumer.rst | 18 ++++++++++-------- > > 1 file changed, 10 insertions(+), 8 deletions(-) > > > > diff --git a/Documentation/driver-api/gpio/consumer.rst b/Documentation/driver-api/gpio/consumer.rst > > index 423492d125b9..173e4c7b037d 100644 > > --- a/Documentation/driver-api/gpio/consumer.rst > > +++ b/Documentation/driver-api/gpio/consumer.rst > > @@ -440,18 +440,20 @@ For details refer to Documentation/firmware-guide/acpi/gpio-properties.rst > > > > Interacting With the Legacy GPIO Subsystem > > ========================================== > > -Many kernel subsystems still handle GPIOs using the legacy integer-based > > -interface. Although it is strongly encouraged to upgrade them to the safer > > -descriptor-based API, the following two functions allow you to convert a GPIO > > -descriptor into the GPIO integer namespace and vice-versa:: > > +Many kernel subsystems and drivers still handle GPIOs using the legacy > > +integer-based interface. It is strongly recommended to update these to the new > > +gpiod interface. For cases where both interfaces need to be used, the following > > +two functions allow to convert a GPIO descriptor into the GPIO integer namespace > > +and vice-versa:: > > > > int desc_to_gpio(const struct gpio_desc *desc) > > struct gpio_desc *gpio_to_desc(unsigned gpio) > > > > -The GPIO number returned by desc_to_gpio() can be safely used as long as the > > -GPIO descriptor has not been freed. All the same, a GPIO number passed to > > -gpio_to_desc() must have been properly acquired, and usage of the returned GPIO > > -descriptor is only possible after the GPIO number has been released. > > +The GPIO number returned by desc_to_gpio() can safely be used as a parameter of > > +the gpio\_*() functions for as long as the GPIO descriptor `desc` is not freed. > > +All the same, a GPIO number passed to gpio_to_desc() must first be properly > > +acquired using e.g. gpio_request_one(), and the returned GPIO descriptor is only > > +considered valid until that GPIO number is released using gpio_free(). > > > > Freeing a GPIO obtained by one API with the other API is forbidden and an > > unchecked error. > > -- > > 2.29.2 > > -- With Best Regards, Andy Shevchenko