linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: tony@atomide.com (Tony Lindgren)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 3/9] pinctrl: single: support pinconf generic
Date: Wed, 7 Nov 2012 16:25:05 -0800	[thread overview]
Message-ID: <20121108002505.GT6801@atomide.com> (raw)
In-Reply-To: <1352301582-12244-4-git-send-email-haojian.zhuang@gmail.com>

Hi,

* Haojian Zhuang <haojian.zhuang@gmail.com> [121107 07:21]:
> diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
> index a7c5fdd..77aec05 100644
> --- a/drivers/pinctrl/pinctrl-single.c
> +++ b/drivers/pinctrl/pinctrl-single.c
>  static int pcs_pinconf_get(struct pinctrl_dev *pctldev,
>  				unsigned pin, unsigned long *config)
>  {
> +	struct pcs_device *pcs = pinctrl_dev_get_drvdata(pctldev);
> +	enum pin_config_param param = pinconf_to_config_param(*config);
> +	unsigned data;
> +	u32 offset;

Do you need a check here (and also in other pinconf related functions)
for driver instances that don't have pinconf enabled?

Something like:

	if (!pcs->pinconf)
		return -ENOTSUPP;
...


> @@ -806,34 +1000,27 @@ static int pcs_dt_node_to_map(struct pinctrl_dev *pctldev,
>  
>  	pcs = pinctrl_dev_get_drvdata(pctldev);
>  
> -	*map = devm_kzalloc(pcs->dev, sizeof(**map), GFP_KERNEL);
> -	if (!map)
> -		return -ENOMEM;
> +	if (!pcs->conf.nconfs)
> +		*num_maps = 1;
> +	else
> +		*num_maps = 2;
>  
> -	*num_maps = 0;
> +	*map = devm_kzalloc(pcs->dev, sizeof(**map) * (*num_maps), GFP_KERNEL);
> +	if (!*map)
> +		return -ENOMEM;
>  
>  	pgnames = devm_kzalloc(pcs->dev, sizeof(*pgnames), GFP_KERNEL);
> -	if (!pgnames) {
> -		ret = -ENOMEM;
> -		goto free_map;
> -	}
> +	if (!pgnames)
> +		return -ENOMEM;
>  
>  	ret = pcs_parse_one_pinctrl_entry(pcs, np_config, map, pgnames);
>  	if (ret < 0) {
>  		dev_err(pcs->dev, "no pins entries for %s\n",
>  			np_config->name);
> -		goto free_pgnames;
> +		return ret;
>  	}
> -	*num_maps = 1;
>  
>  	return 0;
> -
> -free_pgnames:
> -	devm_kfree(pcs->dev, pgnames);
> -free_map:
> -	devm_kfree(pcs->dev, *map);
> -
> -	return ret;
>  }

Here looks like you're changing the behaviour to not free entries in cases
where parsing with cs_parse_one_pinctrl_entry() fails. I'd prefer the freeing
it in case of parsing errors so we don't waste memory when the system is
running. Also there's a tiny chance that *num_maps will be wrong if the
second devm_kzalloc fails.. But it's more likely that we get a broken device
tree to parse and end up potentially hogging hundreds of maps.

Regards,

Tony

  reply	other threads:[~2012-11-08  0:25 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-07 15:19 [PATCH v4 0/9] use pinctrl-single in arch mmp Haojian Zhuang
2012-11-07 15:19 ` [PATCH v4 1/9] ARM: mmp: select pinctrl driver Haojian Zhuang
2012-11-08  1:38   ` Tony Lindgren
2012-11-10 14:53     ` Haojian Zhuang
2012-11-13 13:37       ` Linus Walleij
2012-11-07 15:19 ` [PATCH v4 2/9] pinctrl: single: support gpio request and free Haojian Zhuang
2012-11-07 22:27   ` Tony Lindgren
2012-11-13 13:07     ` Linus Walleij
2012-11-13 17:34       ` Tony Lindgren
2012-11-14  1:44         ` Haojian Zhuang
2012-11-07 15:19 ` [PATCH v4 3/9] pinctrl: single: support pinconf generic Haojian Zhuang
2012-11-08  0:25   ` Tony Lindgren [this message]
2012-11-08 22:55   ` Tony Lindgren
2012-11-08 23:13     ` Tony Lindgren
2012-11-09 21:53   ` Tony Lindgren
2012-11-07 15:19 ` [PATCH v4 4/9] ARM: dts: support pinctrl single in pxa910 Haojian Zhuang
2012-11-09 22:48   ` Tony Lindgren
2012-11-10  5:37     ` Haojian Zhuang
2012-11-10 20:04       ` Tony Lindgren
2012-11-07 15:19 ` [PATCH v4 5/9] document: devicetree: bind pinconf with pin-single Haojian Zhuang
2012-11-08  1:37   ` Tony Lindgren
2012-11-12 20:37   ` Stephen Warren
2012-11-15  8:27     ` Haojian Zhuang
2012-11-15  8:30     ` Haojian Zhuang
2012-11-07 15:19 ` [PATCH v4 6/9] tty: pxa: configure pin Haojian Zhuang
2012-11-07 15:19 ` [PATCH v4 7/9] i2c: pxa: use devm_kzalloc Haojian Zhuang
2012-11-07 15:19 ` [PATCH v4 8/9] i2c: pxa: configure pinmux Haojian Zhuang
2012-11-07 15:19 ` [PATCH v4 9/9] pinctrl: single: dump pinmux register value Haojian Zhuang
2012-11-08  1:25   ` Tony Lindgren
2012-11-13 13:08     ` Linus Walleij
2012-11-13 17:34       ` Tony Lindgren
2012-11-14  1:45         ` Haojian Zhuang
2012-11-15 14:11           ` 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=20121108002505.GT6801@atomide.com \
    --to=tony@atomide.com \
    --cc=linux-arm-kernel@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).