From: Tomi Valkeinen <tomi.valkeinen@ti.com>
To: "Semwal, Sumit" <sumit.semwal@ti.com>
Cc: "linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>,
"Guruswamy, Senthilvadivu" <svadivu@ti.com>
Subject: Re: [Patch 1/2] OMAP2PLUS: DSS2: Add dss_opt_clk_roles in pdata
Date: Mon, 28 Feb 2011 11:10:49 +0200 [thread overview]
Message-ID: <1298884249.9809.8.camel@deskari> (raw)
In-Reply-To: <1298622470-10558-2-git-send-email-sumit.semwal@ti.com>
On Fri, 2011-02-25 at 02:27 -0600, Semwal, Sumit wrote:
> Provide dss_opt_clks roles in pdata, so that it can be retrieved
> in dss driver, thus avoiding the hardcoding of clock role names.
>
> Signed-off-by: Senthilvadivu Guruswamy <svadivu@ti.com>
> (based on implementation from Senthil)
>
> Signed-off-by: Sumit Semwal <sumit.semwal@ti.com>
> ---
> arch/arm/mach-omap2/display.c | 41 ++++++++++++++++++++++++++++-
> arch/arm/plat-omap/include/plat/display.h | 3 +-
> 2 files changed, 42 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/display.c b/arch/arm/mach-omap2/display.c
> index cc7b4f3..f189c07 100644
> --- a/arch/arm/mach-omap2/display.c
> +++ b/arch/arm/mach-omap2/display.c
> @@ -21,6 +21,7 @@
> #include <linux/io.h>
> #include <linux/clk.h>
> #include <linux/err.h>
> +#include <linux/slab.h>
>
> #include <plat/display.h>
> #include <plat/omap_hwmod.h>
> @@ -48,6 +49,7 @@ int __init omap_display_init(struct omap_dss_board_info
> int r = 0;
> struct omap_hwmod *oh;
> struct omap_device *od;
> + struct omap_hwmod_opt_clk *oc = NULL;
> int i;
> struct omap_display_platform_data pdata;
>
> @@ -61,7 +63,7 @@ int __init omap_display_init(struct omap_dss_board_info
> "dss_dsi2", "dss_hdmi"};
> char *dev_name[] = {"omap_dss", "omap_dispc", "omap_rfbi", "omap_venc", "omap_dsi1",
> "omap_dsi2", "omap_hdmi"};
> - int oh_count;
> + int oh_count, oc_count;
>
> memset(&pdata, 0, sizeof(pdata));
>
> @@ -74,7 +76,44 @@ int __init omap_display_init(struct omap_dss_board_info
> oh_count = ARRAY_SIZE(oh_name) - 2;
> /* last 2 hwmod dev in oh_name are not available for omap3 */
>
> + /* opt_clks are always associated with dss hwmod */
> + oh = omap_hwmod_lookup("dss_core");
> + if (!oh) {
> + pr_err("Could not look up %s\n", oh_name[0]);
> + return -ENODEV;
> + }
> + oc = oh->opt_clks;
> + oc_count = oh->opt_clks_cnt;
> +
> + /* copy roles of opt_clocks available from hwmod into pdata */
> + pdata.dss_opt_clk_roles = kzalloc(sizeof(char *) * oc_count,
> + GFP_KERNEL);
> + if (!pdata.dss_opt_clk_roles) {
> + pr_err("could not allocate memory for dss_opt_clk_roles\n");
> + return -ENOMEM;
> + }
> +
> + for (i = 0; i < oc_count; i++) {
> + int oc_length = strlen(oc[i].role);
> +
> + pdata.dss_opt_clk_roles[i] = kzalloc(oc_length + 1,
> + GFP_KERNEL);
> + if (!pdata.dss_opt_clk_roles[i]) {
> + int j = i - 1;
> +
> + pr_err("kzalloc failed for dss_opt_clk[%i]\n", i);
> + for (; j >= 0; j--)
> + kfree(pdata.dss_opt_clk_roles[j]);
> +
> + kfree(pdata.dss_opt_clk_roles);
> +
> + return -ENOMEM;
> + }
> +
> + strncpy(pdata.dss_opt_clk_roles[i], oc[i].role, oc_length+1);
> + }
Do you actually need to copy the role strings? Can they every change? If
they are const data, you could just point to the original strings.
And is there even need to create clk_roles array. If I'm not mistaken,
the only use for this data is for the opt_clock_available() function. We
could just have an opt_clock_available() function pointer in the
omap_display_platform_data, and the function itself would be in
display.c. And the function could use the original hwmod data.
Tomi
next prev parent reply other threads:[~2011-02-28 9:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-25 8:27 [Patch 0/2] OMAP2PLUS:DSS2: use opt-clocks information from hwmod Sumit Semwal
2011-02-25 8:27 ` [Patch 1/2] OMAP2PLUS: DSS2: Add dss_opt_clk_roles in pdata Sumit Semwal
2011-02-28 9:10 ` Tomi Valkeinen [this message]
2011-02-28 9:17 ` Semwal, Sumit
2011-02-28 9:23 ` Tomi Valkeinen
2011-02-25 8:27 ` [Patch 2/2] OMAP2PLUS: DSS2: Use opt-clocks from hwmod Sumit Semwal
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=1298884249.9809.8.camel@deskari \
--to=tomi.valkeinen@ti.com \
--cc=linux-omap@vger.kernel.org \
--cc=sumit.semwal@ti.com \
--cc=svadivu@ti.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox