greybus: protocol: name protocols.
authorGreg Kroah-Hartman <greg@kroah.com>
Wed, 24 Dec 2014 21:01:45 +0000 (13:01 -0800)
committerGreg Kroah-Hartman <greg@kroah.com>
Fri, 2 Jan 2015 21:06:48 +0000 (13:06 -0800)
We want to be able to "blame" a protocol for things at times, so give
them a name we can refer to them by.  Announce when they are added or
removed from the system so we have a chance to know what is going on
in the kernel logs.

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Reviewed-by: Alex Elder <elder@linaro.org>
drivers/staging/greybus/battery-gb.c
drivers/staging/greybus/gpio-gb.c
drivers/staging/greybus/i2c-gb.c
drivers/staging/greybus/protocol.c
drivers/staging/greybus/protocol.h
drivers/staging/greybus/pwm-gb.c
drivers/staging/greybus/sdio-gb.c
drivers/staging/greybus/uart-gb.c
drivers/staging/greybus/usb-gb.c
drivers/staging/greybus/vibrator-gb.c

index 7ce37377bca5a6a1331c25a4c31106639fdf9383..2130d73cbfdee4be8de253e4fe92b069c90796b9 100644 (file)
@@ -359,6 +359,7 @@ static void gb_battery_connection_exit(struct gb_connection *connection)
 }
 
 static struct gb_protocol battery_protocol = {
+       .name                   = "battery",
        .id                     = GREYBUS_PROTOCOL_BATTERY,
        .major                  = 0,
        .minor                  = 1,
index cf60a4a96b292cfa0bcd08609516437e6a33499d..5fcd018141261825233076f8c98fb63686b10d0e 100644 (file)
@@ -524,6 +524,7 @@ static void gb_gpio_connection_exit(struct gb_connection *connection)
 }
 
 static struct gb_protocol gpio_protocol = {
+       .name                   = "gpio",
        .id                     = GREYBUS_PROTOCOL_GPIO,
        .major                  = 0,
        .minor                  = 1,
index b78de6b4be10b268d69e9f4746672c099374943c..3b86258d2dcfd85fbf916f245c3652a82f0950ff 100644 (file)
@@ -430,6 +430,7 @@ static void gb_i2c_connection_exit(struct gb_connection *connection)
 }
 
 static struct gb_protocol i2c_protocol = {
+       .name                   = "i2c",
        .id                     = GREYBUS_PROTOCOL_I2C,
        .major                  = 0,
        .minor                  = 1,
index 654adbc0b787c6fe36d7c1a00b7b2eae7f20bb95..4d6ffdd04ab83ce268be44ea36dc2db7887d6607 100644 (file)
@@ -7,6 +7,8 @@
  * Released under the GPLv2 only.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include "greybus.h"
 
 /* Global list of registered protocols */
@@ -86,6 +88,8 @@ int __gb_protocol_register(struct gb_protocol *protocol, struct module *module)
        list_add_tail(&protocol->links, &existing->links);
        spin_unlock_irq(&gb_protocols_lock);
 
+       pr_info("Registered %s protocol.\n", protocol->name);
+
        /*
         * Go try to bind any unbound connections, as we have a
         * new protocol in the system
@@ -124,6 +128,9 @@ int gb_protocol_deregister(struct gb_protocol *protocol)
        }
        spin_unlock_irq(&gb_protocols_lock);
 
+       if (protocol)
+               pr_info("Deregistered %s protocol.\n", protocol->name);
+
        return protocol && !protocol_count;
 }
 EXPORT_SYMBOL_GPL(gb_protocol_deregister);
index 2d4fcfac8052f1cd2ad4db98389b0d09151ceb3b..8bda524a4d6d7d226e57b32e2d900bd32fab2fe5 100644 (file)
@@ -35,6 +35,7 @@ struct gb_protocol {
        gb_connection_exit_t    connection_exit;
        gb_request_recv_t       request_recv;
        struct module           *owner;
+       char                    *name;
 };
 
 int __gb_protocol_register(struct gb_protocol *protocol, struct module *module);
index 5f02e78029496cab5c5708e0d5b9fc1cb8fa73d7..91f7b87a1caec00834096c21d5458a56d3152159 100644 (file)
@@ -311,6 +311,7 @@ static void gb_pwm_connection_exit(struct gb_connection *connection)
 }
 
 static struct gb_protocol pwm_protocol = {
+       .name                   = "pwm",
        .id                     = GREYBUS_PROTOCOL_PWM,
        .major                  = 0,
        .minor                  = 1,
index 13293a6f358e3c0d1a40b9ccb0984f9cb12e1adb..d324846d09ab25ce647476301384c005a6711e17 100644 (file)
@@ -79,6 +79,7 @@ static void gb_sdio_connection_exit(struct gb_connection *connection)
 }
 
 static struct gb_protocol sdio_protocol = {
+       .name                   = "sdio",
        .id                     = GREYBUS_PROTOCOL_SDIO,
        .major                  = 0,
        .minor                  = 1,
index 825de7462f7be5b041d0f73887dd1726950ffd09..032062019d20612b7524775be5d9c6ba58c2d0a4 100644 (file)
@@ -767,6 +767,7 @@ static void gb_tty_exit(void)
 }
 
 static struct gb_protocol uart_protocol = {
+       .name                   = "uart",
        .id                     = GREYBUS_PROTOCOL_UART,
        .major                  = 0,
        .minor                  = 1,
index b3ba50b502ec6ab5feacd000fd4025dd14d970d4..010ef9ee831f6e5fa903f6dc116b0f2d802861d7 100644 (file)
@@ -376,6 +376,7 @@ static void gb_usb_connection_exit(struct gb_connection *connection)
 }
 
 static struct gb_protocol usb_protocol = {
+       .name                   = "usb",
        .id                     = GREYBUS_PROTOCOL_USB,
        .major                  = 0,
        .minor                  = 1,
index 71c96d3da9eda055551e0f7b4ab8ef80a93a8927..c85d95085040d53f16c8b14e11c2834279eea285 100644 (file)
@@ -197,6 +197,7 @@ static void gb_vibrator_connection_exit(struct gb_connection *connection)
 }
 
 static struct gb_protocol vibrator_protocol = {
+       .name                   = "vibrator",
        .id                     = GREYBUS_PROTOCOL_VIBRATOR,
        .major                  = 0,
        .minor                  = 1,