greybus: protocol: switch gb_protocol_register() to return an int

We will want to return this value as a return value for module_init()
and bool does not play well with module_init().  So make it a "real"
error value and return int and fix up all callers of the function.

Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
This commit is contained in:
Greg Kroah-Hartman 2014-12-23 15:16:51 -08:00
parent 86cad66677
commit 7c7d5b9a94
10 changed files with 33 additions and 31 deletions

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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;
}

View file

@ -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);

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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;