1
0
Fork 0

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: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
hifive-unleashed-5.1
Alex Elder 2015-05-07 13:03:52 -05:00 committed by Greg Kroah-Hartman
parent 5c58640d8d
commit 6d653370c0
7 changed files with 10 additions and 17 deletions

View File

@ -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 {

View File

@ -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

View File

@ -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

View File

@ -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,

View File

@ -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 {

View File

@ -37,7 +37,7 @@
#define GB_UART_VERSION_MAJOR 0x00
#define GB_UART_VERSION_MINOR 0x01
/* Greybus UART request types */
/* Greybus UART operation types */
#define GB_UART_TYPE_INVALID 0x00
#define GB_UART_TYPE_PROTOCOL_VERSION 0x01
#define GB_UART_TYPE_SEND_DATA 0x02
@ -46,7 +46,6 @@
#define GB_UART_TYPE_SET_CONTROL_LINE_STATE 0x05
#define GB_UART_TYPE_SET_BREAK 0x06
#define GB_UART_TYPE_SERIAL_STATE 0x07 /* Unsolicited data */
#define GB_UART_TYPE_RESPONSE 0x80 /* OR'd with rest */
struct gb_uart_send_data_request {
__le16 size;

View File

@ -27,12 +27,11 @@ struct gb_vibrator_device {
#define GB_VIBRATOR_VERSION_MAJOR 0x00
#define GB_VIBRATOR_VERSION_MINOR 0x01
/* Greybus Vibrator request types */
/* 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
#define GB_VIBRATOR_TYPE_RESPONSE 0x80 /* OR'd with rest */
struct gb_vibrator_on_request {
__le16 timeout_ms;