1
0
Fork 0

greybus: es2.c: create dedicated struct for cport_in and cport_out

Instead of keep cport buffers, urbs and endpoints in es1_ap_dev,
move them in two dedicated struct (es1_cport_in and es1_cport_out),
in order to ease the migration to es2 (increase the number of endpoint).

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
hifive-unleashed-5.1
Alexandre Bailon 2015-06-15 18:08:12 +02:00 committed by Greg Kroah-Hartman
parent 611c17390e
commit ddc09acd46
1 changed files with 32 additions and 17 deletions

View File

@ -52,6 +52,24 @@ static DEFINE_KFIFO(apb1_log_fifo, char, APB1_LOG_SIZE);
/* vendor request APB1 log */
#define REQUEST_LOG 0x02
/*
* @endpoint: bulk in endpoint for CPort data
* @urb: array of urbs for the CPort in messages
* @buffer: array of buffers for the @cport_in_urb urbs
*/
struct es1_cport_in {
__u8 endpoint;
struct urb *urb[NUM_CPORT_IN_URB];
u8 *buffer[NUM_CPORT_IN_URB];
};
/*
* @endpoint: bulk out endpoint for CPort data
*/
struct es1_cport_out {
__u8 endpoint;
};
/**
* es1_ap_dev - ES1 USB Bridge to AP structure
* @usb_dev: pointer to the USB device we are.
@ -59,12 +77,11 @@ static DEFINE_KFIFO(apb1_log_fifo, char, APB1_LOG_SIZE);
* @hd: pointer to our greybus_host_device structure
* @control_endpoint: endpoint to send data to SVC
* @svc_endpoint: endpoint for SVC data in
* @cport_in_endpoint: bulk in endpoint for CPort data
* @cport-out_endpoint: bulk out endpoint for CPort data
* @svc_buffer: buffer for SVC messages coming in on @svc_endpoint
* @svc_urb: urb for SVC messages coming in on @svc_endpoint
* @cport_in_urb: array of urbs for the CPort in messages
* @cport_in_buffer: array of buffers for the @cport_in_urb urbs
* @cport_in: endpoint, urbs and buffer for cport in messages
* @cport_out: endpoint for for cport out messages
* @cport_out_urb: array of urbs for the CPort out messages
* @cport_out_urb_busy: array of flags to see if the @cport_out_urb is busy or
* not.
@ -77,14 +94,12 @@ struct es1_ap_dev {
__u8 control_endpoint;
__u8 svc_endpoint;
__u8 cport_in_endpoint;
__u8 cport_out_endpoint;
u8 *svc_buffer;
struct urb *svc_urb;
struct urb *cport_in_urb[NUM_CPORT_IN_URB];
u8 *cport_in_buffer[NUM_CPORT_IN_URB];
struct es1_cport_in cport_in;
struct es1_cport_out cport_out;
struct urb *cport_out_urb[NUM_CPORT_OUT_URB];
bool cport_out_urb_busy[NUM_CPORT_OUT_URB];
spinlock_t cport_out_urb_lock;
@ -212,7 +227,7 @@ static void *message_send(struct greybus_host_device *hd, u16 cport_id,
put_unaligned_le16(cport_id, message->header->pad);
usb_fill_bulk_urb(urb, udev,
usb_sndbulkpipe(udev, es1->cport_out_endpoint),
usb_sndbulkpipe(udev, es1->cport_out.endpoint),
buffer, buffer_size,
cport_out_callback, message);
retval = usb_submit_urb(urb, gfp_mask);
@ -302,14 +317,14 @@ static void ap_disconnect(struct usb_interface *interface)
}
for (i = 0; i < NUM_CPORT_IN_URB; ++i) {
struct urb *urb = es1->cport_in_urb[i];
struct urb *urb = es1->cport_in.urb[i];
if (!urb)
break;
usb_kill_urb(urb);
usb_free_urb(urb);
kfree(es1->cport_in_buffer[i]);
es1->cport_in_buffer[i] = NULL;
kfree(es1->cport_in.buffer[i]);
es1->cport_in.buffer[i] = NULL;
}
usb_kill_urb(es1->svc_urb);
@ -585,10 +600,10 @@ static int ap_probe(struct usb_interface *interface,
svc_interval = endpoint->bInterval;
int_in_found = true;
} else if (usb_endpoint_is_bulk_in(endpoint)) {
es1->cport_in_endpoint = endpoint->bEndpointAddress;
es1->cport_in.endpoint = endpoint->bEndpointAddress;
bulk_in_found = true;
} else if (usb_endpoint_is_bulk_out(endpoint)) {
es1->cport_out_endpoint = endpoint->bEndpointAddress;
es1->cport_out.endpoint = endpoint->bEndpointAddress;
bulk_out_found = true;
} else {
dev_err(&udev->dev,
@ -630,11 +645,11 @@ static int ap_probe(struct usb_interface *interface,
goto error;
usb_fill_bulk_urb(urb, udev,
usb_rcvbulkpipe(udev, es1->cport_in_endpoint),
usb_rcvbulkpipe(udev, es1->cport_in.endpoint),
buffer, ES1_GBUF_MSG_SIZE_MAX,
cport_in_callback, hd);
es1->cport_in_urb[i] = urb;
es1->cport_in_buffer[i] = buffer;
es1->cport_in.urb[i] = urb;
es1->cport_in.buffer[i] = buffer;
retval = usb_submit_urb(urb, GFP_KERNEL);
if (retval)
goto error;