On Fri, Mar 03, 2023 at 10:33:50PM +0800, Pin-yen Lin wrote: > Register USB Type-C mode switches when the "mode-switch" property and > relevant port are available in Device Tree. Configure the "lane_swap" > state based on the entered alternate mode for a specific Type-C > connector, which ends up updating the lane swap registers of the it6505 > chip. ... > + it6505->port_data = devm_kcalloc(dev, switch_desc->num_typec_switches, > + sizeof(struct it6505_typec_port_data), > + GFP_KERNEL); > + Same, no need for a blank line here. > + if (!it6505->port_data) { > + ret = -ENOMEM; > + goto unregister_mux; > + } ... > + it6505->port_data[i].lane_swap = (dp_lanes[0] / 2 == 1); ' % 2 == 0' ? ... Wouldn't be better to have ret = PTR_ERR_OR_ZERO(extcon); here and amend the following accordingly? > if (PTR_ERR(extcon) == -EPROBE_DEFER) > return -EPROBE_DEFER; > if (IS_ERR(extcon)) { > - dev_err(dev, "can not get extcon device!"); > - return PTR_ERR(extcon); > + if (PTR_ERR(extcon) != -ENODEV) > + dev_warn(dev, "Cannot get extcon device: %ld\n", > + PTR_ERR(extcon)); > + it6505->extcon = NULL; > + } else { > + it6505->extcon = extcon; > } > > - it6505->extcon = extcon; > + init_completion(&it6505->mux_register); > + ret = it6505_register_typec_switches(dev, it6505); > + if (ret) { > + if (ret != -ENODEV) > + dev_warn(dev, "Didn't register Type-C switches, err: %d\n", > + ret); > + if (!it6505->extcon) { > + dev_err(dev, "Both extcon and typec-switch are not registered.\n"); > + return -EINVAL; > + } > + } Perhaps if (ret != -ENODEV) dev_warn(dev, "Didn't register Type-C switches, err: %d\n", ret); if (ret && !it6505->extcon) { dev_err(dev, "Both extcon and typec-switch are not registered.\n"); return ret; } ? -- With Best Regards, Andy Shevchenko