[PATCH v3 05/17] usb: typec: Add device managed typec_switch_register()

Andy Shevchenko andriy.shevchenko at linux.intel.com
Tue Aug 20 10:16:09 UTC 2024


On Mon, Aug 19, 2024 at 03:38:19PM -0700, Stephen Boyd wrote:
> Simplify driver error paths by adding devm_typec_switch_register() which
> will unregister the typec switch when the parent device is unbound.

> Cc: Heikki Krogerus <heikki.krogerus at linux.intel.com>
> Cc: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
> Cc: <linux-usb at vger.kernel.org>
> Cc: Pin-yen Lin <treapking at chromium.org>

As per previous patches.

...

> +	ptr = devres_alloc(devm_typec_switch_unregister, sizeof(*ptr), GFP_KERNEL);
> +	if (!ptr)
> +		return ERR_PTR(-ENOMEM);
> +
> +	switch_dev = typec_switch_register(parent ,desc);
> +	if (!IS_ERR(switch_dev)) {
> +		*ptr = switch_dev;
> +		devres_add(parent, ptr);
> +	} else {
> +		devres_free(ptr);
> +	}

devm_add_action_or_reset() ?

-- 
With Best Regards,
Andy Shevchenko




More information about the dri-devel mailing list