diff mbox series

[net-next] nfc: mrvl: use scoped device node handling to simplify cleanup

Message ID 20240813103904.75978-1-krzysztof.kozlowski@linaro.org (mailing list archive)
State Rejected
Delegated to: Netdev Maintainers
Headers show
Series [net-next] nfc: mrvl: use scoped device node handling to simplify cleanup | 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: 29 this patch: 29
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 2 of 2 maintainers
netdev/build_clang success Errors and warnings before: 29 this patch: 29
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: 30 this patch: 30
netdev/checkpatch warning WARNING: line length of 92 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-08-13--12-00 (tests: 706)

Commit Message

Krzysztof Kozlowski Aug. 13, 2024, 10:39 a.m. UTC
Obtain the device node reference with scoped/cleanup.h to reduce error
handling and make the code a bit simpler.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 drivers/nfc/nfcmrvl/uart.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

Simon Horman Aug. 13, 2024, 11:53 a.m. UTC | #1
On Tue, Aug 13, 2024 at 12:39:04PM +0200, Krzysztof Kozlowski wrote:
> Obtain the device node reference with scoped/cleanup.h to reduce error
> handling and make the code a bit simpler.
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Reviewed-by: Simon Horman <horms@kernel.org>
Jakub Kicinski Aug. 16, 2024, 2:08 a.m. UTC | #2
On Tue, 13 Aug 2024 12:39:04 +0200 Krzysztof Kozlowski wrote:
> -	matched_node = of_get_compatible_child(node, "marvell,nfc-uart");
> +	struct device_node *matched_node __free(device_node) = of_get_compatible_child(node,
> +										       "marvell,nfc-uart");

The 100+ character line mixing declaration and code is more than 
I can bear. Sorry.
Krzysztof Kozlowski Aug. 16, 2024, 5:11 a.m. UTC | #3
On 16/08/2024 04:08, Jakub Kicinski wrote:
> On Tue, 13 Aug 2024 12:39:04 +0200 Krzysztof Kozlowski wrote:
>> -	matched_node = of_get_compatible_child(node, "marvell,nfc-uart");
>> +	struct device_node *matched_node __free(device_node) = of_get_compatible_child(node,
>> +										       "marvell,nfc-uart");
> 
> The 100+ character line mixing declaration and code is more than 
> I can bear. Sorry.

If by mixing you mean declaration not on top of the code, that's the
preferred style for __free() usage, as expressed by Linus. Constructor
and destructor in one place.

The 100 line, can be solved with wrapping after '=', but of course it is
not particularly pretty.

Let's drop the patch then.

Best regards,
Krzysztof
diff mbox series

Patch

diff --git a/drivers/nfc/nfcmrvl/uart.c b/drivers/nfc/nfcmrvl/uart.c
index 956ae92f7573..01760f92e68a 100644
--- a/drivers/nfc/nfcmrvl/uart.c
+++ b/drivers/nfc/nfcmrvl/uart.c
@@ -5,6 +5,7 @@ 
  * Copyright (C) 2015, Marvell International Ltd.
  */
 
+#include <linux/cleanup.h>
 #include <linux/module.h>
 #include <linux/delay.h>
 #include <linux/of_gpio.h>
@@ -59,10 +60,10 @@  static const struct nfcmrvl_if_ops uart_ops = {
 static int nfcmrvl_uart_parse_dt(struct device_node *node,
 				 struct nfcmrvl_platform_data *pdata)
 {
-	struct device_node *matched_node;
 	int ret;
 
-	matched_node = of_get_compatible_child(node, "marvell,nfc-uart");
+	struct device_node *matched_node __free(device_node) = of_get_compatible_child(node,
+										       "marvell,nfc-uart");
 	if (!matched_node) {
 		matched_node = of_get_compatible_child(node, "mrvl,nfc-uart");
 		if (!matched_node)
@@ -72,15 +73,12 @@  static int nfcmrvl_uart_parse_dt(struct device_node *node,
 	ret = nfcmrvl_parse_dt(matched_node, pdata);
 	if (ret < 0) {
 		pr_err("Failed to get generic entries\n");
-		of_node_put(matched_node);
 		return ret;
 	}
 
 	pdata->flow_control = of_property_read_bool(matched_node, "flow-control");
 	pdata->break_control = of_property_read_bool(matched_node, "break-control");
 
-	of_node_put(matched_node);
-
 	return 0;
 }