All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Bezdeka <florian.bezdeka@siemens.com>
To: hongzha1 <hongzhan.chen@intel.com>, xenomai@xenomai.org
Subject: Re: [for-upstream/dovetail 1/2] drivers/gpio: core: introduce helper to find array of gpiochips
Date: Fri, 14 May 2021 10:55:35 +0200	[thread overview]
Message-ID: <ab2507ce-cc32-c85e-2e0a-80d95f2067ce@siemens.com> (raw)
In-Reply-To: <20210513010238.32466-2-hongzhan.chen@intel.com>

On 13.05.21 03:02, hongzha1 via Xenomai wrote:
> To find array of gpiochips for non-OF platform
> 
> Signed-off-by: hongzha1 <hongzhan.chen@intel.com>
> ---
>  include/cobalt/kernel/rtdm/gpio.h |  4 ++++
>  kernel/drivers/gpio/gpio-core.c   | 19 +++++++++++++++++++
>  2 files changed, 23 insertions(+)
> 
> diff --git a/include/cobalt/kernel/rtdm/gpio.h b/include/cobalt/kernel/rtdm/gpio.h
> index c5fb20f25..99772f558 100644
> --- a/include/cobalt/kernel/rtdm/gpio.h
> +++ b/include/cobalt/kernel/rtdm/gpio.h
> @@ -64,6 +64,10 @@ int rtdm_gpiochip_post_event(struct rtdm_gpio_chip *rgc,
>  int rtdm_gpiochip_find(struct device_node *from,
>  			  const char *label, int type);
>  
> +int rtdm_gpiochip_array_find(struct device_node *from,
> +				const char *compat[],
> +				int nentries, int type);
> +
>  #ifdef CONFIG_OF
>  
>  int rtdm_gpiochip_scan_of(struct device_node *from,
> diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
> index b3d801fa1..20a6d7875 100644
> --- a/kernel/drivers/gpio/gpio-core.c
> +++ b/kernel/drivers/gpio/gpio-core.c
> @@ -543,6 +543,25 @@ int rtdm_gpiochip_find(struct device_node *from, const char *label,
>  }
>  EXPORT_SYMBOL_GPL(rtdm_gpiochip_find);
>  
> +int rtdm_gpiochip_array_find(struct device_node *from,
> +				const char *compat[],
> +				int nentries, int type)
> +{
> +	int ret = -ENODEV, _ret, n;
> +
> +	for (n = 0; n < nentries; n++) {
> +		_ret = rtdm_gpiochip_find(from, compat[n], type);
> +		if (_ret) {
> +			if (_ret != -ENODEV)
> +				return _ret;
> +		} else
> +			ret = 0;
> +	}
> +
> +	return ret;
> +}

I'm not sure if I completely understand the code, but maybe it could be
simplified to:

{
	int ret, n;

	for (n = 0; n < nentries; n++) {
		ret = rtdm_gpiochip_find(from, compat[n], type);

		if (ret && ret != -ENODEV)
			break;
	}

	return ret;
}

> +EXPORT_SYMBOL_GPL(rtdm_gpiochip_array_find);
> +
>  #ifdef CONFIG_OF
>  
>  #include <linux/of_platform.h>
> 


-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux


  reply	other threads:[~2021-05-14  8:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-13  1:02 [for-upstream/dovetail 0/2] Add support for Cherryview GPIO hongzha1
2021-05-13  1:02 ` [for-upstream/dovetail 1/2] drivers/gpio: core: introduce helper to find array of gpiochips hongzha1
2021-05-14  8:55   ` Florian Bezdeka [this message]
2021-05-14  9:10     ` Florian Bezdeka
2021-05-17  1:15       ` Chen, Hongzhan
2021-05-18 21:25   ` Jan Kiszka
2021-05-18 21:43     ` Jan Kiszka
2021-05-19  1:34       ` Chen, Hongzhan
2021-05-13  1:02 ` [for-upstream/dovetail 2/2] driver/gpio: cherryview: introduce gpio driver for pinctl Cherryview hongzha1

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=ab2507ce-cc32-c85e-2e0a-80d95f2067ce@siemens.com \
    --to=florian.bezdeka@siemens.com \
    --cc=hongzhan.chen@intel.com \
    --cc=xenomai@xenomai.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: link
Be 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.