Re: [RFC/PATCH 1/2] usb: gadget: introduce support for sg lists

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Felipe Balbi | 2011-11-22 11:42:05 [+0200]:

>diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
>index 22c37d2..fd61375 100644
>--- a/include/linux/usb/gadget.h
>+++ b/include/linux/usb/gadget.h
>@@ -88,6 +91,9 @@ struct usb_request {
> 	unsigned		length;
> 	dma_addr_t		dma;
> 
>+	struct scatterlist	*sg;
>+	unsigned		num_sgs;

This is close to what we have on the host side. Okay.

> 	unsigned		stream_id:16;
> 	unsigned		no_interrupt:1;
> 	unsigned		zero:1;
>@@ -102,6 +108,22 @@ struct usb_request {
> 	unsigned		actual;
> };
> 
>+struct usb_request_sg {
>+	int		status;
>+	unsigned	actual;
>+
>+	void		(*complete)(struct usb_ep *ep,
>+			struct usb_request_sg *rsg);
>+	void		*context;
>+
>+	/*
>+	 * Members below are private to the controller. Gadget
>+	 * drivers should not touch them.
>+	 */
>+	struct usb_request	**requests;
>+	int			num_entries;
>+};

Ehm, why do you need this? This seem to be part of something else.

>+
> /*-------------------------------------------------------------------------*/
> 
> /* endpoint-specific parts of the api to the usb controller hardware.
>@@ -120,6 +142,13 @@ struct usb_ep_ops {
> 		gfp_t gfp_flags);
> 	void (*free_request) (struct usb_ep *ep, struct usb_request *req);
> 
>+	int (*sg_prepare)(struct usb_ep *ep, struct usb_request_sg *rsg,
>+			struct scatterlist *sg, unsigned int num_entries,
>+			unsigned int length, gfp_t gfp_flags);
>+	int (*sg_queue)(struct usb_ep *ep, struct usb_request_sg *rsg,
>+			gfp_t gfp_flags);
>+	int (*sg_dequeue)(struct usb_ep *ep, struct usb_request_sg *rsg);
>+
> 	int (*queue) (struct usb_ep *ep, struct usb_request *req,
> 		gfp_t gfp_flags);
> 	int (*dequeue) (struct usb_ep *ep, struct usb_request *req);
>@@ -250,6 +279,45 @@ static inline void usb_ep_free_request(struct usb_ep *ep,
> }
> 
> /**
>+ * usb_ep_sg_prepare - prepares a sg list to be queued to the endpoint
>+ * @ep: the endpoint associated with the request
>+ * @rsg: the SG request
>+ * @sg: the scatterlist
>+ * @num_entries: number of entries
>+ * @length: total length of the SG transfer
>+ * @gfp_flags: flags for memory allocations on this call
>+ */
>+static inline int usb_ep_sg_prepare(struct usb_ep *ep,
>+		struct usb_request_sg *rsg, struct scatterlist *sg,
>+		unsigned int num_entries, unsigned int length, gfp_t gfp_flags)
>+{
>+	return ep->ops->sg_prepare(ep, rsg, sg, num_entries, length, gfp_flags);
>+}
>+
>+/**
>+ * usb_ep_sg_queue - queue a sg list to the endpoint
>+ * @ep: the endpoint associated with the request
>+ * @rsg: the SG request
>+ * @gfp_flags: flags for memory allocations on this call
>+ */
>+static inline int usb_ep_sg_queue(struct usb_ep *ep,
>+		struct usb_request_sg *rsg, gfp_t gfp_flags)
>+{
>+	return ep->ops->sg_queue(ep, rsg, gfp_flags);
>+}
>+
>+/**
>+ * usb_ep_sg_dequeue - dequeues a sg ist from the endpoint
>+ * @ep: the endpoint associated with the request
>+ * @rsg: the SG request to the dequeued
>+ */
>+static inline int usb_ep_sg_dequeue(struct usb_ep *ep,
>+		struct usb_request_sg *rsg)
>+{
>+	return ep->ops->sg_dequeue(ep, rsg);
>+}
>+
>+/**

Why do you need also this extra callbacks?

Sebastian
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux