All of lore.kernel.org
 help / color / mirror / Atom feed
From: s.hauer@pengutronix.de (Sascha Hauer)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/7] pinctrl: imx1 core driver
Date: Mon, 5 Aug 2013 11:29:52 +0200	[thread overview]
Message-ID: <20130805092952.GO26614@pengutronix.de> (raw)
In-Reply-To: <1375439907-10462-4-git-send-email-mpa@pengutronix.de>

On Fri, Aug 02, 2013 at 12:38:23PM +0200, Markus Pargmann wrote:
> Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
> ---
>  drivers/pinctrl/Kconfig             |   5 +
>  drivers/pinctrl/Makefile            |   1 +
>  drivers/pinctrl/pinctrl-imx1-core.c | 667 ++++++++++++++++++++++++++++++++++++
>  drivers/pinctrl/pinctrl-imx1.h      |  23 ++
>  4 files changed, 696 insertions(+)
>  create mode 100644 drivers/pinctrl/pinctrl-imx1-core.c
>  create mode 100644 drivers/pinctrl/pinctrl-imx1.h
> 
> +static int imx1_pinctrl_parse_groups(struct device_node *np,
> +				    struct imx_pin_group *grp,
> +				    struct imx_pinctrl_soc_info *info,
> +				    u32 index)
> +{
> +	int size;
> +	const __be32 *list;
> +	int i;
> +	u32 config;
> +
> +	dev_dbg(info->dev, "group(%d): %s\n", index, np->name);
> +
> +	/* Initialise group */
> +	grp->name = np->name;
> +
> +	/*
> +	 * the binding format is fsl,pins = <PIN_FUNC_ID CONFIG ...>,
> +	 * do sanity check and calculate pins number
> +	 */
> +	list = of_get_property(np, "fsl,pins", &size);
> +	/* we do not check return since it's safe node passed down */
> +	if (!size || size % 12) {
> +		dev_notice(info->dev, "Not a valid fsl,pins property (%s)\n",
> +				np->name);
> +		return -EINVAL;
> +	}
> +
> +	grp->npins = size / 12;
> +	grp->pins = devm_kzalloc(info->dev, grp->npins * sizeof(unsigned int),
> +				GFP_KERNEL);
> +	grp->mux_mode = devm_kzalloc(info->dev,
> +				grp->npins * sizeof(unsigned int), GFP_KERNEL);
> +	grp->configs = devm_kzalloc(info->dev,
> +				grp->npins * sizeof(unsigned long), GFP_KERNEL);

I know this is copied from the existing imx pinctrl driver, but normally
we check for allocation failures.

Also I find it very irritating that you allocate three arrays of
integers instead of a single array of a struct type. I know the pinctrl
framework forces you to pass an array of pin numbers (which is quite
horrible for drivers to handle, who came up with the idea that a pin is
a number instead of some struct pointer which can be attached data to?)


> +	for (i = 0; i < grp->npins; i++) {
> +		grp->pins[i] = be32_to_cpu(*list++);
> +		grp->mux_mode[i] = be32_to_cpu(*list++);
> +
> +		config = be32_to_cpu(*list++);
> +		grp->configs[i] = config;
> +	}
> +
> +	return 0;
> +}
> +

[...]

> +
> +	for_each_child_of_node(np, child) {
> +		func->groups[i] = child->name;
> +		grp = &info->groups[grp_index++];
> +		ret = imx1_pinctrl_parse_groups(child, grp, info, i++);
> +		if (ret)
> +			return ret;

This is one thing which nags me in the imx pinctrl driver aswell. Once
you made a single mistake in a single pinctrl group in the devicetree
you will never see the error message because the whole pinctrl driver
bails out leaving the serial driver with the console unusable. Wouldn't
it be possible to continue here instead of bailing out?

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

  parent reply	other threads:[~2013-08-05  9:29 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-02 10:38 [PATCH 0/7] ARM: imx27 pinctrl Markus Pargmann
2013-08-02 10:38 ` [PATCH 1/7] gpio: mxc: Support initialization as subdevice Markus Pargmann
2013-08-07 19:03   ` Linus Walleij
2013-08-09 17:56     ` Markus Pargmann
2013-08-02 10:38 ` [PATCH 2/7] pinctrl: imx header, conditional probe functions Markus Pargmann
2013-08-05  5:43   ` Shawn Guo
2013-08-09 13:31     ` Markus Pargmann
2013-08-02 10:38 ` [PATCH 3/7] pinctrl: imx1 core driver Markus Pargmann
2013-08-02 10:51   ` Alexander Shiyan
2013-08-02 10:54     ` Markus Pargmann
2013-08-05  9:29   ` Sascha Hauer [this message]
2013-08-09 18:16     ` Markus Pargmann
2013-08-07 19:25   ` Linus Walleij
2013-08-09 19:33     ` Markus Pargmann
2013-08-02 10:38 ` [PATCH 4/7] pinctrl: imx27: imx27 pincontrol driver Markus Pargmann
2013-08-05  6:12   ` Shawn Guo
2013-08-09 13:46     ` Markus Pargmann
2013-08-02 10:38 ` [PATCH 5/7] ARM: dts: imx27 pin functions Markus Pargmann
2013-08-05  6:14   ` Shawn Guo
2013-08-02 10:38 ` [PATCH 6/7] ARM: dts: imx27 pinctrl Markus Pargmann
2013-08-05  6:18   ` Shawn Guo
2013-08-09 13:54     ` Markus Pargmann
2013-08-02 10:38 ` [PATCH 7/7] ARM: imx27: enable pinctrl Markus Pargmann

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=20130805092952.GO26614@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --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 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.