Re: [PATCH v14 10/10] drm/bridge: it6505: Register Type C mode switches

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 22, 2023 at 06:46:39PM +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.

...

> +	struct device_node *port_node = of_graph_get_port_by_id(dev->of_node, 1);
> +	struct drm_dp_typec_switch_desc *switch_desc = &it6505->switch_desc;
> +	int ret;
> +	u32 dp_lanes[4];
> +	unsigned int i, num_lanes;
> +
> +	ret = drm_dp_register_typec_switches(dev, &port_node->fwnode,
> +					     &it6505->switch_desc, it6505,
> +					     it6505_typec_mux_set);
> +	if (ret)
> +		return ret;
> +
> +	it6505->port_data = devm_kcalloc(dev, switch_desc->num_typec_switches,
> +					 sizeof(struct it6505_typec_port_data),
> +					 GFP_KERNEL);
> +	if (!it6505->port_data) {
> +		ret = -ENOMEM;
> +		goto unregister_mux;
> +	}

A couple of the similar comments as per previous similar patch.

...

>  	/* get extcon device from DTS */
>  	extcon = extcon_get_edev_by_phandle(dev, 0);
> -	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);
> +	ret = PTR_ERR_OR_ZERO(extcon);
> +	if (ret == -EPROBE_DEFER)
> +		return ret;

> +

Unnecessary blank line.

> +	if (ret) {
> +		if (ret != -ENODEV)
> +			dev_warn(dev, "Cannot get extcon device: %d\n", ret);
> +
> +		it6505->extcon = NULL;
> +	} else {
> +		it6505->extcon = extcon;

...

> +	ret = it6505_register_typec_switches(dev, it6505);
> +	if (ret != -ENODEV)
> +		dev_warn(dev, "Didn't register Type-C switches, err: %d\n", ret);

> +

Unnecessary blank line.

> +	if (ret && !it6505->extcon) {
> +		dev_err(dev, "Both extcon and Type-C switch are not registered.\n");
> +		return -EINVAL;

Why not return ret here?

> +	}

-- 
With Best Regards,
Andy Shevchenko





[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux