devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
To: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Cc: linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>,
	Grant Likely
	<grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Andrew Morton
	<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
Subject: Re: [PATCH] pps-gpio: add device-tree binding and support
Date: Fri, 31 May 2013 21:15:19 +0200	[thread overview]
Message-ID: <1588516.WvWWFWzAui@wuerfel> (raw)
In-Reply-To: <1370026015-9584-1-git-send-email-jlu-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

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

  parent reply	other threads:[~2013-05-31 19:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-31 18:46 [PATCH] pps-gpio: add device-tree binding and support Jan Luebbe
     [not found] ` <1370026015-9584-1-git-send-email-jlu-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-05-31 19:15   ` Arnd Bergmann [this message]
2013-06-01 10:44     ` [PATCH v2] " Jan Luebbe
     [not found]       ` <1370083449-11986-1-git-send-email-jlu-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-06-01 11:44         ` Arnd Bergmann
2013-06-03 12:04         ` Rodolfo Giometti
2013-06-03 22:56       ` Andrew Morton
2013-06-03 12:01 ` [PATCH] " Rodolfo Giometti

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=1588516.WvWWFWzAui@wuerfel \
    --to=arnd-r2ngtmty4d4@public.gmane.org \
    --cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@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).