From patchwork Thu Jan 26 13:12:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 9539237 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3AA7A60429 for ; Thu, 26 Jan 2017 13:13:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A7C428174 for ; Thu, 26 Jan 2017 13:13:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E95A28249; Thu, 26 Jan 2017 13:13:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7233D281C3 for ; Thu, 26 Jan 2017 13:13:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751900AbdAZNNY (ORCPT ); Thu, 26 Jan 2017 08:13:24 -0500 Received: from smtp-4.sys.kth.se ([130.237.48.193]:38330 "EHLO smtp-4.sys.kth.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751707AbdAZNNY (ORCPT ); Thu, 26 Jan 2017 08:13:24 -0500 Received: from smtp-4.sys.kth.se (localhost.localdomain [127.0.0.1]) by smtp-4.sys.kth.se (Postfix) with ESMTP id 96FA01E79; Thu, 26 Jan 2017 14:13:21 +0100 (CET) X-Virus-Scanned: by amavisd-new at kth.se Received: from smtp-4.sys.kth.se ([127.0.0.1]) by smtp-4.sys.kth.se (smtp-4.sys.kth.se [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 4VO_7HIfz_Fu; Thu, 26 Jan 2017 14:13:15 +0100 (CET) X-KTH-Auth: niso [89.233.230.99] X-KTH-mail-from: niklas.soderlund+renesas@ragnatech.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by smtp-4.sys.kth.se (Postfix) with ESMTPSA id D6C963531; Thu, 26 Jan 2017 14:13:11 +0100 (CET) From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= To: Mauro Carvalho Chehab , Laurent Pinchart Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, =?UTF-8?q?Niklas=20S=C3=B6derlund?= Subject: [PATCH] v4l: of: check for unique lanes in data-lanes and clock-lanes Date: Thu, 26 Jan 2017 14:12:59 +0100 Message-Id: <20170126131259.5621-1-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP All lines in data-lanes and clock-lanes properties must be unique. Instead of drivers checking for this add it to the generic parser. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- drivers/media/v4l2-core/v4l2-of.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/media/v4l2-core/v4l2-of.c b/drivers/media/v4l2-core/v4l2-of.c index 93b33681776c..1042db6bb996 100644 --- a/drivers/media/v4l2-core/v4l2-of.c +++ b/drivers/media/v4l2-core/v4l2-of.c @@ -32,12 +32,19 @@ static int v4l2_of_parse_csi_bus(const struct device_node *node, prop = of_find_property(node, "data-lanes", NULL); if (prop) { const __be32 *lane = NULL; - unsigned int i; + unsigned int i, n; for (i = 0; i < ARRAY_SIZE(bus->data_lanes); i++) { lane = of_prop_next_u32(prop, lane, &v); if (!lane) break; + for (n = 0; n < i; n++) { + if (bus->data_lanes[n] == v) { + pr_warn("%s: duplicated lane %u in data-lanes\n", + node->full_name, v); + return -EINVAL; + } + } bus->data_lanes[i] = v; } bus->num_data_lanes = i; @@ -63,6 +70,15 @@ static int v4l2_of_parse_csi_bus(const struct device_node *node, } if (!of_property_read_u32(node, "clock-lanes", &v)) { + unsigned int n; + + for (n = 0; n < bus->num_data_lanes; n++) { + if (bus->data_lanes[n] == v) { + pr_warn("%s: duplicated lane %u in clock-lanes\n", + node->full_name, v); + return -EINVAL; + } + } bus->clock_lane = v; have_clk_lane = true; }