greybus: uart-gb: convert over to the connection interface
authorGreg Kroah-Hartman <greg@kroah.com>
Mon, 27 Oct 2014 09:32:34 +0000 (17:32 +0800)
committerGreg Kroah-Hartman <greg@kroah.com>
Mon, 27 Oct 2014 09:32:34 +0000 (17:32 +0800)
Move the uart code over to use the "new" connection interface, instead
of the "old" module interface.

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
drivers/staging/greybus/connection.c
drivers/staging/greybus/greybus.h
drivers/staging/greybus/uart-gb.c

index 2d71679ff66cb66038c40e04ff9deadc952d6614..2d3421f6aa10dc5f06a0a6e526f01ca39d2cf24d 100644 (file)
@@ -285,9 +285,11 @@ int gb_connection_init(struct gb_connection *connection)
        case GREYBUS_PROTOCOL_BATTERY:
                ret = gb_battery_device_init(connection);
                break;
+       case GREYBUS_PROTOCOL_UART:
+               ret = gb_uart_device_init(connection);
+               break;
        case GREYBUS_PROTOCOL_CONTROL:
        case GREYBUS_PROTOCOL_AP:
-       case GREYBUS_PROTOCOL_UART:
        case GREYBUS_PROTOCOL_HID:
        case GREYBUS_PROTOCOL_LED:
        case GREYBUS_PROTOCOL_VENDOR:
@@ -318,9 +320,11 @@ void gb_connection_exit(struct gb_connection *connection)
        case GREYBUS_PROTOCOL_BATTERY:
                gb_battery_device_exit(connection);
                break;
+       case GREYBUS_PROTOCOL_UART:
+               gb_uart_device_exit(connection);
+               break;
        case GREYBUS_PROTOCOL_CONTROL:
        case GREYBUS_PROTOCOL_AP:
-       case GREYBUS_PROTOCOL_UART:
        case GREYBUS_PROTOCOL_HID:
        case GREYBUS_PROTOCOL_VENDOR:
        default:
index 1e3f31d4a058349a67e039f6e8e6b1c39da20a1e..c700b0d78a10169983d1c166dadd8c5bfc633863 100644 (file)
@@ -275,6 +275,9 @@ void gb_battery_device_exit(struct gb_connection *connection);
 int gb_gpio_controller_init(struct gb_connection *connection);
 void gb_gpio_controller_exit(struct gb_connection *connection);
 
+int gb_uart_device_init(struct gb_connection *connection);
+void gb_uart_device_exit(struct gb_connection *connection);
+
 int gb_tty_init(void);
 void gb_tty_exit(void);
 
index 301868cd587830ff232d8a1db61fbab7d639f509..d15a49b3b11d4af00d12df208ac78a753e26fdd4 100644 (file)
@@ -35,7 +35,7 @@
 
 struct gb_tty {
        struct tty_port port;
-       struct gb_module *gmod;
+       struct gb_connection *connection;
        u16 cport_id;
        unsigned int minor;
        unsigned char clocal;
@@ -386,8 +386,7 @@ static const struct tty_operations gb_ops = {
 };
 
 
-int gb_tty_probe(struct gb_module *gmod,
-                const struct greybus_module_id *id)
+int gb_uart_device_init(struct gb_connection *connection)
 {
        struct gb_tty *gb_tty;
        struct device *tty_dev;
@@ -401,14 +400,14 @@ int gb_tty_probe(struct gb_module *gmod,
        minor = alloc_minor(gb_tty);
        if (minor < 0) {
                if (minor == -ENOSPC) {
-                       dev_err(&gmod->dev, "no more free minor numbers\n");
+                       dev_err(&connection->dev, "no more free minor numbers\n");
                        return -ENODEV;
                }
                return minor;
        }
 
        gb_tty->minor = minor;
-       gb_tty->gmod = gmod;
+       gb_tty->connection = connection;
        spin_lock_init(&gb_tty->write_lock);
        spin_lock_init(&gb_tty->read_lock);
        init_waitqueue_head(&gb_tty->wioctl);
@@ -416,10 +415,10 @@ int gb_tty_probe(struct gb_module *gmod,
 
        /* FIXME - allocate gb buffers */
 
-       gmod->gb_tty = gb_tty;
+       connection->private = gb_tty;
 
        tty_dev = tty_port_register_device(&gb_tty->port, gb_tty_driver, minor,
-                                          &gmod->dev);
+                                          &connection->dev);
        if (IS_ERR(tty_dev)) {
                retval = PTR_ERR(tty_dev);
                goto error;
@@ -427,14 +426,14 @@ int gb_tty_probe(struct gb_module *gmod,
 
        return 0;
 error:
-       gmod->gb_tty = NULL;
+       connection->private = NULL;
        release_minor(gb_tty);
        return retval;
 }
 
-void gb_tty_disconnect(struct gb_module *gmod)
+void gb_uart_device_exit(struct gb_connection *connection)
 {
-       struct gb_tty *gb_tty = gmod->gb_tty;
+       struct gb_tty *gb_tty = connection->private;
        struct tty_struct *tty;
 
        if (!gb_tty)
@@ -444,7 +443,7 @@ void gb_tty_disconnect(struct gb_module *gmod)
        gb_tty->disconnected = true;
 
        wake_up_all(&gb_tty->wioctl);
-       gmod->gb_tty = NULL;
+       connection->private = NULL;
        mutex_unlock(&gb_tty->mutex);
 
        tty = tty_port_tty_get(&gb_tty->port);
@@ -463,14 +462,6 @@ void gb_tty_disconnect(struct gb_module *gmod)
        kfree(gb_tty);
 }
 
-#if 0
-static struct greybus_driver tty_gb_driver = {
-       .probe =        gb_tty_probe,
-       .disconnect =   gb_tty_disconnect,
-       .id_table =     id_table,
-};
-#endif
-
 int __init gb_tty_init(void)
 {
        int retval = 0;