public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Linus Walleij <linus.walleij@stericsson.com>
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Grant Likely <grant.likely@secretlab.ca>,
	Lee Jones <lee.jones@linaro.org>,
	Martin Persson <martin.persson@stericsson.com>,
	Stephen Warren <swarren@nvidia.com>,
	Russell King <linux@arm.linux.org.uk>,
	Linaro Dev <linaro-dev@lists.linaro.org>,
	Linus Walleij <linus.walleij@linaro.org>
Subject: Re: [PATCH 1/2] drivers: create a pinmux subsystem v3
Date: Mon, 13 Jun 2011 11:11:30 -0700	[thread overview]
Message-ID: <1307988690.26699.9.camel@Joe-Laptop> (raw)
In-Reply-To: <1307984291-9774-1-git-send-email-linus.walleij@stericsson.com>

On Mon, 2011-06-13 at 18:58 +0200, Linus Walleij wrote:
> This creates a subsystem for handling of pinmux devices. These are
> devices that enable and disable groups of pins on primarily PGA and
> BGA type of chip packages and common in embedded systems.

Trivia only:

> diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
[]
> +int pin_is_valid(int pin)
> +{
> +	return pin >= 0 && pin < num_pins;
> +}
> +EXPORT_SYMBOL_GPL(pin_is_valid);

bool pin_is_valid?

> +/* Deletes a range of pin descriptors */
> +static void pinctrl_free_pindescs(struct pinctrl_pin_desc const *pins,
> +				  unsigned num_pins)

const struct pinctrl_pin_desc *pins

> +{
> +	int i;
> +
> +	for (i = 0; i < num_pins; i++) {
> +		struct pin_desc *pindesc;
> +
> +		spin_lock(&pin_desc_tree_lock);
> +		pindesc = radix_tree_lookup(&pin_desc_tree, pins[i].number);
> +		if (pindesc != NULL) {
> +			radix_tree_delete(&pin_desc_tree, pins[i].number);
> +			num_pins --;

No space please

> +		}
> +		spin_unlock(&pin_desc_tree_lock);
> +		kfree(pindesc);
> +	}
> +}

Is it really worthwhile to have spin_lock/unlock in the loop?

> +static int pinctrl_register_one_pin(unsigned number, const char *name)
> +{
> +	/* Copy optional basic pin info */
> +	if (name) {
> +		strncpy(pindesc->name, name, 16);

strlcpy

> +		pindesc->name[15] = '\0';
> +	}
> +
> +	spin_lock(&pin_desc_tree_lock);
> +	radix_tree_insert(&pin_desc_tree, number, pindesc);
> +	num_pins ++;

No space please

> +	spin_unlock(&pin_desc_tree_lock);
> +	return 0;
> +}
> +
> +/* Passing in 0 num_pins means "sparse" */
> +static int pinctrl_register_pins(struct pinctrl_pin_desc const *pins,
> +				 unsigned num_descs, unsigned num_pins)
[]
> +	 * If we are registerering dense pinlists, fill in all holes with

registering

> +	 * anonymous pins.
> +	 */
> +	for (i = 0; i < num_pins; i++) {
> +		char pinname[16];
> +		struct pin_desc *pindesc;
> +
> +		spin_lock(&pin_desc_tree_lock);
> +		pindesc = radix_tree_lookup(&pin_desc_tree, i);
> +		spin_unlock(&pin_desc_tree_lock);
> +		/* Already registered this one, take next */
> +		if (pindesc)
> +			continue;
> +
> +		snprintf(pinname, 15, "anonymous %u", i);
> +		pinname[15] = '\0';

strlcpy

> +int pinctrl_register_pins_dense(struct pinctrl_pin_desc const *pins,
> +				 unsigned num_descs, unsigned num_pins)
> +{
> +	int ret;
> +	unsigned i;
> +
> +	ret = pinctrl_register_pins(pins, num_descs, num_pins);
> +	if (ret) {
> +		for (i = 0; i < num_pins; i++) {
> +			struct pin_desc *pindesc;
> +
> +			spin_lock(&pin_desc_tree_lock);
> +			pindesc = radix_tree_lookup(&pin_desc_tree, i);
> +			if (pindesc != NULL) {
> +				radix_tree_delete(&pin_desc_tree, i);
> +				num_pins --;
> +			}
> +			spin_unlock(&pin_desc_tree_lock);
> +			kfree(pindesc);
> +		}

Second use of this pattern.  Maybe use pinctrl_free_pindescs?



  reply	other threads:[~2011-06-13 18:11 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-13 16:58 [PATCH 1/2] drivers: create a pinmux subsystem v3 Linus Walleij
2011-06-13 18:11 ` Joe Perches [this message]
2011-06-14  9:19   ` Linus Walleij
2011-06-13 19:57 ` Grant Likely
2011-06-14 11:33   ` Linus Walleij
2011-07-09 10:23   ` Mark Brown
2011-08-19 11:59     ` Linus Walleij
2011-06-13 23:28 ` Stephen Warren
2011-06-14 14:25   ` Linus Walleij
2011-06-14 22:11     ` Stephen Warren
2011-06-16 12:47       ` Linus Walleij
2011-06-16 19:10         ` Stephen Warren
2011-06-27 14:34           ` Linus Walleij
2011-06-29 21:23             ` Stephen Warren
2011-08-19 12:34         ` Linus Walleij
2011-07-14  5:57 ` Barry Song
2011-08-08  2:28   ` Barry Song
2011-08-19 11:53   ` Linus Walleij

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=1307988690.26699.9.camel@Joe-Laptop \
    --to=joe@perches.com \
    --cc=grant.likely@secretlab.ca \
    --cc=lee.jones@linaro.org \
    --cc=linaro-dev@lists.linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linus.walleij@stericsson.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=martin.persson@stericsson.com \
    --cc=swarren@nvidia.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox