common/usb_i2c.c: Format with clang-format
BRANCH=none
TEST=none
#include "usb-stream.h"
#include "usb_i2c.h"
-
#define CPRINTS(format, args...) cprints(CC_I2C, format, ##args)
+USB_I2C_CONFIG(i2c, USB_IFACE_I2C, USB_STR_I2C_NAME, USB_EP_I2C)
-USB_I2C_CONFIG(i2c,
- USB_IFACE_I2C,
- USB_STR_I2C_NAME,
- USB_EP_I2C)
-
-static int (*cros_cmd_handler)(void *data_in,
- size_t in_size,
- void *data_out,
+static int (*cros_cmd_handler)(void *data_in, size_t in_size, void *data_out,
size_t out_size);
static int16_t usb_i2c_map_error(int error)
{
switch (error) {
- case EC_SUCCESS: return USB_I2C_SUCCESS;
- case EC_ERROR_TIMEOUT: return USB_I2C_TIMEOUT;
- case EC_ERROR_BUSY: return USB_I2C_BUSY;
- default: return USB_I2C_UNKNOWN_ERROR | (error & 0x7fff);
+ case EC_SUCCESS:
+ return USB_I2C_SUCCESS;
+ case EC_ERROR_TIMEOUT:
+ return USB_I2C_TIMEOUT;
+ case EC_ERROR_BUSY:
+ return USB_I2C_BUSY;
+ default:
+ return USB_I2C_UNKNOWN_ERROR | (error & 0x7fff);
}
}
@@ -72,9 +69,8 @@ static uint8_t usb_i2c_executable(struct usb_i2c_config const *config)
* In order to support larger write payload, we need to peek
* the queue to see if we need to wait for more data.
*/
- if (queue_peek_units(config->consumer.queue,
- peek, 0, sizeof(peek))
- != sizeof(peek)) {
+ if (queue_peek_units(config->consumer.queue, peek, 0,
+ sizeof(peek)) != sizeof(peek)) {
/* Not enough data to calculate expected_size. */
return 0;
}
@@ -92,7 +88,6 @@ static uint8_t usb_i2c_executable(struct usb_i2c_config const *config)
expected_size += (((size_t)peek[0] & 0xf0) << 4) | peek[2];
}
-
if (queue_count(config->consumer.queue) >= expected_size) {
expected_size = 0;
return 1;
@@ -156,8 +151,7 @@ static void usb_i2c_execute(struct usb_i2c_config const *config)
*/
ret = i2c_xfer(i2c_ports[portindex].port, addr_flags,
(uint8_t *)(config->buffer + 2) + offset,
- write_count,
- (uint8_t *)(config->buffer + 2),
+ write_count, (uint8_t *)(config->buffer + 2),
read_count);
config->buffer[0] = usb_i2c_map_error(ret);
}
@@ -183,11 +177,8 @@ struct consumer_ops const usb_i2c_consumer_ops = {
.written = usb_i2c_written,
};
-int usb_i2c_register_cros_cmd_handler(int (*cmd_handler)
- (void *data_in,
- size_t in_size,
- void *data_out,
- size_t out_size))
+int usb_i2c_register_cros_cmd_handler(int (*cmd_handler)(
+ void *data_in, size_t in_size, void *data_out, size_t out_size))
{
if (cros_cmd_handler)
return -1;
