Thread (21 messages) 21 messages, 5 authors, 2014-07-02
STALE4401d
Revisions (5)
  1. rfc [diff vs current]
  2. rfc [diff vs current]
  3. rfc current
  4. v2 [diff vs current]
  5. v3 [diff vs current]

[PATCH RFC 3/8] component: add support for component match array

From: Russell King - ARM Linux <hidden>
Date: 2014-06-24 19:08:18

On Mon, Apr 28, 2014 at 11:21:32AM +0200, Thierry Reding wrote:
On Sun, Apr 27, 2014 at 12:01:58AM +0100, Russell King wrote:
quoted
Add support for generating a set of component matches at master probe
time, and submitting them to the component layer.  This allows the
component layer to perform the matches internally without needing to
call into the master driver, and allows for further restructuring of
the component helper.

Signed-off-by: Russell King <redacted>
---
 drivers/base/component.c  | 118 ++++++++++++++++++++++++++++++++++++++++++++--
 include/linux/component.h |   7 +++
 2 files changed, 122 insertions(+), 3 deletions(-)
diff --git a/drivers/base/component.c b/drivers/base/component.c
[...]
quoted
+void component_match_add(struct device *dev, struct component_match **matchptr,
+	int (*compare)(struct device *, void *), void *compare_data)
+{
+	struct component_match *match = *matchptr;
+
+	if (IS_ERR(match))
+		return;
+
+	if (!match || ++match->num == match->alloc) {
+		size_t new_size = match ? match->alloc + 16 : 15;
Doesn't this allocate prematurely? If component_match_add() is called on
the final component of a master, then match->num will be incremented to
it's final value. If that matches match->alloc, then things are just
fine, aren't they? No need to allocate another 16 entries.
This code appears to be correct - `num' is actually one less than the
number of components.

However, that makes code elsewhere wrong... v2 coming up soon with this
fixed.  Good catch.

-- 
FTTC broadband for 0.8mile line: now at 9.7Mbps down 460kbps up... slowly
improving, and getting towards what was expected from it.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help