diff options
| author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2012-10-22 16:14:57 -0400 |
|---|---|---|
| committer | Felipe Balbi <balbi@ti.com> | 2012-10-31 09:01:15 -0400 |
| commit | bcb2f99c6c43a8da6cb4002e8b0acf6f1275f3a8 (patch) | |
| tree | 290cfa3262734c9010bd08dbf22cf45498e77bd9 | |
| parent | fad8deb274edcef1c8ca38946338f5f4f8126fe2 (diff) | |
usb: gadget: use a computation macro for INT endpoint interval
The 5+4 magic for HS tries to aim 32ms which is also what is intended
with 1 << 5 for FS. This little macro should make this easier to
understand.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
| -rw-r--r-- | drivers/usb/gadget/f_acm.c | 7 | ||||
| -rw-r--r-- | drivers/usb/gadget/f_ecm.c | 8 | ||||
| -rw-r--r-- | drivers/usb/gadget/f_ncm.c | 6 | ||||
| -rw-r--r-- | drivers/usb/gadget/f_rndis.c | 8 | ||||
| -rw-r--r-- | include/linux/usb/composite.h | 2 |
5 files changed, 16 insertions, 15 deletions
diff --git a/drivers/usb/gadget/f_acm.c b/drivers/usb/gadget/f_acm.c index d672250a61fa..7c30bb49850b 100644 --- a/drivers/usb/gadget/f_acm.c +++ b/drivers/usb/gadget/f_acm.c | |||
| @@ -87,7 +87,7 @@ static inline struct f_acm *port_to_acm(struct gserial *p) | |||
| 87 | 87 | ||
| 88 | /* notification endpoint uses smallish and infrequent fixed-size messages */ | 88 | /* notification endpoint uses smallish and infrequent fixed-size messages */ |
| 89 | 89 | ||
| 90 | #define GS_LOG2_NOTIFY_INTERVAL 5 /* 1 << 5 == 32 msec */ | 90 | #define GS_NOTIFY_INTERVAL_MS 32 |
| 91 | #define GS_NOTIFY_MAXPACKET 10 /* notification + 2 bytes */ | 91 | #define GS_NOTIFY_MAXPACKET 10 /* notification + 2 bytes */ |
| 92 | 92 | ||
| 93 | /* interface and class descriptors: */ | 93 | /* interface and class descriptors: */ |
| @@ -167,7 +167,7 @@ static struct usb_endpoint_descriptor acm_fs_notify_desc = { | |||
| 167 | .bEndpointAddress = USB_DIR_IN, | 167 | .bEndpointAddress = USB_DIR_IN, |
| 168 | .bmAttributes = USB_ENDPOINT_XFER_INT, | 168 | .bmAttributes = USB_ENDPOINT_XFER_INT, |
| 169 | .wMaxPacketSize = cpu_to_le16(GS_NOTIFY_MAXPACKET), | 169 | .wMaxPacketSize = cpu_to_le16(GS_NOTIFY_MAXPACKET), |
| 170 | .bInterval = 1 << GS_LOG2_NOTIFY_INTERVAL, | 170 | .bInterval = GS_NOTIFY_INTERVAL_MS, |
| 171 | }; | 171 | }; |
| 172 | 172 | ||
| 173 | static struct usb_endpoint_descriptor acm_fs_in_desc = { | 173 | static struct usb_endpoint_descriptor acm_fs_in_desc = { |
| @@ -199,14 +199,13 @@ static struct usb_descriptor_header *acm_fs_function[] = { | |||
| 199 | }; | 199 | }; |
| 200 | 200 | ||
| 201 | /* high speed support: */ | 201 | /* high speed support: */ |
| 202 | |||
| 203 | static struct usb_endpoint_descriptor acm_hs_notify_desc = { | 202 | static struct usb_endpoint_descriptor acm_hs_notify_desc = { |
| 204 | .bLength = USB_DT_ENDPOINT_SIZE, | 203 | .bLength = USB_DT_ENDPOINT_SIZE, |
| 205 | .bDescriptorType = USB_DT_ENDPOINT, | 204 | .bDescriptorType = USB_DT_ENDPOINT, |
| 206 | .bEndpointAddress = USB_DIR_IN, | 205 | .bEndpointAddress = USB_DIR_IN, |
| 207 | .bmAttributes = USB_ENDPOINT_XFER_INT, | 206 | .bmAttributes = USB_ENDPOINT_XFER_INT, |
| 208 | .wMaxPacketSize = cpu_to_le16(GS_NOTIFY_MAXPACKET), | 207 | .wMaxPacketSize = cpu_to_le16(GS_NOTIFY_MAXPACKET), |
| 209 | .bInterval = GS_LOG2_NOTIFY_INTERVAL+4, | 208 | .bInterval = USB_MS_TO_HS_INTERVAL(GS_NOTIFY_INTERVAL_MS), |
| 210 | }; | 209 | }; |
| 211 | 210 | ||
| 212 | static struct usb_endpoint_descriptor acm_hs_in_desc = { | 211 | static struct usb_endpoint_descriptor acm_hs_in_desc = { |
diff --git a/drivers/usb/gadget/f_ecm.c b/drivers/usb/gadget/f_ecm.c index 8ab9e9638f91..789242749df5 100644 --- a/drivers/usb/gadget/f_ecm.c +++ b/drivers/usb/gadget/f_ecm.c | |||
| @@ -91,7 +91,7 @@ static inline unsigned ecm_bitrate(struct usb_gadget *g) | |||
| 91 | * encapsulated commands (vendor-specific, using control-OUT). | 91 | * encapsulated commands (vendor-specific, using control-OUT). |
| 92 | */ | 92 | */ |
| 93 | 93 | ||
| 94 | #define LOG2_STATUS_INTERVAL_MSEC 5 /* 1 << 5 == 32 msec */ | 94 | #define ECM_STATUS_INTERVAL_MS 32 |
| 95 | #define ECM_STATUS_BYTECOUNT 16 /* 8 byte header + data */ | 95 | #define ECM_STATUS_BYTECOUNT 16 /* 8 byte header + data */ |
| 96 | 96 | ||
| 97 | 97 | ||
| @@ -192,7 +192,7 @@ static struct usb_endpoint_descriptor fs_ecm_notify_desc = { | |||
| 192 | .bEndpointAddress = USB_DIR_IN, | 192 | .bEndpointAddress = USB_DIR_IN, |
| 193 | .bmAttributes = USB_ENDPOINT_XFER_INT, | 193 | .bmAttributes = USB_ENDPOINT_XFER_INT, |
| 194 | .wMaxPacketSize = cpu_to_le16(ECM_STATUS_BYTECOUNT), | 194 | .wMaxPacketSize = cpu_to_le16(ECM_STATUS_BYTECOUNT), |
| 195 | .bInterval = 1 << LOG2_STATUS_INTERVAL_MSEC, | 195 | .bInterval = ECM_STATUS_INTERVAL_MS, |
| 196 | }; | 196 | }; |
| 197 | 197 | ||
| 198 | static struct usb_endpoint_descriptor fs_ecm_in_desc = { | 198 | static struct usb_endpoint_descriptor fs_ecm_in_desc = { |
| @@ -239,7 +239,7 @@ static struct usb_endpoint_descriptor hs_ecm_notify_desc = { | |||
| 239 | .bEndpointAddress = USB_DIR_IN, | 239 | .bEndpointAddress = USB_DIR_IN, |
| 240 | .bmAttributes = USB_ENDPOINT_XFER_INT, | 240 | .bmAttributes = USB_ENDPOINT_XFER_INT, |
| 241 | .wMaxPacketSize = cpu_to_le16(ECM_STATUS_BYTECOUNT), | 241 | .wMaxPacketSize = cpu_to_le16(ECM_STATUS_BYTECOUNT), |
| 242 | .bInterval = LOG2_STATUS_INTERVAL_MSEC + 4, | 242 | .bInterval = USB_MS_TO_HS_INTERVAL(ECM_STATUS_INTERVAL_MS), |
| 243 | }; | 243 | }; |
| 244 | 244 | ||
| 245 | static struct usb_endpoint_descriptor hs_ecm_in_desc = { | 245 | static struct usb_endpoint_descriptor hs_ecm_in_desc = { |
| @@ -288,7 +288,7 @@ static struct usb_endpoint_descriptor ss_ecm_notify_desc = { | |||
| 288 | .bEndpointAddress = USB_DIR_IN, | 288 | .bEndpointAddress = USB_DIR_IN, |
| 289 | .bmAttributes = USB_ENDPOINT_XFER_INT, | 289 | .bmAttributes = USB_ENDPOINT_XFER_INT, |
| 290 | .wMaxPacketSize = cpu_to_le16(ECM_STATUS_BYTECOUNT), | 290 | .wMaxPacketSize = cpu_to_le16(ECM_STATUS_BYTECOUNT), |
| 291 | .bInterval = LOG2_STATUS_INTERVAL_MSEC + 4, | 291 | .bInterval = USB_MS_TO_HS_INTERVAL(ECM_STATUS_INTERVAL_MS), |
| 292 | }; | 292 | }; |
| 293 | 293 | ||
| 294 | static struct usb_ss_ep_comp_descriptor ss_ecm_intr_comp_desc = { | 294 | static struct usb_ss_ep_comp_descriptor ss_ecm_intr_comp_desc = { |
diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c index b651b529c67f..4f0950069a43 100644 --- a/drivers/usb/gadget/f_ncm.c +++ b/drivers/usb/gadget/f_ncm.c | |||
| @@ -121,7 +121,7 @@ static struct usb_cdc_ncm_ntb_parameters ntb_parameters = { | |||
| 121 | * waste less bandwidth. | 121 | * waste less bandwidth. |
| 122 | */ | 122 | */ |
| 123 | 123 | ||
| 124 | #define LOG2_STATUS_INTERVAL_MSEC 5 /* 1 << 5 == 32 msec */ | 124 | #define NCM_STATUS_INTERVAL_MS 32 |
| 125 | #define NCM_STATUS_BYTECOUNT 16 /* 8 byte header + data */ | 125 | #define NCM_STATUS_BYTECOUNT 16 /* 8 byte header + data */ |
| 126 | 126 | ||
| 127 | static struct usb_interface_assoc_descriptor ncm_iad_desc __initdata = { | 127 | static struct usb_interface_assoc_descriptor ncm_iad_desc __initdata = { |
| @@ -230,7 +230,7 @@ static struct usb_endpoint_descriptor fs_ncm_notify_desc __initdata = { | |||
| 230 | .bEndpointAddress = USB_DIR_IN, | 230 | .bEndpointAddress = USB_DIR_IN, |
| 231 | .bmAttributes = USB_ENDPOINT_XFER_INT, | 231 | .bmAttributes = USB_ENDPOINT_XFER_INT, |
| 232 | .wMaxPacketSize = cpu_to_le16(NCM_STATUS_BYTECOUNT), | 232 | .wMaxPacketSize = cpu_to_le16(NCM_STATUS_BYTECOUNT), |
| 233 | .bInterval = 1 << LOG2_STATUS_INTERVAL_MSEC, | 233 | .bInterval = NCM_STATUS_INTERVAL_MS, |
| 234 | }; | 234 | }; |
| 235 | 235 | ||
| 236 | static struct usb_endpoint_descriptor fs_ncm_in_desc __initdata = { | 236 | static struct usb_endpoint_descriptor fs_ncm_in_desc __initdata = { |
| @@ -275,7 +275,7 @@ static struct usb_endpoint_descriptor hs_ncm_notify_desc __initdata = { | |||
| 275 | .bEndpointAddress = USB_DIR_IN, | 275 | .bEndpointAddress = USB_DIR_IN, |
| 276 | .bmAttributes = USB_ENDPOINT_XFER_INT, | 276 | .bmAttributes = USB_ENDPOINT_XFER_INT, |
| 277 | .wMaxPacketSize = cpu_to_le16(NCM_STATUS_BYTECOUNT), | 277 | .wMaxPacketSize = cpu_to_le16(NCM_STATUS_BYTECOUNT), |
| 278 | .bInterval = LOG2_STATUS_INTERVAL_MSEC + 4, | 278 | .bInterval = USB_MS_TO_HS_INTERVAL(NCM_STATUS_INTERVAL_MS), |
| 279 | }; | 279 | }; |
| 280 | static struct usb_endpoint_descriptor hs_ncm_in_desc __initdata = { | 280 | static struct usb_endpoint_descriptor hs_ncm_in_desc __initdata = { |
| 281 | .bLength = USB_DT_ENDPOINT_SIZE, | 281 | .bLength = USB_DT_ENDPOINT_SIZE, |
diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c index b1681e45aca7..61f4b13c6cf5 100644 --- a/drivers/usb/gadget/f_rndis.c +++ b/drivers/usb/gadget/f_rndis.c | |||
| @@ -101,7 +101,7 @@ static unsigned int bitrate(struct usb_gadget *g) | |||
| 101 | /* | 101 | /* |
| 102 | */ | 102 | */ |
| 103 | 103 | ||
| 104 | #define LOG2_STATUS_INTERVAL_MSEC 5 /* 1 << 5 == 32 msec */ | 104 | #define RNDIS_STATUS_INTERVAL_MS 32 |
| 105 | #define STATUS_BYTECOUNT 8 /* 8 bytes data */ | 105 | #define STATUS_BYTECOUNT 8 /* 8 bytes data */ |
| 106 | 106 | ||
| 107 | 107 | ||
| @@ -190,7 +190,7 @@ static struct usb_endpoint_descriptor fs_notify_desc = { | |||
| 190 | .bEndpointAddress = USB_DIR_IN, | 190 | .bEndpointAddress = USB_DIR_IN, |
| 191 | .bmAttributes = USB_ENDPOINT_XFER_INT, | 191 | .bmAttributes = USB_ENDPOINT_XFER_INT, |
| 192 | .wMaxPacketSize = cpu_to_le16(STATUS_BYTECOUNT), | 192 | .wMaxPacketSize = cpu_to_le16(STATUS_BYTECOUNT), |
| 193 | .bInterval = 1 << LOG2_STATUS_INTERVAL_MSEC, | 193 | .bInterval = RNDIS_STATUS_INTERVAL_MS, |
| 194 | }; | 194 | }; |
| 195 | 195 | ||
| 196 | static struct usb_endpoint_descriptor fs_in_desc = { | 196 | static struct usb_endpoint_descriptor fs_in_desc = { |
| @@ -236,7 +236,7 @@ static struct usb_endpoint_descriptor hs_notify_desc = { | |||
| 236 | .bEndpointAddress = USB_DIR_IN, | 236 | .bEndpointAddress = USB_DIR_IN, |
| 237 | .bmAttributes = USB_ENDPOINT_XFER_INT, | 237 | .bmAttributes = USB_ENDPOINT_XFER_INT, |
| 238 | .wMaxPacketSize = cpu_to_le16(STATUS_BYTECOUNT), | 238 | .wMaxPacketSize = cpu_to_le16(STATUS_BYTECOUNT), |
| 239 | .bInterval = LOG2_STATUS_INTERVAL_MSEC + 4, | 239 | .bInterval = USB_MS_TO_HS_INTERVAL(RNDIS_STATUS_INTERVAL_MS) |
| 240 | }; | 240 | }; |
| 241 | 241 | ||
| 242 | static struct usb_endpoint_descriptor hs_in_desc = { | 242 | static struct usb_endpoint_descriptor hs_in_desc = { |
| @@ -284,7 +284,7 @@ static struct usb_endpoint_descriptor ss_notify_desc = { | |||
| 284 | .bEndpointAddress = USB_DIR_IN, | 284 | .bEndpointAddress = USB_DIR_IN, |
| 285 | .bmAttributes = USB_ENDPOINT_XFER_INT, | 285 | .bmAttributes = USB_ENDPOINT_XFER_INT, |
| 286 | .wMaxPacketSize = cpu_to_le16(STATUS_BYTECOUNT), | 286 | .wMaxPacketSize = cpu_to_le16(STATUS_BYTECOUNT), |
| 287 | .bInterval = LOG2_STATUS_INTERVAL_MSEC + 4, | 287 | .bInterval = USB_MS_TO_HS_INTERVAL(RNDIS_STATUS_INTERVAL_MS) |
| 288 | }; | 288 | }; |
| 289 | 289 | ||
| 290 | static struct usb_ss_ep_comp_descriptor ss_intr_comp_desc = { | 290 | static struct usb_ss_ep_comp_descriptor ss_intr_comp_desc = { |
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h index f8dda0621800..8634a127bdd3 100644 --- a/include/linux/usb/composite.h +++ b/include/linux/usb/composite.h | |||
| @@ -38,6 +38,7 @@ | |||
| 38 | #include <linux/version.h> | 38 | #include <linux/version.h> |
| 39 | #include <linux/usb/ch9.h> | 39 | #include <linux/usb/ch9.h> |
| 40 | #include <linux/usb/gadget.h> | 40 | #include <linux/usb/gadget.h> |
| 41 | #include <linux/log2.h> | ||
| 41 | 42 | ||
| 42 | /* | 43 | /* |
| 43 | * USB function drivers should return USB_GADGET_DELAYED_STATUS if they | 44 | * USB function drivers should return USB_GADGET_DELAYED_STATUS if they |
| @@ -51,6 +52,7 @@ | |||
| 51 | /* big enough to hold our biggest descriptor */ | 52 | /* big enough to hold our biggest descriptor */ |
| 52 | #define USB_COMP_EP0_BUFSIZ 1024 | 53 | #define USB_COMP_EP0_BUFSIZ 1024 |
| 53 | 54 | ||
| 55 | #define USB_MS_TO_HS_INTERVAL(x) (ilog2((x * 1000 / 125)) + 1) | ||
| 54 | struct usb_configuration; | 56 | struct usb_configuration; |
| 55 | 57 | ||
| 56 | /** | 58 | /** |
