pinctrl: Quiet logging about missing DT nodes when not using DT
PATCH 1/1 pinctrl: Quiet logging about missing DT nodes when not using DT
From: Mark Brown <[email protected]>
On systems which were not booted using DT it is entirely unsurprising that device nodes don't have any DT information and this is going to happen for every single device in the system. Make pinctrl be less chatty about this situation by only logging in the case where we have DT.
--- drivers/pinctrl/devicetree.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pinctrl/devicetree.c +3 -1
@@ -186,7 +186,9 @@ int pinctrl_dt_to_map(struct pinctrl *p)/* CONFIG_OF enabled, p->dev not instantiated from DT */ if (!np) { -dev_dbg (p->dev,"no of_node; not parsing pinctrl DT\n" ); +if (of_have_populated_dt ()) +dev_dbg (p->dev, +"no of_node; not parsing pinctrl DT\n" );return 0 ; }
Signature · 1 line
1.9.rc1
Quoted 6 lines · Mark Brown
From: Mark Brown <[email protected]>
On systems which were not booted using DT it is entirely unsurprising that device nodes don't have any DT information and this is going to happen for every single device in the system. Make pinctrl be less chatty about this situation by only logging in the case where we have DT.
trivia:
drivers/pinctrl/devicetree.c
Quoted 1 line
drivers/pinctrl/devicetree.c +0
-0
[]
drivers/pinctrl/devicetree.c int pinctrl_dt_to_map(struct pinctrl *p) · line 191
Quoted 8 lines
drivers/pinctrl/devicetree.c +3
-1@@ -186,7 +186,9 @@ int pinctrl_dt_to_map(struct pinctrl *p)/* CONFIG_OF enabled, p->dev not instantiated from DT */ if (!np) { -dev_dbg (p->dev,"no of_node; not parsing pinctrl DT\n" ); +if (of_have_populated_dt ()) +dev_dbg (p->dev, +"no of_node; not parsing pinctrl DT\n" );
There are 80 columns. It's OK to use them all.
dev_dbg(p->dev, "no of_node; not parsing pinctrl DT\n");
PATCH 1/1 pinctrl: Avoid kasprintf/kfree
Avoid an unnecessary allocation/free by using stack instead.
Signed-off-by; Joe Perches <[email protected]>
---
This allocation seems unnecessary and the kasprintf isn't checked for non-null, so maybe this is better.
drivers/pinctrl/devicetree.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/pinctrl/devicetree.c +2 -3
@@ -176,13 +176,13 @@ int pinctrl_dt_to_map(struct pinctrl *p) {struct device_node *np = p->dev->of_node;int state, ret; -char *propname;struct property *prop;const char *statename;const __be32 *list;int size, config;phandle phandle;struct device_node *np_config; +char propname[9 +sizeof (int ) *2 +4 ] ="pinctrl-" ;/* CONFIG_OF enabled, p->dev not instantiated from DT */ if (!np) {
@@ -196,9 +196,8 @@ int pinctrl_dt_to_map(struct pinctrl *p)/* For each defined state ID */ for (state =0 ; ; state++) {/* Retrieve the pinctrl-* property */ - propname =kasprintf (GFP_KERNEL ,"pinctrl-%d" , state); +snprintf (&propname[8 ],ARRAY_SIZE (propname) -9 ,"%d" , state); prop =of_find_property (np, propname, &size); -kfree (propname);if (!prop)break ; list = prop->value;
Re: [PATCH] pinctrl: Avoid kasprintf/kfree
drivers/pinctrl/devicetree.c int pinctrl_dt_to_map(struct pinctrl *p) · line 185
Quoted 1 line · Joe Perches
drivers/pinctrl/devicetree.c +1
-0+char propname[9 +sizeof (int ) *2 +4 ] ="pinctrl-" ;
I'm not sure this is a triumph of legibility - there's several magic numbers there and it's not blindlingly obvious where the caclculation came from. Is this really a hot enough code path to benefit from an optimisation like this?
Re: [PATCH] pinctrl: Avoid kasprintf/kfree
In reply to Joe PerchesQuoted 3 lines · Joe Perches
Avoid an unnecessary allocation/free by using stack instead.
Signed-off-by; Joe Perches <[email protected]>
Hm.
Quoted 1 line
+ char propname[9 + sizeof(int) * 2 + 4] = "pinctrl-";
If you absolutely want to do this you have to
#define PINCTRL_PREFIX "pinctrl-"
char propname[strlen(PINCTRL_PREFIX) + sizeof(int)*2 + 4] = PINCTRL_PREFIX;
Then add a comment above stating why you add 4.
Quoted 2 lines
This allocation seems unnecessary and the kasprintf isn't checked for non-null, so maybe this is better.
Another option would be to just add a NULL-check? This is definately not on a performance-critical path.
Yours,
Linus Walleij
Re: [PATCH] pinctrl: Avoid kasprintf/kfree
Quoted 9 lines · Linus Walleij
Quoted 3 lines · Joe Perches
Avoid an unnecessary allocation/free by using stack instead.
Signed-off-by; Joe Perches <[email protected]>
Hm.
Quoted 1 line
+ char propname[9 + sizeof(int) * 2 + 4] = "pinctrl-";
Quoted 7 lines
If you absolutely want to do this you have to
#define
PINCTRL_PREFIX"pinctrl-"char propname[strlen(PINCTRL_PREFIX) + sizeof(int)*2 + 4] =
PINCTRL_PREFIX;Then add a comment above stating why you add 4.
No, I don't really.
Quoted 5 lines
Quoted 2 lines
This allocation seems unnecessary and the kasprintf isn't checked for non-null, so maybe this is better.
Another option would be to just add a NULL-check? This is definately not on a performance-critical path.
It's a defect not to check the kasprintf return before writing through it.
I submitted what I think appropriate.
Fix it as you choose. Or not.
cheers, Joe
Quoted 8 lines · Mark Brown
From: Mark Brown <[email protected]>
On systems which were not booted using DT it is entirely unsurprising that device nodes don't have any DT information and this is going to happen for every single device in the system. Make pinctrl be less chatty about this situation by only logging in the case where we have DT.
Signed-off-by Mark Brown <[email protected]>
Makes perfect sense. Patch applied.
Sorry for leaving it in limbo for so long!
Yours,
Linus Walleij