Commit dcacb364 authored by Zijun Hu's avatar Zijun Hu Committed by Jakub Kicinski
Browse files

net: wan: framer: Simplify API framer_provider_simple_of_xlate() implementation



Simplify framer_provider_simple_of_xlate() implementation by API
class_find_device_by_of_node().

Also correct comments to mark its parameter @dev as unused instead of
@args in passing.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarZijun Hu <quic_zijuhu@quicinc.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20241213-net_fix-v2-1-6d06130d630f@quicinc.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 734ff310
Loading
Loading
Loading
Loading
+8 −15
Original line number Diff line number Diff line
@@ -732,8 +732,8 @@ EXPORT_SYMBOL_GPL(devm_framer_create);

/**
 * framer_provider_simple_of_xlate() - returns the framer instance from framer provider
 * @dev: the framer provider device
 * @args: of_phandle_args (not used here)
 * @dev: the framer provider device (not used here)
 * @args: of_phandle_args
 *
 * Intended to be used by framer provider for the common case where #framer-cells is
 * 0. For other cases where #framer-cells is greater than '0', the framer provider
@@ -743,21 +743,14 @@ EXPORT_SYMBOL_GPL(devm_framer_create);
struct framer *framer_provider_simple_of_xlate(struct device *dev,
					       const struct of_phandle_args *args)
{
	struct class_dev_iter iter;
	struct framer *framer;

	class_dev_iter_init(&iter, &framer_class, NULL, NULL);
	while ((dev = class_dev_iter_next(&iter))) {
		framer = dev_to_framer(dev);
		if (args->np != framer->dev.of_node)
			continue;
	struct device *target_dev;

		class_dev_iter_exit(&iter);
		return framer;
	}

	class_dev_iter_exit(&iter);
	target_dev = class_find_device_by_of_node(&framer_class, args->np);
	if (!target_dev)
		return ERR_PTR(-ENODEV);

	put_device(target_dev);
	return dev_to_framer(target_dev);
}
EXPORT_SYMBOL_GPL(framer_provider_simple_of_xlate);