lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <1355168499-5847-11-git-send-email-s.nawrocki@samsung.com>
Date:	Mon, 10 Dec 2012 20:41:36 +0100
From:	Sylwester Nawrocki <s.nawrocki@...sung.com>
To:	g.liakhovetski@....de, linux-media@...r.kernel.org
Cc:	grant.likely@...retlab.ca, rob.herring@...xeda.com,
	thomas.abraham@...aro.org, t.figa@...sung.com,
	sw0312.kim@...sung.com, kyungmin.park@...sung.com,
	devicetree-discuss@...ts.ozlabs.org, linux-kernel@...r.kernel.org,
	Sylwester Nawrocki <s.nawrocki@...sung.com>
Subject: [PATCH RFC 10/13] v4l2-of: Support variable length of data-lanes
 property

Based on code from Guennadi Liakhovetski <g.liakhovetski@....de>.

Add data_lanes property which relects the number of active data lanes,
that is length of the data-lanes array. Previously we assumed the
data-lanes array had fixed length which doesn't match the binding
semantics.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@...sung.com>
---
 drivers/media/v4l2-core/v4l2-of.c |   15 +++++++++++----
 include/media/v4l2-of.h           |    1 +
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-of.c b/drivers/media/v4l2-core/v4l2-of.c
index f45d64b..4e6658c 100644
--- a/drivers/media/v4l2-core/v4l2-of.c
+++ b/drivers/media/v4l2-core/v4l2-of.c
@@ -33,6 +33,7 @@ void v4l2_of_parse_link(const struct device_node *node,
 	unsigned int v;
 	u32 data_lanes[ARRAY_SIZE(link->mipi_csi_2.data_lanes)];
 	bool data_lanes_present;
+	struct property *prop;
 
 	memset(link, 0, sizeof(*link));
 
@@ -83,10 +84,16 @@ void v4l2_of_parse_link(const struct device_node *node,
 	if (!of_property_read_u32(node, "clock-lanes", &v))
 		link->mipi_csi_2.clock_lane = v;
 
-	if (!of_property_read_u32_array(node, "data-lanes", data_lanes,
-					ARRAY_SIZE(data_lanes))) {
-		int i;
-		for (i = 0; i < ARRAY_SIZE(data_lanes); i++)
+	prop = of_find_property(node, "data-lanes", NULL);
+	if (prop) {
+		int i = 0;
+		const __be32 *lane = NULL;
+		do {
+			lane = of_prop_next_u32(prop, lane, &data_lanes[i]);
+		} while (lane && i++ < ARRAY_SIZE(data_lanes));
+
+		link->mipi_csi_2.num_data_lanes = i;
+		while (i--)
 			link->mipi_csi_2.data_lanes[i] = data_lanes[i];
 		data_lanes_present = true;
 	} else {
diff --git a/include/media/v4l2-of.h b/include/media/v4l2-of.h
index 6fafedb..ccb1ebe 100644
--- a/include/media/v4l2-of.h
+++ b/include/media/v4l2-of.h
@@ -33,6 +33,7 @@ struct v4l2_of_link {
 		struct {
 			unsigned char data_lanes[4];
 			unsigned char clock_lane;
+			unsigned short num_data_lanes;
 		} mipi_csi_2;
 	};
 };
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ