linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] staging: greybus: loopback.c: remove unused gb_loopback::lbid
@ 2018-10-05 14:28 Rasmus Villemoes
  2018-10-05 14:28 ` [PATCH 2/3] staging: greybus: loopback.c: do insertion in O(n) instead of O(n lg n) Rasmus Villemoes
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Rasmus Villemoes @ 2018-10-05 14:28 UTC (permalink / raw)
  To: Bryan O'Donoghue, Johan Hovold, Alex Elder, Greg Kroah-Hartman
  Cc: Rasmus Villemoes, greybus-dev, devel, linux-kernel

It's not obvious how the code prevents adding more than 31 elements to
the list and thus invoking undefined behaviour in the 1 << new_lbid
expression, and in practice causing ->lbid values to repeat every 32
elements.

But the definition of struct gb_loopback is local to loopback.c, and the
lbid field is entirely unused outside of this function, so it seems we
can just drop it entirely.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
Since lbid isn't mentioned anywhere else in greybus/, it's hard to
figure out how it was meant to be used. It does seem like entirely
dead (write-only) code.

 drivers/staging/greybus/loopback.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c
index 42f6f3de967c..7080294f705c 100644
--- a/drivers/staging/greybus/loopback.c
+++ b/drivers/staging/greybus/loopback.c
@@ -97,7 +97,6 @@ struct gb_loopback {
 	u32 timeout_min;
 	u32 timeout_max;
 	u32 outstanding_operations_max;
-	u32 lbid;
 	u64 elapsed_nsecs;
 	u32 apbridge_latency_ts;
 	u32 gbphy_latency_ts;
@@ -1014,16 +1013,9 @@ static int gb_loopback_bus_id_compare(void *priv, struct list_head *lha,
 
 static void gb_loopback_insert_id(struct gb_loopback *gb)
 {
-	struct gb_loopback *gb_list;
-	u32 new_lbid = 0;
-
 	/* perform an insertion sort */
 	list_add_tail(&gb->entry, &gb_dev.list);
 	list_sort(NULL, &gb_dev.list, gb_loopback_bus_id_compare);
-	list_for_each_entry(gb_list, &gb_dev.list, entry) {
-		gb_list->lbid = 1 << new_lbid;
-		new_lbid++;
-	}
 }
 
 #define DEBUGFS_NAMELEN 32
-- 
2.19.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-10-24 10:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-05 14:28 [PATCH 1/3] staging: greybus: loopback.c: remove unused gb_loopback::lbid Rasmus Villemoes
2018-10-05 14:28 ` [PATCH 2/3] staging: greybus: loopback.c: do insertion in O(n) instead of O(n lg n) Rasmus Villemoes
2018-10-10 23:03   ` Bryan O'Donoghue
2018-10-11 10:11     ` Rasmus Villemoes
2018-10-23 16:20     ` Rasmus Villemoes
2018-10-23 22:30       ` Bryan O'Donoghue
2018-10-05 14:28 ` [PATCH 3/3] staging: greybus: loopback.c: simplify prototype of gb_loopback_bus_id_compare Rasmus Villemoes
2018-10-10 22:57 ` [PATCH 1/3] staging: greybus: loopback.c: remove unused gb_loopback::lbid Bryan O'Donoghue
2018-10-24 10:48 ` [PATCH v2] staging: greybus: loopback.c: remove unused lists Rasmus Villemoes

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).