diff options
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2013-05-16 08:29:06 -0400 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2013-05-28 07:42:51 -0400 |
commit | fcf7e6e5bd84b561eca4f7977c2a547f724f5942 (patch) | |
tree | 1dae7d4c04bacd47486fd3a9a492a55b7f89b88a /drivers/video | |
parent | 301bc0675b677a98475187050d56cd2b39ff0acf (diff) |
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>
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/of_display_timing.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/drivers/video/of_display_timing.c b/drivers/video/of_display_timing.c index 56009bc02b02..0e8102344b2e 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, | |||
56 | * of_get_display_timing - parse display_timing entry from device_node | 56 | * of_get_display_timing - parse display_timing entry from device_node |
57 | * @np: device_node with the properties | 57 | * @np: device_node with the properties |
58 | **/ | 58 | **/ |
59 | static struct display_timing *of_get_display_timing(struct device_node *np) | 59 | static int of_get_display_timing(struct device_node *np, |
60 | struct display_timing *dt) | ||
60 | { | 61 | { |
61 | struct display_timing *dt; | ||
62 | u32 val = 0; | 62 | u32 val = 0; |
63 | int ret = 0; | 63 | int ret = 0; |
64 | 64 | ||
65 | dt = kzalloc(sizeof(*dt), GFP_KERNEL); | 65 | memset(dt, 0, sizeof(*dt)); |
66 | if (!dt) { | ||
67 | pr_err("%s: could not allocate display_timing struct\n", | ||
68 | of_node_full_name(np)); | ||
69 | return NULL; | ||
70 | } | ||
71 | 66 | ||
72 | ret |= parse_timing_property(np, "hback-porch", &dt->hback_porch); | 67 | ret |= parse_timing_property(np, "hback-porch", &dt->hback_porch); |
73 | ret |= parse_timing_property(np, "hfront-porch", &dt->hfront_porch); | 68 | 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) | |||
101 | if (ret) { | 96 | if (ret) { |
102 | pr_err("%s: error reading timing properties\n", | 97 | pr_err("%s: error reading timing properties\n", |
103 | of_node_full_name(np)); | 98 | of_node_full_name(np)); |
104 | kfree(dt); | 99 | return -EINVAL; |
105 | return NULL; | ||
106 | } | 100 | } |
107 | 101 | ||
108 | return dt; | 102 | return 0; |
109 | } | 103 | } |
110 | 104 | ||
111 | /** | 105 | /** |
@@ -174,9 +168,17 @@ struct display_timings *of_get_display_timings(struct device_node *np) | |||
174 | 168 | ||
175 | for_each_child_of_node(timings_np, entry) { | 169 | for_each_child_of_node(timings_np, entry) { |
176 | struct display_timing *dt; | 170 | struct display_timing *dt; |
171 | int r; | ||
177 | 172 | ||
178 | dt = of_get_display_timing(entry); | 173 | dt = kzalloc(sizeof(*dt), GFP_KERNEL); |
179 | if (!dt) { | 174 | if (!dt) { |
175 | pr_err("%s: could not allocate display_timing struct\n", | ||
176 | of_node_full_name(np)); | ||
177 | goto timingfail; | ||
178 | } | ||
179 | |||
180 | r = of_get_display_timing(entry, dt); | ||
181 | if (r) { | ||
180 | /* | 182 | /* |
181 | * to not encourage wrong devicetrees, fail in case of | 183 | * to not encourage wrong devicetrees, fail in case of |
182 | * an error | 184 | * an error |