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