devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
To: Haojian Zhuang <haojian.zhuang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: [PATCH 06/10] pinctrl: single: support gpio request and free
Date: Fri, 19 Oct 2012 15:37:35 -0700	[thread overview]
Message-ID: <20121019223734.GU4730@atomide.com> (raw)
In-Reply-To: <1350551224-12857-6-git-send-email-haojian.zhuang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Hi,

Few minor comments below.

* Haojian Zhuang <haojian.zhuang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> [121018 02:08]:
> Marvell's PXA/MMP silicon also match the behavior of pinctrl-single.
> Each pin binds to one register. A lot of pins could be configured
> as gpio.
> 
> Now add three properties in below.
> pinctrl-single,gpio-mask: mask of enable/disable value of gpio
> pinctrl-single,gpio-ranges: gpio range array
> pinctrl-single,gpio: <gpio base, npins in range, pin base>
> pinctrl-single,gpio-enable: <gpio enable register offset, enable
> value>
> pinctrl-single,gpio-disable: <gpio disable register offset, disable
> value>

Looks like this needs to be rebased also against v3.7-rc1 to apply
cleanly. Maybe also undo the wrapping in the description above while
at it?
 
> --- a/drivers/pinctrl/pinctrl-single.c
> +++ b/drivers/pinctrl/pinctrl-single.c
> @@ -75,6 +76,26 @@ struct pcs_function {
>  };
>  
>  /**
> + * struct pcs_gpio_range - pinctrl gpio range
> + * @range:	subrange of the GPIO number space
> + * @reg_en:	register of enabling gpio function
> + * @reg_dis:	register of disabling gpio function
> + * @val_en:	enable value on gpio function
> + * @val_dis:	disable value on gpio function
> + * @need_en:	need to handle enable value on gpio function
> + * @need_dis:	need to handle disable value on gpio function
> + */
> +struct pcs_gpio_range {
> +	struct pinctrl_gpio_range range;
> +	u32 reg_en;
> +	u32 reg_dis;

These should be void __iomem *reg_en and reg_dis to avoid casts?

You now introduce few "warning: cast removes address space of
expression" warnings when checking with sparse..

> @@ -387,9 +414,48 @@ static void pcs_disable(struct pinctrl_dev *pctldev, unsigned fselector,
>  }
>  
>  static int pcs_request_gpio(struct pinctrl_dev *pctldev,
> -			struct pinctrl_gpio_range *range, unsigned offset)
> +			    struct pinctrl_gpio_range *range, unsigned offset)
>  {
> -	return -ENOTSUPP;
> +	struct pcs_device *pcs = pinctrl_dev_get_drvdata(pctldev);
> +	struct pcs_gpio_range *gpio = NULL;
> +	int end;
> +	unsigned data;

Should you return -ENOTSUPP if not configured for GPIO here?

> +	gpio = container_of(range, struct pcs_gpio_range, range);
> +	if (!gpio->need_en)
> +		return 0;
> +	end = range->pin_base + range->npins - 1;
> +	if (offset < range->pin_base || offset > end) {
> +		dev_err(pctldev->dev, "offset %d isn't in the range of "
> +			"%d to %d\n", offset, range->pin_base, end);
> +		return -EINVAL;
> +	}
> +	data = pcs_readl((void __iomem *)gpio->reg_en) & ~pcs->gmask;
> +	data |= gpio->val_en;
> +	pcs_writel(data, (void __iomem *)gpio->reg_en);

These casts should not be needed then.

> +	return 0;
> +}
> +
> +static void pcs_disable_gpio(struct pinctrl_dev *pctldev,
> +			     struct pinctrl_gpio_range *range, unsigned offset)
> +{
> +	struct pcs_device *pcs = pinctrl_dev_get_drvdata(pctldev);
> +	struct pcs_gpio_range *gpio = NULL;
> +	int end;
> +	unsigned data;
> +
> +	gpio = container_of(range, struct pcs_gpio_range, range);
> +	if (!gpio->need_dis)
> +		return;
> +	end = range->pin_base + range->npins - 1;
> +	if (offset < range->pin_base || offset > end) {
> +		dev_err(pctldev->dev, "offset %d isn't in the range of "
> +			"%d to %d\n", offset, range->pin_base, end);
> +		return;
> +	}
> +	data = pcs_readl((void __iomem *)gpio->reg_dis) & ~pcs->gmask;
> +	data |= gpio->val_dis;
> +	pcs_writel(data, (void __iomem *)gpio->reg_dis);

And these casts.

> +static int __devinit pcs_add_gpio_range(struct device_node *node,
> +					struct pcs_device *pcs)
> +{
> +	struct pcs_gpio_range *gpio;
> +	struct device_node *np;
> +	const __be32 *list;
> +	const char list_name[] = "pinctrl-single,gpio-ranges";
> +	const char name[] = "pinctrl-single";
> +	u32 gpiores[PCS_MAX_GPIO_VALUES];
> +	int ret, size, i, mux_bytes = 0;
> +
> +	ret = of_property_read_u32(node, "pinctrl-single,gpio-mask",
> +				&pcs->gmask);
> +	if (ret < 0)
> +		return 0;
> +	list = of_get_property(node, list_name, &size);
> +	if (!list)
> +		return -ENOENT;
> +	size = size / sizeof(*list);
> +	for (i = 0; i < size; i++) {
> +		np = of_parse_phandle(node, list_name, i);
> +		memset(gpiores, 0, sizeof(u32) * PCS_MAX_GPIO_VALUES);
> +		ret = of_property_read_u32_array(np, "pinctrl-single,gpio",
> +						 gpiores, PCS_MAX_GPIO_VALUES);
> +		if (ret < 0)
> +			return -ENOENT;
> +		gpio = devm_kzalloc(pcs->dev, sizeof(*gpio), GFP_KERNEL);
> +		if (!gpio) {
> +			dev_err(pcs->dev, "failed to allocate pcs gpio\n");
> +			return -ENOMEM;
> +		}
> +		gpio->range.id = i;
> +		gpio->range.base = gpiores[0];
> +		gpio->range.npins = gpiores[1];
> +		gpio->range.name = kmemdup(name, sizeof(name), GFP_KERNEL);
> +		mux_bytes = pcs->width / BITS_PER_BYTE;
> +		gpio->range.pin_base = gpiores[2] / mux_bytes;
> +		memset(gpiores, 0, sizeof(u32) * PCS_MAX_GPIO_VALUES);
> +		ret = of_property_read_u32_array(np,
> +				"pinctrl-single,gpio-enable", gpiores, 2);
> +		if (!ret) {
> +			gpio->reg_en = (u32)pcs->base + gpiores[0];
> +			gpio->val_en = gpiores[1];
> +			gpio->need_en = 1;
> +		}
> +		memset(gpiores, 0, sizeof(u32) * PCS_MAX_GPIO_VALUES);
> +		ret = of_property_read_u32_array(np,
> +				"pinctrl-single,gpio-disable", gpiores, 2);
> +		if (!ret) {
> +			gpio->reg_dis = (u32)pcs->base + gpiores[0];
> +			gpio->val_dis = gpiores[1];
> +			gpio->need_dis = 1;
> +		}

I think it's the u32 casts here that introduce the sparse warnings.

Other than that looks OK to me.

Regards,

Tony

  parent reply	other threads:[~2012-10-19 22:37 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-18  9:06 [PATCH 01/10] pinctrl: use postcore_initcall Haojian Zhuang
     [not found] ` <1350551224-12857-1-git-send-email-haojian.zhuang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-18  9:06   ` [PATCH 02/10] ARM: mmp: select pinctrl driver Haojian Zhuang
2012-10-18  9:06   ` [PATCH 03/10] tty: pxa: configure pin Haojian Zhuang
     [not found]     ` <1350551224-12857-3-git-send-email-haojian.zhuang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-18 18:21       ` Linus Walleij
2012-10-18 22:20       ` Stephen Warren
     [not found]         ` <508080CB.5010904-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-10-22  8:45           ` Linus Walleij
     [not found]             ` <CACRpkdb5Jiw71jBLDXpf2VTJQx7_gABqs03_20CeCLbVT=JkaA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-10-22 20:26               ` Stephen Warren
     [not found]                 ` <5085AC06.8070508-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-10-23  9:26                   ` Linus Walleij
     [not found]                     ` <CACRpkdY-XyagxGU_ya_FZirzbqStTirOC5nuBBwwFY3f4bBTYA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-10-23  9:37                       ` Mark Brown
     [not found]                         ` <20121023093711.GS4477-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2012-10-23  9:59                           ` Linus Walleij
     [not found]                             ` <CACRpkdb+DkZbTDZamGMN+9t07kPktuA_3QtHQJFv+Vu859r7KA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-10-23 11:58                               ` Mark Brown
     [not found]                                 ` <20121023115806.GX4477-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2012-10-24  5:43                                   ` Linus Walleij
2012-10-18  9:06   ` [PATCH 04/10] i2c: pxa: configure pins Haojian Zhuang
     [not found]     ` <1350551224-12857-4-git-send-email-haojian.zhuang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-18 18:22       ` Linus Walleij
2012-10-18  9:06   ` [PATCH 05/10] i2c: pxa: use devm_kzalloc Haojian Zhuang
     [not found]     ` <1350551224-12857-5-git-send-email-haojian.zhuang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-18 22:27       ` Stephen Warren
     [not found]         ` <5080826D.6040108-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-10-19  1:16           ` Haojian Zhuang
2012-10-18  9:07   ` [PATCH 06/10] pinctrl: single: support gpio request and free Haojian Zhuang
     [not found]     ` <1350551224-12857-6-git-send-email-haojian.zhuang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-19 22:37       ` Tony Lindgren [this message]
2012-10-18  9:07   ` [PATCH 07/10] pinctrl: remove mutex lock in groups show Haojian Zhuang
     [not found]     ` <1350551224-12857-7-git-send-email-haojian.zhuang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-18 18:29       ` Linus Walleij
2012-10-18 22:26       ` Stephen Warren
     [not found]         ` <50808200.3080207-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-10-22  8:53           ` Linus Walleij
2012-10-18  9:07   ` [PATCH 08/10] pinctrl: single: support pinconf generic Haojian Zhuang
     [not found]     ` <1350551224-12857-8-git-send-email-haojian.zhuang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-18 18:30       ` Linus Walleij
     [not found]         ` <CACRpkda0QLkdKns3CXNOijYBjaDtW1QyhNYjTqDvRH-in8pvZQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-10-18 22:29           ` Tony Lindgren
     [not found]             ` <20121018222907.GH30550-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2012-10-19  2:23               ` Haojian Zhuang
     [not found]                 ` <CAN1soZzsruhWt7VFgf5Fi79npcjLiMSUEVwnE3hR5iWEh+9GRw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-10-19  2:40                   ` Tony Lindgren
     [not found]                     ` <20121019024012.GP30550-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2012-10-19 18:44                       ` Tony Lindgren
2012-10-19 18:53                   ` Tony Lindgren
2012-10-19 19:13       ` Tony Lindgren
     [not found]         ` <20121019191333.GT4730-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2012-10-22 10:09           ` Haojian Zhuang
     [not found]             ` <CAN1soZzE_tTkmPBechvUcdAbWKSScwcaqe_cb0TTmnRJi9gtRg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-10-22 17:09               ` Tony Lindgren
     [not found]                 ` <20121022170917.GB4730-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2012-10-25 23:43                   ` Tony Lindgren
     [not found]                     ` <20121025234328.GF11928-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2012-10-26  1:47                       ` Haojian Zhuang
     [not found]                         ` <CAN1soZyosQJYZAT61tUig6PGVrfXzwDeiC1R0hnKWoFLVP4Ayw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-10-26 17:29                           ` Tony Lindgren
2012-10-31 22:37                       ` Haojian Zhuang
2012-10-18  9:07   ` [PATCH 09/10] ARM: dts: support pinctrl single in pxa910 Haojian Zhuang
2012-10-18  9:07   ` [PATCH 10/10] document: devicetree: bind pinconf in pinctrl single Haojian Zhuang
     [not found]     ` <1350551224-12857-10-git-send-email-haojian.zhuang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-19 22:40       ` Tony Lindgren
2012-10-18 18:20   ` [PATCH 01/10] pinctrl: use postcore_initcall Linus Walleij
2012-10-18 22:18   ` Stephen Warren
     [not found]     ` <5080802B.3000209-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-10-18 22:28       ` Tony Lindgren
     [not found]         ` <20121018222802.GG30550-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2012-10-19  2:16           ` Haojian Zhuang
     [not found]             ` <CAN1soZy17wO2s7WoRSRod8k5Zh7fuUc1gxhQiHEb0=zwLhyj6A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-10-19  2:38               ` Tony Lindgren
     [not found]                 ` <20121019023818.GO30550-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2012-10-19  2:53                   ` Haojian Zhuang
     [not found]                     ` <CAN1soZw+EzFjEcxDJfi50BEhuQqDUwsB4DMGEXg+oyU-6gO_Jw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-10-19 17:41                       ` Tony Lindgren
2012-10-19  2:24   ` Jean-Christophe PLAGNIOL-VILLARD

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=20121019223734.GU4730@atomide.com \
    --to=tony-4v6ys6ai5vpbdgjk7y7tuq@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=haojian.zhuang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.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).