From patchwork Sun Apr 24 21:08:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivaylo Dimitrov X-Patchwork-Id: 8921571 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C7D489F1C1 for ; Sun, 24 Apr 2016 21:10:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E39EF20219 for ; Sun, 24 Apr 2016 21:10:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F1CDB20222 for ; Sun, 24 Apr 2016 21:10:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753315AbcDXVKa (ORCPT ); Sun, 24 Apr 2016 17:10:30 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:34175 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753268AbcDXVKW (ORCPT ); Sun, 24 Apr 2016 17:10:22 -0400 Received: by mail-wm0-f67.google.com with SMTP id n3so20028028wmn.1 for ; Sun, 24 Apr 2016 14:10:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hoIWOD7EbAO8AwFd8EHvhx2S1Jv4PPArg5wI3h0LmEo=; b=NQazHEeXmSSFsJCZtvTwt5NSjpy/SrVzBdRvfBDZDiXVdYiUTcnnBwhIZavItaOZop gsdf/3Mr53Rus2D3zQuVxV6VP6z81htPC19RFyXPBpItoCJvRRSUHzY4zha3iURghH12 Z2S9m/ODXRyxcHoEyVkl01RvTNiFMUhclYo55mzBM2kdfQ8Iii1LcIl0jAgu2QWQ4PYn HWXaFhECTs4mFG3pKQOoXeXSzusxpYDA2jP01ch1E+09ndm3nScqsryr9sN5odL6jfuw 3XXoNZSk5MoL8sVCdbYVwviaQMA1op9O9GYmYmZv/nybZ1tuu/IO0kCS98Gq41MRvrO6 YdUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hoIWOD7EbAO8AwFd8EHvhx2S1Jv4PPArg5wI3h0LmEo=; b=QSZaJFoN/a4sV3fn7zFnx0/mAIdadUM9Wyy4EMgHUUy+RWD4jmt0pSEcY8Lom0BYFZ mb4HxZDNQYcUSNx3T7GkEKIgN3IECS/vbuy/vyREI+tB+nTibUF9k5//erERyEhYE44V CkqoGdPeuQmW5FrBExImjODes34Y9omDmpwCmj6lKbxMUAZHXhQcNfcL7w6nFPeSpLCS S6YdTB87KIINb8Otr2BPfKlVfDtcpoV7QpUx+2q2kUvZCU0JOjTz89b1nT9MCxCIykNr SZauohYhHLxoN1MoNq/W1OQafBqX2W5N0c7GuD0RnEkuNKrP7XPC9ZP2EE5SgdYPxBlk veGg== X-Gm-Message-State: AOPr4FUM0zsvQQb1ZDxFBNjP3ocx/gHMXSxN1jnycAcNIjBJ5tM7J6pLxOmJ7Ho+oPjIMg== X-Received: by 10.28.16.17 with SMTP id 17mr8054270wmq.17.1461532221104; Sun, 24 Apr 2016 14:10:21 -0700 (PDT) Received: from localhost.localdomain ([46.249.74.23]) by smtp.gmail.com with ESMTPSA id b2sm15440182wmb.9.2016.04.24.14.10.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 24 Apr 2016 14:10:20 -0700 (PDT) From: Ivaylo Dimitrov To: sakari.ailus@iki.fi Cc: sre@kernel.org, pali.rohar@gmail.com, pavel@ucw.cz, linux-media@vger.kernel.org Subject: [RFC PATCH 08/24] v4l: of: Obtain data bus type from bus-type property Date: Mon, 25 Apr 2016 00:08:08 +0300 Message-Id: <1461532104-24032-9-git-send-email-ivo.g.dimitrov.75@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1461532104-24032-1-git-send-email-ivo.g.dimitrov.75@gmail.com> References: <20160420081427.GZ32125@valkosipuli.retiisi.org.uk> <1461532104-24032-1-git-send-email-ivo.g.dimitrov.75@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sakari Ailus Only try parsing bus specific properties in this case. Signed-off-by: Sakari Ailus --- drivers/media/v4l2-core/v4l2-of.c | 42 +++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-of.c b/drivers/media/v4l2-core/v4l2-of.c index f2618fd..5304137 100644 --- a/drivers/media/v4l2-core/v4l2-of.c +++ b/drivers/media/v4l2-core/v4l2-of.c @@ -20,6 +20,11 @@ #include +enum v4l2_of_bus_type { + V4L2_OF_BUS_TYPE_CSI2 = 0, + V4L2_OF_BUS_TYPE_PARALLEL, +}; + static int v4l2_of_parse_csi2_bus(const struct device_node *node, struct v4l2_of_endpoint *endpoint) { @@ -151,6 +156,7 @@ static void v4l2_of_parse_parallel_bus(const struct device_node *node, int v4l2_of_parse_endpoint(const struct device_node *node, struct v4l2_of_endpoint *endpoint) { + u32 bus_type; int rval; of_graph_parse_endpoint(node, &endpoint->base); @@ -158,17 +164,33 @@ int v4l2_of_parse_endpoint(const struct device_node *node, memset(&endpoint->bus_type, 0, sizeof(*endpoint) - offsetof(typeof(*endpoint), bus_type)); - rval = v4l2_of_parse_csi2_bus(node, endpoint); - if (rval) - return rval; - /* - * Parse the parallel video bus properties only if none - * of the MIPI CSI-2 specific properties were found. - */ - if (endpoint->bus.mipi_csi2.flags == 0) - v4l2_of_parse_parallel_bus(node, endpoint); + rval = of_property_read_u32(node, "bus-type", &bus_type); + if (rval < 0) { + endpoint->bus_type = 0; + rval = v4l2_of_parse_csi2_bus(node, endpoint); + if (rval) + return rval; + /* + * Parse the parallel video bus properties only if none + * of the MIPI CSI-2 specific properties were found. + */ + if (endpoint->bus.mipi_csi2.flags == 0) + v4l2_of_parse_parallel_bus(node, endpoint); + + return 0; + } - return 0; + switch (bus_type) { + case V4L2_OF_BUS_TYPE_CSI2: + return v4l2_of_parse_csi2_bus(node, endpoint); + case V4L2_OF_BUS_TYPE_PARALLEL: + v4l2_of_parse_parallel_bus(node, endpoint); + return 0; + default: + pr_warn("bad bus-type %u, device_node \"%s\"\n", + bus_type, node->full_name); + return -EINVAL; + } } EXPORT_SYMBOL(v4l2_of_parse_endpoint);