Template:Jetson Camera Drivers - Fixed V4L2 Video Devices-Template4

From RidgeRun Developer Wiki
@@ -518,6 +518,7 @@ int tegra_vi_get_port_info(struct tegra_channel *chan,
 	struct device_node *port;
 	int value = 0xFFFF;
 	int ret = 0, i;
+	const char *temp_str = NULL;
 
 	ports = of_get_child_by_name(node, "ports");
 	if (ports == NULL)
@@ -550,6 +551,20 @@ int tegra_vi_get_port_info(struct tegra_channel *chan,
 				return -EINVAL;
 			}
 
+			/* Get video device name */
+			ret = of_property_read_string(ep, "devnode", &temp_str);
+			if (ret < 0) {
+				strcpy(chan->devnode_name, "");
+				dev_err(chan->vi->dev, "devnode name not defined\n");
+			} else {
+				/* Validate that the name plus the null character fits */
+				if (ARRAY_SIZE(chan->devnode_name) >= strlen(temp_str) + 1) {
+					strncpy(chan->devnode_name, temp_str, strlen(temp_str) + 1);
+				} else {
+					dev_err(chan->vi->dev, "Not enough space for devnode name");
+					return -ENOMEM;
+				}
+			}
 			/* Get CSI port */
 			ret = of_property_read_u32(ep, "port-index", &value);
 			if (ret < 0)