]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
greybus: set up connection->private properly
authorAlex Elder <elder@linaro.org>
Wed, 3 Dec 2014 18:27:42 +0000 (12:27 -0600)
committerGreg Kroah-Hartman <greg@kroah.com>
Wed, 3 Dec 2014 23:08:17 +0000 (15:08 -0800)
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 <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
drivers/staging/greybus/gpio-gb.c
drivers/staging/greybus/i2c-gb.c
drivers/staging/greybus/pwm-gb.c
drivers/staging/greybus/uart-gb.c
drivers/staging/greybus/usb-gb.c
drivers/staging/greybus/vibrator-gb.c

index 09d77c1e6c0730426fb33daaf1b6ca298bdb09f9..c573ccec40aa9b65b0f8cf7413e7753fb5ec5cef 100644 (file)
@@ -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:
index bd1bada3b372b22a0b651e2a65c8524b5f85ec1a..8936389f5e2e9c6ccca02e4b65832ef3b81ea842 100644 (file)
@@ -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) */
index 9678b6431760625a8d3fd865935792160df0404b..c505f1d2d67608afa58a4d09ed391ad6b42c01de 100644 (file)
@@ -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:
index 6432c64fbd6065ec0ab3e0e2ff2c19a142f711d0..fad8635a8335947a7a4858c7e57e9a5d7264d743 100644 (file)
@@ -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 */
index e5da72a60b89efc91d4656640da0a38e8e87b551..b3092ed1a1917983ce75c1aff5fefe161601142c 100644 (file)
@@ -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);
index d00301dce8f007368cd5b9c445c29d813dbd8e47..8970c69ea89366d06d9e01962314e0e7b4de021d 100644 (file)
@@ -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)