Commit 93bbe859 authored by Alex Elder's avatar Alex Elder Committed by Greg Kroah-Hartman

greybus: set up connection->private properly

The connection->private pointer should refer to a protocol-specific
data structure.  Change two protocol drivers (USB and vibrator) so
they now set this.

In addition, because the setup routine may need access to the
data structure, the private pointer should be set early--as
early as possible.  Make the UART, i2c, and GPIO protocol drivers
set the private pointer earlier.
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 62749a05
...@@ -472,6 +472,7 @@ static int gb_gpio_connection_init(struct gb_connection *connection) ...@@ -472,6 +472,7 @@ static int gb_gpio_connection_init(struct gb_connection *connection)
if (!gb_gpio_controller) if (!gb_gpio_controller)
return -ENOMEM; return -ENOMEM;
gb_gpio_controller->connection = connection; gb_gpio_controller->connection = connection;
connection->private = gb_gpio_controller;
ret = gb_gpio_controller_setup(gb_gpio_controller); ret = gb_gpio_controller_setup(gb_gpio_controller);
if (ret) if (ret)
...@@ -502,7 +503,6 @@ static int gb_gpio_connection_init(struct gb_connection *connection) ...@@ -502,7 +503,6 @@ static int gb_gpio_connection_init(struct gb_connection *connection)
pr_err("Failed to register GPIO\n"); pr_err("Failed to register GPIO\n");
return ret; return ret;
} }
connection->private = gb_gpio_controller;
return 0; return 0;
out_err: out_err:
......
...@@ -377,6 +377,7 @@ static int gb_i2c_connection_init(struct gb_connection *connection) ...@@ -377,6 +377,7 @@ static int gb_i2c_connection_init(struct gb_connection *connection)
return -ENOMEM; return -ENOMEM;
gb_i2c_dev->connection = connection; /* refcount? */ gb_i2c_dev->connection = connection; /* refcount? */
connection->private = gb_i2c_dev;
ret = gb_i2c_device_setup(gb_i2c_dev); ret = gb_i2c_device_setup(gb_i2c_dev);
if (ret) if (ret)
...@@ -399,8 +400,6 @@ static int gb_i2c_connection_init(struct gb_connection *connection) ...@@ -399,8 +400,6 @@ static int gb_i2c_connection_init(struct gb_connection *connection)
if (ret) if (ret)
goto out_err; goto out_err;
connection->private = gb_i2c_dev;
return 0; return 0;
out_err: out_err:
/* kref_put(gb_i2c_dev->connection) */ /* kref_put(gb_i2c_dev->connection) */
......
...@@ -266,6 +266,7 @@ static int gb_pwm_connection_init(struct gb_connection *connection) ...@@ -266,6 +266,7 @@ static int gb_pwm_connection_init(struct gb_connection *connection)
if (!pwmc) if (!pwmc)
return -ENOMEM; return -ENOMEM;
pwmc->connection = connection; pwmc->connection = connection;
connection->private = pwmc;
/* Check for compatible protocol version */ /* Check for compatible protocol version */
ret = gb_pwm_proto_version_operation(pwmc); ret = gb_pwm_proto_version_operation(pwmc);
...@@ -290,7 +291,6 @@ static int gb_pwm_connection_init(struct gb_connection *connection) ...@@ -290,7 +291,6 @@ static int gb_pwm_connection_init(struct gb_connection *connection)
pr_err("Failed to register PWM\n"); pr_err("Failed to register PWM\n");
return ret; return ret;
} }
connection->private = pwmc;
return 0; return 0;
out_err: out_err:
......
...@@ -637,6 +637,7 @@ static int gb_uart_connection_init(struct gb_connection *connection) ...@@ -637,6 +637,7 @@ static int gb_uart_connection_init(struct gb_connection *connection)
if (!gb_tty) if (!gb_tty)
return -ENOMEM; return -ENOMEM;
gb_tty->connection = connection; gb_tty->connection = connection;
connection->private = gb_tty;
/* Check for compatible protocol version */ /* Check for compatible protocol version */
retval = get_version(gb_tty); retval = get_version(gb_tty);
...@@ -659,8 +660,6 @@ static int gb_uart_connection_init(struct gb_connection *connection) ...@@ -659,8 +660,6 @@ static int gb_uart_connection_init(struct gb_connection *connection)
init_waitqueue_head(&gb_tty->wioctl); init_waitqueue_head(&gb_tty->wioctl);
mutex_init(&gb_tty->mutex); mutex_init(&gb_tty->mutex);
connection->private = gb_tty;
send_control(gb_tty, gb_tty->ctrlout); send_control(gb_tty, gb_tty->ctrlout);
/* initialize the uart to be 9600n81 */ /* initialize the uart to be 9600n81 */
......
...@@ -341,6 +341,7 @@ static int gb_usb_connection_init(struct gb_connection *connection) ...@@ -341,6 +341,7 @@ static int gb_usb_connection_init(struct gb_connection *connection)
return -ENOMEM; return -ENOMEM;
gb_usb_dev->connection = connection; gb_usb_dev->connection = connection;
connection->private = gb_usb_dev;
/* Check for compatible protocol version */ /* Check for compatible protocol version */
retval = get_version(gb_usb_dev); retval = get_version(gb_usb_dev);
......
...@@ -139,6 +139,7 @@ static int gb_vibrator_connection_init(struct gb_connection *connection) ...@@ -139,6 +139,7 @@ static int gb_vibrator_connection_init(struct gb_connection *connection)
return -ENOMEM; return -ENOMEM;
vib->connection = connection; vib->connection = connection;
connection->private = vib;
retval = get_version(vib); retval = get_version(vib);
if (retval) if (retval)
......
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