]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
greybus: Merge branch 'master' into branch 'svc'.
authorGreg Kroah-Hartman <gregkh@google.com>
Wed, 12 Aug 2015 02:39:27 +0000 (19:39 -0700)
committerGreg Kroah-Hartman <gregkh@google.com>
Wed, 12 Aug 2015 02:40:01 +0000 (19:40 -0700)
This required some hand-tweaking in connection.c, hopefully I got it all
correct...

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
23 files changed:
drivers/staging/greybus/audio-gb-cmds.c
drivers/staging/greybus/audio.c
drivers/staging/greybus/audio.h
drivers/staging/greybus/battery.c
drivers/staging/greybus/connection.c
drivers/staging/greybus/connection.h
drivers/staging/greybus/control.c
drivers/staging/greybus/control.h
drivers/staging/greybus/gpio.c
drivers/staging/greybus/greybus_protocols.h
drivers/staging/greybus/hid.c
drivers/staging/greybus/i2c.c
drivers/staging/greybus/loopback.c
drivers/staging/greybus/protocol.c
drivers/staging/greybus/protocol.h
drivers/staging/greybus/pwm.c
drivers/staging/greybus/raw.c
drivers/staging/greybus/sdio.c
drivers/staging/greybus/spi.c
drivers/staging/greybus/svc.c
drivers/staging/greybus/uart.c
drivers/staging/greybus/usb.c
drivers/staging/greybus/vibrator.c

index 10de34d6fa93805b7e6cee863644a5556ffe09b6..112aed994fd260153a76d3f9299c38e50d3e9d0a 100644 (file)
 #include "greybus.h"
 #include "audio.h"
 
-#define GB_I2S_MGMT_VERSION_MAJOR              0x00
-#define GB_I2S_MGMT_VERSION_MINOR              0x01
-
-#define GB_I2S_DATA_VERSION_MAJOR              0x00
-#define GB_I2S_DATA_VERSION_MINOR              0x01
-
 /***********************************
  * GB I2S helper functions
  ***********************************/
-int gb_i2s_mgmt_get_version(struct gb_connection *connection)
-{
-       struct gb_protocol_version_response response;
-
-       memset(&response, 0, sizeof(response));
-       return gb_protocol_get_version(connection,
-                                      GB_I2S_MGMT_TYPE_PROTOCOL_VERSION,
-                                      NULL, 0, &response,
-                                      GB_I2S_MGMT_VERSION_MAJOR);
-}
-
-int gb_i2s_data_get_version(struct gb_connection *connection)
-{
-       struct gb_protocol_version_response response;
-
-       memset(&response, 0, sizeof(response));
-       return gb_protocol_get_version(connection,
-                                      GB_I2S_DATA_TYPE_PROTOCOL_VERSION,
-                                      NULL, 0, &response,
-                                      GB_I2S_DATA_VERSION_MAJOR);
-}
-
 int gb_i2s_mgmt_activate_cport(struct gb_connection *connection,
                                      uint16_t cport)
 {
index 9f5f95913e8f49c1598a8f0510c6aed9dc810e8c..6754c907cd6ef9bb84b1291f6912ada33b716db2 100644 (file)
@@ -225,12 +225,6 @@ static int gb_i2s_transmitter_connection_init(struct gb_connection *connection)
                goto out_card;
        }
 
-       ret = gb_i2s_data_get_version(connection);
-       if (ret) {
-               pr_err("i2s data get_version() failed: %d\n", ret);
-               goto out_get_ver;
-       }
-
 #if USE_RT5645
        rt5647_info.addr = RT5647_I2C_ADDR;
        strlcpy(rt5647_info.type, "rt5647", I2C_NAME_SIZE);
@@ -251,8 +245,10 @@ static int gb_i2s_transmitter_connection_init(struct gb_connection *connection)
 
        return 0;
 
+#if USE_RT5645
 out_get_ver:
        platform_device_unregister(&snd_dev->card);
+#endif
 out_card:
        platform_device_unregister(&snd_dev->cpu_dai);
 out_dai:
@@ -296,12 +292,6 @@ static int gb_i2s_mgmt_connection_init(struct gb_connection *connection)
        connection->private = snd_dev;
        spin_unlock_irqrestore(&snd_dev->lock, flags);
 
-       ret = gb_i2s_mgmt_get_version(connection);
-       if (ret) {
-               pr_err("i2s mgmt get_version() failed: %d\n", ret);
-               goto err_free_snd_dev;
-       }
-
        ret = gb_i2s_mgmt_get_cfgs(snd_dev, connection);
        if (ret) {
                pr_err("can't get i2s configurations: %d\n", ret);
@@ -357,7 +347,7 @@ static int gb_i2s_mgmt_report_event_recv(u8 type, struct gb_operation *op)
        }
 
        if (op->request->payload_size < sizeof(*req)) {
-               dev_err(&connection->dev, "Short request received: %zu, %zu\n",
+               dev_err(&connection->dev, "Short request received (%zu < %zu)\n",
                        op->request->payload_size, sizeof(*req));
                return -EINVAL;
        }
index da95c1b3cb1e9777abceb370292ba1e70b96d377..e4975930f29ad7c576d2b4f68d86b3c6798a9e81 100644 (file)
@@ -75,8 +75,6 @@ struct gb_snd {
 /*
  * GB I2S cmd functions
  */
-int gb_i2s_mgmt_get_version(struct gb_connection *connection);
-int gb_i2s_data_get_version(struct gb_connection *connection);
 int gb_i2s_mgmt_activate_cport(struct gb_connection *connection,
                                      uint16_t cport);
 int gb_i2s_mgmt_deactivate_cport(struct gb_connection *connection,
index e66623966dc92fa232d34372b0b7806a811804d7..a56eb81b23862a29d9b5d502dbe61be5ec09fe92 100644 (file)
@@ -32,8 +32,6 @@ struct gb_battery {
        // updates from the SVC "on the fly" so we don't have to always go ask
        // the battery for some information.  Hopefully...
        struct gb_connection *connection;
-       u8 version_major;
-       u8 version_minor;
 
 };
 
@@ -42,8 +40,6 @@ struct gb_battery {
 #define        GB_BATTERY_VERSION_MINOR                0x01
 
 /* Greybus battery request types */
-#define        GB_BATTERY_TYPE_INVALID                 0x00
-#define        GB_BATTERY_TYPE_PROTOCOL_VERSION        0x01
 #define        GB_BATTERY_TYPE_TECHNOLOGY              0x02
 #define        GB_BATTERY_TYPE_STATUS                  0x03
 #define        GB_BATTERY_TYPE_MAX_VOLTAGE             0x04
@@ -94,9 +90,6 @@ struct gb_battery_voltage_response {
        __le32  voltage;
 };
 
-/* Define get_version() routine */
-define_get_version(gb_battery, BATTERY);
-
 static int get_tech(struct gb_battery *gb)
 {
        struct gb_battery_technology_response tech_response;
@@ -345,12 +338,7 @@ static int gb_battery_connection_init(struct gb_connection *connection)
        gb->connection = connection;
        connection->private = gb;
 
-       /* Check the version */
-       retval = get_version(gb);
-       if (retval)
-               goto out;
        retval = init_and_register(connection, gb);
-out:
        if (retval)
                kfree(gb);
 
@@ -372,8 +360,8 @@ static void gb_battery_connection_exit(struct gb_connection *connection)
 static struct gb_protocol battery_protocol = {
        .name                   = "battery",
        .id                     = GREYBUS_PROTOCOL_BATTERY,
-       .major                  = 0,
-       .minor                  = 1,
+       .major                  = GB_BATTERY_VERSION_MAJOR,
+       .minor                  = GB_BATTERY_VERSION_MINOR,
        .connection_init        = gb_battery_connection_init,
        .connection_exit        = gb_battery_connection_exit,
        .request_recv           = NULL, /* no incoming requests */
index 1a657f706b93124303151ac521d057e1a6e9cb14..ef837c50fcfbfbc9e72e0f371f18b9055c16eb3c 100644 (file)
@@ -335,6 +335,28 @@ void gb_connection_destroy(struct gb_connection *connection)
        device_unregister(&connection->dev);
 }
 
+static void gb_connection_disconnected(struct gb_connection *connection)
+{
+       struct gb_control *control;
+       int cport_id = connection->intf_cport_id;
+       int ret;
+
+       /*
+        * Inform Interface about In-active CPorts. We don't need to do this
+        * operation for control cport.
+        */
+       if ((cport_id == GB_CONTROL_CPORT_ID) ||
+           (connection->hd_cport_id == GB_SVC_CPORT_ID))
+               return;
+
+       control = connection->bundle->intf->control;
+
+       ret = gb_control_disconnected_operation(control, cport_id);
+       if (ret)
+               dev_warn(&connection->dev,
+                       "Failed to disconnect CPort-%d (%d)\n", cport_id, ret);
+}
+
 int gb_connection_init(struct gb_connection *connection)
 {
        int cport_id = connection->intf_cport_id;
@@ -367,20 +389,35 @@ int gb_connection_init(struct gb_connection *connection)
        connection->state = GB_CONNECTION_STATE_ENABLED;
        spin_unlock_irq(&connection->lock);
 
-       ret = connection->protocol->connection_init(connection);
-       if (ret) {
-               spin_lock_irq(&connection->lock);
-               connection->state = GB_CONNECTION_STATE_ERROR;
-               spin_unlock_irq(&connection->lock);
+       /*
+        * Request protocol version supported by the module. We don't need to do
+        * this for SVC as that is initiated by the SVC.
+        */
+       if (connection->hd_cport_id != GB_SVC_CPORT_ID) {
+               ret = gb_protocol_get_version(connection, NULL, 0);
+               if (ret) {
+                       dev_err(&connection->dev,
+                               "Failed to get version CPort-%d (%d)\n",
+                               cport_id, ret);
+                       goto disconnect;
+               }
        }
 
+       ret = connection->protocol->connection_init(connection);
+       if (!ret)
+               return 0;
+
+disconnect:
+       spin_lock_irq(&connection->lock);
+       connection->state = GB_CONNECTION_STATE_ERROR;
+       spin_unlock_irq(&connection->lock);
+
+       gb_connection_disconnected(connection);
        return ret;
 }
 
 void gb_connection_exit(struct gb_connection *connection)
 {
-       int cport_id = connection->intf_cport_id;
-
        if (!connection->protocol) {
                dev_warn(&connection->dev, "exit without protocol.\n");
                return;
@@ -397,22 +434,7 @@ void gb_connection_exit(struct gb_connection *connection)
        gb_connection_cancel_operations(connection, -ESHUTDOWN);
 
        connection->protocol->connection_exit(connection);
-
-       /*
-        * Inform Interface about In-active CPorts. We don't need to do this
-        * operation for control cport.
-        */
-       if (cport_id != GB_CONTROL_CPORT_ID &&
-           connection->hd_cport_id != GB_SVC_CPORT_ID) {
-               struct gb_control *control = connection->bundle->intf->control;
-               int ret;
-
-               ret = gb_control_disconnected_operation(control, cport_id);
-               if (ret)
-                       dev_warn(&connection->dev,
-                                "Failed to disconnect CPort-%d (%d)\n",
-                                cport_id, ret);
-       }
+       gb_connection_disconnected(connection);
 }
 
 void gb_hd_connections_exit(struct greybus_host_device *hd)
index f02b9d9fb0845223b378dc5bc3f5b977983951bc..0dbbc202e9539087bb1e0b0630bfda496755f1aa 100644 (file)
@@ -34,6 +34,8 @@ struct gb_connection {
        u8                              protocol_id;
        u8                              major;
        u8                              minor;
+       u8                              module_major;
+       u8                              module_minor;
 
        spinlock_t                      lock;
        enum gb_connection_state        state;
index a69a703a18485f1db90a93610006fb893f0002b2..605e6134d564b05f4beb225a4a161588fff27547 100644 (file)
@@ -12,9 +12,6 @@
 #include <linux/slab.h>
 #include "greybus.h"
 
-/* Define get_version() routine */
-define_get_version(gb_control, CONTROL);
-
 /* Get Manifest's size from the interface */
 int gb_control_get_manifest_size_operation(struct gb_interface *intf)
 {
@@ -100,7 +97,6 @@ static int gb_control_request_recv(u8 type, struct gb_operation *op)
 static int gb_control_connection_init(struct gb_connection *connection)
 {
        struct gb_control *control;
-       int ret;
 
        control = kzalloc(sizeof(*control), GFP_KERNEL);
        if (!control)
@@ -109,14 +105,10 @@ static int gb_control_connection_init(struct gb_connection *connection)
        control->connection = connection;
        connection->private = control;
 
-       ret = get_version(control);
-       if (ret)
-               kfree(control);
-
        /* Set interface's control connection */
        connection->bundle->intf->control = control;
 
-       return ret;
+       return 0;
 }
 
 static void gb_control_connection_exit(struct gb_connection *connection)
index 6e41a2b4c70d3a536648eb362a6a54da9bba88cf..3248d965e59354ffaec308f0cc761b645f742d88 100644 (file)
@@ -12,8 +12,6 @@
 
 struct gb_control {
        struct gb_connection    *connection;
-       u8                      version_major;
-       u8                      version_minor;
 };
 
 int gb_control_connected_operation(struct gb_control *control, u16 cport_id);
index caee9d19d723565eeeed33e9c710a0cb91a0becd..6a04a1be573a6d86ee9ac17faa8a401e20fe39cd 100644 (file)
@@ -33,8 +33,6 @@ struct gb_gpio_line {
 
 struct gb_gpio_controller {
        struct gb_connection    *connection;
-       u8                      version_major;
-       u8                      version_minor;
        u8                      line_max;       /* max line number */
        struct gb_gpio_line     *lines;
 
@@ -51,9 +49,6 @@ struct gb_gpio_controller {
        container_of(chip, struct gb_gpio_controller, chip)
 #define irq_data_to_gpio_chip(d) (d->domain->host_data)
 
-/* Define get_version() routine */
-define_get_version(gb_gpio_controller, GPIO);
-
 static int gb_gpio_line_count_operation(struct gb_gpio_controller *ggc)
 {
        struct gb_gpio_line_count_response response;
@@ -476,11 +471,6 @@ static int gb_gpio_controller_setup(struct gb_gpio_controller *ggc)
 {
        int ret;
 
-       /* First thing we need to do is check the version */
-       ret = get_version(ggc);
-       if (ret)
-               return ret;
-
        /* Now find out how many lines there are */
        ret = gb_gpio_line_count_operation(ggc);
        if (ret)
@@ -719,8 +709,8 @@ static void gb_gpio_connection_exit(struct gb_connection *connection)
 static struct gb_protocol gpio_protocol = {
        .name                   = "gpio",
        .id                     = GREYBUS_PROTOCOL_GPIO,
-       .major                  = 0,
-       .minor                  = 1,
+       .major                  = GB_GPIO_VERSION_MAJOR,
+       .minor                  = GB_GPIO_VERSION_MINOR,
        .connection_init        = gb_gpio_connection_init,
        .connection_exit        = gb_gpio_connection_exit,
        .request_recv           = gb_gpio_request_recv,
index 2db6af9cda40b61d3053407fefe763328684409c..3cfb92325a549998b839861cf554fe8e7f61f742 100644 (file)
@@ -99,6 +99,10 @@ struct gb_operation_msg_hdr {
 };
 
 
+/* Generic request numbers supported by all modules */
+#define GB_REQUEST_TYPE_INVALID                        0x00
+#define GB_REQUEST_TYPE_PROTOCOL_VERSION       0x01
+
 /* Control Protocol */
 
 /* version request has no payload */
index a367fd5fad70ba9761fa90841f1492ee8a40031c..887dbac8c117bd8323273abe175ab47b4e7dc561 100644 (file)
@@ -68,8 +68,6 @@ struct gb_hid_input_report_request {
 /* Greybus HID device's structure */
 struct gb_hid {
        struct gb_connection            *connection;
-       u8                              version_major;
-       u8                              version_minor;
 
        struct hid_device               *hid;
        struct gb_hid_desc_response     hdesc;
@@ -84,10 +82,7 @@ struct gb_hid {
 
 static DEFINE_MUTEX(gb_hid_open_mutex);
 
-/* Routines to get controller's infomation over greybus */
-
-/* Define get_version() routine */
-define_get_version(gb_hid, HID);
+/* Routines to get controller's information over greybus */
 
 /* Operations performed on greybus */
 static int gb_hid_get_desc(struct gb_hid *ghid)
@@ -445,10 +440,6 @@ static int gb_hid_init(struct gb_hid *ghid)
        struct hid_device *hid = ghid->hid;
        int ret;
 
-       ret = get_version(ghid);
-       if (ret)
-               return ret;
-
        ret = gb_hid_get_desc(ghid);
        if (ret)
                return ret;
@@ -523,8 +514,8 @@ static void gb_hid_connection_exit(struct gb_connection *connection)
 static struct gb_protocol hid_protocol = {
        .name                   = "hid",
        .id                     = GREYBUS_PROTOCOL_HID,
-       .major                  = 0,
-       .minor                  = 1,
+       .major                  = GB_HID_VERSION_MAJOR,
+       .minor                  = GB_HID_VERSION_MINOR,
        .connection_init        = gb_hid_connection_init,
        .connection_exit        = gb_hid_connection_exit,
        .request_recv           = gb_hid_irq_handler,
index 9514e69d0d4b77ea88a32ad18c839272b3d10f69..75b92d68303675c9a690c2e7f0ace5ddc65c97bf 100644 (file)
@@ -16,8 +16,6 @@
 
 struct gb_i2c_device {
        struct gb_connection    *connection;
-       u8                      version_major;
-       u8                      version_minor;
 
        u32                     functionality;
        u16                     timeout_msec;
@@ -26,9 +24,6 @@ struct gb_i2c_device {
        struct i2c_adapter      adapter;
 };
 
-/* Define get_version() routine */
-define_get_version(gb_i2c_device, I2C);
-
 /*
  * Map Greybus i2c functionality bits into Linux ones
  */
@@ -277,11 +272,6 @@ static int gb_i2c_device_setup(struct gb_i2c_device *gb_i2c_dev)
 {
        int ret;
 
-       /* First thing we need to do is check the version */
-       ret = get_version(gb_i2c_dev);
-       if (ret)
-               return ret;
-
        /* Assume the functionality never changes, just get it once */
        ret = gb_i2c_functionality_operation(gb_i2c_dev);
        if (ret)
@@ -349,8 +339,8 @@ static void gb_i2c_connection_exit(struct gb_connection *connection)
 static struct gb_protocol i2c_protocol = {
        .name                   = "i2c",
        .id                     = GREYBUS_PROTOCOL_I2C,
-       .major                  = 0,
-       .minor                  = 1,
+       .major                  = GB_I2C_VERSION_MAJOR,
+       .minor                  = GB_I2C_VERSION_MINOR,
        .connection_init        = gb_i2c_connection_init,
        .connection_exit        = gb_i2c_connection_exit,
        .request_recv           = NULL, /* no incoming requests */
index 564276d90da2fa6d2b598193ec1124175166ea8c..88c329afd3ea08d554fe3a7aec15ed00bc4525b5 100644 (file)
@@ -31,8 +31,6 @@ struct gb_loopback_stats {
 
 struct gb_loopback {
        struct gb_connection *connection;
-       u8 version_major;
-       u8 version_minor;
 
        struct kfifo kfifo;
        struct mutex mutex;
@@ -73,9 +71,6 @@ module_param(kfifo_depth, uint, 0444);
 
 #define GB_LOOPBACK_MS_WAIT_MAX                                1000
 
-/* Define get_version() routine */
-define_get_version(gb_loopback, LOOPBACK);
-
 /* interface sysfs attributes */
 #define gb_loopback_ro_attr(field)                                     \
 static ssize_t field##_show(struct device *dev,                                \
@@ -493,11 +488,6 @@ static int gb_loopback_connection_init(struct gb_connection *connection)
                goto out_sysfs;
        }
 
-       /* Check the version */
-       retval = get_version(gb);
-       if (retval)
-               goto out_minor;
-
        /* Calculate maximum payload */
        gb->size_max = gb_operation_get_payload_size_max(connection);
        if (gb->size_max <= sizeof(struct gb_loopback_transfer_request)) {
index 06b4841173ce1c0693bda65130af1c6a77ea13d7..b63e28c1b950b7d16dfd791a3779b5f63b2fa3af 100644 (file)
@@ -163,27 +163,30 @@ struct gb_protocol *gb_protocol_get(u8 id, u8 major, u8 minor)
        return protocol;
 }
 
-int gb_protocol_get_version(struct gb_connection *connection, int type,
-                           void *request, int request_size,
-                           struct gb_protocol_version_response *response,
-                           __u8 major)
+int gb_protocol_get_version(struct gb_connection *connection, void *request,
+                           int request_size)
 {
+       struct gb_protocol_version_response response;
        int retval;
 
-       retval = gb_operation_sync(connection, type, request, request_size,
-                                  response, sizeof(*response));
+       retval = gb_operation_sync(connection, GB_REQUEST_TYPE_PROTOCOL_VERSION,
+                                  request, request_size, &response,
+                                  sizeof(response));
        if (retval)
                return retval;
 
-       if (response->major > major) {
+       if (response.major > connection->protocol->major) {
                dev_err(&connection->dev,
                        "unsupported major version (%hhu > %hhu)\n",
-                       response->major, major);
+                       response.major, connection->protocol->major);
                return -ENOTSUPP;
        }
 
+       connection->module_major = response.major;
+       connection->module_minor = response.minor;
+
        dev_dbg(&connection->dev, "version_major = %u version_minor = %u\n",
-               response->major, response->minor);
+               response.major, response.minor);
 
        return 0;
 }
index 758b36ef1f55d51e750c77d6925c6063ac30b05c..34a7f185a6383f27035aff2b0f46d40b121f15fc 100644 (file)
@@ -44,10 +44,8 @@ int gb_protocol_deregister(struct gb_protocol *protocol);
        __gb_protocol_register(protocol, THIS_MODULE)
 
 struct gb_protocol *gb_protocol_get(u8 id, u8 major, u8 minor);
-int gb_protocol_get_version(struct gb_connection *connection, int type,
-                           void *request, int request_size,
-                           struct gb_protocol_version_response *response,
-                           __u8 major);
+int gb_protocol_get_version(struct gb_connection *connection, void *request,
+                           int request_size);
 
 void gb_protocol_put(struct gb_protocol *protocol);
 
@@ -107,27 +105,4 @@ void gb_##__protocol##_exit(void)                  \
        gb_protocol_deregister(&__protocol);            \
 }                                                      \
 
-/*
- * Macro to create get_version() routine for protocols
- * @__device: name of the device struct
- * @__protocol: name of protocol in CAPITALS
- */
-#define define_get_version(__device, __protocol)       \
-static int get_version(struct __device *dev)           \
-{                                                      \
-       struct gb_protocol_version_response response;   \
-       int retval;                                     \
-                                                       \
-       retval = gb_protocol_get_version(dev->connection,               \
-                               GB_##__protocol##_TYPE_PROTOCOL_VERSION,\
-                               NULL, 0, &response,                     \
-                               GB_##__protocol##_VERSION_MAJOR);       \
-       if (retval)                                     \
-               return retval;                          \
-                                                       \
-       dev->version_major = response.major;            \
-       dev->version_minor = response.minor;            \
-       return 0;                                       \
-}
-
 #endif /* __PROTOCOL_H */
index be7131a41a97e03cf02ae7c273566cabb5d64f11..5f335895d2300365a23862fe48ef2e1fa4e3db62 100644 (file)
@@ -16,8 +16,6 @@
 
 struct gb_pwm_chip {
        struct gb_connection    *connection;
-       u8                      version_major;
-       u8                      version_minor;
        u8                      pwm_max;        /* max pwm number */
 
        struct pwm_chip         chip;
@@ -27,9 +25,6 @@ struct gb_pwm_chip {
        container_of(chip, struct gb_pwm_chip, chip)
 
 
-/* Define get_version() routine */
-define_get_version(gb_pwm_chip, PWM);
-
 static int gb_pwm_count_operation(struct gb_pwm_chip *pwmc)
 {
        struct gb_pwm_count_response response;
@@ -194,11 +189,6 @@ static int gb_pwm_connection_init(struct gb_connection *connection)
        pwmc->connection = connection;
        connection->private = pwmc;
 
-       /* Check for compatible protocol version */
-       ret = get_version(pwmc);
-       if (ret)
-               goto out_err;
-
        /* Query number of pwms present */
        ret = gb_pwm_count_operation(pwmc);
        if (ret)
@@ -239,8 +229,8 @@ static void gb_pwm_connection_exit(struct gb_connection *connection)
 static struct gb_protocol pwm_protocol = {
        .name                   = "pwm",
        .id                     = GREYBUS_PROTOCOL_PWM,
-       .major                  = 0,
-       .minor                  = 1,
+       .major                  = GB_PWM_VERSION_MAJOR,
+       .minor                  = GB_PWM_VERSION_MINOR,
        .connection_init        = gb_pwm_connection_init,
        .connection_exit        = gb_pwm_connection_exit,
        .request_recv           = NULL, /* no incoming requests */
index a17a9868a08e772ffb261ea427592ff6d7e9d9e1..215d4216528210186fc466bb957b966830aa1866 100644 (file)
@@ -19,8 +19,6 @@
 
 struct gb_raw {
        struct gb_connection *connection;
-       u8 version_major;
-       u8 version_minor;
 
        struct list_head list;
        int list_data;
@@ -35,13 +33,8 @@ struct gb_raw {
 #define        GB_RAW_VERSION_MINOR                    0x01
 
 /* Greybus raw request types */
-#define        GB_RAW_TYPE_INVALID                     0x00
-#define        GB_RAW_TYPE_PROTOCOL_VERSION            0x01
 #define        GB_RAW_TYPE_SEND                        0x02
 
-/* Define get_version() routine */
-define_get_version(gb_raw, RAW);
-
 struct gb_raw_send_request {
        __le32  len;
        __u8    data[0];
@@ -180,11 +173,6 @@ static int gb_raw_connection_init(struct gb_connection *connection)
        raw->connection = connection;
        connection->private = raw;
 
-       /* Check the protocol version */
-       retval = get_version(raw);
-       if (retval)
-               goto error_free;
-
        INIT_LIST_HEAD(&raw->list);
        mutex_init(&raw->list_lock);
 
index a709bd64f82474ea32867a3c72984089d89ae41e..24b2e3152fa1778d16be794214572080030b0984 100644 (file)
@@ -18,8 +18,6 @@
 
 struct gb_sdio_host {
        struct gb_connection    *connection;
-       u8                      version_major;
-       u8                      version_minor;
        struct mmc_host         *mmc;
        struct mmc_request      *mrq;
        struct mutex            lock;   /* lock for this host */
@@ -36,9 +34,6 @@ struct gb_sdio_host {
 
 static struct workqueue_struct *gb_sdio_mrq_workqueue;
 
-/* Define get_version() routine */
-define_get_version(gb_sdio_host, SDIO);
-
 #define GB_SDIO_RSP_R1_R5_R6_R7        (GB_SDIO_RSP_PRESENT | GB_SDIO_RSP_CRC | \
                                 GB_SDIO_RSP_OPCODE)
 #define GB_SDIO_RSP_R3_R4      (GB_SDIO_RSP_PRESENT)
@@ -192,8 +187,9 @@ static int gb_sdio_event_recv(u8 type, struct gb_operation *op)
 
        request = op->request;
 
-       if (request->payload_size != sizeof(*payload)) {
-               dev_err(mmc_dev(host->mmc), "wrong event size received\n");
+       if (request->payload_size < sizeof(*payload)) {
+               dev_err(mmc_dev(host->mmc), "wrong event size received (%zu < %zu)\n",
+                       request->payload_size, sizeof(*payload));
                return -EINVAL;
        }
 
@@ -694,10 +690,6 @@ static int gb_sdio_connection_init(struct gb_connection *connection)
        host->connection = connection;
        connection->private = host;
 
-       ret = get_version(host);
-       if (ret < 0)
-               goto free_mmc;
-
        ret = gb_sdio_get_caps(host);
        if (ret < 0)
                goto free_mmc;
index 306fb074c183a5aee7b3c59850e3e16924d9d3df..ef3cc33772f8de5d611f59d5df8cfe87c5cc1f3b 100644 (file)
@@ -17,8 +17,6 @@
 
 struct gb_spi {
        struct gb_connection    *connection;
-       u8                      version_major;
-       u8                      version_minor;
 
        /* Modes supported by spi controller */
        u16                     mode;
@@ -181,9 +179,6 @@ static void gb_spi_cleanup(struct spi_device *spi)
 
 /* Routines to get controller infomation */
 
-/* Define get_version() routine */
-define_get_version(gb_spi, SPI);
-
 /*
  * Map Greybus spi mode bits/flags/bpw into Linux ones.
  * All bits are same for now and so these macro's return same values.
@@ -264,11 +259,6 @@ static int gb_spi_init(struct gb_spi *spi)
 {
        int ret;
 
-       /* First thing we need to do is check the version */
-       ret = get_version(spi);
-       if (ret)
-               return ret;
-
        /* mode never changes, just get it once */
        ret = gb_spi_mode_operation(spi);
        if (ret)
@@ -340,8 +330,8 @@ static void gb_spi_connection_exit(struct gb_connection *connection)
 static struct gb_protocol spi_protocol = {
        .name                   = "spi",
        .id                     = GREYBUS_PROTOCOL_SPI,
-       .major                  = 0,
-       .minor                  = 1,
+       .major                  = GB_SPI_VERSION_MAJOR,
+       .minor                  = GB_SPI_VERSION_MINOR,
        .connection_init        = gb_spi_connection_init,
        .connection_exit        = gb_spi_connection_exit,
        .request_recv           = NULL,
index 4bf55e0e4f3440ade912da86e6ad9806d8116574..16a37f22135c8dae659b88a041f7617f6a7c9da8 100644 (file)
@@ -16,8 +16,6 @@
 
 struct gb_svc {
        struct gb_connection    *connection;
-       u8                      version_major;
-       u8                      version_minor;
 };
 
 struct svc_hotplug {
@@ -201,6 +199,9 @@ static int gb_svc_version_request(struct gb_operation *op)
                return -ENOTSUPP;
        }
 
+       connection->module_major = version->major;
+       connection->module_minor = version->minor;
+
        if (!gb_operation_response_alloc(op, sizeof(*version), GFP_KERNEL)) {
                dev_err(dev, "%s: error allocating response\n",
                                __func__);
@@ -231,8 +232,8 @@ static int gb_svc_hello(struct gb_operation *op)
         * SVC sends information about the endo and interface-id on the hello
         * request, use that to create an endo.
         */
-       if (op->request->payload_size != sizeof(*hello_request)) {
-               dev_err(dev, "%s: Illegal size of hello request (%zu %zu)\n",
+       if (op->request->payload_size < sizeof(*hello_request)) {
+               dev_err(dev, "%s: Illegal size of hello request (%zu %zu)\n",
                        __func__, op->request->payload_size,
                        sizeof(*hello_request));
                return -EINVAL;
@@ -290,7 +291,6 @@ static void svc_process_hotplug(struct work_struct *work)
        ara_vend_id = le32_to_cpu(hotplug->data.ara_vend_id);
        ara_prod_id = le32_to_cpu(hotplug->data.ara_prod_id);
 
-       // FIXME May require firmware download
        intf = gb_interface_create(hd, intf_id);
        if (!intf) {
                dev_err(dev, "%s: Failed to create interface with id %hhu\n",
index 0166c4cdb4519a3c75ddbf8f6e7e665b1eff4fab..9e8bf6f4b8d7936123817011b1540be8b7bd94c3 100644 (file)
@@ -55,8 +55,6 @@ struct gb_tty {
        struct async_icount oldcount;
        wait_queue_head_t wioctl;
        struct mutex mutex;
-       u8 version_major;
-       u8 version_minor;
        u8 ctrlin;      /* input control lines */
        u8 ctrlout;     /* output control lines */
        struct gb_tty_line_coding line_coding;
@@ -67,9 +65,6 @@ static DEFINE_IDR(tty_minors);
 static DEFINE_MUTEX(table_lock);
 static atomic_t reference_count = ATOMIC_INIT(0);
 
-/* Define get_version() routine */
-define_get_version(gb_tty, UART);
-
 static int gb_uart_receive_data(struct gb_tty *gb_tty,
                                struct gb_connection *connection,
                                struct gb_uart_recv_data_request *receive_data)
@@ -628,21 +623,16 @@ static int gb_uart_connection_init(struct gb_connection *connection)
        gb_tty->connection = connection;
        connection->private = gb_tty;
 
-       /* Check for compatible protocol version */
-       retval = get_version(gb_tty);
-       if (retval)
-               goto error_version;
-
        minor = alloc_minor(gb_tty);
        if (minor < 0) {
                if (minor == -ENOSPC) {
                        dev_err(&connection->dev,
                                "no more free minor numbers\n");
                        retval = -ENODEV;
-                       goto error_version;
+                       goto error_minor;
                }
                retval = minor;
-               goto error_version;
+               goto error_minor;
        }
 
        gb_tty->minor = minor;
@@ -674,7 +664,7 @@ static int gb_uart_connection_init(struct gb_connection *connection)
 error:
        tty_port_destroy(&gb_tty->port);
        release_minor(gb_tty);
-error_version:
+error_minor:
        connection->private = NULL;
        kfree(gb_tty->buffer);
 error_payload:
@@ -767,8 +757,8 @@ static void gb_tty_exit(void)
 static struct gb_protocol uart_protocol = {
        .name                   = "uart",
        .id                     = GREYBUS_PROTOCOL_UART,
-       .major                  = 0,
-       .minor                  = 1,
+       .major                  = GB_UART_VERSION_MAJOR,
+       .minor                  = GB_UART_VERSION_MINOR,
        .connection_init        = gb_uart_connection_init,
        .connection_exit        = gb_uart_connection_exit,
        .request_recv           = gb_uart_request_recv,
index 50173b96f7120d4691efffe0a3c2065f3e696dfe..2133d0d25f25a764ddfac319574ecf61aabcb852 100644 (file)
@@ -20,8 +20,6 @@
 #define GB_USB_VERSION_MINOR           0x01
 
 /* Greybus USB request types */
-#define GB_USB_TYPE_INVALID            0x00
-#define GB_USB_TYPE_PROTOCOL_VERSION   0x01
 #define GB_USB_TYPE_HCD_START          0x02
 #define GB_USB_TYPE_HCD_STOP           0x03
 #define GB_USB_TYPE_HUB_CONTROL                0x04
@@ -39,9 +37,6 @@ struct gb_usb_hub_control_response {
 
 struct gb_usb_device {
        struct gb_connection *connection;
-
-       u8 version_major;
-       u8 version_minor;
 };
 
 static inline struct gb_usb_device *to_gb_usb_device(struct usb_hcd *hcd)
@@ -54,9 +49,6 @@ static inline struct usb_hcd *gb_usb_device_to_hcd(struct gb_usb_device *dev)
        return container_of((void *)dev, struct usb_hcd, hcd_priv);
 }
 
-/* Define get_version() routine */
-define_get_version(gb_usb_device, USB);
-
 static void hcd_stop(struct usb_hcd *hcd)
 {
        struct gb_usb_device *dev = to_gb_usb_device(hcd);
@@ -183,11 +175,6 @@ static int gb_usb_connection_init(struct gb_connection *connection)
        gb_usb_dev->connection = connection;
        connection->private = gb_usb_dev;
 
-       /* Check for compatible protocol version */
-       retval = get_version(gb_usb_dev);
-       if (retval)
-               goto err_put_hcd;
-
        hcd->has_tt = 1;
 
        /*
@@ -226,8 +213,8 @@ static void gb_usb_connection_exit(struct gb_connection *connection)
 static struct gb_protocol usb_protocol = {
        .name                   = "usb",
        .id                     = GREYBUS_PROTOCOL_USB,
-       .major                  = 0,
-       .minor                  = 1,
+       .major                  = GB_USB_VERSION_MAJOR,
+       .minor                  = GB_USB_VERSION_MINOR,
        .connection_init        = gb_usb_connection_init,
        .connection_exit        = gb_usb_connection_exit,
        .request_recv           = NULL, /* FIXME we have requests!!! */
index 62b3552006fc8a93799ba7a0e432bdd85e8bd80b..96d649acf122a8de81f91a7467b30b4b2a81166d 100644 (file)
@@ -19,8 +19,6 @@ struct gb_vibrator_device {
        struct gb_connection    *connection;
        struct device           *dev;
        int                     minor;          /* vibrator minor number */
-       u8                      version_major;
-       u8                      version_minor;
 };
 
 /* Version of the Greybus vibrator protocol we support */
@@ -28,8 +26,6 @@ struct gb_vibrator_device {
 #define        GB_VIBRATOR_VERSION_MINOR               0x01
 
 /* Greybus Vibrator operation types */
-#define        GB_VIBRATOR_TYPE_INVALID                0x00
-#define        GB_VIBRATOR_TYPE_PROTOCOL_VERSION       0x01
 #define        GB_VIBRATOR_TYPE_ON                     0x02
 #define        GB_VIBRATOR_TYPE_OFF                    0x03
 
@@ -37,9 +33,6 @@ struct gb_vibrator_on_request {
        __le16  timeout_ms;
 };
 
-/* Define get_version() routine */
-define_get_version(gb_vibrator_device, VIBRATOR);
-
 static int turn_on(struct gb_vibrator_device *vib, u16 timeout_ms)
 {
        struct gb_vibrator_on_request request;
@@ -108,10 +101,6 @@ static int gb_vibrator_connection_init(struct gb_connection *connection)
        vib->connection = connection;
        connection->private = vib;
 
-       retval = get_version(vib);
-       if (retval)
-               goto error;
-
        /*
         * For now we create a device in sysfs for the vibrator, but odds are
         * there is a "real" device somewhere in the kernel for this, but I
@@ -167,8 +156,8 @@ static void gb_vibrator_connection_exit(struct gb_connection *connection)
 static struct gb_protocol vibrator_protocol = {
        .name                   = "vibrator",
        .id                     = GREYBUS_PROTOCOL_VIBRATOR,
-       .major                  = 0,
-       .minor                  = 1,
+       .major                  = GB_VIBRATOR_VERSION_MAJOR,
+       .minor                  = GB_VIBRATOR_VERSION_MINOR,
        .connection_init        = gb_vibrator_connection_init,
        .connection_exit        = gb_vibrator_connection_exit,
        .request_recv           = NULL, /* no incoming requests */