Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3087028pxk; Tue, 15 Sep 2020 09:42:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsiT+kglfXcqJAC3zSQjrltyISB74r/gboGnjk84laPCV14QaXV05424pQoi7n5nS0kf4H X-Received: by 2002:a05:6402:78b:: with SMTP id d11mr24267448edy.341.1600188147727; Tue, 15 Sep 2020 09:42:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600188147; cv=none; d=google.com; s=arc-20160816; b=FE0fO45JMRTiymCSb7Fz8MyVuHDckpFsRZDsZaDnJdBOoOe+4UVJ1R4R+tiNdDC42I TWQ+WHahMtqzwYEVqQaX6cL33tdr65KvNav0x4f18vhybgaXCq6ZmZU0vtJjSrEGd6GR ilxepFo6jTTEIQ9Lrv8fxj4qzmrwMkniRQHrl8+yROUYz6K8Ar2RU7J57TWNBdtlWtuh z0ikRrDrPod/qx0JOHHdsM9kT7dhh87KWhoq9Wd78Daxm7TiMf1Ld+C17ySKHmopzM78 O87tk4e2iqOHVfEY3wxVWKM2Zjc5VSghnbcbG2tlNkCf0NuJSeRCMgePfb4miqovZKkB V7cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=lmU/fysO4MxgfnaNk7djjA3uS6foII3QSa3sBM/2JXU=; b=gJN1IYLm843ntjMAEopEnJehEwKaBA7y8mB3ywMrUZDMv9Xm9oAZ37w7g0TEOAUdTK h0AsBHyA9TuG1t73t4QH2S0Qlv0sDfDpFLgyZhhpG7A7fk9HMo9ffCXD0rGQBMCwDxl9 bAJoASjiwrDP17tLfgpTzICd2wZ8v9M8MhRO09S3gJwybqWUbchTzBTRdMpSTmSHOx7q M2vQDl1IJGl7ut5CCwKigoh9Cocevelmb7+De6SitednEn5BsOf+nlsUFdddTYMGOPfd rzXz5smpFLWPfZMkJuCA5uutD7lmYgVdgHD77lR/ytlqFR1+Mgym77RTiv+iBCyk8pBs snqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dr18si9726206ejc.702.2020.09.15.09.42.05; Tue, 15 Sep 2020 09:42:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727697AbgIOQiK (ORCPT + 99 others); Tue, 15 Sep 2020 12:38:10 -0400 Received: from relmlor1.renesas.com ([210.160.252.171]:44828 "EHLO relmlie5.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727533AbgIOP4S (ORCPT ); Tue, 15 Sep 2020 11:56:18 -0400 X-IronPort-AV: E=Sophos;i="5.76,430,1592838000"; d="scan'208";a="57341061" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 16 Sep 2020 00:56:08 +0900 Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 5BEEF400F7C1; Wed, 16 Sep 2020 00:56:05 +0900 (JST) From: Lad Prabhakar To: Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Laurent Pinchart , Marco Felsch , Steve Longerbeam , Jacopo Mondi , linux-media@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Biju Das , Fabrizio Castro , Lad Prabhakar , Prabhakar Subject: [PATCH] media: v4l2-fwnode: Return -EINVAL for invalid bus-type Date: Tue, 15 Sep 2020 16:55:44 +0100 Message-Id: <20200915155544.826-1-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With the current implementation if invalid bus-type is passed via DT v4l2_fwnode_endpoint_parse() defaulted the mus-type to V4L2_MBUS_PARALLEL instead of returning error. This Patch adds V4L2_MBUS_INVALID entry to v4l2_mbus_type enum and when invalid bus-type is detected in v4l2_fwnode_endpoint_parse() it returns -EINVAL to the caller. Signed-off-by: Lad Prabhakar --- drivers/media/v4l2-core/v4l2-fwnode.c | 6 +++++- include/media/v4l2-mediabus.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c index a4c3c77c1894..a6f3549eadd3 100644 --- a/drivers/media/v4l2-core/v4l2-fwnode.c +++ b/drivers/media/v4l2-core/v4l2-fwnode.c @@ -93,7 +93,7 @@ v4l2_fwnode_bus_type_to_mbus(enum v4l2_fwnode_bus_type type) const struct v4l2_fwnode_bus_conv *conv = get_v4l2_fwnode_bus_conv_by_fwnode_bus(type); - return conv ? conv->mbus_type : V4L2_MBUS_UNKNOWN; + return conv ? conv->mbus_type : V4L2_MBUS_INVALID; } static const char * @@ -436,6 +436,10 @@ static int __v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode, v4l2_fwnode_mbus_type_to_string(vep->bus_type), vep->bus_type); mbus_type = v4l2_fwnode_bus_type_to_mbus(bus_type); + if (mbus_type == V4L2_MBUS_INVALID) { + pr_debug("unsupported bus type %u\n", bus_type); + return -EINVAL; + } if (vep->bus_type != V4L2_MBUS_UNKNOWN) { if (mbus_type != V4L2_MBUS_UNKNOWN && diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h index 45f88f0248c4..b4f630783cb7 100644 --- a/include/media/v4l2-mediabus.h +++ b/include/media/v4l2-mediabus.h @@ -78,6 +78,7 @@ * @V4L2_MBUS_CCP2: CCP2 (Compact Camera Port 2) * @V4L2_MBUS_CSI2_DPHY: MIPI CSI-2 serial interface, with D-PHY * @V4L2_MBUS_CSI2_CPHY: MIPI CSI-2 serial interface, with C-PHY + * @V4L2_MBUS_INVALID: invalid bus type (keep it last for sanity) */ enum v4l2_mbus_type { V4L2_MBUS_UNKNOWN, @@ -87,6 +88,7 @@ enum v4l2_mbus_type { V4L2_MBUS_CCP2, V4L2_MBUS_CSI2_DPHY, V4L2_MBUS_CSI2_CPHY, + V4L2_MBUS_INVALID, }; /** -- 2.17.1