[PATCH v3 04/17] usb: typec: Add device managed typec_mux_register()

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


On Mon, Aug 19, 2024 at 03:38:18PM -0700, Stephen Boyd wrote:
> Simplify driver error paths by adding devm_typec_mux_register() which
> will unregister the typec mux 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 comment, move these after --- line
(hint: You may have it in your Git commit with --- line,
 it will be removed on the receiver side by `git am`)

...

> +/** devm_typec_mux_register - resource managed typec_mux_register()

Wrong comment style.

> + * @parent: Parent device
> + * @desc: Multiplexer description
> + *
> + * Register a typec mux and automatically unregister the typec mux
> + * when @parent is unbound from its driver.
> + *
> + * The arguments to this function are identical to typec_mux_register().
> + *
> + * Return: the typec_mux_dev structure on success, else an error pointer.
> + */
> +struct typec_mux_dev *
> +devm_typec_mux_register(struct device *parent, const struct typec_mux_desc *desc)
> +{
> +	struct typec_mux_dev **ptr, *mux_dev;
> +
> +	ptr = devres_alloc(devm_typec_mux_unregister, sizeof(*ptr), GFP_KERNEL);
> +	if (!ptr)
> +		return ERR_PTR(-ENOMEM);
> +
> +	mux_dev = typec_mux_register(parent ,desc);
> +	if (!IS_ERR(mux_dev)) {
> +		*ptr = mux_dev;
> +		devres_add(parent, ptr);
> +	} else {
> +		devres_free(ptr);
> +	}

What does prevent you from using devm_add_action_or_reset()?

> +	return mux_dev;
> +}

-- 
With Best Regards,
Andy Shevchenko




More information about the dri-devel mailing list