Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fcf7e6e5 authored by Tomi Valkeinen's avatar Tomi Valkeinen
Browse files

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: default avatarTomi 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>
parent 301bc067
Loading
Loading
Loading
Loading
+14 −12
Original line number Diff line number Diff line
@@ -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