From: Todd Poynor <toddpoynor@google.com>
To: Tarun Kanti DebBarma <tarun.kanti@ti.com>
Cc: linux-omap@vger.kernel.org, khilman@ti.com,
santosh.shilimkar@ti.com, tony@atomide.com,
linux-arm-kernel@lists.infradead.org,
Thara Gopinath <thara@ti.com>
Subject: Re: [PATCH v14 04/12] OMAP2+: dmtimer: convert to platform devices
Date: Mon, 11 Jul 2011 16:19:35 -0700 [thread overview]
Message-ID: <20110711231935.GB8312@google.com> (raw)
In-Reply-To: <1310383759-19059-5-git-send-email-tarun.kanti@ti.com>
On Mon, Jul 11, 2011 at 04:59:11PM +0530, Tarun Kanti DebBarma wrote:
> Add routines to converts dmtimers to platform devices. The device data
> is obtained from hwmod database of respective platform and is registered
> to device model after successful binding to driver.
> In addition, capability attribute of each of the timers is added in
> hwmod database.
>
...
> +static int omap2_dm_timer_set_src(struct platform_device *pdev, int source)
> +{
> + int ret;
> + struct dmtimer_platform_data *pdata = pdev->dev.platform_data;
> + struct clk *fclk, *parent;
> + char *parent_name = NULL;
> +
> + fclk = clk_get(&pdev->dev, "fck");
> + if (IS_ERR_OR_NULL(fclk)) {
> + dev_err(&pdev->dev, "%s: %d: clk_get() FAILED\n",
> + __func__, __LINE__);
> + return -EINVAL;
> + }
> +
> + switch (source) {
> + case OMAP_TIMER_SRC_SYS_CLK:
> + parent_name = "sys_ck";
> + break;
> +
> + case OMAP_TIMER_SRC_32_KHZ:
> + parent_name = "32k_ck";
> + break;
> +
> + case OMAP_TIMER_SRC_EXT_CLK:
> + if (pdata->timer_ip_type == OMAP_TIMER_IP_VERSION_1) {
> + parent_name = "alt_ck";
> + break;
> + }
> + dev_err(&pdev->dev, "%s: %d: invalid clk src.\n",
> + __func__, __LINE__);
> + return -EINVAL;
Should clk_put(fclk);
...
> + pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
> + if (!pdata) {
> + pr_err("%s: No memory for [%s]\n", __func__, oh->name);
> + return -ENOMEM;
> + }
> +
> + /*
> + * Extract the IDs from name field in hwmod database
> + * and use the same for constructing ids' for the
> + * timer devices. In a way, we are avoiding usage of
> + * static variable witin the function to do the same.
> + * CAUTION: We have to be careful and make sure the
> + * name in hwmod database does not change in which case
> + * we might either make corresponding change here or
> + * switch back static variable mechanism.
> + */
> + sscanf(oh->name, "timer%2d", &id);
> +
> + pdata->set_timer_src = omap2_dm_timer_set_src;
> + pdata->timer_ip_type = oh->class->rev;
> + pdata->needs_manual_reset = 0;
Can omit init to zero of kzalloc'ed mem.
Todd
WARNING: multiple messages have this Message-ID (diff)
From: toddpoynor@google.com (Todd Poynor)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v14 04/12] OMAP2+: dmtimer: convert to platform devices
Date: Mon, 11 Jul 2011 16:19:35 -0700 [thread overview]
Message-ID: <20110711231935.GB8312@google.com> (raw)
In-Reply-To: <1310383759-19059-5-git-send-email-tarun.kanti@ti.com>
On Mon, Jul 11, 2011 at 04:59:11PM +0530, Tarun Kanti DebBarma wrote:
> Add routines to converts dmtimers to platform devices. The device data
> is obtained from hwmod database of respective platform and is registered
> to device model after successful binding to driver.
> In addition, capability attribute of each of the timers is added in
> hwmod database.
>
...
> +static int omap2_dm_timer_set_src(struct platform_device *pdev, int source)
> +{
> + int ret;
> + struct dmtimer_platform_data *pdata = pdev->dev.platform_data;
> + struct clk *fclk, *parent;
> + char *parent_name = NULL;
> +
> + fclk = clk_get(&pdev->dev, "fck");
> + if (IS_ERR_OR_NULL(fclk)) {
> + dev_err(&pdev->dev, "%s: %d: clk_get() FAILED\n",
> + __func__, __LINE__);
> + return -EINVAL;
> + }
> +
> + switch (source) {
> + case OMAP_TIMER_SRC_SYS_CLK:
> + parent_name = "sys_ck";
> + break;
> +
> + case OMAP_TIMER_SRC_32_KHZ:
> + parent_name = "32k_ck";
> + break;
> +
> + case OMAP_TIMER_SRC_EXT_CLK:
> + if (pdata->timer_ip_type == OMAP_TIMER_IP_VERSION_1) {
> + parent_name = "alt_ck";
> + break;
> + }
> + dev_err(&pdev->dev, "%s: %d: invalid clk src.\n",
> + __func__, __LINE__);
> + return -EINVAL;
Should clk_put(fclk);
...
> + pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
> + if (!pdata) {
> + pr_err("%s: No memory for [%s]\n", __func__, oh->name);
> + return -ENOMEM;
> + }
> +
> + /*
> + * Extract the IDs from name field in hwmod database
> + * and use the same for constructing ids' for the
> + * timer devices. In a way, we are avoiding usage of
> + * static variable witin the function to do the same.
> + * CAUTION: We have to be careful and make sure the
> + * name in hwmod database does not change in which case
> + * we might either make corresponding change here or
> + * switch back static variable mechanism.
> + */
> + sscanf(oh->name, "timer%2d", &id);
> +
> + pdata->set_timer_src = omap2_dm_timer_set_src;
> + pdata->timer_ip_type = oh->class->rev;
> + pdata->needs_manual_reset = 0;
Can omit init to zero of kzalloc'ed mem.
Todd
next prev parent reply other threads:[~2011-07-11 23:19 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-11 11:29 [PATCH v14 00/12] dmtimer adaptation to platform_driver Tarun Kanti DebBarma
2011-07-11 11:29 ` Tarun Kanti DebBarma
2011-07-11 11:29 ` [PATCH v14 01/12] OMAP2+: dmtimer: add device names to flck nodes Tarun Kanti DebBarma
2011-07-11 11:29 ` Tarun Kanti DebBarma
2011-07-11 11:29 ` [PATCH v14 02/12] OMAP4: hwmod data: add dmtimer version information Tarun Kanti DebBarma
2011-07-11 11:29 ` Tarun Kanti DebBarma
2011-07-11 11:29 ` [PATCH v14 03/12] OMAP1: dmtimer: conversion to platform devices Tarun Kanti DebBarma
2011-07-11 11:29 ` Tarun Kanti DebBarma
2011-07-11 11:29 ` [PATCH v14 04/12] OMAP2+: dmtimer: convert " Tarun Kanti DebBarma
2011-07-11 11:29 ` Tarun Kanti DebBarma
2011-07-11 23:19 ` Todd Poynor [this message]
2011-07-11 23:19 ` Todd Poynor
2011-07-11 23:29 ` DebBarma, Tarun Kanti
2011-07-11 23:29 ` DebBarma, Tarun Kanti
2011-07-11 11:29 ` [PATCH v14 05/12] OMAP: dmtimer: platform driver Tarun Kanti DebBarma
2011-07-11 11:29 ` Tarun Kanti DebBarma
2011-07-11 23:10 ` Todd Poynor
2011-07-11 23:10 ` Todd Poynor
2011-07-11 23:27 ` DebBarma, Tarun Kanti
2011-07-11 23:27 ` DebBarma, Tarun Kanti
2011-07-11 11:29 ` [PATCH v14 06/12] OMAP: dmtimer: switch-over to platform device driver Tarun Kanti DebBarma
2011-07-11 11:29 ` Tarun Kanti DebBarma
2011-07-11 11:29 ` [PATCH v14 07/12] OMAP: dmtimer: pm_runtime support Tarun Kanti DebBarma
2011-07-11 11:29 ` Tarun Kanti DebBarma
2011-07-11 11:29 ` [PATCH v14 08/12] OMAP: dmtimer: add timeout to low-level routines Tarun Kanti DebBarma
2011-07-11 11:29 ` Tarun Kanti DebBarma
2011-07-11 11:29 ` [PATCH v14 09/12] OMAP: dmtimer: use mutex instead of spinlock Tarun Kanti DebBarma
2011-07-11 11:29 ` Tarun Kanti DebBarma
2011-07-11 11:29 ` [PATCH v14 10/12] OMAP: dmtimer: mark clocksource and clockevent timers reserved Tarun Kanti DebBarma
2011-07-11 11:29 ` Tarun Kanti DebBarma
2011-07-11 11:29 ` [PATCH v14 11/12] OMAP: dmtimer: add context save/restore routines Tarun Kanti DebBarma
2011-07-11 11:29 ` Tarun Kanti DebBarma
2011-07-11 11:29 ` [PATCH v14 12/12] OMAP: dmtimer: Off mode support Tarun Kanti DebBarma
2011-07-11 11:29 ` Tarun Kanti DebBarma
-- strict thread matches above, loose matches on Subject: below --
2011-07-11 11:21 [PATCH v14 00/12] dmtimer adaptation to platform_driver Tarun Kanti DebBarma
2011-07-11 11:21 ` [PATCH v14 04/12] OMAP2+: dmtimer: convert to platform devices Tarun Kanti DebBarma
2011-07-11 11:21 ` Tarun Kanti DebBarma
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=20110711231935.GB8312@google.com \
--to=toddpoynor@google.com \
--cc=khilman@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-omap@vger.kernel.org \
--cc=santosh.shilimkar@ti.com \
--cc=tarun.kanti@ti.com \
--cc=thara@ti.com \
--cc=tony@atomide.com \
/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.