Commit 6d653370 authored by Alex Elder's avatar Alex Elder Committed by Greg Kroah-Hartman
Browse files

greybus: eliminate extra response flag definitions



All protocols use the same value to distinguish between request and
response message types.  This is a requirement.

Use GB_MESSAGE_TYPE_RESPONSE rather than GB_OPERATION_TYPE_RESPONSE
for the name of the flag used to distiguish between request and
response messages.

Get rid of the redundant response flag definitions that are
associated with specific protocols.

Describe the symbolic values as "operation types" rather than
"message types" where they are defined.  The message type for a
request is the same as the operation type; the message type for a
response is the operation type OR'd with GB_MESSAGE_TYPE_RESPONSE.

Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 5c58640d
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -65,7 +65,6 @@
#define GB_I2C_TYPE_TIMEOUT		0x03
#define GB_I2C_TYPE_RETRIES		0x04
#define GB_I2C_TYPE_TRANSFER		0x05
#define GB_I2C_TYPE_RESPONSE		0x80	/* OR'd with rest */

#define GB_I2C_RETRIES_DEFAULT		3
#define GB_I2C_TIMEOUT_DEFAULT		1000	/* milliseconds */
@@ -133,7 +132,6 @@ struct gb_i2c_transfer_response {
#define GB_GPIO_TYPE_IRQ_MASK		0x0d
#define GB_GPIO_TYPE_IRQ_UNMASK		0x0e
#define GB_GPIO_TYPE_IRQ_EVENT		0x0f
#define GB_GPIO_TYPE_RESPONSE		0x80	/* OR'd with rest */

#define GB_GPIO_DEBOUNCE_USEC_DEFAULT	0	/* microseconds */

@@ -223,7 +221,7 @@ struct gb_gpio_irq_event_request {
#define GB_PWM_VERSION_MAJOR		0x00
#define GB_PWM_VERSION_MINOR		0x01

/* Greybus PWM request types */
/* Greybus PWM operation types */
#define GB_PWM_TYPE_INVALID		0x00
#define GB_PWM_TYPE_PROTOCOL_VERSION	0x01
#define GB_PWM_TYPE_PWM_COUNT		0x02
@@ -233,7 +231,6 @@ struct gb_gpio_irq_event_request {
#define GB_PWM_TYPE_POLARITY		0x06
#define GB_PWM_TYPE_ENABLE		0x07
#define GB_PWM_TYPE_DISABLE		0x08
#define GB_PWM_TYPE_RESPONSE		0x80	/* OR'd with rest */

/* pwm count request has no payload */
struct gb_pwm_count_response {
+1 −2
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@
#define GB_HID_VERSION_MAJOR		0x00
#define GB_HID_VERSION_MINOR		0x01

/* Greybus HID request types */
/* Greybus HID operation types */
#define GB_HID_TYPE_INVALID		0x00
#define GB_HID_TYPE_PROTOCOL_VERSION	0x01
#define GB_HID_TYPE_GET_DESC		0x02
@@ -30,7 +30,6 @@
#define GB_HID_TYPE_GET_REPORT		0x06
#define GB_HID_TYPE_SET_REPORT		0x07
#define GB_HID_TYPE_IRQ_EVENT		0x08
#define GB_HID_TYPE_RESPONSE		0x80	/* OR'd with rest */

/* Report type */
#define GB_HID_INPUT_REPORT		0
+4 −4
Original line number Diff line number Diff line
@@ -396,7 +396,7 @@ bool gb_operation_response_alloc(struct gb_operation *operation,
	struct gb_message *response;
	u8 type;

	type = operation->type | GB_OPERATION_TYPE_RESPONSE;
	type = operation->type | GB_MESSAGE_TYPE_RESPONSE;
	response = gb_operation_message_alloc(hd, type, response_size,
						GFP_KERNEL);
	if (!response)
@@ -508,8 +508,8 @@ struct gb_operation *gb_operation_create(struct gb_connection *connection,
{
	if (WARN_ON_ONCE(type == GB_OPERATION_TYPE_INVALID))
		return NULL;
	if (WARN_ON_ONCE(type & GB_OPERATION_TYPE_RESPONSE))
		type &= ~GB_OPERATION_TYPE_RESPONSE;
	if (WARN_ON_ONCE(type & GB_MESSAGE_TYPE_RESPONSE))
		type &= ~GB_MESSAGE_TYPE_RESPONSE;

	return gb_operation_create_common(connection, type,
					request_size, response_size);
@@ -855,7 +855,7 @@ void gb_connection_recv(struct gb_connection *connection,
	}

	operation_id = le16_to_cpu(header.operation_id);
	if (header.type & GB_OPERATION_TYPE_RESPONSE)
	if (header.type & GB_MESSAGE_TYPE_RESPONSE)
		gb_connection_recv_response(connection, operation_id,
						header.result, data, msg_size);
	else
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ struct gb_operation;
 * The top bit of the type in an operation message header indicates
 * whether the message is a request (bit clear) or response (bit set)
 */
#define GB_OPERATION_TYPE_RESPONSE	((u8)0x80)
#define GB_MESSAGE_TYPE_RESPONSE	((u8)0x80)

enum gb_operation_result {
	GB_OP_SUCCESS		= 0x00,
+1 −2
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ struct gb_spi {
#define GB_SPI_FLAG_NO_RX		BIT(1)		/* can't do buffer read */
#define GB_SPI_FLAG_NO_TX		BIT(2)		/* can't do buffer write */

/* Greybus spi request types */
/* Greybus spi operation types */
#define GB_SPI_TYPE_INVALID		0x00
#define GB_SPI_TYPE_PROTOCOL_VERSION	0x01
#define GB_SPI_TYPE_MODE		0x02
@@ -74,7 +74,6 @@ struct gb_spi {
#define GB_SPI_TYPE_BITS_PER_WORD_MASK	0x04
#define GB_SPI_TYPE_NUM_CHIPSELECT	0x05
#define GB_SPI_TYPE_TRANSFER		0x06
#define GB_SPI_TYPE_RESPONSE		0x80	/* OR'd with rest */

/* mode request has no payload */
struct gb_spi_mode_response {
Loading