From: Geert Uytterhoeven <geert+renesas@glider.be> To: Linus Walleij <linus.walleij@linaro.org>, Bartosz Golaszewski <bgolaszewski@baylibre.com>, Jonathan Corbet <corbet@lwn.net>, Harish Jenny K N <harish_kandiga@mentor.com>, Eugeniu Rosca <erosca@de.adit-jv.com> Cc: Alexander Graf <graf@amazon.com>, Peter Maydell <peter.maydell@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, Phil Reid <preid@electromag.com.au>, Marc Zyngier <marc.zyngier@arm.com>, Christoffer Dall <christoffer.dall@arm.com>, Magnus Damm <magnus.damm@gmail.com>, Rob Herring <robh+dt@kernel.org>, Mark Rutland <mark.rutland@arm.com>, 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 <geert+renesas@glider.be> Subject: [PATCH v4 1/5] gpiolib: Add support for gpiochipN-based table lookup Date: Wed, 15 Jan 2020 19:15:19 +0100 [thread overview] Message-ID: <20200115181523.23556-2-geert+renesas@glider.be> (raw) In-Reply-To: <20200115181523.23556-1-geert+renesas@glider.be> 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 <geert+renesas@glider.be> Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu> --- 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
WARNING: multiple messages have this Message-ID (diff)
From: Geert Uytterhoeven <geert+renesas@glider.be> To: Linus Walleij <linus.walleij@linaro.org>, Bartosz Golaszewski <bgolaszewski@baylibre.com>, Jonathan Corbet <corbet@lwn.net>, Harish Jenny K N <harish_kandiga@mentor.com>, Eugeniu Rosca <erosca@de.adit-jv.com> Cc: Mark Rutland <mark.rutland@arm.com>, Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org, Geert Uytterhoeven <geert+renesas@glider.be>, linux-doc@vger.kernel.org, Marc Zyngier <marc.zyngier@arm.com>, Magnus Damm <magnus.damm@gmail.com>, Christoffer Dall <christoffer.dall@arm.com>, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-gpio@vger.kernel.org, Rob Herring <robh+dt@kernel.org>, Alexander Graf <graf@amazon.com>, Paolo Bonzini <pbonzini@redhat.com>, Phil Reid <preid@electromag.com.au> Subject: [PATCH v4 1/5] gpiolib: Add support for gpiochipN-based table lookup Date: Wed, 15 Jan 2020 19:15:19 +0100 [thread overview] Message-ID: <20200115181523.23556-2-geert+renesas@glider.be> (raw) In-Reply-To: <20200115181523.23556-1-geert+renesas@glider.be> 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 <geert+renesas@glider.be> Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu> --- 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
next prev parent reply other threads:[~2020-01-15 18:15 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-01-15 18:15 [PATCH v4 0/5] gpio: Add GPIO Aggregator Geert Uytterhoeven 2020-01-15 18:15 ` Geert Uytterhoeven 2020-01-15 18:15 ` Geert Uytterhoeven [this message] 2020-01-15 18:15 ` [PATCH v4 1/5] gpiolib: Add support for gpiochipN-based table lookup Geert Uytterhoeven 2020-01-15 18:15 ` [PATCH v4 2/5] gpiolib: Add support for GPIO line " Geert Uytterhoeven 2020-01-15 18:15 ` Geert Uytterhoeven 2020-01-15 18:15 ` [PATCH v4 3/5] gpio: Add GPIO Aggregator Geert Uytterhoeven 2020-01-15 18:15 ` Geert Uytterhoeven 2020-01-15 18:15 ` [PATCH v4 4/5] docs: gpio: Add GPIO Aggregator documentation Geert Uytterhoeven 2020-01-15 18:15 ` Geert Uytterhoeven 2020-01-15 18:15 ` [PATCH v4 5/5] MAINTAINERS: Add GPIO Aggregator section Geert Uytterhoeven 2020-01-15 18:15 ` Geert Uytterhoeven 2020-01-20 13:26 ` [PATCH v4 0/5] gpio: Add GPIO Aggregator Eugeniu Rosca 2020-01-20 13:26 ` Eugeniu Rosca
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200115181523.23556-2-geert+renesas@glider.be \ --to=geert+renesas@glider.be \ --cc=bgolaszewski@baylibre.com \ --cc=christoffer.dall@arm.com \ --cc=corbet@lwn.net \ --cc=erosca@de.adit-jv.com \ --cc=graf@amazon.com \ --cc=harish_kandiga@mentor.com \ --cc=linus.walleij@linaro.org \ --cc=linux-doc@vger.kernel.org \ --cc=linux-gpio@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-renesas-soc@vger.kernel.org \ --cc=magnus.damm@gmail.com \ --cc=marc.zyngier@arm.com \ --cc=mark.rutland@arm.com \ --cc=pbonzini@redhat.com \ --cc=peter.maydell@linaro.org \ --cc=preid@electromag.com.au \ --cc=qemu-devel@nongnu.org \ --cc=robh+dt@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.