summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2013-05-16 15:29:06 +0300
committerTomi Valkeinen <tomi.valkeinen@ti.com>2013-05-28 14:42:51 +0300
commitfcf7e6e5bd84b561eca4f7977c2a547f724f5942 (patch)
tree1dae7d4c04bacd47486fd3a9a492a55b7f89b88a
parent301bc0675b677a98475187050d56cd2b39ff0acf (diff)
downloadop-kernel-dev-fcf7e6e5bd84b561eca4f7977c2a547f724f5942.zip
op-kernel-dev-fcf7e6e5bd84b561eca4f7977c2a547f724f5942.tar.gz
videomode: don't allocate mem in of_get_display_timing()
Move the allocation of display_timing memory from of_get_display_timing() to of_get_display_timings(). This allows us to use of_get_display_timing() in a way that doesn't require dynamic memory allocation. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Cc: Steffen Trumtrar <s.trumtrar@pengutronix.de> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Cc: Philipp Zabel <p.zabel@pengutronix.de>
-rw-r--r--drivers/video/of_display_timing.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/drivers/video/of_display_timing.c b/drivers/video/of_display_timing.c
index 56009bc..0e81023 100644
--- a/drivers/video/of_display_timing.c
+++ b/drivers/video/of_display_timing.c
@@ -56,18 +56,13 @@ static int parse_timing_property(struct device_node *np, const char *name,
* of_get_display_timing - parse display_timing entry from device_node
* @np: device_node with the properties
**/
-static struct display_timing *of_get_display_timing(struct device_node *np)
+static int of_get_display_timing(struct device_node *np,
+ struct display_timing *dt)
{
- struct display_timing *dt;
u32 val = 0;
int ret = 0;
- dt = kzalloc(sizeof(*dt), GFP_KERNEL);
- if (!dt) {
- pr_err("%s: could not allocate display_timing struct\n",
- of_node_full_name(np));
- return NULL;
- }
+ memset(dt, 0, sizeof(*dt));
ret |= parse_timing_property(np, "hback-porch", &dt->hback_porch);
ret |= parse_timing_property(np, "hfront-porch", &dt->hfront_porch);
@@ -101,11 +96,10 @@ static struct display_timing *of_get_display_timing(struct device_node *np)
if (ret) {
pr_err("%s: error reading timing properties\n",
of_node_full_name(np));
- kfree(dt);
- return NULL;
+ return -EINVAL;
}
- return dt;
+ return 0;
}
/**
@@ -174,9 +168,17 @@ struct display_timings *of_get_display_timings(struct device_node *np)
for_each_child_of_node(timings_np, entry) {
struct display_timing *dt;
+ int r;
- dt = of_get_display_timing(entry);
+ dt = kzalloc(sizeof(*dt), GFP_KERNEL);
if (!dt) {
+ pr_err("%s: could not allocate display_timing struct\n",
+ of_node_full_name(np));
+ goto timingfail;
+ }
+
+ r = of_get_display_timing(entry, dt);
+ if (r) {
/*
* to not encourage wrong devicetrees, fail in case of
* an error
OpenPOWER on IntegriCloud