diff mbox series

[net-next,v2] net: wan: framer: Simplify API framer_provider_simple_of_xlate() implementation

Message ID 20241213-net_fix-v2-1-6d06130d630f@quicinc.com (mailing list archive)
State Accepted
Commit dcacb364772eb463bde225176086bd7738b7102f
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v2] net: wan: framer: Simplify API framer_provider_simple_of_xlate() implementation | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 1 maintainers not CCed: ricardo@marliere.net
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 37 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 9 this patch: 9
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-12-15--09-00 (tests: 795)

Commit Message

Zijun Hu Dec. 13, 2024, 12:09 p.m. UTC
From: Zijun Hu <quic_zijuhu@quicinc.com>

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>
---
Changes in v2:
- Use non-error path solution suggested by Simon Horman
- Link to v1: https://lore.kernel.org/r/20241211-framer-core-fix-v1-1-0688c6905a0b@quicinc.com
---
 drivers/net/wan/framer/framer-core.c | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)


---
base-commit: 2c27c7663390d28bc71e97500eb68e0ce2a7223f
change-id: 20241213-net_fix-5c580d48c39c

Best regards,

Comments

Simon Horman Dec. 13, 2024, 8 p.m. UTC | #1
On Fri, Dec 13, 2024 at 08:09:11PM +0800, Zijun Hu wrote:
> From: Zijun Hu <quic_zijuhu@quicinc.com>
> 
> 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>
> ---
> Changes in v2:
> - Use non-error path solution suggested by Simon Horman
> - Link to v1: https://lore.kernel.org/r/20241211-framer-core-fix-v1-1-0688c6905a0b@quicinc.com

Thanks for the update.

Reviewed-by: Simon Horman <horms@kernel.org>
patchwork-bot+netdevbpf@kernel.org Dec. 15, 2024, 10:20 p.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 13 Dec 2024 20:09:11 +0800 you wrote:
> From: Zijun Hu <quic_zijuhu@quicinc.com>
> 
> 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.
> 
> [...]

Here is the summary with links:
  - [net-next,v2] net: wan: framer: Simplify API framer_provider_simple_of_xlate() implementation
    https://git.kernel.org/netdev/net-next/c/dcacb364772e

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/wan/framer/framer-core.c b/drivers/net/wan/framer/framer-core.c
index f547c22e26ac2b9986e48ed77143f12a0c8f62fb..58f5143359dfd715e63e6dd82d794cf74357a9ff 100644
--- a/drivers/net/wan/framer/framer-core.c
+++ b/drivers/net/wan/framer/framer-core.c
@@ -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;
-	}
+	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 ERR_PTR(-ENODEV);
+	put_device(target_dev);
+	return dev_to_framer(target_dev);
 }
 EXPORT_SYMBOL_GPL(framer_provider_simple_of_xlate);