From: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
To: Mauro Carvalho Chehab <mchehab@kernel.org>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: "Geert Uytterhoeven" <geert@linux-m68k.org>,
linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
"Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
Subject: [PATCHv2] v4l: of: check for unique lanes in data-lanes and clock-lanes
Date: Tue, 31 Jan 2017 13:08:31 +0100 [thread overview]
Message-ID: <20170131120831.11283-1-niklas.soderlund+renesas@ragnatech.se> (raw)
All lanes in data-lanes and clock-lanes properties should be unique. Add
a check for this in v4l2_of_parse_csi_bus() and print a warning if
duplicated lanes are found.
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
Changes since v1:
- Do not return -EINVAL if a duplicate is found. Sakari pointed out
there are drivers where the number of lanes matter but not the actual
lane numbers. Updated commit message to highlight that only a warning
is printed.
- Switched to a bitmask to track lanes used instead of a nested loop,
thanks Laurent for the suggestion.
drivers/media/v4l2-core/v4l2-of.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/media/v4l2-core/v4l2-of.c b/drivers/media/v4l2-core/v4l2-of.c
index 93b33681776ca427..4f59f442dd0a64c9 100644
--- a/drivers/media/v4l2-core/v4l2-of.c
+++ b/drivers/media/v4l2-core/v4l2-of.c
@@ -26,7 +26,7 @@ static int v4l2_of_parse_csi_bus(const struct device_node *node,
struct v4l2_of_bus_mipi_csi2 *bus = &endpoint->bus.mipi_csi2;
struct property *prop;
bool have_clk_lane = false;
- unsigned int flags = 0;
+ unsigned int flags = 0, lanes_used = 0;
u32 v;
prop = of_find_property(node, "data-lanes", NULL);
@@ -38,6 +38,12 @@ static int v4l2_of_parse_csi_bus(const struct device_node *node,
lane = of_prop_next_u32(prop, lane, &v);
if (!lane)
break;
+
+ if (lanes_used & BIT(v))
+ pr_warn("%s: duplicated lane %u in data-lanes\n",
+ node->full_name, v);
+ lanes_used |= BIT(v);
+
bus->data_lanes[i] = v;
}
bus->num_data_lanes = i;
@@ -63,6 +69,11 @@ static int v4l2_of_parse_csi_bus(const struct device_node *node,
}
if (!of_property_read_u32(node, "clock-lanes", &v)) {
+ if (lanes_used & BIT(v))
+ pr_warn("%s: duplicated lane %u in clock-lanes\n",
+ node->full_name, v);
+ lanes_used |= BIT(v);
+
bus->clock_lane = v;
have_clk_lane = true;
}
--
2.11.0
next reply other threads:[~2017-01-31 12:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-31 12:08 Niklas Söderlund [this message]
2017-01-31 12:12 ` [PATCHv2] v4l: of: check for unique lanes in data-lanes and clock-lanes Sakari Ailus
2017-02-01 12:31 ` Laurent Pinchart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170131120831.11283-1-niklas.soderlund+renesas@ragnatech.se \
--to=niklas.soderlund+renesas@ragnatech.se \
--cc=geert@linux-m68k.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=mchehab@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).