Hi Heikki,
I love your patch! Perhaps something to improve:
[auto build test WARNING on usb/usb-testing] [also build test WARNING on v5.1-rc3 next-20190401] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Heikki-Krogerus/usb-typec-Registeri... base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing reproduce: make htmldocs
All warnings (new ones prefixed by >>):
WARNING: convert(1) not found, for SVG to PDF conversion install ImageMagick (https://www.imagemagick.org) include/linux/generic-radix-tree.h:1: warning: no structured comments found kernel/rcu/tree_plugin.h:1: warning: no structured comments found kernel/rcu/tree_plugin.h:1: warning: no structured comments found include/linux/firmware/intel/stratix10-svc-client.h:1: warning: no structured comments found include/linux/gpio/driver.h:371: warning: Function parameter or member 'init_valid_mask' not described in 'gpio_chip' include/linux/i2c.h:343: warning: Function parameter or member 'init_irq' not described in 'i2c_client' include/linux/iio/hw-consumer.h:1: warning: no structured comments found include/linux/input/sparse-keymap.h:46: warning: Function parameter or member 'sw' not described in 'key_entry' include/linux/regulator/machine.h:199: warning: Function parameter or member 'max_uV_step' not described in 'regulation_constraints' include/linux/regulator/driver.h:228: warning: Function parameter or member 'resume' not described in 'regulator_ops' drivers/slimbus/stream.c:1: warning: no structured comments found include/linux/spi/spi.h:188: warning: Function parameter or member 'driver_override' not described in 'spi_device' drivers/target/target_core_device.c:1: warning: no structured comments found
drivers/usb/typec/mux.c:106: warning: Function parameter or member 'parent' not described in 'typec_switch_register' drivers/usb/typec/mux.c:106: warning: Function parameter or member 'desc' not described in 'typec_switch_register'
drivers/usb/typec/mux.c:106: warning: Excess function parameter 'sw' description in 'typec_switch_register'
drivers/usb/typec/mux.c:281: warning: Function parameter or member 'parent' not described in 'typec_mux_register' drivers/usb/typec/mux.c:281: warning: Function parameter or member 'desc' not described in 'typec_mux_register'
drivers/usb/typec/mux.c:281: warning: Excess function parameter 'mux' description in 'typec_mux_register' drivers/usb/typec/bus.c:1: warning: no structured comments found drivers/usb/typec/class.c:1: warning: no structured comments found include/linux/w1.h:281: warning: Function parameter or member 'of_match_table' not described in 'w1_family' fs/direct-io.c:257: warning: Excess function parameter 'offset' description in 'dio_complete' fs/file_table.c:1: warning: no structured comments found fs/libfs.c:477: warning: Excess function parameter 'available' description in 'simple_write_end' fs/posix_acl.c:646: warning: Function parameter or member 'inode' not described in 'posix_acl_update_mode' fs/posix_acl.c:646: warning: Function parameter or member 'mode_p' not described in 'posix_acl_update_mode' fs/posix_acl.c:646: warning: Function parameter or member 'acl' not described in 'posix_acl_update_mode' drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c:294: warning: Excess function parameter 'mm' description in 'amdgpu_mn_invalidate_range_start_hsa' drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c:294: warning: Excess function parameter 'start' description in 'amdgpu_mn_invalidate_range_start_hsa' drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c:294: warning: Excess function parameter 'end' description in 'amdgpu_mn_invalidate_range_start_hsa' drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c:343: warning: Excess function parameter 'mm' description in 'amdgpu_mn_invalidate_range_end' drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c:343: warning: Excess function parameter 'start' description in 'amdgpu_mn_invalidate_range_end' drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c:343: warning: Excess function parameter 'end' description in 'amdgpu_mn_invalidate_range_end' drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c:183: warning: Function parameter or member 'blockable' not described in 'amdgpu_mn_read_lock' drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c:295: warning: Function parameter or member 'range' not described in 'amdgpu_mn_invalidate_range_start_hsa' drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c:295: warning: Excess function parameter 'mm' description in 'amdgpu_mn_invalidate_range_start_hsa' drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c:295: warning: Excess function parameter 'start' description in 'amdgpu_mn_invalidate_range_start_hsa' drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c:295: warning: Excess function parameter 'end' description in 'amdgpu_mn_invalidate_range_start_hsa' drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c:344: warning: Function parameter or member 'range' not described in 'amdgpu_mn_invalidate_range_end' drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c:344: warning: Excess function parameter 'mm' description in 'amdgpu_mn_invalidate_range_end' drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c:344: warning: Excess function parameter 'start' description in 'amdgpu_mn_invalidate_range_end' drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c:344: warning: Excess function parameter 'end' description in 'amdgpu_mn_invalidate_range_end' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:374: warning: cannot understand function prototype: 'struct amdgpu_vm_pt_cursor ' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:375: warning: cannot understand function prototype: 'struct amdgpu_vm_pt_cursor ' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:547: warning: Function parameter or member 'adev' not described in 'for_each_amdgpu_vm_pt_leaf' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:547: warning: Function parameter or member 'vm' not described in 'for_each_amdgpu_vm_pt_leaf' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:547: warning: Function parameter or member 'start' not described in 'for_each_amdgpu_vm_pt_leaf' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:547: warning: Function parameter or member 'end' not described in 'for_each_amdgpu_vm_pt_leaf' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:547: warning: Function parameter or member 'cursor' not described in 'for_each_amdgpu_vm_pt_leaf' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:595: warning: Function parameter or member 'adev' not described in 'for_each_amdgpu_vm_pt_dfs_safe' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:595: warning: Function parameter or member 'vm' not described in 'for_each_amdgpu_vm_pt_dfs_safe' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:595: warning: Function parameter or member 'cursor' not described in 'for_each_amdgpu_vm_pt_dfs_safe' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:595: warning: Function parameter or member 'entry' not described in 'for_each_amdgpu_vm_pt_dfs_safe' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:868: warning: Function parameter or member 'level' not described in 'amdgpu_vm_bo_param' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1348: warning: Function parameter or member 'params' not described in 'amdgpu_vm_update_func' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1348: warning: Function parameter or member 'bo' not described in 'amdgpu_vm_update_func' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1348: warning: Function parameter or member 'pe' not described in 'amdgpu_vm_update_func' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1348: warning: Function parameter or member 'addr' not described in 'amdgpu_vm_update_func' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1348: warning: Function parameter or member 'count' not described in 'amdgpu_vm_update_func' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1348: warning: Function parameter or member 'incr' not described in 'amdgpu_vm_update_func' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1348: warning: Function parameter or member 'flags' not described in 'amdgpu_vm_update_func' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1516: warning: Function parameter or member 'params' not described in 'amdgpu_vm_update_flags' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1516: warning: Function parameter or member 'bo' not described in 'amdgpu_vm_update_flags' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1516: warning: Function parameter or member 'level' not described in 'amdgpu_vm_update_flags' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1516: warning: Function parameter or member 'pe' not described in 'amdgpu_vm_update_flags' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1516: warning: Function parameter or member 'addr' not described in 'amdgpu_vm_update_flags' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1516: warning: Function parameter or member 'count' not described in 'amdgpu_vm_update_flags' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1516: warning: Function parameter or member 'incr' not described in 'amdgpu_vm_update_flags' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1516: warning: Function parameter or member 'flags' not described in 'amdgpu_vm_update_flags' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:3107: warning: Function parameter or member 'pasid' not described in 'amdgpu_vm_make_compute' drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c:375: warning: Excess function parameter 'entry' description in 'amdgpu_irq_dispatch' drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c:376: warning: Function parameter or member 'ih' not described in 'amdgpu_irq_dispatch' drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c:376: warning: Excess function parameter 'entry' description in 'amdgpu_irq_dispatch' drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c:1: warning: no structured comments found drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h:128: warning: Incorrect use of kernel-doc format: Documentation Makefile include scripts source @atomic_obj drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h:203: warning: Function parameter or member 'atomic_obj' not described in 'amdgpu_display_manager' drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h:203: warning: Function parameter or member 'atomic_obj_lock' not described in 'amdgpu_display_manager' drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h:203: warning: Function parameter or member 'backlight_link' not described in 'amdgpu_display_manager' drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h:203: warning: Function parameter or member 'backlight_caps' not described in 'amdgpu_display_manager' drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h:203: warning: Function parameter or member 'freesync_module' not described in 'amdgpu_display_manager' drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h:203: warning: Function parameter or member 'fw_dmcu' not described in 'amdgpu_display_manager' drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h:203: warning: Function parameter or member 'dmcu_fw_version' not described in 'amdgpu_display_manager' drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c:1: warning: no structured comments found include/drm/drm_drv.h:715: warning: Function parameter or member 'gem_prime_pin' not described in 'drm_driver' include/drm/drm_drv.h:715: warning: Function parameter or member 'gem_prime_unpin' not described in 'drm_driver' include/drm/drm_drv.h:715: warning: Function parameter or member 'gem_prime_res_obj' not described in 'drm_driver' include/drm/drm_drv.h:715: warning: Function parameter or member 'gem_prime_get_sg_table' not described in 'drm_driver' include/drm/drm_drv.h:715: warning: Function parameter or member 'gem_prime_import_sg_table' not described in 'drm_driver' include/drm/drm_drv.h:715: warning: Function parameter or member 'gem_prime_vmap' not described in 'drm_driver' include/drm/drm_drv.h:715: warning: Function parameter or member 'gem_prime_vunmap' not described in 'drm_driver' include/drm/drm_drv.h:715: warning: Function parameter or member 'gem_prime_mmap' not described in 'drm_driver' include/drm/drm_atomic_state_helper.h:1: warning: no structured comments found drivers/gpu/drm/scheduler/sched_main.c:376: warning: Excess function parameter 'bad' description in 'drm_sched_stop' drivers/gpu/drm/scheduler/sched_main.c:377: warning: Excess function parameter 'bad' description in 'drm_sched_stop' drivers/gpu/drm/scheduler/sched_main.c:420: warning: Function parameter or member 'full_recovery' not described in 'drm_sched_start' drivers/gpu/drm/i915/i915_vma.h:50: warning: cannot understand function prototype: 'struct i915_vma ' drivers/gpu/drm/i915/i915_vma.h:1: warning: no structured comments found drivers/gpu/drm/i915/intel_guc_fwif.h:536: warning: cannot understand function prototype: 'struct guc_log_buffer_state ' drivers/gpu/drm/i915/i915_trace.h:1: warning: no structured comments found drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h:126: warning: Function parameter or member 'hw_id' not described in 'komeda_component' drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h:126: warning: Function parameter or member 'max_active_outputs' not described in 'komeda_component' drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h:126: warning: Function parameter or member 'supported_outputs' not described in 'komeda_component' drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h:142: warning: Function parameter or member 'output_port' not described in 'komeda_component_output' drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h:196: warning: Function parameter or member 'component' not described in 'komeda_component_state' drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h:196: warning: Function parameter or member 'crtc' not described in 'komeda_component_state' drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h:196: warning: Function parameter or member 'plane' not described in 'komeda_component_state' drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h:196: warning: Function parameter or member 'wb_conn' not described in 'komeda_component_state' drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h:196: warning: Function parameter or member 'changed_active_inputs' not described in 'komeda_component_state' drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h:196: warning: Function parameter or member 'affected_inputs' not described in 'komeda_component_state' drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h:300: warning: Function parameter or member 'n_layers' not described in 'komeda_pipeline' drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h:300: warning: Function parameter or member 'layers' not described in 'komeda_pipeline' drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h:300: warning: Function parameter or member 'n_scalers' not described in 'komeda_pipeline' drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h:300: warning: Function parameter or member 'scalers' not described in 'komeda_pipeline' drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h:300: warning: Function parameter or member 'compiz' not described in 'komeda_pipeline' drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h:300: warning: Function parameter or member 'wb_layer' not described in 'komeda_pipeline' drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h:300: warning: Function parameter or member 'improc' not described in 'komeda_pipeline' drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h:300: warning: Function parameter or member 'ctrlr' not described in 'komeda_pipeline'
vim +106 drivers/usb/typec/mux.c
e900bf53 Heikki Krogerus 2019-04-01 93 bdecb33a Heikki Krogerus 2018-03-20 94 /** bdecb33a Heikki Krogerus 2018-03-20 95 * typec_switch_register - Register USB Type-C orientation switch bdecb33a Heikki Krogerus 2018-03-20 96 * @sw: USB Type-C orientation switch bdecb33a Heikki Krogerus 2018-03-20 97 * bdecb33a Heikki Krogerus 2018-03-20 98 * This function registers a switch that can be used for routing the correct bdecb33a Heikki Krogerus 2018-03-20 99 * data pairs depending on the cable plug orientation from the USB Type-C bdecb33a Heikki Krogerus 2018-03-20 100 * connector to the USB controllers. USB Type-C plugs can be inserted bdecb33a Heikki Krogerus 2018-03-20 101 * right-side-up or upside-down. bdecb33a Heikki Krogerus 2018-03-20 102 */ e900bf53 Heikki Krogerus 2019-04-01 103 struct typec_switch * e900bf53 Heikki Krogerus 2019-04-01 104 typec_switch_register(struct device *parent, e900bf53 Heikki Krogerus 2019-04-01 105 const struct typec_switch_desc *desc) bdecb33a Heikki Krogerus 2018-03-20 @106 { e900bf53 Heikki Krogerus 2019-04-01 107 struct typec_switch *sw; e900bf53 Heikki Krogerus 2019-04-01 108 int ret; e900bf53 Heikki Krogerus 2019-04-01 109 e900bf53 Heikki Krogerus 2019-04-01 110 if (!desc || !desc->set) e900bf53 Heikki Krogerus 2019-04-01 111 return ERR_PTR(-EINVAL); e900bf53 Heikki Krogerus 2019-04-01 112 e900bf53 Heikki Krogerus 2019-04-01 113 sw = kzalloc(sizeof(*sw), GFP_KERNEL); e900bf53 Heikki Krogerus 2019-04-01 114 if (!sw) e900bf53 Heikki Krogerus 2019-04-01 115 return ERR_PTR(-ENOMEM); e900bf53 Heikki Krogerus 2019-04-01 116 e900bf53 Heikki Krogerus 2019-04-01 117 sw->set = desc->set; e900bf53 Heikki Krogerus 2019-04-01 118 e900bf53 Heikki Krogerus 2019-04-01 119 device_initialize(&sw->dev); e900bf53 Heikki Krogerus 2019-04-01 120 sw->dev.parent = parent; e900bf53 Heikki Krogerus 2019-04-01 121 sw->dev.class = &typec_mux_class; e900bf53 Heikki Krogerus 2019-04-01 122 sw->dev.type = &typec_switch_dev_type; e900bf53 Heikki Krogerus 2019-04-01 123 sw->dev.driver_data = desc->drvdata; e900bf53 Heikki Krogerus 2019-04-01 124 sw->dev.fwnode = desc->fwnode; e900bf53 Heikki Krogerus 2019-04-01 125 dev_set_name(&sw->dev, "%s-switch", dev_name(parent)); e900bf53 Heikki Krogerus 2019-04-01 126 e900bf53 Heikki Krogerus 2019-04-01 127 ret = device_add(&sw->dev); e900bf53 Heikki Krogerus 2019-04-01 128 if (ret) { e900bf53 Heikki Krogerus 2019-04-01 129 dev_err(parent, "failed to register switch (%d)\n", ret); e900bf53 Heikki Krogerus 2019-04-01 130 put_device(&sw->dev); e900bf53 Heikki Krogerus 2019-04-01 131 return ERR_PTR(ret); e900bf53 Heikki Krogerus 2019-04-01 132 } bdecb33a Heikki Krogerus 2018-03-20 133 e900bf53 Heikki Krogerus 2019-04-01 134 return sw; bdecb33a Heikki Krogerus 2018-03-20 135 } bdecb33a Heikki Krogerus 2018-03-20 136 EXPORT_SYMBOL_GPL(typec_switch_register); bdecb33a Heikki Krogerus 2018-03-20 137 bdecb33a Heikki Krogerus 2018-03-20 138 /** bdecb33a Heikki Krogerus 2018-03-20 139 * typec_switch_unregister - Unregister USB Type-C orientation switch bdecb33a Heikki Krogerus 2018-03-20 140 * @sw: USB Type-C orientation switch bdecb33a Heikki Krogerus 2018-03-20 141 * bdecb33a Heikki Krogerus 2018-03-20 142 * Unregister switch that was registered with typec_switch_register(). bdecb33a Heikki Krogerus 2018-03-20 143 */ bdecb33a Heikki Krogerus 2018-03-20 144 void typec_switch_unregister(struct typec_switch *sw) bdecb33a Heikki Krogerus 2018-03-20 145 { e900bf53 Heikki Krogerus 2019-04-01 146 if (!IS_ERR_OR_NULL(sw)) e900bf53 Heikki Krogerus 2019-04-01 147 device_unregister(&sw->dev); bdecb33a Heikki Krogerus 2018-03-20 148 } bdecb33a Heikki Krogerus 2018-03-20 149 EXPORT_SYMBOL_GPL(typec_switch_unregister); bdecb33a Heikki Krogerus 2018-03-20 150 e900bf53 Heikki Krogerus 2019-04-01 151 void *typec_switch_get_drvdata(struct typec_switch *sw) e900bf53 Heikki Krogerus 2019-04-01 152 { e900bf53 Heikki Krogerus 2019-04-01 153 return dev_get_drvdata(&sw->dev); e900bf53 Heikki Krogerus 2019-04-01 154 } e900bf53 Heikki Krogerus 2019-04-01 155 EXPORT_SYMBOL_GPL(typec_switch_get_drvdata); e900bf53 Heikki Krogerus 2019-04-01 156 bdecb33a Heikki Krogerus 2018-03-20 157 /* ------------------------------------------------------------------------- */ bdecb33a Heikki Krogerus 2018-03-20 158 bdecb33a Heikki Krogerus 2018-03-20 159 static void *typec_mux_match(struct device_connection *con, int ep, void *data) bdecb33a Heikki Krogerus 2018-03-20 160 { 96a6d031 Heikki Krogerus 2019-02-13 161 const struct typec_altmode_desc *desc = data; e900bf53 Heikki Krogerus 2019-04-01 162 struct device *dev; 96a6d031 Heikki Krogerus 2019-02-13 163 bool match; e900bf53 Heikki Krogerus 2019-04-01 164 int nval; 96a6d031 Heikki Krogerus 2019-02-13 165 u16 *val; 96a6d031 Heikki Krogerus 2019-02-13 166 int i; bdecb33a Heikki Krogerus 2018-03-20 167 96a6d031 Heikki Krogerus 2019-02-13 168 if (!con->fwnode) { e900bf53 Heikki Krogerus 2019-04-01 169 dev = class_find_device(&typec_mux_class, NULL, e900bf53 Heikki Krogerus 2019-04-01 170 con->endpoint[ep], name_match); e900bf53 Heikki Krogerus 2019-04-01 171 e900bf53 Heikki Krogerus 2019-04-01 172 return dev ? to_typec_switch(dev) : ERR_PTR(-EPROBE_DEFER); 96a6d031 Heikki Krogerus 2019-02-13 173 } bdecb33a Heikki Krogerus 2018-03-20 174 bdecb33a Heikki Krogerus 2018-03-20 175 /* 96a6d031 Heikki Krogerus 2019-02-13 176 * Check has the identifier already been "consumed". If it 96a6d031 Heikki Krogerus 2019-02-13 177 * has, no need to do any extra connection identification. bdecb33a Heikki Krogerus 2018-03-20 178 */ 96a6d031 Heikki Krogerus 2019-02-13 179 match = !con->id; 96a6d031 Heikki Krogerus 2019-02-13 180 if (match) 96a6d031 Heikki Krogerus 2019-02-13 181 goto find_mux; 96a6d031 Heikki Krogerus 2019-02-13 182 96a6d031 Heikki Krogerus 2019-02-13 183 /* Accessory Mode muxes */ 96a6d031 Heikki Krogerus 2019-02-13 184 if (!desc) { 96a6d031 Heikki Krogerus 2019-02-13 185 match = fwnode_property_present(con->fwnode, "accessory"); 96a6d031 Heikki Krogerus 2019-02-13 186 if (match) 96a6d031 Heikki Krogerus 2019-02-13 187 goto find_mux; 96a6d031 Heikki Krogerus 2019-02-13 188 return NULL; 96a6d031 Heikki Krogerus 2019-02-13 189 } 96a6d031 Heikki Krogerus 2019-02-13 190 96a6d031 Heikki Krogerus 2019-02-13 191 /* Alternate Mode muxes */ 96a6d031 Heikki Krogerus 2019-02-13 192 nval = fwnode_property_read_u16_array(con->fwnode, "svid", NULL, 0); 96a6d031 Heikki Krogerus 2019-02-13 193 if (nval <= 0) 96a6d031 Heikki Krogerus 2019-02-13 194 return NULL; 96a6d031 Heikki Krogerus 2019-02-13 195 96a6d031 Heikki Krogerus 2019-02-13 196 val = kcalloc(nval, sizeof(*val), GFP_KERNEL); 96a6d031 Heikki Krogerus 2019-02-13 197 if (!val) 96a6d031 Heikki Krogerus 2019-02-13 198 return ERR_PTR(-ENOMEM); 96a6d031 Heikki Krogerus 2019-02-13 199 96a6d031 Heikki Krogerus 2019-02-13 200 nval = fwnode_property_read_u16_array(con->fwnode, "svid", val, nval); 96a6d031 Heikki Krogerus 2019-02-13 201 if (nval < 0) { 96a6d031 Heikki Krogerus 2019-02-13 202 kfree(val); 96a6d031 Heikki Krogerus 2019-02-13 203 return ERR_PTR(nval); 96a6d031 Heikki Krogerus 2019-02-13 204 } 96a6d031 Heikki Krogerus 2019-02-13 205 96a6d031 Heikki Krogerus 2019-02-13 206 for (i = 0; i < nval; i++) { 96a6d031 Heikki Krogerus 2019-02-13 207 match = val[i] == desc->svid; 96a6d031 Heikki Krogerus 2019-02-13 208 if (match) { 96a6d031 Heikki Krogerus 2019-02-13 209 kfree(val); 96a6d031 Heikki Krogerus 2019-02-13 210 goto find_mux; 96a6d031 Heikki Krogerus 2019-02-13 211 } 96a6d031 Heikki Krogerus 2019-02-13 212 } 96a6d031 Heikki Krogerus 2019-02-13 213 kfree(val); 96a6d031 Heikki Krogerus 2019-02-13 214 return NULL; 96a6d031 Heikki Krogerus 2019-02-13 215 96a6d031 Heikki Krogerus 2019-02-13 216 find_mux: e900bf53 Heikki Krogerus 2019-04-01 217 dev = class_find_device(&typec_mux_class, NULL, con->fwnode, e900bf53 Heikki Krogerus 2019-04-01 218 fwnode_match); 96a6d031 Heikki Krogerus 2019-02-13 219 e900bf53 Heikki Krogerus 2019-04-01 220 return dev ? to_typec_switch(dev) : ERR_PTR(-EPROBE_DEFER); bdecb33a Heikki Krogerus 2018-03-20 221 } bdecb33a Heikki Krogerus 2018-03-20 222 bdecb33a Heikki Krogerus 2018-03-20 223 /** bdecb33a Heikki Krogerus 2018-03-20 224 * typec_mux_get - Find USB Type-C Multiplexer bdecb33a Heikki Krogerus 2018-03-20 225 * @dev: The caller device 540bfab7 Heikki Krogerus 2019-02-13 226 * @desc: Alt Mode description bdecb33a Heikki Krogerus 2018-03-20 227 * bdecb33a Heikki Krogerus 2018-03-20 228 * Finds a mux linked to the caller. This function is primarily meant for the bdecb33a Heikki Krogerus 2018-03-20 229 * Type-C drivers. Returns a reference to the mux on success, NULL if no bdecb33a Heikki Krogerus 2018-03-20 230 * matching connection was found, or ERR_PTR(-EPROBE_DEFER) when a connection bdecb33a Heikki Krogerus 2018-03-20 231 * was found but the mux has not been enumerated yet. bdecb33a Heikki Krogerus 2018-03-20 232 */ 540bfab7 Heikki Krogerus 2019-02-13 233 struct typec_mux *typec_mux_get(struct device *dev, 540bfab7 Heikki Krogerus 2019-02-13 234 const struct typec_altmode_desc *desc) bdecb33a Heikki Krogerus 2018-03-20 235 { bdecb33a Heikki Krogerus 2018-03-20 236 struct typec_mux *mux; bdecb33a Heikki Krogerus 2018-03-20 237 540bfab7 Heikki Krogerus 2019-02-13 238 mux = device_connection_find_match(dev, "mode-switch", (void *)desc, 540bfab7 Heikki Krogerus 2019-02-13 239 typec_mux_match); e900bf53 Heikki Krogerus 2019-04-01 240 if (!IS_ERR_OR_NULL(mux)) e900bf53 Heikki Krogerus 2019-04-01 241 get_device(&mux->dev); bdecb33a Heikki Krogerus 2018-03-20 242 bdecb33a Heikki Krogerus 2018-03-20 243 return mux; bdecb33a Heikki Krogerus 2018-03-20 244 } bdecb33a Heikki Krogerus 2018-03-20 245 EXPORT_SYMBOL_GPL(typec_mux_get); bdecb33a Heikki Krogerus 2018-03-20 246 bdecb33a Heikki Krogerus 2018-03-20 247 /** bdecb33a Heikki Krogerus 2018-03-20 248 * typec_mux_put - Release handle to a Multiplexer bdecb33a Heikki Krogerus 2018-03-20 249 * @mux: USB Type-C Connector Multiplexer/DeMultiplexer bdecb33a Heikki Krogerus 2018-03-20 250 * bdecb33a Heikki Krogerus 2018-03-20 251 * Decrements reference count for @mux. bdecb33a Heikki Krogerus 2018-03-20 252 */ bdecb33a Heikki Krogerus 2018-03-20 253 void typec_mux_put(struct typec_mux *mux) bdecb33a Heikki Krogerus 2018-03-20 254 { e900bf53 Heikki Krogerus 2019-04-01 255 if (!IS_ERR_OR_NULL(mux)) e900bf53 Heikki Krogerus 2019-04-01 256 put_device(&mux->dev); 3e3b8196 Heikki Krogerus 2018-09-19 257 } bdecb33a Heikki Krogerus 2018-03-20 258 EXPORT_SYMBOL_GPL(typec_mux_put); bdecb33a Heikki Krogerus 2018-03-20 259 e900bf53 Heikki Krogerus 2019-04-01 260 static void typec_mux_release(struct device *dev) e900bf53 Heikki Krogerus 2019-04-01 261 { e900bf53 Heikki Krogerus 2019-04-01 262 kfree(to_typec_mux(dev)); e900bf53 Heikki Krogerus 2019-04-01 263 } e900bf53 Heikki Krogerus 2019-04-01 264 e900bf53 Heikki Krogerus 2019-04-01 265 static const struct device_type typec_mux_dev_type = { e900bf53 Heikki Krogerus 2019-04-01 266 .name = "mode_switch", e900bf53 Heikki Krogerus 2019-04-01 267 .release = typec_mux_release, e900bf53 Heikki Krogerus 2019-04-01 268 }; e900bf53 Heikki Krogerus 2019-04-01 269 bdecb33a Heikki Krogerus 2018-03-20 270 /** bdecb33a Heikki Krogerus 2018-03-20 271 * typec_mux_register - Register Multiplexer routing USB Type-C pins bdecb33a Heikki Krogerus 2018-03-20 272 * @mux: USB Type-C Connector Multiplexer/DeMultiplexer bdecb33a Heikki Krogerus 2018-03-20 273 * bdecb33a Heikki Krogerus 2018-03-20 274 * USB Type-C connectors can be used for alternate modes of operation besides bdecb33a Heikki Krogerus 2018-03-20 275 * USB when Accessory/Alternate Modes are supported. With some of those modes, bdecb33a Heikki Krogerus 2018-03-20 276 * the pins on the connector need to be reconfigured. This function registers bdecb33a Heikki Krogerus 2018-03-20 277 * multiplexer switches routing the pins on the connector. bdecb33a Heikki Krogerus 2018-03-20 278 */ e900bf53 Heikki Krogerus 2019-04-01 279 struct typec_mux * e900bf53 Heikki Krogerus 2019-04-01 280 typec_mux_register(struct device *parent, const struct typec_mux_desc *desc) bdecb33a Heikki Krogerus 2018-03-20 @281 { e900bf53 Heikki Krogerus 2019-04-01 282 struct typec_mux *mux; e900bf53 Heikki Krogerus 2019-04-01 283 int ret; e900bf53 Heikki Krogerus 2019-04-01 284 e900bf53 Heikki Krogerus 2019-04-01 285 if (!desc || !desc->set) e900bf53 Heikki Krogerus 2019-04-01 286 return ERR_PTR(-EINVAL); bdecb33a Heikki Krogerus 2018-03-20 287 e900bf53 Heikki Krogerus 2019-04-01 288 mux = kzalloc(sizeof(*mux), GFP_KERNEL); e900bf53 Heikki Krogerus 2019-04-01 289 if (!mux) e900bf53 Heikki Krogerus 2019-04-01 290 return ERR_PTR(-ENOMEM); e900bf53 Heikki Krogerus 2019-04-01 291 e900bf53 Heikki Krogerus 2019-04-01 292 mux->set = desc->set; e900bf53 Heikki Krogerus 2019-04-01 293 e900bf53 Heikki Krogerus 2019-04-01 294 device_initialize(&mux->dev); e900bf53 Heikki Krogerus 2019-04-01 295 mux->dev.parent = parent; e900bf53 Heikki Krogerus 2019-04-01 296 mux->dev.class = &typec_mux_class; e900bf53 Heikki Krogerus 2019-04-01 297 mux->dev.type = &typec_mux_dev_type; e900bf53 Heikki Krogerus 2019-04-01 298 mux->dev.fwnode = desc->fwnode; e900bf53 Heikki Krogerus 2019-04-01 299 mux->dev.driver_data = desc->drvdata; e900bf53 Heikki Krogerus 2019-04-01 300 dev_set_name(&mux->dev, "%s-mux", dev_name(parent)); e900bf53 Heikki Krogerus 2019-04-01 301 e900bf53 Heikki Krogerus 2019-04-01 302 ret = device_add(&mux->dev); e900bf53 Heikki Krogerus 2019-04-01 303 if (ret) { e900bf53 Heikki Krogerus 2019-04-01 304 dev_err(parent, "failed to register mux (%d)\n", ret); e900bf53 Heikki Krogerus 2019-04-01 305 put_device(&mux->dev); e900bf53 Heikki Krogerus 2019-04-01 306 return ERR_PTR(ret); e900bf53 Heikki Krogerus 2019-04-01 307 } e900bf53 Heikki Krogerus 2019-04-01 308 e900bf53 Heikki Krogerus 2019-04-01 309 return mux; bdecb33a Heikki Krogerus 2018-03-20 310 } bdecb33a Heikki Krogerus 2018-03-20 311 EXPORT_SYMBOL_GPL(typec_mux_register); bdecb33a Heikki Krogerus 2018-03-20 312
:::::: The code at line 106 was first introduced by commit :::::: bdecb33af34f79cbfbb656661210f77c8b8b5b5f usb: typec: API for controlling USB Type-C Multiplexers
:::::: TO: Heikki Krogerus heikki.krogerus@linux.intel.com :::::: CC: Greg Kroah-Hartman gregkh@linuxfoundation.org
--- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation