Commit 6869eb56 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

greybus: Revert "protocol: dedup protocol find code"

This reverts commit 241b5fefc54eae95239b0f7dc4e2b0db49457729 as it's
wrong, we want to insert into the correct place in the list.
Reported-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent c1a0a8fc
...@@ -20,13 +20,6 @@ static struct gb_protocol *_gb_protocol_find(u8 id, u8 major, u8 minor) ...@@ -20,13 +20,6 @@ static struct gb_protocol *_gb_protocol_find(u8 id, u8 major, u8 minor)
{ {
struct gb_protocol *protocol; struct gb_protocol *protocol;
/*
* The protocols list is sorted first by protocol id (low to
* high), then by major version (high to low), and finally
* by minor version (high to low). Searching only by
* protocol id will produce the newest implemented version
* of the protocol.
*/
list_for_each_entry(protocol, &gb_protocols, links) { list_for_each_entry(protocol, &gb_protocols, links) {
if (protocol->id < id) if (protocol->id < id)
continue; continue;
...@@ -57,12 +50,34 @@ int __gb_protocol_register(struct gb_protocol *protocol, struct module *module) ...@@ -57,12 +50,34 @@ int __gb_protocol_register(struct gb_protocol *protocol, struct module *module)
protocol->owner = module; protocol->owner = module;
/*
* The protocols list is sorted first by protocol id (low to
* high), then by major version (high to low), and finally
* by minor version (high to low). Searching only by
* protocol id will produce the newest implemented version
* of the protocol.
*/
spin_lock_irq(&gb_protocols_lock); spin_lock_irq(&gb_protocols_lock);
/* check if the protocol already wos registered */ list_for_each_entry(existing, &gb_protocols, links) {
existing = _gb_protocol_find(id, major, minor); if (existing->id < id)
if (existing) { continue;
if (existing->id > id)
break;
if (existing->major > major)
continue;
if (existing->major < major)
break;
if (existing->minor > minor)
continue;
if (existing->minor < minor)
break;
/* A matching protocol has already been registered */
spin_unlock_irq(&gb_protocols_lock); spin_unlock_irq(&gb_protocols_lock);
return -EEXIST; return -EEXIST;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment