Message ID | 20241010-input_automate_of_node_put-v1-8-ebc62138fbf8@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | input: automate of_node_put() calls for device_node | expand |
On Thu, Oct 10, 2024 at 11:25:58PM +0200, Javier Carrasco wrote: > Use the '__free(device_node)' macro to automatically free the device > node, removing the need for explicit calls to 'of_node_put()' to > decrement its refcount. > > Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> > --- > drivers/input/serio/i8042-sparcio.h | 6 +----- > 1 file changed, 1 insertion(+), 5 deletions(-) > > diff --git a/drivers/input/serio/i8042-sparcio.h b/drivers/input/serio/i8042-sparcio.h > index c2fda54dc384..8f38b6f4ae77 100644 > --- a/drivers/input/serio/i8042-sparcio.h > +++ b/drivers/input/serio/i8042-sparcio.h > @@ -106,17 +106,13 @@ static struct platform_driver sparc_i8042_driver = { > > static bool i8042_is_mr_coffee(void) > { > - struct device_node *root; > + struct device_node *root __free(device_node) = of_find_node_by_path("/"); > const char *name; > bool is_mr_coffee; This temporary is no longer needed. I removed it and applied, thanks. > > - root = of_find_node_by_path("/"); > - > name = of_get_property(root, "name", NULL); > is_mr_coffee = name && !strcmp(name, "SUNW,JavaStation-1"); > > - of_node_put(root); > - > return is_mr_coffee; > } > > > -- > 2.43.0 >
diff --git a/drivers/input/serio/i8042-sparcio.h b/drivers/input/serio/i8042-sparcio.h index c2fda54dc384..8f38b6f4ae77 100644 --- a/drivers/input/serio/i8042-sparcio.h +++ b/drivers/input/serio/i8042-sparcio.h @@ -106,17 +106,13 @@ static struct platform_driver sparc_i8042_driver = { static bool i8042_is_mr_coffee(void) { - struct device_node *root; + struct device_node *root __free(device_node) = of_find_node_by_path("/"); const char *name; bool is_mr_coffee; - root = of_find_node_by_path("/"); - name = of_get_property(root, "name", NULL); is_mr_coffee = name && !strcmp(name, "SUNW,JavaStation-1"); - of_node_put(root); - return is_mr_coffee; }
Use the '__free(device_node)' macro to automatically free the device node, removing the need for explicit calls to 'of_node_put()' to decrement its refcount. Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> --- drivers/input/serio/i8042-sparcio.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)