]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
greybus: protocol: warn on protocol put errors
authorJohan Hovold <johan@hovoldconsulting.com>
Tue, 13 Oct 2015 17:10:25 +0000 (19:10 +0200)
committerGreg Kroah-Hartman <gregkh@google.com>
Wed, 14 Oct 2015 19:06:00 +0000 (12:06 -0700)
Issue a warning if we fail to look up a protocol when dropping a
reference.

This should never happen as we hold a reference to the protocol module
and protocols should only be deregistered at module unload.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/protocol.c

index 140baa68546980f865849f5918c2b8e47ae2729f..b9de152bade08b1665f92b64662b4c84e6673b41 100644 (file)
@@ -188,7 +188,6 @@ void gb_protocol_put(struct gb_protocol *protocol)
        u8 id;
        u8 major;
        u8 minor;
-       u8 protocol_count;
 
        id = protocol->id;
        major = protocol->major;
@@ -196,16 +195,11 @@ void gb_protocol_put(struct gb_protocol *protocol)
 
        spin_lock_irq(&gb_protocols_lock);
        protocol = gb_protocol_find(id, major, minor);
-       if (protocol) {
-               protocol_count = protocol->count;
-               if (protocol_count)
-                       protocol->count--;
-               module_put(protocol->owner);
-       }
+       if (WARN_ON(!protocol || !protocol->count))
+               goto out;
+
+       protocol->count--;
+       module_put(protocol->owner);
+out:
        spin_unlock_irq(&gb_protocols_lock);
-       if (protocol)
-               WARN_ON(!protocol_count);
-       else
-               pr_err("protocol id %hhu version %hhu.%hhu not found\n",
-                       id, major, minor);
 }