Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5965449ybv; Tue, 18 Feb 2020 07:19:12 -0800 (PST) X-Google-Smtp-Source: APXvYqyMiOgYkarLSXCX6r8lLO0tfKPINfYr3Rwanw+8Urs+SXbszp7O+tmNFCemDuiCjmN1aGrr X-Received: by 2002:a05:6830:9a:: with SMTP id a26mr16669078oto.273.1582039152762; Tue, 18 Feb 2020 07:19:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582039152; cv=none; d=google.com; s=arc-20160816; b=AtaLaP5jjpGnZPAKux1Y39aZjiM09wpb2P4kS3RUGKdPaB2UQ2OHjCKiFv3VTOpR7F WKl8mWmBWG5Jmi5hd5/O/nEHzXmmv7tx73jgfVGfuyQjeNqdhNxG+LrzpA5FjneuW/pT u+/Fmcy7KzJfxaRcbRpSmcZfBpyKyeEUcz1RXfyLscLt44ZaUXkOVuz+4HcrM+bl4HCt /9+FzKecAGFKAnmmVwqRhPI68dYgCq7/dsq3/IaVxCY1orSWf3wFMTrBNG7qW7sxB5SY fcq2vnuoK+XLqB3SmtYhbEQa/v83dscT+9wh6MmzQrVLR5AUXw0ZhwejVWcFHquWxtgo BgyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=y+yxvfQ8TlKgBOxvnWCBFCTMCOnqk2+4b2oK8FaFQKs=; b=h46iUldY4LM0VoDmtMC+1JVnALY7tTci2ctQOH0BEAj/l2P7eckCFRcxQATsiudFbu mx+7FivrmIon3BVKa2Cznzlb11ln8Ejl/FaBEoGSk/pKzwiEt9OtipijbnVmQXA3i4sD FXrI6Z4PuHMs8IqRCJ84GtmesYYyi8EVJ+6Kh0Z9bg+TvQ7p/G6hADz/XLl7CGTfE189 pJcrHIf25ZlkcWZeHqtxy2dPy8k/OdfKTJ9O55c6oSY5p6vsqX2T2FPFAJBzRfc6bScP i9sMceAgZqUvJ/0fil0IT/QW0vIz0II1eJPt1SPbMZrEbcXBBCoXbozqHPe0TN44iGWk Fu9Q== ARC-Authentication-Results: i=1; mx.google.com; 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 j65si1788170otc.308.2020.02.18.07.19.00; Tue, 18 Feb 2020 07:19:12 -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; 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 S1727208AbgBRPS3 (ORCPT + 99 others); Tue, 18 Feb 2020 10:18:29 -0500 Received: from laurent.telenet-ops.be ([195.130.137.89]:39496 "EHLO laurent.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726963AbgBRPS2 (ORCPT ); Tue, 18 Feb 2020 10:18:28 -0500 Received: from ramsan ([84.195.182.253]) by laurent.telenet-ops.be with bizsmtp id 4FJD2200x5USYZQ01FJDuz; Tue, 18 Feb 2020 16:18:25 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan with esmtp (Exim 4.90_1) (envelope-from ) id 1j44dZ-0006yB-Pw; Tue, 18 Feb 2020 16:18:13 +0100 Received: from geert by rox.of.borg with local (Exim 4.90_1) (envelope-from ) id 1j44dZ-00022w-O1; Tue, 18 Feb 2020 16:18:13 +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 v5 1/5] gpiolib: Add support for gpiochipN-based table lookup Date: Tue, 18 Feb 2020 16:18:08 +0100 Message-Id: <20200218151812.7816-2-geert+renesas@glider.be> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200218151812.7816-1-geert+renesas@glider.be> References: <20200218151812.7816-1-geert+renesas@glider.be> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 Reviewed-by: Eugeniu Rosca Tested-by: Eugeniu Rosca --- v5: - Add Reviewed-by, Tested-by, 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 4d0106ceeba7bb24..200c2d2be4b78043 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