Commit c15ccabe authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

greybus: es2: sync up with recent es1 changes

Fix two bugs in es2 and do some minor clean up.
Signed-off-by: default avatarJohan Hovold <johan@hovoldconsulting.com>
Reviewed-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent bfd9a94d
...@@ -132,7 +132,7 @@ static void hd_buffer_constraints(struct greybus_host_device *hd) ...@@ -132,7 +132,7 @@ static void hd_buffer_constraints(struct greybus_host_device *hd)
* that's better aligned for the user. * that's better aligned for the user.
*/ */
hd->buffer_headroom = sizeof(u32); /* For cport id */ hd->buffer_headroom = sizeof(u32); /* For cport id */
hd->buffer_size_max = ES1_GBUF_MSG_SIZE_MAX; hd->buffer_size_max = ES1_GBUF_MSG_SIZE_MAX - hd->buffer_headroom;
BUILD_BUG_ON(hd->buffer_headroom > GB_BUFFER_HEADROOM_MAX); BUILD_BUG_ON(hd->buffer_headroom > GB_BUFFER_HEADROOM_MAX);
} }
...@@ -244,7 +244,7 @@ static void *buffer_send(struct greybus_host_device *hd, u16 cport_id, ...@@ -244,7 +244,7 @@ static void *buffer_send(struct greybus_host_device *hd, u16 cport_id,
pr_err("request to send inbound data buffer\n"); pr_err("request to send inbound data buffer\n");
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
if (cport_id > (u16)U8_MAX) { if (cport_id > U8_MAX) {
pr_err("cport_id (%hd) is out of range for ES1\n", cport_id); pr_err("cport_id (%hd) is out of range for ES1\n", cport_id);
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
...@@ -423,7 +423,7 @@ static void cport_in_callback(struct urb *urb) ...@@ -423,7 +423,7 @@ static void cport_in_callback(struct urb *urb)
* the rest of the stream is "real" data * the rest of the stream is "real" data
*/ */
data = urb->transfer_buffer; data = urb->transfer_buffer;
cport_id = (u16)data[0]; cport_id = data[0];
data = &data[1]; data = &data[1];
/* Pass this data to the greybus core */ /* Pass this data to the greybus core */
...@@ -454,14 +454,13 @@ static void cport_out_callback(struct urb *urb) ...@@ -454,14 +454,13 @@ static void cport_out_callback(struct urb *urb)
free_urb(es1, urb); free_urb(es1, urb);
} }
static void apb1_log_get(struct es1_ap_dev *es1) #define APB1_LOG_MSG_SIZE 64
static void apb1_log_get(struct es1_ap_dev *es1, char *buf)
{ {
char buf[65];
int retval; int retval;
/* SVC messages go down our control pipe */ /* SVC messages go down our control pipe */
do { do {
memset(buf, 0, 65);
retval = usb_control_msg(es1->usb_dev, retval = usb_control_msg(es1->usb_dev,
usb_rcvctrlpipe(es1->usb_dev, usb_rcvctrlpipe(es1->usb_dev,
es1->control_endpoint), es1->control_endpoint),
...@@ -469,7 +468,7 @@ static void apb1_log_get(struct es1_ap_dev *es1) ...@@ -469,7 +468,7 @@ static void apb1_log_get(struct es1_ap_dev *es1)
USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
0x00, 0x00, 0x00, 0x00,
buf, buf,
64, APB1_LOG_MSG_SIZE,
ES1_TIMEOUT); ES1_TIMEOUT);
if (retval > 0) if (retval > 0)
kfifo_in(&apb1_log_fifo, buf, retval); kfifo_in(&apb1_log_fifo, buf, retval);
...@@ -478,10 +477,20 @@ static void apb1_log_get(struct es1_ap_dev *es1) ...@@ -478,10 +477,20 @@ static void apb1_log_get(struct es1_ap_dev *es1)
static int apb1_log_poll(void *data) static int apb1_log_poll(void *data)
{ {
struct es1_ap_dev *es1 = data;
char *buf;
buf = kmalloc(APB1_LOG_MSG_SIZE, GFP_KERNEL);
if (!buf)
return -ENOMEM;
while (!kthread_should_stop()) { while (!kthread_should_stop()) {
msleep(1000); msleep(1000);
apb1_log_get((struct es1_ap_dev *)data); apb1_log_get(es1, buf);
} }
kfree(buf);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment