Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2606663ybk; Tue, 12 May 2020 03:45:26 -0700 (PDT) X-Google-Smtp-Source: APiQypIxfiBYrzteuxpihdlP1le/tq9r5SLx689hK6DeYNlfwZe7UFG7344/3d8n1CEH+Gd3MqXf X-Received: by 2002:a05:6402:1d89:: with SMTP id dk9mr16951595edb.382.1589280326494; Tue, 12 May 2020 03:45:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589280326; cv=none; d=google.com; s=arc-20160816; b=MGFYGAYkTW4BjIWl8mBqHM3sGpTIOxE7I6PhvmFGwJ7ckSSUX8rLMnD9NBYXVKrjry 5uzQ7os8w9wgL7PcbhqtAAVZo4TN5tQKYlRGJ046E3uPrW+CreRnBrJ3h+ars9CLeA+a 3/W0TAw8U8a5t6ulnGxymC1iA+eXlqoyFLsHvKLz7d3CJQOR+FaMDvuxyhZ5hzuMMpef X+pggtk+xKP24DUoc76pjBNf94OyHUMXzVdHX3LaowLXG0DhalKdkwT72v5qXxQIIjem Iz6cX2H1JrAKfrrwmTjsMfosn/kX9cvJ39KPAtNt0O8kXDdJwbDBI00u81YcwPAs2XZh dBWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=90JVe73i/s7Z9GUVzBQi0xV2WZvGBs6rUJMcUr4qmBc=; b=AUSahr1b5WIhSGeIuR/ZOOGdIW5sO2Gsh0uI7za/DpwJF1BGNjkpcVjlKI44lV50hB Vf4mx3wGMTLyIaYEYPxhESbvzDAtx1EfHifSWeBVsMK+m6iiZoWAK2xwNzNdG38U2Rh3 6HnFC8bLQgaOyXbrRM/Dssun6cfWPwilejC8K9j55FU+8S8HRiXIYuYHUcOF+QEUqGsu 6DDHzkAMIxa2SGsaXdQfn0aiRVriQxMzYvSMdifjZyE/LkU7SI80rqLWHtfNGhZ/v1EF RO13eQPE+jG6qE+vrhaH4SgKUU83Kjz1bLqgNljZQL6E4ZBrLqQJdKWHVAEnzy+HaF8u QEJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=gXpfEIdM; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e25si6500762ejc.36.2020.05.12.03.45.03; Tue, 12 May 2020 03:45:26 -0700 (PDT) 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=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=gXpfEIdM; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729597AbgELKn3 (ORCPT + 99 others); Tue, 12 May 2020 06:43:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729405AbgELKn2 (ORCPT ); Tue, 12 May 2020 06:43:28 -0400 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BE8BC061A0C for ; Tue, 12 May 2020 03:43:28 -0700 (PDT) Received: by mail-qt1-x842.google.com with SMTP id x8so10481478qtr.2 for ; Tue, 12 May 2020 03:43:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=90JVe73i/s7Z9GUVzBQi0xV2WZvGBs6rUJMcUr4qmBc=; b=gXpfEIdMgQC9SYThaLjtF+JqTksuh2TpO3KwtRaD0Q/d8/sF3X0ZEzgSBYCSJvZBgb LfZq8BXeVObsfo7eI9HNitAYfiVa/foKQJOoDZPBx8SKbNJ8qjpSYYCrsWR7ZJhhJq/w uhjAJXQhseAaw7m8NNeOJMjc9NNHfC1s3CmzFbdnRp12CYtN1jgbemJRhEv1qCuMfTqk wLGqkroGqd7yh0IbTK3DmImx+XkHSk/9VwzGLane1nmKEVhHZ1X1JLHHRxdLW+vo1ubq TIPdRPbIXHtLQT2ahTZB/MN5+3gdERRz9tkXJK+EIdNB6wuhxOUbKNBteWju1XM/oWqo pZjA== 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:content-transfer-encoding; bh=90JVe73i/s7Z9GUVzBQi0xV2WZvGBs6rUJMcUr4qmBc=; b=SIJAUVX4zmOx853mxnJuvJOFIujDPV3OBbpzwAnESUDVTBLy7T8N+40HP1U7K3HmTO IrsJWm4/nbj6AkU1/wrUkfvZkNFCW4DT6CNIRA9Vh4VVazytt+LjhZYIF7Bv56/YGZBD 8SvGtYUqvVegfhh6ycHpthLX9DKHdHKYAo6sH+vaxF8ijVvZPa+rnzGkQmcahtq87RPg Of/qcnPb/R6LxVHyLkLx4WE68z/+eZr9FmlZ5XfbxuvA/1UZ8zb22t/WYS3sINqnc1qJ vIzgGxOaSFPwRfxpLmyU/yy14yQ4JNchixUxqAlxP4WWehoPiclPcwPVP2iT8vV9ND5A vxzg== X-Gm-Message-State: AGi0PuYhSrFVbVq4CGXiSMcrk/+OLTc1WXhepGtTugFFqmhVn6o+xMBU PiMzsFlBVuC+i0qYWiDILCHJEPF12zyzmcPy2Og+ibco X-Received: by 2002:ac8:5209:: with SMTP id r9mr20680327qtn.57.1589280207508; Tue, 12 May 2020 03:43:27 -0700 (PDT) MIME-Version: 1.0 References: <20200511101828.30046-1-geert+renesas@glider.be> In-Reply-To: <20200511101828.30046-1-geert+renesas@glider.be> From: Bartosz Golaszewski Date: Tue, 12 May 2020 12:43:16 +0200 Message-ID: Subject: Re: [PATCH] gpiolib: Document that GPIO line names are not globally unique To: Geert Uytterhoeven Cc: Linus Walleij , linux-gpio , LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org pon., 11 maj 2020 o 12:18 Geert Uytterhoeven napisa=C5=82(a): > > gpiochip_set_desc_names() no longer rejects GPIO line name collisions. > Hence GPIO line names are not guaranteed to be globally unique. > In case of multiple GPIO lines with the same name, gpio_name_to_desc() > will return the first match found. > > Update the comments for gpio_name_to_desc() and > gpiochip_set_desc_names() to match reality. > > Fixes: f881bab038c9667d ("gpio: keep the GPIO line names internal") > Signed-off-by: Geert Uytterhoeven > --- > drivers/gpio/gpiolib.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c > index 99533f4cb5d332a9..98822412f565073a 100644 > --- a/drivers/gpio/gpiolib.c > +++ b/drivers/gpio/gpiolib.c > @@ -296,6 +296,9 @@ static int gpiodev_add_to_list(struct gpio_device *gd= ev) > > /* > * Convert a GPIO name to its descriptor > + * Note that there is no guarantee that GPIO names are globally unique! > + * Hence this function will return, if it exists, a reference to the fir= st GPIO > + * line found that matches the given name. > */ > static struct gpio_desc *gpio_name_to_desc(const char * const name) > { > @@ -329,10 +332,12 @@ static struct gpio_desc *gpio_name_to_desc(const ch= ar * const name) > } > > /* > - * Takes the names from gc->names and checks if they are all unique. If = they > - * are, they are assigned to their gpio descriptors. > + * Take the names from gc->names and assign them to their GPIO descripto= rs. > + * Warn if a name is already used for a GPIO line on a different GPIO ch= ip. > * > - * Warning if one of the names is already used for a different GPIO. > + * Note that: > + * 1. Non-unique names are still accepted, > + * 2. Name collisions within the same GPIO chip are not reported. > */ > static int gpiochip_set_desc_names(struct gpio_chip *gc) > { > -- > 2.17.1 > This makes me wonder whether I should do something about this in libgpiod? Looks to me like gpiod_chip_find_line() and the global gpiod_line_find() are no longer reliable and should probably return all lines whose names match. Bart