Re: [PATCH 2/2] pinmux: add a driver for the U300 pinmux

From: Barry Song
Date: Sat Oct 08 2011 - 05:13:21 EST


> +static int __init u300_pmx_probe(struct platform_device *pdev)
> +{
> + Â Â Â int ret;
> + Â Â Â struct u300_pmx *upmx;
> + Â Â Â struct resource *res;
> +
> + Â Â Â /* Create state holders etc for this driver */
> + Â Â Â upmx = devm_kzalloc(&pdev->dev, sizeof(struct u300_pmx), GFP_KERNEL);

and this would be "devm_kzalloc(&pdev->dev, sizeof(*upmx), GFP_KERNEL); " ?

> + Â Â Â if (!upmx)
> + Â Â Â Â Â Â Â return -ENOMEM;
> +
> + Â Â Â upmx->dev = &pdev->dev;
> +
> + Â Â Â res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + Â Â Â if (!res) {
> + Â Â Â Â Â Â Â ret = -ENOENT;
> + Â Â Â Â Â Â Â goto out_no_resource;
> + Â Â Â }
> + Â Â Â upmx->phybase = res->start;
> + Â Â Â upmx->physize = resource_size(res);
> +
> + Â Â Â if (request_mem_region(upmx->phybase, upmx->physize,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â ÂDRIVER_NAME) == NULL) {
> + Â Â Â Â Â Â Â ret = -EBUSY;
> + Â Â Â Â Â Â Â goto out_no_memregion;
> + Â Â Â }
> +
> + Â Â Â upmx->virtbase = ioremap(upmx->phybase, upmx->physize);
> + Â Â Â if (!upmx->virtbase) {
> + Â Â Â Â Â Â Â ret = -ENOMEM;
> + Â Â Â Â Â Â Â goto out_no_remap;
> + Â Â Â }
> +
> + Â Â Â upmx->pctl = pinctrl_register(&u300_pmx_desc, &pdev->dev, upmx);
> + Â Â Â if (IS_ERR(upmx->pctl)) {
> + Â Â Â Â Â Â Â dev_err(&pdev->dev, "could not register U300 pinmux driver\n");
> + Â Â Â Â Â Â Â ret = PTR_ERR(upmx->pctl);
> + Â Â Â Â Â Â Â goto out_no_pmx;
> + Â Â Â }
> +
> + Â Â Â /* We will handle a range of GPIO pins */
> + Â Â Â pinctrl_add_gpio_range(upmx->pctl, &u300_gpio_range);
> +
> + Â Â Â platform_set_drvdata(pdev, upmx);
> +
> + Â Â Â u300_pmx_dumpregs(upmx);
> +
> + Â Â Â dev_info(&pdev->dev, "initialized U300 pinmux driver\n");
> +
> + Â Â Â return 0;
> +
> +out_no_pmx:
> + Â Â Â iounmap(upmx->virtbase);
> +out_no_remap:
> + Â Â Â platform_set_drvdata(pdev, NULL);
> +out_no_memregion:
> + Â Â Â release_mem_region(upmx->phybase, upmx->physize);
> +out_no_resource:
> + Â Â Â devm_kfree(&pdev->dev, upmx);
> + Â Â Â return ret;
> +}
> +
-barry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/