hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/include/linux/usb.h
....@@ -331,7 +331,7 @@
331331
332332 /* variable-length array of alternate settings for this interface,
333333 * stored in no particular order */
334
- struct usb_host_interface altsetting[0];
334
+ struct usb_host_interface altsetting[];
335335 };
336336 #define ref_to_usb_interface_cache(r) \
337337 container_of(r, struct usb_interface_cache, ref)
....@@ -347,7 +347,7 @@
347347 * @interface: array of pointers to usb_interface structures, one for each
348348 * interface in the configuration. The number of interfaces is stored
349349 * in desc.bNumInterfaces. These pointers are valid only while the
350
- * the configuration is active.
350
+ * configuration is active.
351351 * @intf_cache: array of pointers to usb_interface_cache structures, one
352352 * for each interface in the configuration. These structures exist
353353 * for the entire life of the device.
....@@ -408,8 +408,6 @@
408408 struct usb_ssp_cap_descriptor *ssp_cap;
409409 struct usb_ss_container_id_descriptor *ss_id;
410410 struct usb_ptm_cap_descriptor *ptm_cap;
411
- struct usb_config_summary_descriptor *config_summary;
412
- unsigned int num_config_summary_desc;
413411
414412 ANDROID_KABI_RESERVE(1);
415413 ANDROID_KABI_RESERVE(2);
....@@ -435,11 +433,10 @@
435433 * Allocated per bus (tree of devices) we have:
436434 */
437435 struct usb_bus {
438
- struct device *controller; /* host/master side hardware */
436
+ struct device *controller; /* host side hardware */
439437 struct device *sysdev; /* as seen from firmware or bus */
440438 int busnum; /* Bus number (in order of reg) */
441439 const char *bus_name; /* stable id (PCI slot_name etc) */
442
- u8 uses_dma; /* Does the host controller use DMA? */
443440 u8 uses_pio_for_control; /*
444441 * Does the host controller use PIO
445442 * for control transfers?
....@@ -479,15 +476,6 @@
479476 struct mon_bus *mon_bus; /* non-null when associated */
480477 int monitored; /* non-zero when monitored */
481478 #endif
482
- unsigned skip_resume:1; /* All USB devices are brought into full
483
- * power state after system resume. It
484
- * is desirable for some buses to keep
485
- * their devices in suspend state even
486
- * after system resume. The devices
487
- * are resumed later when a remote
488
- * wakeup is detected or an interface
489
- * driver starts I/O.
490
- */
491479
492480 ANDROID_KABI_RESERVE(1);
493481 ANDROID_KABI_RESERVE(2);
....@@ -605,6 +593,7 @@
605593 * @bus_mA: Current available from the bus
606594 * @portnum: parent port number (origin 1)
607595 * @level: number of USB hub ancestors
596
+ * @devaddr: device address, XHCI: assigned by HW, others: same as devnum
608597 * @can_submit: URBs may be submitted
609598 * @persist_enabled: USB_PERSIST enabled for this device
610599 * @have_langid: whether string_langid is valid
....@@ -647,9 +636,9 @@
647636 * Management to be disabled for this usb_device. This count should only
648637 * be manipulated by those functions, with the bandwidth_mutex is held.
649638 * @hub_delay: cached value consisting of:
650
- * parent->hub_delay + wHubDelay + tTPTransmissionDelay (40ns)
651
- *
639
+ * parent->hub_delay + wHubDelay + tTPTransmissionDelay (40ns)
652640 * Will be used as wValue for SetIsochDelay requests.
641
+ * @use_generic_driver: ask driver core to reprobe using the generic driver.
653642 *
654643 * Notes:
655644 * Usbcore drivers should not set usbdev->state directly. Instead use
....@@ -688,6 +677,7 @@
688677 unsigned short bus_mA;
689678 u8 portnum;
690679 u8 level;
680
+ u8 devaddr;
691681
692682 unsigned can_submit:1;
693683 unsigned persist_enabled:1;
....@@ -734,6 +724,7 @@
734724 unsigned lpm_disable_count;
735725
736726 u16 hub_delay;
727
+ unsigned use_generic_driver:1;
737728
738729 ANDROID_KABI_RESERVE(1);
739730 ANDROID_KABI_RESERVE(2);
....@@ -775,6 +766,8 @@
775766 /* USB port reset for device reinitialization */
776767 extern int usb_reset_device(struct usb_device *dev);
777768 extern void usb_queue_reset_device(struct usb_interface *dev);
769
+
770
+extern struct device *usb_intf_get_dma_device(struct usb_interface *intf);
778771
779772 #ifdef CONFIG_ACPI
780773 extern int usb_acpi_set_power_state(struct usb_device *hdev, int index,
....@@ -856,19 +849,6 @@
856849
857850 /* for drivers using iso endpoints */
858851 extern int usb_get_current_frame_number(struct usb_device *usb_dev);
859
-extern int usb_sec_event_ring_setup(struct usb_device *dev,
860
- unsigned int intr_num);
861
-extern int usb_sec_event_ring_cleanup(struct usb_device *dev,
862
- unsigned int intr_num);
863
-
864
-extern phys_addr_t usb_get_sec_event_ring_phys_addr(
865
- struct usb_device *dev, unsigned int intr_num, dma_addr_t *dma);
866
-extern phys_addr_t usb_get_xfer_ring_phys_addr(struct usb_device *dev,
867
- struct usb_host_endpoint *ep, dma_addr_t *dma);
868
-extern int usb_get_controller_id(struct usb_device *dev);
869
-
870
-extern int usb_stop_endpoint(struct usb_device *dev,
871
- struct usb_host_endpoint *ep);
872852
873853 /* Sets up a group of bulk endpoints to support multiple stream IDs. */
874854 extern int usb_alloc_streams(struct usb_interface *interface,
....@@ -1194,6 +1174,8 @@
11941174 * @id_table: USB drivers use ID table to support hotplugging.
11951175 * Export this with MODULE_DEVICE_TABLE(usb,...). This must be set
11961176 * or your driver's probe function will never get called.
1177
+ * @dev_groups: Attributes attached to the device that will be created once it
1178
+ * is bound to the driver.
11971179 * @dynids: used internally to hold the list of dynamically added device
11981180 * ids for this driver.
11991181 * @drvwrap: Driver-model core structure wrapper.
....@@ -1241,6 +1223,7 @@
12411223 int (*post_reset)(struct usb_interface *intf);
12421224
12431225 const struct usb_device_id *id_table;
1226
+ const struct attribute_group **dev_groups;
12441227
12451228 struct usb_dynids dynids;
12461229 struct usbdrv_wrap drvwrap;
....@@ -1260,6 +1243,7 @@
12601243 * struct usb_device_driver - identifies USB device driver to usbcore
12611244 * @name: The driver name should be unique among USB drivers,
12621245 * and should normally be the same as the module name.
1246
+ * @match: If set, used for better device/driver matching.
12631247 * @probe: Called to see if the driver is willing to manage a particular
12641248 * device. If it is, probe returns zero and uses dev_set_drvdata()
12651249 * to associate driver-specific data with the device. If unwilling
....@@ -1269,22 +1253,34 @@
12691253 * module is being unloaded.
12701254 * @suspend: Called when the device is going to be suspended by the system.
12711255 * @resume: Called when the device is being resumed by the system.
1256
+ * @dev_groups: Attributes attached to the device that will be created once it
1257
+ * is bound to the driver.
12721258 * @drvwrap: Driver-model core structure wrapper.
1259
+ * @id_table: used with @match() to select better matching driver at
1260
+ * probe() time.
12731261 * @supports_autosuspend: if set to 0, the USB core will not allow autosuspend
12741262 * for devices bound to this driver.
1263
+ * @generic_subclass: if set to 1, the generic USB driver's probe, disconnect,
1264
+ * resume and suspend functions will be called in addition to the driver's
1265
+ * own, so this part of the setup does not need to be replicated.
12751266 *
1276
- * USB drivers must provide all the fields listed above except drvwrap.
1267
+ * USB drivers must provide all the fields listed above except drvwrap,
1268
+ * match, and id_table.
12771269 */
12781270 struct usb_device_driver {
12791271 const char *name;
12801272
1273
+ bool (*match) (struct usb_device *udev);
12811274 int (*probe) (struct usb_device *udev);
12821275 void (*disconnect) (struct usb_device *udev);
12831276
12841277 int (*suspend) (struct usb_device *udev, pm_message_t message);
12851278 int (*resume) (struct usb_device *udev, pm_message_t message);
1279
+ const struct attribute_group **dev_groups;
12861280 struct usbdrv_wrap drvwrap;
1281
+ const struct usb_device_id *id_table;
12871282 unsigned int supports_autosuspend:1;
1283
+ unsigned int generic_subclass:1;
12881284 };
12891285 #define to_usb_device_driver(d) container_of(d, struct usb_device_driver, \
12901286 drvwrap.driver)
....@@ -1505,7 +1501,7 @@
15051501 * field rather than determining a dma address themselves.
15061502 *
15071503 * Note that transfer_buffer must still be set if the controller
1508
- * does not support DMA (as indicated by bus.uses_dma) and when talking
1504
+ * does not support DMA (as indicated by hcd_uses_dma()) and when talking
15091505 * to root hub. If you have to trasfer between highmem zone and the device
15101506 * on such controller, create a bounce buffer or bail out with an error.
15111507 * If transfer_buffer cannot be set (is in highmem) and the controller is DMA
....@@ -1593,10 +1589,10 @@
15931589 struct urb {
15941590 /* private: usb core and host controller only fields in the urb */
15951591 struct kref kref; /* reference count of the URB */
1592
+ int unlinked; /* unlink error code */
15961593 void *hcpriv; /* private data for host controller */
15971594 atomic_t use_count; /* concurrent submissions counter */
15981595 atomic_t reject; /* submissions will fail */
1599
- int unlinked; /* unlink error code */
16001596
16011597 /* public: documented fields in the urb that can be used by drivers */
16021598 struct list_head urb_list; /* list head for use by the urb's
....@@ -1625,12 +1621,14 @@
16251621 int error_count; /* (return) number of ISO errors */
16261622 void *context; /* (in) context for completion */
16271623 usb_complete_t complete; /* (in) completion routine */
1628
- struct usb_iso_packet_descriptor iso_frame_desc[0];
1629
- /* (in) ISO ONLY */
1624
+
16301625 ANDROID_KABI_RESERVE(1);
16311626 ANDROID_KABI_RESERVE(2);
16321627 ANDROID_KABI_RESERVE(3);
16331628 ANDROID_KABI_RESERVE(4);
1629
+
1630
+ struct usb_iso_packet_descriptor iso_frame_desc[];
1631
+ /* (in) ISO ONLY */
16341632 };
16351633
16361634 /* ----------------------------------------------------------------------- */
....@@ -1800,6 +1798,7 @@
18001798 return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_OUT;
18011799 }
18021800
1801
+int usb_pipe_type_check(struct usb_device *dev, unsigned int pipe);
18031802 int usb_urb_ep_type_check(const struct urb *urb);
18041803
18051804 void *usb_alloc_coherent(struct usb_device *dev, size_t size,
....@@ -1837,6 +1836,14 @@
18371836 int timeout);
18381837
18391838 /* wrappers around usb_control_msg() for the most common standard requests */
1839
+int usb_control_msg_send(struct usb_device *dev, __u8 endpoint, __u8 request,
1840
+ __u8 requesttype, __u16 value, __u16 index,
1841
+ const void *data, __u16 size, int timeout,
1842
+ gfp_t memflags);
1843
+int usb_control_msg_recv(struct usb_device *dev, __u8 endpoint, __u8 request,
1844
+ __u8 requesttype, __u16 value, __u16 index,
1845
+ void *data, __u16 size, int timeout,
1846
+ gfp_t memflags);
18401847 extern int usb_get_descriptor(struct usb_device *dev, unsigned char desctype,
18411848 unsigned char descindex, void *buf, int size);
18421849 extern int usb_get_status(struct usb_device *dev,
....@@ -2044,11 +2051,8 @@
20442051 #define USB_DEVICE_REMOVE 0x0002
20452052 #define USB_BUS_ADD 0x0003
20462053 #define USB_BUS_REMOVE 0x0004
2047
-#define USB_BUS_DIED 0x0005
20482054 extern void usb_register_notify(struct notifier_block *nb);
20492055 extern void usb_unregister_notify(struct notifier_block *nb);
2050
-extern void usb_register_atomic_notify(struct notifier_block *nb);
2051
-extern void usb_unregister_atomic_notify(struct notifier_block *nb);
20522056
20532057 /* debugfs stuff */
20542058 extern struct dentry *usb_debug_root;