Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d0ad31ec authored by Sujeet Kumar's avatar Sujeet Kumar
Browse files

USB: f_diag: Report max request size handled by controller



ChipIdea controller can be queued a maximum packet size of 16KB.
If a request larger than this size arrives on IN endpoint,
request is failed.

Provide an api which can be used for diag driver to query the
max packet size and split packets in chunks of max request size.

Change-Id: I5d26d9d4fe5987305611e1c528ef26b572a1cfc5
Signed-off-by: default avatarSujeet Kumar <ksujeet@codeaurora.org>
parent 81e1da90
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -424,6 +424,27 @@ fail:
}
EXPORT_SYMBOL(usb_diag_alloc_req);

#define DWC3_MAX_REQUEST_SIZE (1024 * 1024)
#define CI_MAX_REQUEST_SIZE   (16 * 1024)
/**
 * usb_diag_request_size - Max request size for controller
 * @ch: Channel handler
 *
 * Infom max request size so that diag driver can split packets
 * in chunks of max size which controller can handle.
 */
int usb_diag_request_size(struct usb_diag_ch *ch)
{
	struct diag_context *ctxt = ch->priv_usb;
	struct usb_composite_dev *cdev = ctxt->cdev;

	if (gadget_is_dwc3(cdev->gadget))
		return DWC3_MAX_REQUEST_SIZE;
	else
		return CI_MAX_REQUEST_SIZE;
}
EXPORT_SYMBOL(usb_diag_request_size);

/**
 * usb_diag_read() - Read data from USB diag channel
 * @ch: Channel handler
+1 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ struct usb_diag_ch {
};

#ifdef CONFIG_USB_G_ANDROID
int usb_diag_request_size(struct usb_diag_ch *ch);
struct usb_diag_ch *usb_diag_open(const char *name, void *priv,
		void (*notify)(void *, unsigned, struct diag_request *));
void usb_diag_close(struct usb_diag_ch *ch);