Lines Matching refs:dev
348 struct usb_interface *usb_ifnum_to_if(const struct usb_device *dev, in usb_ifnum_to_if() argument
351 struct usb_host_config *config = dev->actconfig; in usb_ifnum_to_if()
403 static int __find_interface(struct device *dev, const void *data) in __find_interface() argument
408 if (!is_usb_interface(dev)) in __find_interface()
411 if (dev->driver != arg->drv) in __find_interface()
413 intf = to_usb_interface(dev); in __find_interface()
431 struct device *dev; in usb_find_interface() local
436 dev = bus_find_device(&usb_bus_type, NULL, &argb, __find_interface); in usb_find_interface()
439 put_device(dev); in usb_find_interface()
441 return dev ? to_usb_interface(dev) : NULL; in usb_find_interface()
450 static int __each_dev(struct device *dev, void *data) in __each_dev() argument
455 if (!is_usb_device(dev)) in __each_dev()
458 return arg->fn(to_usb_device(dev), arg->data); in __each_dev()
485 static void usb_release_dev(struct device *dev) in usb_release_dev() argument
490 udev = to_usb_device(dev); in usb_release_dev()
495 of_node_put(dev->of_node); in usb_release_dev()
503 static int usb_dev_uevent(const struct device *dev, struct kobj_uevent_env *env) in usb_dev_uevent() argument
507 usb_dev = to_usb_device(dev); in usb_dev_uevent()
527 static int usb_dev_prepare(struct device *dev) in usb_dev_prepare() argument
532 static void usb_dev_complete(struct device *dev) in usb_dev_complete() argument
535 usb_resume_complete(dev); in usb_dev_complete()
538 static int usb_dev_suspend(struct device *dev) in usb_dev_suspend() argument
540 return usb_suspend(dev, PMSG_SUSPEND); in usb_dev_suspend()
543 static int usb_dev_resume(struct device *dev) in usb_dev_resume() argument
545 return usb_resume(dev, PMSG_RESUME); in usb_dev_resume()
548 static int usb_dev_freeze(struct device *dev) in usb_dev_freeze() argument
550 return usb_suspend(dev, PMSG_FREEZE); in usb_dev_freeze()
553 static int usb_dev_thaw(struct device *dev) in usb_dev_thaw() argument
555 return usb_resume(dev, PMSG_THAW); in usb_dev_thaw()
558 static int usb_dev_poweroff(struct device *dev) in usb_dev_poweroff() argument
560 return usb_suspend(dev, PMSG_HIBERNATE); in usb_dev_poweroff()
563 static int usb_dev_restore(struct device *dev) in usb_dev_restore() argument
565 return usb_resume(dev, PMSG_RESTORE); in usb_dev_restore()
585 static char *usb_devnode(const struct device *dev, in usb_devnode() argument
590 usb_dev = to_usb_device(dev); in usb_devnode()
605 static bool usb_dev_authorized(struct usb_device *dev, struct usb_hcd *hcd) in usb_dev_authorized() argument
609 if (!dev->parent) in usb_dev_authorized()
621 hub = usb_hub_to_struct_hub(dev->parent); in usb_dev_authorized()
622 return hub->ports[dev->portnum - 1]->connect_type == in usb_dev_authorized()
646 struct usb_device *dev; in usb_alloc_dev() local
650 dev = kzalloc(sizeof(*dev), GFP_KERNEL); in usb_alloc_dev()
651 if (!dev) in usb_alloc_dev()
655 kfree(dev); in usb_alloc_dev()
660 !usb_hcd->driver->alloc_dev(usb_hcd, dev)) { in usb_alloc_dev()
662 kfree(dev); in usb_alloc_dev()
666 device_initialize(&dev->dev); in usb_alloc_dev()
667 dev->dev.bus = &usb_bus_type; in usb_alloc_dev()
668 dev->dev.type = &usb_device_type; in usb_alloc_dev()
669 dev->dev.groups = usb_device_groups; in usb_alloc_dev()
670 set_dev_node(&dev->dev, dev_to_node(bus->sysdev)); in usb_alloc_dev()
671 dev->state = USB_STATE_ATTACHED; in usb_alloc_dev()
672 dev->lpm_disable_count = 1; in usb_alloc_dev()
673 atomic_set(&dev->urbnum, 0); in usb_alloc_dev()
675 INIT_LIST_HEAD(&dev->ep0.urb_list); in usb_alloc_dev()
676 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE; in usb_alloc_dev()
677 dev->ep0.desc.bDescriptorType = USB_DT_ENDPOINT; in usb_alloc_dev()
679 usb_enable_endpoint(dev, &dev->ep0, false); in usb_alloc_dev()
680 dev->can_submit = 1; in usb_alloc_dev()
691 dev->devpath[0] = '0'; in usb_alloc_dev()
692 dev->route = 0; in usb_alloc_dev()
694 dev->dev.parent = bus->controller; in usb_alloc_dev()
695 device_set_of_node_from_dev(&dev->dev, bus->sysdev); in usb_alloc_dev()
696 dev_set_name(&dev->dev, "usb%d", bus->busnum); in usb_alloc_dev()
700 snprintf(dev->devpath, sizeof dev->devpath, in usb_alloc_dev()
703 dev->route = 0; in usb_alloc_dev()
705 snprintf(dev->devpath, sizeof dev->devpath, in usb_alloc_dev()
709 dev->route = parent->route + in usb_alloc_dev()
712 dev->route = parent->route + in usb_alloc_dev()
716 dev->dev.parent = &parent->dev; in usb_alloc_dev()
717 dev_set_name(&dev->dev, "%d-%s", bus->busnum, dev->devpath); in usb_alloc_dev()
724 dev->dev.of_node = usb_of_get_device_node(parent, raw_port); in usb_alloc_dev()
729 dev->portnum = port1; in usb_alloc_dev()
730 dev->bus = bus; in usb_alloc_dev()
731 dev->parent = parent; in usb_alloc_dev()
732 INIT_LIST_HEAD(&dev->filelist); in usb_alloc_dev()
735 pm_runtime_set_autosuspend_delay(&dev->dev, in usb_alloc_dev()
737 dev->connect_time = jiffies; in usb_alloc_dev()
738 dev->active_duration = -jiffies; in usb_alloc_dev()
741 dev->authorized = usb_dev_authorized(dev, usb_hcd); in usb_alloc_dev()
742 return dev; in usb_alloc_dev()
762 struct usb_device *usb_get_dev(struct usb_device *dev) in usb_get_dev() argument
764 if (dev) in usb_get_dev()
765 get_device(&dev->dev); in usb_get_dev()
766 return dev; in usb_get_dev()
777 void usb_put_dev(struct usb_device *dev) in usb_put_dev() argument
779 if (dev) in usb_put_dev()
780 put_device(&dev->dev); in usb_put_dev()
803 get_device(&intf->dev); in usb_get_intf()
819 put_device(&intf->dev); in usb_put_intf()
932 int usb_get_current_frame_number(struct usb_device *dev) in usb_get_current_frame_number() argument
934 return usb_hcd_get_frame_number(dev); in usb_get_current_frame_number()
996 void *usb_alloc_coherent(struct usb_device *dev, size_t size, gfp_t mem_flags, in usb_alloc_coherent() argument
999 if (!dev || !dev->bus) in usb_alloc_coherent()
1001 return hcd_buffer_alloc(dev->bus, size, mem_flags, dma); in usb_alloc_coherent()
1016 void usb_free_coherent(struct usb_device *dev, size_t size, void *addr, in usb_free_coherent() argument
1019 if (!dev || !dev->bus) in usb_free_coherent()
1023 hcd_buffer_free(dev->bus, size, addr, dma); in usb_free_coherent()
1033 struct device *dev = data; in usb_bus_notify() local
1037 if (dev->type == &usb_device_type) in usb_bus_notify()
1038 (void) usb_create_sysfs_dev_files(to_usb_device(dev)); in usb_bus_notify()
1039 else if (dev->type == &usb_if_device_type) in usb_bus_notify()
1040 usb_create_sysfs_intf_files(to_usb_interface(dev)); in usb_bus_notify()
1044 if (dev->type == &usb_device_type) in usb_bus_notify()
1045 usb_remove_sysfs_dev_files(to_usb_device(dev)); in usb_bus_notify()
1046 else if (dev->type == &usb_if_device_type) in usb_bus_notify()
1047 usb_remove_sysfs_intf_files(to_usb_interface(dev)); in usb_bus_notify()