Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp538804pxk; Thu, 17 Sep 2020 09:25:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFKNMzdoyp4if/DS85ShEwW00qTH8ZRdA3aLOGPUVDDfe3mYr069LVcfeelvrZe8LrXgNY X-Received: by 2002:a17:906:1f08:: with SMTP id w8mr30897311ejj.181.1600359903829; Thu, 17 Sep 2020 09:25:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600359903; cv=none; d=google.com; s=arc-20160816; b=RJicFheWYNwCruzjfTAVjzs55rkAxkR+3fiMa7cIsbqSeP8Q7flLKg9wvbqAd+d7vJ +kfxOuaA5bwFJy32qhvGbTN1trwUda6OADVzAvPSU8iN1+REdZS4BLiE3gMOgnv8Fdct iKRC868yKgGolekgWBp5Cdqpth/dshzQYpUM9079N2Bnej59UzmPeHzB2Qt7LKIQh8U5 Q0pTdqH+Mq1r4usH1iiGC5BhNR6lTLVKIpkXKKNTlWuKTol73r2mMs1EY4OpEJ05HIxb jpKVlYIvAjGqMZowc54woUHnHIFba8GJOJC+74zwUtYLFjqUaS5QkzYPuP+33JPr9WWL t9DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=neIdRO+se+u1pjB/Chq9fptf6TQ1RcbKNvM8vekGBlI=; b=DSYjQfn1Ed6mgpUJ7MAR1omK0IkF48lXLM8lLBVX/MNJNx7P5jkamBlnadD5aJltPO dTwHZsjare9vM2aMqkkx2C1Xu+6zd9MdZCvhtJ4wEOY81XPAiahfElJ7HIEuDkOzIj7i TuAs4zDdfjdNjY9TWejnCRF/67PM5YjpF3dvPtJfLVuQIC+1170cnhDavipc2+KMaEAv h30EqpDDEAvzSofwpEM2UIHApCsWI3buoyfjEtMDLO9PwQliYbmpjCGbJbcDofbylZ0Y yMZdhNOUmn82BIv6OJrK6HZQot1A9Nh9vVUs4fLMqP0XjENdKzPYxHezYLc/a14/a1XF u74Q== 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 c6si92071edq.397.2020.09.17.09.24.40; Thu, 17 Sep 2020 09:25:03 -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 S1726980AbgIQQVS (ORCPT + 99 others); Thu, 17 Sep 2020 12:21:18 -0400 Received: from relmlor2.renesas.com ([210.160.252.172]:42560 "EHLO relmlie6.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728397AbgIQQTO (ORCPT ); Thu, 17 Sep 2020 12:19:14 -0400 X-Greylist: delayed 417 seconds by postgrey-1.27 at vger.kernel.org; Thu, 17 Sep 2020 12:18:49 EDT X-IronPort-AV: E=Sophos;i="5.77,271,1596466800"; d="scan'208";a="57331016" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 18 Sep 2020 01:09:26 +0900 Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 7A5394011AC1; Fri, 18 Sep 2020 01:09:24 +0900 (JST) From: Lad Prabhakar To: Sakari Ailus , Hans Verkuil , Laurent Pinchart , Mauro Carvalho Chehab , Jacopo Mondi Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Lad Prabhakar , Prabhakar Subject: [PATCH v2] media: v4l2-fwnode: Return -EINVAL for invalid bus-type Date: Thu, 17 Sep 2020 17:08:47 +0100 Message-Id: <20200917160847.31936-1-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return -EINVAL if invalid bus-type is detected while parsing endpoints. Signed-off-by: Lad Prabhakar --- v1->v2 * Updated commit description * Fixed nit pointed by Sakari v1 - https://patchwork.kernel.org/patch/11777127/ --- 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 d7bbe33840cb..dfc53d11053f 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 59b1de197114..c20e2dc6d432 100644 --- a/include/media/v4l2-mediabus.h +++ b/include/media/v4l2-mediabus.h @@ -103,6 +103,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 as last) */ enum v4l2_mbus_type { V4L2_MBUS_UNKNOWN, @@ -112,6 +113,7 @@ enum v4l2_mbus_type { V4L2_MBUS_CCP2, V4L2_MBUS_CSI2_DPHY, V4L2_MBUS_CSI2_CPHY, + V4L2_MBUS_INVALID, }; /** -- 2.17.1