From: Alex Elder Date: Thu, 11 Dec 2014 22:48:38 +0000 (-0600) Subject: greybus: switch cport id used for sends X-Git-Tag: v4.9-rc1~119^2~378^2~21^2~1773 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=0a9c4d70d372a85252c00a94cd45622b657397be;p=karo-tx-linux.git greybus: switch cport id used for sends In talking with Perry today I learned that the CPort id expected to supplied over the HSIC interface to the APB is different from the way I understood it. My understanding was that the CPort id to supply always specified the CPort id on the other end of a connection. However, Perry says the mapping between local CPort id and remote CPort id (and device id) is done by the host UniPro interface. So whether sending or receiving data, the CPort id that the Greybus code should supply to the AP Bridge is the one representing the AP side of a connection. This patch fixes this. The receive side already used that CPort id; it's only the sending code that needed to be changed. Signed-off-by: Alex Elder Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/greybus/es1-ap-usb.c b/drivers/staging/greybus/es1-ap-usb.c index f551907ced2d..277699758973 100644 --- a/drivers/staging/greybus/es1-ap-usb.c +++ b/drivers/staging/greybus/es1-ap-usb.c @@ -190,7 +190,7 @@ static struct urb *next_free_urb(struct es1_ap_dev *es1, gfp_t gfp_mask) * error otherwise. If the caller wishes to cancel the in-flight * buffer, it must supply the returned cookie to the cancel routine. */ -static void *buffer_send(struct greybus_host_device *hd, u16 dest_cport_id, +static void *buffer_send(struct greybus_host_device *hd, u16 cport_id, void *buffer, size_t buffer_size, gfp_t gfp_mask) { struct es1_ap_dev *es1 = hd_to_es1(hd); @@ -216,17 +216,16 @@ static void *buffer_send(struct greybus_host_device *hd, u16 dest_cport_id, * of where the data should be sent. Do one last check of * the target CPort id before filling it in. */ - if (dest_cport_id == CPORT_ID_BAD) { + if (cport_id == CPORT_ID_BAD) { pr_err("request to send inbound data buffer\n"); return ERR_PTR(-EINVAL); } - if (dest_cport_id > (u16)U8_MAX) { - pr_err("dest_cport_id (%hd) is out of range for ES1\n", - dest_cport_id); + if (cport_id > (u16)U8_MAX) { + pr_err("cport_id (%hd) is out of range for ES1\n", cport_id); return ERR_PTR(-EINVAL); } /* OK, the destination is fine; record it in the transfer buffer */ - *transfer_buffer = dest_cport_id; + *transfer_buffer = cport_id; /* Find a free urb */ urb = next_free_urb(es1, gfp_mask); @@ -393,8 +392,8 @@ static void cport_in_callback(struct urb *urb) } /* - * The CPort number is the first byte of the data stream, the rest of - * the stream is "real" data + * Our CPort number is the first byte of the data stream, + * the rest of the stream is "real" data */ data = urb->transfer_buffer; cport_id = (u16)data[0]; diff --git a/drivers/staging/greybus/operation.c b/drivers/staging/greybus/operation.c index 742eccc4b989..6c815d29502c 100644 --- a/drivers/staging/greybus/operation.c +++ b/drivers/staging/greybus/operation.c @@ -167,13 +167,12 @@ static int gb_message_send(struct gb_message *message) { size_t message_size = sizeof(*message->header) + message->payload_size; struct gb_connection *connection = message->operation->connection; - u16 dest_cport_id = connection->interface_cport_id; int ret = 0; void *cookie; mutex_lock(&gb_message_mutex); cookie = connection->hd->driver->buffer_send(connection->hd, - dest_cport_id, + connection->hd_cport_id, message->header, message_size, GFP_KERNEL);