Trivial code cleanup for DT resolver
cover Trivial code cleanup for DT resolver
Two trivial patches to the DT resolver code.
Stephen Boyd (2):
of/resolver: Simplify to be32_add_cpu() of/resolver: Replace kmalloc + memcpy with kmemdup()
drivers/of/resolver.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
Signature · 1 line
2.14.GIT
PATCH 1/2 of/resolver: Simplify to be32_add_cpu()
This is the same as be32_add_cpu(), so simplify the code and remove the now unused local variable.
--- drivers/of/resolver.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/of/resolver.c +1 -4
@@ -165,7 +165,6 @@ static int adjust_local_phandle_references(struct device_node *local_fixups,struct property *prop_fix, *prop;int err, i, count;unsigned int off; -phandle phandle;if (!local_fixups)return 0 ;
@@ -195,9 +194,7 @@ static int adjust_local_phandle_references(struct device_node *local_fixups,if ((off +4 ) > prop->length)return -EINVAL ; - phandle =be32_to_cpu (*(__be32 *)(prop->value + off)); - phandle += phandle_delta; - *(__be32 *)(prop->value + off) =cpu_to_be32 (phandle); +be32_add_cpu (prop->value + off, phandle_delta); } }
Signature · 1 line
2.14.GIT
PATCH 2/2 of/resolver: Replace kmalloc + memcpy with kmemdup()
In reply to Stephen BoydSave one line.
--- drivers/of/resolver.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/of/resolver.c +1 -2
@@ -84,10 +84,9 @@ static int update_usages_of_a_phandle_reference(struct device_node *overlay,int offset, len;int err =0 ; - value =kmalloc (prop_fixup->length,GFP_KERNEL ); + value =kmemdup (prop_fixup->value, prop_fixup->length,GFP_KERNEL );if (!value)return -ENOMEM ; -memcpy (value, prop_fixup->value, prop_fixup->length);/* prop_fixup contains a list of tuples of path:property_name:offset */ end = value + prop_fixup->length;
Signature · 1 line
2.14.GIT
Re: [PATCH 2/2] of/resolver: Replace kmalloc + memcpy with kmemdup()
Quoted 14 lines · Stephen Boyd
Save one line.
Signed-off-by Stephen Boyd <[email protected]>--- drivers/of/resolver.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/of/resolver.c +0
-0@@ -84,10 +84,9 @@ static int update_usages_of_a_phandle_reference(struct device_node *overlay,int offset, len;
drivers/of/resolver.c static int update_usages_of_a_phandle_reference(struct device_node *overlay, · line 92
Quoted 10 lines
drivers/of/resolver.c +1
-2int err =0 ; - value =kmalloc (prop_fixup->length,GFP_KERNEL ); + value =kmemdup (prop_fixup->value, prop_fixup->length,GFP_KERNEL );if (!value)return -ENOMEM ; -memcpy (value, prop_fixup->value, prop_fixup->length);/* prop_fixup contains a list of tuples of path:property_name:offset */ end = value + prop_fixup->length;
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/2] of/resolver: Simplify to be32_add_cpu()
In reply to Stephen BoydQuoted 22 lines · Stephen Boyd
This is the same as
be32_add_cpu(), so simplify the code and remove the now unused local variable.Signed-off-by Stephen Boyd <[email protected]>--- drivers/of/resolver.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)drivers/of/resolver.c +0
-1@@ -165,7 +165,6 @@ static int adjust_local_phandle_references(struct device_node *local_fixups,struct property *prop_fix, *prop;int err, i, count;unsigned int off; -phandle phandle;if (!local_fixups)return 0 ;
drivers/of/resolver.c static int adjust_local_phandle_references(struct device_node *local_fixups, · line 200
Quoted 10 lines
drivers/of/resolver.c +1
-3@@ -195,9 +194,7 @@ static int adjust_local_phandle_references(struct device_node *local_fixups,if ((off +4 ) > prop->length)return -EINVAL ; - phandle =be32_to_cpu (*(__be32 *)(prop->value + off)); - phandle += phandle_delta; - *(__be32 *)(prop->value + off) =cpu_to_be32 (phandle); +be32_add_cpu (prop->value + off, phandle_delta); } }
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Rob Herring
maintainerRe: [PATCH 2/2] of/resolver: Replace kmalloc + memcpy with kmemdup()
In reply to Stephen BoydQuoted 6 lines · Stephen Boyd
Save one line.
Signed-off-by Stephen Boyd <[email protected]>--- drivers/of/resolver.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Both applied. Thanks.
Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html