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: Zijun Hu <quic_zijuhu@quicinc.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20241213-net_fix-v2-1-6d06130d630f@quicinc.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Zijun Hu 2024-12-13 20:09:11 +08:00 committed by Jakub Kicinski
parent 734ff310d3
commit dcacb36477

View File

@ -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;
struct device *target_dev;
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;
target_dev = class_find_device_by_of_node(&framer_class, args->np);
if (!target_dev)
return ERR_PTR(-ENODEV);
class_dev_iter_exit(&iter);
return framer;
}
class_dev_iter_exit(&iter);
return ERR_PTR(-ENODEV);
put_device(target_dev);
return dev_to_framer(target_dev);
}
EXPORT_SYMBOL_GPL(framer_provider_simple_of_xlate);