Lines Matching refs:th
106 struct intel_th *th = to_intel_th(hub); in intel_th_remove() local
119 for (i = 0, lowest = -1; i < th->num_thdevs; i++) { in intel_th_remove()
125 if (th->thdev[i]->type != INTEL_TH_OUTPUT) { in intel_th_remove()
127 th->thdev[lowest] = th->thdev[i]; in intel_th_remove()
128 th->thdev[i] = NULL; in intel_th_remove()
138 intel_th_device_remove(th->thdev[i]); in intel_th_remove()
139 th->thdev[i] = NULL; in intel_th_remove()
143 th->num_thdevs = lowest; in intel_th_remove()
192 struct intel_th *th = to_intel_th(thdev); in intel_th_output_devnode() local
196 node = kasprintf(GFP_KERNEL, "intel_th%d/%s%d", th->id, in intel_th_output_devnode()
199 node = kasprintf(GFP_KERNEL, "intel_th%d/%s", th->id, in intel_th_output_devnode()
222 struct intel_th *th = to_intel_th(thdev); in intel_th_output_activate() local
233 if (th->activate) in intel_th_output_activate()
234 ret = th->activate(th); in intel_th_output_activate()
249 if (th->deactivate) in intel_th_output_activate()
250 th->deactivate(th); in intel_th_output_activate()
263 struct intel_th *th = to_intel_th(thdev); in intel_th_output_deactivate() local
273 if (th->deactivate) in intel_th_output_deactivate()
274 th->deactivate(th); in intel_th_output_deactivate()
355 intel_th_device_alloc(struct intel_th *th, unsigned int type, const char *name, in intel_th_device_alloc() argument
362 parent = &th->hub->dev; in intel_th_device_alloc()
364 parent = th->dev; in intel_th_device_alloc()
382 dev_set_name(&thdev->dev, "%d-%s%d", th->id, name, id); in intel_th_device_alloc()
384 dev_set_name(&thdev->dev, "%d-%s", th->id, name); in intel_th_device_alloc()
548 struct intel_th *th = container_of(work, struct intel_th, in __intel_th_request_hub_module() local
551 request_module("intel_th_%s", th->hub->name); in __intel_th_request_hub_module()
554 static int intel_th_request_hub_module(struct intel_th *th) in intel_th_request_hub_module() argument
556 INIT_WORK(&th->request_module_work, __intel_th_request_hub_module); in intel_th_request_hub_module()
557 schedule_work(&th->request_module_work); in intel_th_request_hub_module()
562 static void intel_th_request_hub_module_flush(struct intel_th *th) in intel_th_request_hub_module_flush() argument
564 flush_work(&th->request_module_work); in intel_th_request_hub_module_flush()
567 static inline int intel_th_request_hub_module(struct intel_th *th) in intel_th_request_hub_module() argument
572 static inline void intel_th_request_hub_module_flush(struct intel_th *th) in intel_th_request_hub_module_flush() argument
578 intel_th_subdevice_alloc(struct intel_th *th, in intel_th_subdevice_alloc() argument
587 thdev = intel_th_device_alloc(th, subdev->type, subdev->name, in intel_th_subdevice_alloc()
592 thdev->drvdata = th->drvdata; in intel_th_subdevice_alloc()
594 for (r = 0; r < th->num_resources; r++) in intel_th_subdevice_alloc()
595 if (th->resource[r].flags & IORESOURCE_MEM_64) { in intel_th_subdevice_alloc()
604 struct resource *devres = th->resource; in intel_th_subdevice_alloc()
624 dev_dbg(th->dev, "%s:%d @ %pR\n", in intel_th_subdevice_alloc()
627 res[r].start = th->irq; in intel_th_subdevice_alloc()
638 thdev->dev.devt = MKDEV(th->major, th->num_thdevs); in intel_th_subdevice_alloc()
644 INTEL_TH_CAP(th, host_mode_only) ? true : host_mode; in intel_th_subdevice_alloc()
645 th->hub = thdev; in intel_th_subdevice_alloc()
656 err = intel_th_request_hub_module(th); in intel_th_subdevice_alloc()
681 int intel_th_output_enable(struct intel_th *th, unsigned int otype) in intel_th_output_enable() argument
686 for (src = 0, dst = 0; dst <= th->num_thdevs; src++, dst++) { in intel_th_output_enable()
701 for (; dst < th->num_thdevs; dst++) { in intel_th_output_enable()
702 if (th->thdev[dst]->type != INTEL_TH_OUTPUT) in intel_th_output_enable()
705 if (th->thdev[dst]->output.type != otype) in intel_th_output_enable()
715 if (dst == th->num_thdevs) in intel_th_output_enable()
722 thdev = intel_th_subdevice_alloc(th, &intel_th_subdevices[src]); in intel_th_output_enable()
726 th->thdev[th->num_thdevs++] = thdev; in intel_th_output_enable()
732 static int intel_th_populate(struct intel_th *th) in intel_th_populate() argument
743 if ((INTEL_TH_CAP(th, host_mode_only) || host_mode) && in intel_th_populate()
755 thdev = intel_th_subdevice_alloc(th, subdev); in intel_th_populate()
760 th->thdev[th->num_thdevs++] = thdev; in intel_th_populate()
819 struct intel_th *th; in intel_th_alloc() local
829 th = kzalloc(sizeof(*th), GFP_KERNEL); in intel_th_alloc()
830 if (!th) in intel_th_alloc()
833 th->id = ida_simple_get(&intel_th_ida, 0, 0, GFP_KERNEL); in intel_th_alloc()
834 if (th->id < 0) { in intel_th_alloc()
835 err = th->id; in intel_th_alloc()
839 th->major = __register_chrdev(0, 0, TH_POSSIBLE_OUTPUTS, in intel_th_alloc()
841 if (th->major < 0) { in intel_th_alloc()
842 err = th->major; in intel_th_alloc()
845 th->dev = dev; in intel_th_alloc()
846 th->drvdata = drvdata; in intel_th_alloc()
848 th->resource = devres; in intel_th_alloc()
849 th->num_resources = ndevres; in intel_th_alloc()
850 th->irq = irq; in intel_th_alloc()
852 dev_set_drvdata(dev, th); in intel_th_alloc()
858 err = intel_th_populate(th); in intel_th_alloc()
861 intel_th_free(th); in intel_th_alloc()
865 return th; in intel_th_alloc()
868 ida_simple_remove(&intel_th_ida, th->id); in intel_th_alloc()
871 kfree(th); in intel_th_alloc()
877 void intel_th_free(struct intel_th *th) in intel_th_free() argument
881 intel_th_request_hub_module_flush(th); in intel_th_free()
883 intel_th_device_remove(th->hub); in intel_th_free()
884 for (i = 0; i < th->num_thdevs; i++) { in intel_th_free()
885 if (th->thdev[i] != th->hub) in intel_th_free()
886 intel_th_device_remove(th->thdev[i]); in intel_th_free()
887 th->thdev[i] = NULL; in intel_th_free()
890 th->num_thdevs = 0; in intel_th_free()
892 pm_runtime_get_sync(th->dev); in intel_th_free()
893 pm_runtime_forbid(th->dev); in intel_th_free()
895 __unregister_chrdev(th->major, 0, TH_POSSIBLE_OUTPUTS, in intel_th_free()
898 ida_simple_remove(&intel_th_ida, th->id); in intel_th_free()
900 kfree(th); in intel_th_free()