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 X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3C40C32771 for ; Wed, 15 Jan 2020 18:15:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BFFFB2081E for ; Wed, 15 Jan 2020 18:15:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729275AbgAOSPx (ORCPT ); Wed, 15 Jan 2020 13:15:53 -0500 Received: from andre.telenet-ops.be ([195.130.132.53]:53994 "EHLO andre.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729279AbgAOSPp (ORCPT ); Wed, 15 Jan 2020 13:15:45 -0500 Received: from ramsan ([84.195.182.253]) by andre.telenet-ops.be with bizsmtp id qiFR2100W5USYZQ01iFRmd; Wed, 15 Jan 2020 19:15:43 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan with esmtp (Exim 4.90_1) (envelope-from ) id 1irnCP-00012W-F4; Wed, 15 Jan 2020 19:15:25 +0100 Received: from geert by rox.of.borg with local (Exim 4.90_1) (envelope-from ) id 1irnCP-000692-Cf; Wed, 15 Jan 2020 19:15:25 +0100 From: Geert Uytterhoeven To: Linus Walleij , Bartosz Golaszewski , Jonathan Corbet , Harish Jenny K N , Eugeniu Rosca Cc: Alexander Graf , Peter Maydell , Paolo Bonzini , Phil Reid , Marc Zyngier , Christoffer Dall , Magnus Damm , Rob Herring , Mark Rutland , linux-gpio@vger.kernel.org, linux-doc@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, qemu-devel@nongnu.org, Geert Uytterhoeven Subject: [PATCH v4 1/5] gpiolib: Add support for gpiochipN-based table lookup Date: Wed, 15 Jan 2020 19:15:19 +0100 Message-Id: <20200115181523.23556-2-geert+renesas@glider.be> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200115181523.23556-1-geert+renesas@glider.be> References: <20200115181523.23556-1-geert+renesas@glider.be> Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org 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" the corresponding GPIO device's ID number. Signed-off-by: Geert Uytterhoeven Reviewed-by: Ulrich Hecht --- v4: - Add Reviewed-by, - Drop support for legacy sysfs interface based name matching, - Replace complex custom matching by a simple additional check in the existing gpiochip_match_name() function, - Add kerneldoc() for find_chip_by_name(), documenting matching order. v3: - New. --- drivers/gpio/gpiolib.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 9fd2dfb658546159..114325b366ae33d5 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1738,9 +1738,18 @@ static int gpiochip_match_name(struct gpio_chip *chip, void *data) { const char *name = data; - return !strcmp(chip->label, name); + return !strcmp(chip->label, name) || + !strcmp(dev_name(&chip->gpiodev->dev), name); } +/** + * find_chip_by_name() - Find a specific gpio_chip by name + * @name: Name to match + * + * Return a reference to a gpio_chip that matches the passed name. + * This function first tries matching on the gpio_chip's label, followed by + * matching on dev_name() of the corresponding gpio_device. + */ static struct gpio_chip *find_chip_by_name(const char *name) { return gpiochip_find((void *)name, gpiochip_match_name); -- 2.17.1 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 X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C793DC32771 for ; Wed, 15 Jan 2020 18:23:15 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 97D42214AF for ; Wed, 15 Jan 2020 18:23:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 97D42214AF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=glider.be Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:58598 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irnJy-00076t-Ko for qemu-devel@archiver.kernel.org; Wed, 15 Jan 2020 13:23:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53060) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irnCk-0006aa-GU for qemu-devel@nongnu.org; Wed, 15 Jan 2020 13:15:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irnCj-0003cG-G8 for qemu-devel@nongnu.org; Wed, 15 Jan 2020 13:15:46 -0500 Received: from andre.telenet-ops.be ([2a02:1800:120:4::f00:15]:55970) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1irnCj-0003b7-9r for qemu-devel@nongnu.org; Wed, 15 Jan 2020 13:15:45 -0500 Received: from ramsan ([84.195.182.253]) by andre.telenet-ops.be with bizsmtp id qiFR2100W5USYZQ01iFRmd; Wed, 15 Jan 2020 19:15:43 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan with esmtp (Exim 4.90_1) (envelope-from ) id 1irnCP-00012W-F4; Wed, 15 Jan 2020 19:15:25 +0100 Received: from geert by rox.of.borg with local (Exim 4.90_1) (envelope-from ) id 1irnCP-000692-Cf; Wed, 15 Jan 2020 19:15:25 +0100 From: Geert Uytterhoeven To: Linus Walleij , Bartosz Golaszewski , Jonathan Corbet , Harish Jenny K N , Eugeniu Rosca Subject: [PATCH v4 1/5] gpiolib: Add support for gpiochipN-based table lookup Date: Wed, 15 Jan 2020 19:15:19 +0100 Message-Id: <20200115181523.23556-2-geert+renesas@glider.be> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200115181523.23556-1-geert+renesas@glider.be> References: <20200115181523.23556-1-geert+renesas@glider.be> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 2a02:1800:120:4::f00:15 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Peter Maydell , qemu-devel@nongnu.org, Geert Uytterhoeven , linux-doc@vger.kernel.org, Marc Zyngier , Magnus Damm , Christoffer Dall , linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-gpio@vger.kernel.org, Rob Herring , Alexander Graf , Paolo Bonzini , Phil Reid Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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" the corresponding GPIO device's ID number. Signed-off-by: Geert Uytterhoeven Reviewed-by: Ulrich Hecht --- v4: - Add Reviewed-by, - Drop support for legacy sysfs interface based name matching, - Replace complex custom matching by a simple additional check in the existing gpiochip_match_name() function, - Add kerneldoc() for find_chip_by_name(), documenting matching order. v3: - New. --- drivers/gpio/gpiolib.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 9fd2dfb658546159..114325b366ae33d5 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1738,9 +1738,18 @@ static int gpiochip_match_name(struct gpio_chip *chip, void *data) { const char *name = data; - return !strcmp(chip->label, name); + return !strcmp(chip->label, name) || + !strcmp(dev_name(&chip->gpiodev->dev), name); } +/** + * find_chip_by_name() - Find a specific gpio_chip by name + * @name: Name to match + * + * Return a reference to a gpio_chip that matches the passed name. + * This function first tries matching on the gpio_chip's label, followed by + * matching on dev_name() of the corresponding gpio_device. + */ static struct gpio_chip *find_chip_by_name(const char *name) { return gpiochip_find((void *)name, gpiochip_match_name); -- 2.17.1