From: Alex Elder Date: Wed, 3 Dec 2014 18:27:42 +0000 (-0600) Subject: greybus: set up connection->private properly X-Git-Tag: v4.9-rc1~119^2~378^2~21^2~1782 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=93bbe859b75616ebdc33722c3b30cf36e74161a8;p=karo-tx-linux.git 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: Alex Elder Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/greybus/gpio-gb.c b/drivers/staging/greybus/gpio-gb.c index 09d77c1e6c07..c573ccec40aa 100644 --- a/drivers/staging/greybus/gpio-gb.c +++ b/drivers/staging/greybus/gpio-gb.c @@ -472,6 +472,7 @@ static int gb_gpio_connection_init(struct gb_connection *connection) if (!gb_gpio_controller) return -ENOMEM; gb_gpio_controller->connection = connection; + connection->private = gb_gpio_controller; ret = gb_gpio_controller_setup(gb_gpio_controller); if (ret) @@ -502,7 +503,6 @@ static int gb_gpio_connection_init(struct gb_connection *connection) pr_err("Failed to register GPIO\n"); return ret; } - connection->private = gb_gpio_controller; return 0; out_err: diff --git a/drivers/staging/greybus/i2c-gb.c b/drivers/staging/greybus/i2c-gb.c index bd1bada3b372..8936389f5e2e 100644 --- a/drivers/staging/greybus/i2c-gb.c +++ b/drivers/staging/greybus/i2c-gb.c @@ -377,6 +377,7 @@ static int gb_i2c_connection_init(struct gb_connection *connection) return -ENOMEM; gb_i2c_dev->connection = connection; /* refcount? */ + connection->private = gb_i2c_dev; ret = gb_i2c_device_setup(gb_i2c_dev); if (ret) @@ -399,8 +400,6 @@ static int gb_i2c_connection_init(struct gb_connection *connection) if (ret) goto out_err; - connection->private = gb_i2c_dev; - return 0; out_err: /* kref_put(gb_i2c_dev->connection) */ diff --git a/drivers/staging/greybus/pwm-gb.c b/drivers/staging/greybus/pwm-gb.c index 9678b6431760..c505f1d2d676 100644 --- a/drivers/staging/greybus/pwm-gb.c +++ b/drivers/staging/greybus/pwm-gb.c @@ -266,6 +266,7 @@ static int gb_pwm_connection_init(struct gb_connection *connection) if (!pwmc) return -ENOMEM; pwmc->connection = connection; + connection->private = pwmc; /* Check for compatible protocol version */ ret = gb_pwm_proto_version_operation(pwmc); @@ -290,7 +291,6 @@ static int gb_pwm_connection_init(struct gb_connection *connection) pr_err("Failed to register PWM\n"); return ret; } - connection->private = pwmc; return 0; out_err: diff --git a/drivers/staging/greybus/uart-gb.c b/drivers/staging/greybus/uart-gb.c index 6432c64fbd60..fad8635a8335 100644 --- a/drivers/staging/greybus/uart-gb.c +++ b/drivers/staging/greybus/uart-gb.c @@ -637,6 +637,7 @@ static int gb_uart_connection_init(struct gb_connection *connection) if (!gb_tty) return -ENOMEM; gb_tty->connection = connection; + connection->private = gb_tty; /* Check for compatible protocol version */ retval = get_version(gb_tty); @@ -659,8 +660,6 @@ static int gb_uart_connection_init(struct gb_connection *connection) init_waitqueue_head(&gb_tty->wioctl); mutex_init(&gb_tty->mutex); - connection->private = gb_tty; - send_control(gb_tty, gb_tty->ctrlout); /* initialize the uart to be 9600n81 */ diff --git a/drivers/staging/greybus/usb-gb.c b/drivers/staging/greybus/usb-gb.c index e5da72a60b89..b3092ed1a191 100644 --- a/drivers/staging/greybus/usb-gb.c +++ b/drivers/staging/greybus/usb-gb.c @@ -341,6 +341,7 @@ static int gb_usb_connection_init(struct gb_connection *connection) return -ENOMEM; gb_usb_dev->connection = connection; + connection->private = gb_usb_dev; /* Check for compatible protocol version */ retval = get_version(gb_usb_dev); diff --git a/drivers/staging/greybus/vibrator-gb.c b/drivers/staging/greybus/vibrator-gb.c index d00301dce8f0..8970c69ea893 100644 --- a/drivers/staging/greybus/vibrator-gb.c +++ b/drivers/staging/greybus/vibrator-gb.c @@ -139,6 +139,7 @@ static int gb_vibrator_connection_init(struct gb_connection *connection) return -ENOMEM; vib->connection = connection; + connection->private = vib; retval = get_version(vib); if (retval)