Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6314146ybc; Wed, 27 Nov 2019 19:46:46 -0800 (PST) X-Google-Smtp-Source: APXvYqxJks2AHgcEAzITmOZW2ILMUaQ+O6k+Ix3wxLVVCZOqYORJXfP5JagjBlKpkI8x5qH4rqnS X-Received: by 2002:a17:906:958b:: with SMTP id r11mr53202867ejx.332.1574912806246; Wed, 27 Nov 2019 19:46:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574912806; cv=none; d=google.com; s=arc-20160816; b=dtjEqjshEGZCILrhn7z8swcGEjagmLee+9tuOLbhZ2CWlaSBhCahEc5GpxCmQ2ac9o 2wAokDP9u5CH5Qg1O1HoXWNKnk4kLEtYMR35pSsWLhcnFIlo+5ro8rbYyrS05L+GHU/5 ghUsKguK5lNzscHmR8r2lwKny3xPPbzdT9MtR05RVegM4cpYTLmonT9anzfKpY5q+LZg 0eama0sW6dMBt66Yl+pMwmZ59OuVePQ7bfKxa+GMExCibY27+U2AAMNhiKlYUISGBjz0 XtHnnaEHLDg202pPAf5Tw5HdpaJPwfX6z2Z0ydu9xuOWaD9lEyvDDH/Pe+XnA0E6p/PN 1a9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:importance:content-transfer-encoding :mime-version:subject:references:in-reply-to:message-id:cc:to:from :date:dkim-signature; bh=va5LV254c4pnUOB90TgtULX8HfyB7kptyTfdt98+XQ0=; b=dyg4o5ibf92Ez71xoS1dFtRrDLdI0wBBJC6SEUxp1UrvpyJO9MUonytz26kP6Zq8EY wlzGQBarKYqjV+QukUxXdsf6eziQV8DLVyXO4uvpsyo4YT41PN/Zt0mtJUGu8sKO4aa/ 5lgiGkEYJ13BrKDZBY7OWNdQb2vzoGmpH80FDv/KNWzGb5W1wJcjBc16WtvLH631x5rq a4psMWIHiZPoH/4KgMx/8cJdkf2EUOIMyhmrXdSNDiabzBvj3fayR9zjwNGwxlCffvrw OGYeftx2Tvd6vtXrsawJ1PZrobVuHmXvzZj+29G81GYaZamE0mX7osM8ALfLQvERGxmc N+nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@fpond.eu header.s=strato-dkim-0002 header.b=eoLiJ7fI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ay20si2180794edb.62.2019.11.27.19.46.21; Wed, 27 Nov 2019 19:46:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@fpond.eu header.s=strato-dkim-0002 header.b=eoLiJ7fI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727498AbfK1DpD (ORCPT + 99 others); Wed, 27 Nov 2019 22:45:03 -0500 Received: from mo4-p02-ob.smtp.rzone.de ([85.215.255.83]:23329 "EHLO mo4-p02-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727117AbfK1DpD (ORCPT ); Wed, 27 Nov 2019 22:45:03 -0500 X-Greylist: delayed 340 seconds by postgrey-1.27 at vger.kernel.org; Wed, 27 Nov 2019 22:45:01 EST DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1574912701; s=strato-dkim-0002; d=fpond.eu; h=Subject:References:In-Reply-To:Message-ID:Cc:To:From:Date: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=va5LV254c4pnUOB90TgtULX8HfyB7kptyTfdt98+XQ0=; b=eoLiJ7fIGeWAMnZFcC2Ru8ARPFKn+Yk2y1fQx0ThD5Y4GUhW5ZHalT30UM3MThad41 0BA9BkMAn+Wy0L0hklW16IxxVbc7uAnYBuHQrIEC1TG1cFLdLRiSARlHlFsXO/o6XON+ 41uWD4nTLxuYNILLO7ZwBfo446z+OT77nGnUtf1dx7RY1bv9RRZARbM2qFNZR+88b+9p tf7MAUI3edEP5wavdM/vdPvp38cLil2rqQ/41OhYXXGcpUVoQpNLO7Nm35mlCPHgLvAL e2e6lQrVoQLQw/M5D8oazMKKkKHAb0PCsIaCVwMRYpt8MGb8jJ2Os0tnwyih5wkI6I/H wsgg== X-RZG-AUTH: ":OWANVUa4dPFUgKR/3dpvnYP0Np73amq+g13rqGzmt2bYDnKIKaws6YXTsc4=" X-RZG-CLASS-ID: mo00 Received: from oxapp04-01.back.ox.d0m.de by smtp-ox.front (RZmta 46.0.0 AUTH) with ESMTPSA id 604beevAS3ct2Ip (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve X9_62_prime256v1 with 256 ECDH bits, eq. 3072 bits RSA)) (Client did not present a certificate); Thu, 28 Nov 2019 04:38:55 +0100 (CET) Date: Thu, 28 Nov 2019 04:38:55 +0100 (CET) From: Ulrich Hecht To: Geert Uytterhoeven , Linus Walleij , Bartosz Golaszewski , Jonathan Corbet , Rob Herring , Mark Rutland , Harish Jenny K N , Eugeniu Rosca Cc: Alexander Graf , Peter Maydell , Paolo Bonzini , Phil Reid , Marc Zyngier , Christoffer Dall , Magnus Damm , linux-gpio@vger.kernel.org, linux-doc@vger.kernel.org, devicetree@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, qemu-devel@nongnu.org Message-ID: <1979629875.1467698.1574912335764@webmail.strato.com> In-Reply-To: <20191127084253.16356-3-geert+renesas@glider.be> References: <20191127084253.16356-1-geert+renesas@glider.be> <20191127084253.16356-3-geert+renesas@glider.be> Subject: Re: [PATCH v3 2/7] gpiolib: Add support for gpiochipN-based table lookup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Normal X-Mailer: Open-Xchange Mailer v7.10.1-Rev22 X-Originating-IP: 112.198.74.215 X-Originating-Client: open-xchange-appsuite Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On November 27, 2019 at 9:42 AM Geert Uytterhoeven wrote: > > > Currently GPIO controllers can only be referred to by label in GPIO > lookup tables. > > Add support for looking them up by "gpiochipN" name, with "N" either the > corresponding GPIO device's ID number, or the GPIO controller's first > GPIO number. > > Signed-off-by: Geert Uytterhoeven > --- > If this is rejected, the GPIO Aggregator documentation must be updated. > > The second variant is currently used by the legacy sysfs interface only, > so perhaps the chip->base check should be dropped? > > v3: > - New. > --- > drivers/gpio/gpiolib.c | 22 +++++++++++++++++++++- > 1 file changed, 21 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c > index c9e47620d2434983..d24a3d79dcfe69ad 100644 > --- a/drivers/gpio/gpiolib.c > +++ b/drivers/gpio/gpiolib.c > @@ -1746,9 +1746,29 @@ static int gpiochip_match_name(struct gpio_chip *chip, void *data) > return !strcmp(chip->label, name); > } > > +static int gpiochip_match_id(struct gpio_chip *chip, void *data) > +{ > + int id = (uintptr_t)data; > + > + return id == chip->base || id == chip->gpiodev->id; > +} > + > static struct gpio_chip *find_chip_by_name(const char *name) > { > - return gpiochip_find((void *)name, gpiochip_match_name); > + struct gpio_chip *chip; > + int id; > + > + chip = gpiochip_find((void *)name, gpiochip_match_name); > + if (chip) > + return chip; > + > + if (!str_has_prefix(name, GPIOCHIP_NAME)) > + return NULL; > + > + if (kstrtoint(name + strlen(GPIOCHIP_NAME), 10, &id)) > + return NULL; > + > + return gpiochip_find((void *)(uintptr_t)id, gpiochip_match_id); > } > > #ifdef CONFIG_GPIOLIB_IRQCHIP > -- > 2.17.1 > Reviewed-by: Ulrich Hecht CU Uli