#define GB_REQUEST_TYPE_INVALID 0x00
#define GB_REQUEST_TYPE_PROTOCOL_VERSION 0x01
-/* Control Protocol */
+struct gb_protocol_version_request {
+ __u8 major;
+ __u8 minor;
+} __packed;
-/* version request has no payload */
struct gb_protocol_version_response {
__u8 major;
__u8 minor;
#define GB_SVC_TYPE_ROUTE_CREATE 0x0b
#define GB_SVC_TYPE_ROUTE_DESTROY 0x0c
-/* SVC version request/response have same payload as gb_protocol_version_response */
+/*
+ * SVC version request/response has the same payload as
+ * gb_protocol_version_request/response.
+ */
/* SVC protocol hello request */
struct gb_svc_hello_request {
int gb_protocol_get_version(struct gb_connection *connection)
{
- struct gb_protocol_version_response version;
+ struct gb_protocol_version_request request;
+ struct gb_protocol_version_response response;
int retval;
- version.major = connection->protocol->major;
- version.minor = connection->protocol->minor;
+ request.major = connection->protocol->major;
+ request.minor = connection->protocol->minor;
retval = gb_operation_sync(connection, GB_REQUEST_TYPE_PROTOCOL_VERSION,
- &version, sizeof(version), &version,
- sizeof(version));
+ &request, sizeof(request), &response,
+ sizeof(response));
if (retval)
return retval;
- if (version.major > connection->protocol->major) {
+ if (response.major > connection->protocol->major) {
dev_err(&connection->dev,
"unsupported major version (%hhu > %hhu)\n",
- version.major, connection->protocol->major);
+ response.major, connection->protocol->major);
return -ENOTSUPP;
}
- connection->module_major = version.major;
- connection->module_minor = version.minor;
+ connection->module_major = response.major;
+ connection->module_minor = response.minor;
dev_dbg(&connection->dev, "version_major = %u version_minor = %u\n",
- version.major, version.minor);
+ response.major, response.minor);
return 0;
}
static int gb_svc_version_request(struct gb_operation *op)
{
struct gb_connection *connection = op->connection;
- struct gb_protocol_version_response *version;
+ struct gb_protocol_version_request *request;
+ struct gb_protocol_version_response *response;
struct device *dev = &connection->dev;
- version = op->request->payload;
+ request = op->request->payload;
- if (version->major > GB_SVC_VERSION_MAJOR) {
+ if (request->major > GB_SVC_VERSION_MAJOR) {
dev_err(&connection->dev,
"unsupported major version (%hhu > %hhu)\n",
- version->major, GB_SVC_VERSION_MAJOR);
+ request->major, GB_SVC_VERSION_MAJOR);
return -ENOTSUPP;
}
- connection->module_major = version->major;
- connection->module_minor = version->minor;
+ connection->module_major = request->major;
+ connection->module_minor = request->minor;
- if (!gb_operation_response_alloc(op, sizeof(*version), GFP_KERNEL)) {
+ if (!gb_operation_response_alloc(op, sizeof(*response), GFP_KERNEL)) {
dev_err(dev, "%s: error allocating response\n",
__func__);
return -ENOMEM;
}
- version = op->response->payload;
- version->major = connection->module_major;
- version->minor = connection->module_minor;
+ response = op->response->payload;
+ response->major = connection->module_major;
+ response->minor = connection->module_minor;
return 0;
}