All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi@ti.com>
To: Tony Lindgren <tony@atomide.com>
Cc: <linus.walleij@linaro.org>, <linux-omap@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	Stephen Warren <swarren@wwwdotorg.org>
Subject: Re: [PATCH 3/4] pinctrl: Add support for additional dynamic states
Date: Tue, 16 Jul 2013 12:35:41 +0300	[thread overview]
Message-ID: <20130716093541.GK8880@arwen.pp.htv.fi> (raw)
In-Reply-To: <20130716090536.5541.36289.stgit@localhost>

[-- Attachment #1: Type: text/plain, Size: 2082 bytes --]

Hi,

On Tue, Jul 16, 2013 at 02:05:36AM -0700, Tony Lindgren wrote:
> +int pinctrl_check_dynamic(struct device *dev, struct pinctrl_state *st1,
> +			  struct pinctrl_state *st2)
> +{
> +	struct pinctrl_setting *s1, *s2;
> +
> +	list_for_each_entry(s1, &st1->settings, node) {
> +		struct pinctrl_dev *pctldev1;
> +		const struct pinctrl_ops *pctlops1;
> +		const unsigned *pins1;
> +		unsigned num_pins1;
> +		int res;
> +
> +		if (s1->type != PIN_MAP_TYPE_MUX_GROUP)
> +			continue;
> +
> +		pctldev1 = s1->pctldev;
> +		pctlops1 = pctldev1->desc->pctlops;
> +		res = pctlops1->get_group_pins(pctldev1, s1->data.mux.group,
> +					       &pins1, &num_pins1);
> +		if (res) {
> +			dev_dbg(dev, "could not get state1 group pins\n");
> +			return -EINVAL;
> +		}
> +
> +		list_for_each_entry(s2, &st2->settings, node) {
> +			struct pinctrl_dev *pctldev2;
> +			const struct pinctrl_ops *pctlops2;
> +			const unsigned *pins2;
> +			unsigned num_pins2;
> +			int i, j, found = 0;
> +
> +			if (s2->type != PIN_MAP_TYPE_MUX_GROUP)
> +				continue;
> +
> +			pctldev2 = s2->pctldev;
> +			if (pctldev1 != pctldev2) {
> +				dev_dbg(dev, "pctldev must be the same for states\n");
> +				return -EINVAL;
> +			}
> +			pctlops2 = pctldev2->desc->pctlops;
> +			res = pctlops2->get_group_pins(pctldev2,
> +						       s2->data.mux.group,
> +						       &pins2, &num_pins2);
> +			if (res) {
> +				dev_dbg(dev, "could not get state2 group pins\n");
> +				return -EINVAL;
> +			}
> +
> +			for (i = 0; i < num_pins1; i++) {
> +				int pin1 = pins1[i];
> +
> +				for (j = 0; j < num_pins2; j++) {
> +					int pin2 = pins2[j];
> +
> +					if (pin1 == pin2) {
> +						found++;
> +						break;
> +					}
> +				}
> +			}

4 levels of nested loops ? Isn't this way too much ? OTOH, it points to
the fact that, perhaps, a list isn't the best data structure for
pinctrl ??

Or perhaps you could just assume that if num_pins1 == num_pins2 it's
enough ? But that will, likely, leave some uncovered corners...

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Felipe Balbi <balbi@ti.com>
To: Tony Lindgren <tony@atomide.com>
Cc: linus.walleij@linaro.org, linux-omap@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Stephen Warren <swarren@wwwdotorg.org>
Subject: Re: [PATCH 3/4] pinctrl: Add support for additional dynamic states
Date: Tue, 16 Jul 2013 12:35:41 +0300	[thread overview]
Message-ID: <20130716093541.GK8880@arwen.pp.htv.fi> (raw)
In-Reply-To: <20130716090536.5541.36289.stgit@localhost>


[-- Attachment #1.1: Type: text/plain, Size: 2082 bytes --]

Hi,

On Tue, Jul 16, 2013 at 02:05:36AM -0700, Tony Lindgren wrote:
> +int pinctrl_check_dynamic(struct device *dev, struct pinctrl_state *st1,
> +			  struct pinctrl_state *st2)
> +{
> +	struct pinctrl_setting *s1, *s2;
> +
> +	list_for_each_entry(s1, &st1->settings, node) {
> +		struct pinctrl_dev *pctldev1;
> +		const struct pinctrl_ops *pctlops1;
> +		const unsigned *pins1;
> +		unsigned num_pins1;
> +		int res;
> +
> +		if (s1->type != PIN_MAP_TYPE_MUX_GROUP)
> +			continue;
> +
> +		pctldev1 = s1->pctldev;
> +		pctlops1 = pctldev1->desc->pctlops;
> +		res = pctlops1->get_group_pins(pctldev1, s1->data.mux.group,
> +					       &pins1, &num_pins1);
> +		if (res) {
> +			dev_dbg(dev, "could not get state1 group pins\n");
> +			return -EINVAL;
> +		}
> +
> +		list_for_each_entry(s2, &st2->settings, node) {
> +			struct pinctrl_dev *pctldev2;
> +			const struct pinctrl_ops *pctlops2;
> +			const unsigned *pins2;
> +			unsigned num_pins2;
> +			int i, j, found = 0;
> +
> +			if (s2->type != PIN_MAP_TYPE_MUX_GROUP)
> +				continue;
> +
> +			pctldev2 = s2->pctldev;
> +			if (pctldev1 != pctldev2) {
> +				dev_dbg(dev, "pctldev must be the same for states\n");
> +				return -EINVAL;
> +			}
> +			pctlops2 = pctldev2->desc->pctlops;
> +			res = pctlops2->get_group_pins(pctldev2,
> +						       s2->data.mux.group,
> +						       &pins2, &num_pins2);
> +			if (res) {
> +				dev_dbg(dev, "could not get state2 group pins\n");
> +				return -EINVAL;
> +			}
> +
> +			for (i = 0; i < num_pins1; i++) {
> +				int pin1 = pins1[i];
> +
> +				for (j = 0; j < num_pins2; j++) {
> +					int pin2 = pins2[j];
> +
> +					if (pin1 == pin2) {
> +						found++;
> +						break;
> +					}
> +				}
> +			}

4 levels of nested loops ? Isn't this way too much ? OTOH, it points to
the fact that, perhaps, a list isn't the best data structure for
pinctrl ??

Or perhaps you could just assume that if num_pins1 == num_pins2 it's
enough ? But that will, likely, leave some uncovered corners...

-- 
balbi

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: balbi@ti.com (Felipe Balbi)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/4] pinctrl: Add support for additional dynamic states
Date: Tue, 16 Jul 2013 12:35:41 +0300	[thread overview]
Message-ID: <20130716093541.GK8880@arwen.pp.htv.fi> (raw)
In-Reply-To: <20130716090536.5541.36289.stgit@localhost>

Hi,

On Tue, Jul 16, 2013 at 02:05:36AM -0700, Tony Lindgren wrote:
> +int pinctrl_check_dynamic(struct device *dev, struct pinctrl_state *st1,
> +			  struct pinctrl_state *st2)
> +{
> +	struct pinctrl_setting *s1, *s2;
> +
> +	list_for_each_entry(s1, &st1->settings, node) {
> +		struct pinctrl_dev *pctldev1;
> +		const struct pinctrl_ops *pctlops1;
> +		const unsigned *pins1;
> +		unsigned num_pins1;
> +		int res;
> +
> +		if (s1->type != PIN_MAP_TYPE_MUX_GROUP)
> +			continue;
> +
> +		pctldev1 = s1->pctldev;
> +		pctlops1 = pctldev1->desc->pctlops;
> +		res = pctlops1->get_group_pins(pctldev1, s1->data.mux.group,
> +					       &pins1, &num_pins1);
> +		if (res) {
> +			dev_dbg(dev, "could not get state1 group pins\n");
> +			return -EINVAL;
> +		}
> +
> +		list_for_each_entry(s2, &st2->settings, node) {
> +			struct pinctrl_dev *pctldev2;
> +			const struct pinctrl_ops *pctlops2;
> +			const unsigned *pins2;
> +			unsigned num_pins2;
> +			int i, j, found = 0;
> +
> +			if (s2->type != PIN_MAP_TYPE_MUX_GROUP)
> +				continue;
> +
> +			pctldev2 = s2->pctldev;
> +			if (pctldev1 != pctldev2) {
> +				dev_dbg(dev, "pctldev must be the same for states\n");
> +				return -EINVAL;
> +			}
> +			pctlops2 = pctldev2->desc->pctlops;
> +			res = pctlops2->get_group_pins(pctldev2,
> +						       s2->data.mux.group,
> +						       &pins2, &num_pins2);
> +			if (res) {
> +				dev_dbg(dev, "could not get state2 group pins\n");
> +				return -EINVAL;
> +			}
> +
> +			for (i = 0; i < num_pins1; i++) {
> +				int pin1 = pins1[i];
> +
> +				for (j = 0; j < num_pins2; j++) {
> +					int pin2 = pins2[j];
> +
> +					if (pin1 == pin2) {
> +						found++;
> +						break;
> +					}
> +				}
> +			}

4 levels of nested loops ? Isn't this way too much ? OTOH, it points to
the fact that, perhaps, a list isn't the best data structure for
pinctrl ??

Or perhaps you could just assume that if num_pins1 == num_pins2 it's
enough ? But that will, likely, leave some uncovered corners...

-- 
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130716/bb3331b7/attachment.sig>

  reply	other threads:[~2013-07-16  9:36 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-16  9:05 [PATCH 0/4] improved support for runtime muxing for pinctrl Tony Lindgren
2013-07-16  9:05 ` Tony Lindgren
2013-07-16  9:05 ` [PATCH 1/4] pinctrl: Remove duplicate code in pinctrl_pm_select_state functions Tony Lindgren
2013-07-16  9:05   ` Tony Lindgren
2013-07-16 13:15   ` Grygorii Strashko
2013-07-16 13:15     ` Grygorii Strashko
2013-07-16 13:15     ` Grygorii Strashko
2013-07-16 13:41     ` Tony Lindgren
2013-07-16 13:41       ` Tony Lindgren
2013-07-16 14:25       ` Grygorii Strashko
2013-07-16 14:25         ` Grygorii Strashko
2013-07-16 14:25         ` Grygorii Strashko
2013-07-17  6:31         ` Tony Lindgren
2013-07-17  6:31           ` Tony Lindgren
2013-07-16  9:05 ` [PATCH 2/4] pinctrl: Allow pinctrl to have multiple active states Tony Lindgren
2013-07-16  9:05   ` Tony Lindgren
2013-07-17 20:55   ` Stephen Warren
2013-07-17 20:55     ` Stephen Warren
2013-07-16  9:05 ` [PATCH 3/4] pinctrl: Add support for additional dynamic states Tony Lindgren
2013-07-16  9:05   ` Tony Lindgren
2013-07-16  9:35   ` Felipe Balbi [this message]
2013-07-16  9:35     ` Felipe Balbi
2013-07-16  9:35     ` Felipe Balbi
2013-07-16 12:06     ` Tony Lindgren
2013-07-16 12:06       ` Tony Lindgren
2013-07-17 21:14   ` Stephen Warren
2013-07-17 21:14     ` Stephen Warren
2013-07-18  7:25     ` Tony Lindgren
2013-07-18  7:25       ` Tony Lindgren
2013-07-18 10:53       ` Tony Lindgren
2013-07-18 10:53         ` Tony Lindgren
2013-07-18 19:21       ` Stephen Warren
2013-07-18 19:21         ` Stephen Warren
2013-07-19  7:29         ` Tony Lindgren
2013-07-19  7:29           ` Tony Lindgren
2013-07-19 18:52           ` Stephen Warren
2013-07-19 18:52             ` Stephen Warren
2013-07-29  9:05             ` Tony Lindgren
2013-07-29  9:05               ` Tony Lindgren
2013-07-29 22:01               ` Stephen Warren
2013-07-29 22:01                 ` Stephen Warren
2013-08-14 16:41                 ` Linus Walleij
2013-08-14 16:41                   ` Linus Walleij
2013-08-14 16:41                   ` Linus Walleij
2013-07-17 21:23   ` Stephen Warren
2013-07-17 21:23     ` Stephen Warren
2013-07-18  7:36     ` Tony Lindgren
2013-07-18  7:36       ` Tony Lindgren
2013-07-18 19:26       ` Stephen Warren
2013-07-18 19:26         ` Stephen Warren
2013-07-19  7:39         ` Tony Lindgren
2013-07-19  7:39           ` Tony Lindgren
2013-07-19 10:29           ` Grygorii Strashko
2013-07-19 10:29             ` Grygorii Strashko
2013-07-19 10:29             ` Grygorii Strashko
2013-07-19 19:03             ` Stephen Warren
2013-07-19 19:03               ` Stephen Warren
2013-07-22 23:15               ` Linus Walleij
2013-07-22 23:15                 ` Linus Walleij
2013-07-22 23:15                 ` Linus Walleij
2013-07-29  9:08               ` Tony Lindgren
2013-07-29  9:08                 ` Tony Lindgren
2013-07-19 18:58           ` Stephen Warren
2013-07-19 18:58             ` Stephen Warren
2013-07-29  9:21             ` Tony Lindgren
2013-07-29  9:21               ` Tony Lindgren
2013-07-29 22:08               ` Stephen Warren
2013-07-29 22:08                 ` Stephen Warren
2013-07-22 23:07   ` Linus Walleij
2013-07-22 23:07     ` Linus Walleij
2013-07-22 23:07     ` Linus Walleij
2013-07-29  9:31     ` Tony Lindgren
2013-07-29  9:31       ` Tony Lindgren
2013-07-29  9:31       ` Tony Lindgren
2013-07-16  9:05 ` [PATCH 4/4] drivers: Add pinctrl handling for dynamic pin states Tony Lindgren
2013-07-16  9:05   ` Tony Lindgren
2013-07-17 21:21   ` Stephen Warren
2013-07-17 21:21     ` Stephen Warren
2013-07-18  7:50     ` Tony Lindgren
2013-07-18  7:50       ` Tony Lindgren
2013-07-18 13:48       ` Tony Lindgren
2013-07-18 13:48         ` Tony Lindgren
2013-07-16  9:14 ` [PATCH 0/4] improved support for runtime muxing for pinctrl Tony Lindgren
2013-07-16  9:14   ` Tony Lindgren
2013-07-17 11:49 ` Grygorii Strashko
2013-07-17 11:49   ` Grygorii Strashko
2013-07-17 11:49   ` Grygorii Strashko
2013-07-18 15:15 [PATCHv2 " Tony Lindgren
2013-07-18 15:15 ` [PATCH 3/4] pinctrl: Add support for additional dynamic states Tony Lindgren
2013-07-18 15:15   ` Tony Lindgren

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=20130716093541.GK8880@arwen.pp.htv.fi \
    --to=balbi@ti.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=swarren@wwwdotorg.org \
    --cc=tony@atomide.com \
    /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.