Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1747452ybk; Mon, 11 May 2020 03:20:22 -0700 (PDT) X-Google-Smtp-Source: APiQypINnJkVPGEFaumB9OAtoDjk5q0Si/M+hnVZQQrNzq8yYoBaomB93BT2aCwPDb/oBe2MNOMu X-Received: by 2002:a17:906:b84f:: with SMTP id ga15mr13058379ejb.83.1589192422780; Mon, 11 May 2020 03:20:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589192422; cv=none; d=google.com; s=arc-20160816; b=jMAAymrvYjsKNAJHVu3syOT2rTwWwYAfnFFEKiAUObEgjohiDYzWVC1p5PPOo7qenE 6/5nxN2jOMOsaEj+dmMIuyvD9CLfdC03+BvimMG20FsOtVQ9cj/iyCqWeRIHF1utdZdU AD38OfKEZnTNZwVnWG/dwCBxeSNa8kS9s7t7TQv3LXbaIQdajlSJHrq7+FE+JIVfaD6a ahOWROec1+ogRh8Ask7FWiVe85vEbyTais93xpvcd5hIpNsXCE/i2LplZb9n5omIcZmk nT4kFql3kgVU8gxgw3ZGBsUcGwRjFkcR/3nEW5RQTnMIUERwutCHblOsy1XAXlJkQUER 1dzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=oUytt/qkbWQ8P7DubTh7x5YlBY0cW5XKkNcvdhDsJ7Y=; b=XgkRxbOtv+1lbpZOnw9Fv0C4rO/oN9vENpTHimNLgihVn/yAE2hCOjzUwoldsgbPge 7HMtbqtZejvzYmMafwo8e/SACAFOYUQPA31ilGfef03rCWsl2/gYPmCqVuHrHX4mJb38 0RedPUUqGEgJDQR1wO0SPLjPc0UTWot7ChCYuFORw2EP5C+01wd/F11I8f698YX250nD 75zIve83OqBR0BN8zZ5NAUIuNl1kA1spXR+E3IWkhPiRbdUziMQmKoxGOc/gb2N2jlc8 ncxyTS1WIAUa6RzkFG3kjG1b0Jkm2nlgnc4neNjn4EtrYPesuzdZ8VwpUgdERp0doaSX vZ8g== ARC-Authentication-Results: i=1; mx.google.com; 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 q22si5414221edb.5.2020.05.11.03.19.59; Mon, 11 May 2020 03:20:22 -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; 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 S1729327AbgEKKSg (ORCPT + 99 others); Mon, 11 May 2020 06:18:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725983AbgEKKSe (ORCPT ); Mon, 11 May 2020 06:18:34 -0400 Received: from albert.telenet-ops.be (albert.telenet-ops.be [IPv6:2a02:1800:110:4::f00:1a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C806C061A0C for ; Mon, 11 May 2020 03:18:34 -0700 (PDT) Received: from ramsan ([IPv6:2a02:1810:ac12:ed60:702c:fb99:3097:2049]) by albert.telenet-ops.be with bizsmtp id dNJW220070GoAb606NJWfT; Mon, 11 May 2020 12:18:30 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan with esmtp (Exim 4.90_1) (envelope-from ) id 1jY5W2-0002Q8-4k; Mon, 11 May 2020 12:18:30 +0200 Received: from geert by rox.of.borg with local (Exim 4.90_1) (envelope-from ) id 1jY5W2-0007pN-1T; Mon, 11 May 2020 12:18:30 +0200 From: Geert Uytterhoeven To: Linus Walleij , Bartosz Golaszewski Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH] gpiolib: Document that GPIO line names are not globally unique Date: Mon, 11 May 2020 12:18:28 +0200 Message-Id: <20200511101828.30046-1-geert+renesas@glider.be> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 *gdev) /* * 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 first 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 char * 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 descriptors. + * Warn if a name is already used for a GPIO line on a different GPIO chip. * - * 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