diff --git a/drivers/staging/greybus/battery-gb.c b/drivers/staging/greybus/battery-gb.c index df1d7ee08199..f6b0dd681430 100644 --- a/drivers/staging/greybus/battery-gb.c +++ b/drivers/staging/greybus/battery-gb.c @@ -367,7 +367,7 @@ static struct gb_protocol battery_protocol = { .request_recv = NULL, /* no incoming requests */ }; -bool gb_battery_protocol_init(void) +int gb_battery_protocol_init(void) { return gb_protocol_register(&battery_protocol); } diff --git a/drivers/staging/greybus/gpio-gb.c b/drivers/staging/greybus/gpio-gb.c index 152ba50d1693..cf60a4a96b29 100644 --- a/drivers/staging/greybus/gpio-gb.c +++ b/drivers/staging/greybus/gpio-gb.c @@ -532,7 +532,7 @@ static struct gb_protocol gpio_protocol = { .request_recv = NULL, /* no incoming requests */ }; -bool gb_gpio_protocol_init(void) +int gb_gpio_protocol_init(void) { return gb_protocol_register(&gpio_protocol); } diff --git a/drivers/staging/greybus/i2c-gb.c b/drivers/staging/greybus/i2c-gb.c index 491fac4feaf3..b78de6b4be10 100644 --- a/drivers/staging/greybus/i2c-gb.c +++ b/drivers/staging/greybus/i2c-gb.c @@ -438,7 +438,7 @@ static struct gb_protocol i2c_protocol = { .request_recv = NULL, /* no incoming requests */ }; -bool gb_i2c_protocol_init(void) +int gb_i2c_protocol_init(void) { return gb_protocol_register(&i2c_protocol); } diff --git a/drivers/staging/greybus/protocol.c b/drivers/staging/greybus/protocol.c index 4ca3ae533354..227c531fa903 100644 --- a/drivers/staging/greybus/protocol.c +++ b/drivers/staging/greybus/protocol.c @@ -39,8 +39,7 @@ static struct gb_protocol *_gb_protocol_find(u8 id, u8 major, u8 minor) return NULL; } -/* Returns true if protocol was successfully registered, false otherwise */ -bool gb_protocol_register(struct gb_protocol *protocol) +int gb_protocol_register(struct gb_protocol *protocol) { struct gb_protocol *existing; u8 id = protocol->id; @@ -75,7 +74,7 @@ bool gb_protocol_register(struct gb_protocol *protocol) /* A matching protocol has already been registered */ spin_unlock_irq(&gb_protocols_lock); - return false; + return -EEXIST; } /* @@ -85,7 +84,7 @@ bool gb_protocol_register(struct gb_protocol *protocol) list_add_tail(&protocol->links, &existing->links); spin_unlock_irq(&gb_protocols_lock); - return true; + return 0; } /* @@ -99,10 +98,13 @@ bool gb_protocol_register(struct gb_protocol *protocol) * * Returns true if successful, false otherwise. */ -bool gb_protocol_deregister(struct gb_protocol *protocol) +int gb_protocol_deregister(struct gb_protocol *protocol) { u8 protocol_count = 0; + if (!protocol) + return 0; + spin_lock_irq(&gb_protocols_lock); protocol = _gb_protocol_find(protocol->id, protocol->major, protocol->minor); @@ -166,35 +168,35 @@ bool gb_protocol_init(void) { bool ret = true; - if (!gb_battery_protocol_init()) { + if (gb_battery_protocol_init()) { pr_err("error initializing battery protocol\n"); ret = false; } - if (!gb_gpio_protocol_init()) { + if (gb_gpio_protocol_init()) { pr_err("error initializing gpio protocol\n"); ret = false; } - if (!gb_i2c_protocol_init()) { + if (gb_i2c_protocol_init()) { pr_err("error initializing i2c protocol\n"); ret = false; } - if (!gb_pwm_protocol_init()) { + if (gb_pwm_protocol_init()) { pr_err("error initializing pwm protocol\n"); ret = false; } - if (!gb_uart_protocol_init()) { + if (gb_uart_protocol_init()) { pr_err("error initializing uart protocol\n"); ret = false; } - if (!gb_sdio_protocol_init()) { + if (gb_sdio_protocol_init()) { pr_err("error initializing sdio protocol\n"); ret = false; } - if (!gb_vibrator_protocol_init()) { + if (gb_vibrator_protocol_init()) { pr_err("error initializing vibrator protocol\n"); ret = false; } - if (!gb_usb_protocol_init()) { + if (gb_usb_protocol_init()) { pr_err("error initializing usb protocol\n"); ret = false; } diff --git a/drivers/staging/greybus/protocol.h b/drivers/staging/greybus/protocol.h index 7d33b20b1808..49214d6a9af0 100644 --- a/drivers/staging/greybus/protocol.h +++ b/drivers/staging/greybus/protocol.h @@ -36,8 +36,8 @@ struct gb_protocol { gb_request_recv_t request_recv; }; -bool gb_protocol_register(struct gb_protocol *protocol); -bool gb_protocol_deregister(struct gb_protocol *protocol); +int gb_protocol_register(struct gb_protocol *protocol); +int gb_protocol_deregister(struct gb_protocol *protocol); struct gb_protocol *gb_protocol_get(u8 id, u8 major, u8 minor); void gb_protocol_put(struct gb_protocol *protocol); @@ -47,28 +47,28 @@ void gb_protocol_put(struct gb_protocol *protocol); * Declared here for now. They could be added via modules, or maybe * just use initcalls (which level?). */ -extern bool gb_battery_protocol_init(void); +extern int gb_battery_protocol_init(void); extern void gb_battery_protocol_exit(void); -extern bool gb_gpio_protocol_init(void); +extern int gb_gpio_protocol_init(void); extern void gb_gpio_protocol_exit(void); -extern bool gb_i2c_protocol_init(void); +extern int gb_i2c_protocol_init(void); extern void gb_i2c_protocol_exit(void); -extern bool gb_pwm_protocol_init(void); +extern int gb_pwm_protocol_init(void); extern void gb_pwm_protocol_exit(void); -extern bool gb_uart_protocol_init(void); +extern int gb_uart_protocol_init(void); extern void gb_uart_protocol_exit(void); -extern bool gb_sdio_protocol_init(void); +extern int gb_sdio_protocol_init(void); extern void gb_sdio_protocol_exit(void); -extern bool gb_vibrator_protocol_init(void); +extern int gb_vibrator_protocol_init(void); extern void gb_vibrator_protocol_exit(void); -extern bool gb_usb_protocol_init(void); +extern int gb_usb_protocol_init(void); extern void gb_usb_protocol_exit(void); bool gb_protocol_init(void); diff --git a/drivers/staging/greybus/pwm-gb.c b/drivers/staging/greybus/pwm-gb.c index c505f1d2d676..5f02e7802949 100644 --- a/drivers/staging/greybus/pwm-gb.c +++ b/drivers/staging/greybus/pwm-gb.c @@ -319,7 +319,7 @@ static struct gb_protocol pwm_protocol = { .request_recv = NULL, /* no incoming requests */ }; -bool gb_pwm_protocol_init(void) +int gb_pwm_protocol_init(void) { return gb_protocol_register(&pwm_protocol); } diff --git a/drivers/staging/greybus/sdio-gb.c b/drivers/staging/greybus/sdio-gb.c index 8de7dc467b31..13293a6f358e 100644 --- a/drivers/staging/greybus/sdio-gb.c +++ b/drivers/staging/greybus/sdio-gb.c @@ -87,7 +87,7 @@ static struct gb_protocol sdio_protocol = { .request_recv = NULL, /* no incoming requests */ }; -bool gb_sdio_protocol_init(void) +int gb_sdio_protocol_init(void) { return gb_protocol_register(&sdio_protocol); } diff --git a/drivers/staging/greybus/uart-gb.c b/drivers/staging/greybus/uart-gb.c index faba00ef1c22..825de7462f7b 100644 --- a/drivers/staging/greybus/uart-gb.c +++ b/drivers/staging/greybus/uart-gb.c @@ -775,7 +775,7 @@ static struct gb_protocol uart_protocol = { .request_recv = NULL, /* FIXME we have 2 types of requests!!! */ }; -bool gb_uart_protocol_init(void) +int gb_uart_protocol_init(void) { return gb_protocol_register(&uart_protocol); } diff --git a/drivers/staging/greybus/usb-gb.c b/drivers/staging/greybus/usb-gb.c index 2b5f69e59a46..b3ba50b502ec 100644 --- a/drivers/staging/greybus/usb-gb.c +++ b/drivers/staging/greybus/usb-gb.c @@ -384,7 +384,7 @@ static struct gb_protocol usb_protocol = { .request_recv = NULL, /* FIXME we have requests!!! */ }; -bool gb_usb_protocol_init(void) +int gb_usb_protocol_init(void) { return gb_protocol_register(&usb_protocol); } diff --git a/drivers/staging/greybus/vibrator-gb.c b/drivers/staging/greybus/vibrator-gb.c index fb48112692cf..3ef7d06160bb 100644 --- a/drivers/staging/greybus/vibrator-gb.c +++ b/drivers/staging/greybus/vibrator-gb.c @@ -205,7 +205,7 @@ static struct gb_protocol vibrator_protocol = { .request_recv = NULL, /* no incoming requests */ }; -bool gb_vibrator_protocol_init(void) +int gb_vibrator_protocol_init(void) { int retval;