lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 31 May 2013 21:15:19 +0200
From:	Arnd Bergmann <arnd@...db.de>
To:	devicetree-discuss@...ts.ozlabs.org
Cc:	Jan Luebbe <jlu@...gutronix.de>,
	Grant Likely <grant.likely@...aro.org>,
	Rob Herring <rob.herring@...xeda.com>,
	Rodolfo Giometti <giometti@...eenne.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	linux-kernel@...r.kernel.org, linux-doc@...r.kernel.org
Subject: Re: [PATCH] pps-gpio: add device-tree binding and support

On Friday 31 May 2013 20:46:55 Jan Luebbe wrote:
> 
> +#ifdef CONFIG_OF
> +static const struct of_device_id pps_gpio_dt_ids[] = {
> +       { .compatible = "pps-gpio", },
> +       { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, pps_gpio_dt_ids);
> +
> +static struct pps_gpio_platform_data *
> +of_get_pps_gpio_pdata(struct platform_device *pdev)
> +{
> +       struct device_node *np = pdev->dev.of_node;
> +       struct pps_gpio_platform_data *pdata;
> +       int ret;
> +
> +       pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
> +       if (!pdata)
> +               return NULL;
> +
> +       ret = of_get_gpio(np, 0);
> +       if (ret < 0) {
> +               pr_err("failed to get GPIO from device tree\n");
> +               return NULL;
> +       }
> +
> +       pdata->gpio_pin = ret;
> +       pdata->gpio_label = PPS_GPIO_NAME;
> +
> +       if (of_get_property(np, "assert-falling-edge", NULL))
> +               pdata->assert_falling_edge = true;
> +
> +       return pdata;
> +}
> +#else
> +static struct pps_gpio_platform_data *
> +of_get_pps_gpio_pdata(struct platform_device *pdev)
> +{
> +       return NULL;
> +}
> +#endif

I don't think it's worth the effort of doing a dynamic
allocation if you just need to store two integers and a flag.
I would just put them all into pps_gpio_device_data, which also
gets rid of a couple of indirect pointer accesses and the #ifdef
above.

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ