Skip to contentSkip to conversation

soc: imx: gpc: Use kemdup() function

PATCH New Fabio Estevam 2 participants 2 messages Mar 11, 2018 – Mar 15, 2018 Arm i.MX and Layerscape

lore
Share & tools
lore

Fabio Estevam

author reviewer
#0 lore raw

PATCH 1/1 soc: imx: gpc: Use kemdup() function

From: Fabio Estevam <[email protected]>

Use kmemdup() rather than duplicating its implementation.

Detected with Coccinelle script.

---
 drivers/soc/imx/gpc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/soc/imx/gpc.c +2 -2
index 196f17b..cc3bad8 100644
@@ -444,12 +444,12 @@ static int imx_gpc_probe(struct platform_device *pdev)
 			if (domain_index >= of_id_data->num_domains)
 				continue;
 
-			domain = kmalloc(sizeof(*domain), GFP_KERNEL);
+			domain = kmemdup(&imx_gpc_domains[domain_index],
+					 sizeof(*domain), GFP_KERNEL);
 			if (!domain) {
 				of_node_put(np);
 				return -ENOMEM;
 			}
-			memcpy(domain, &imx_gpc_domains[domain_index], sizeof(*domain));
 			domain->regmap = regmap;
 			domain->ipg_rate_mhz = ipg_rate_mhz;
 
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 soc: imx: gpc: Use kemdup() function

Hi Fabio,

Quoted 7 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

Use kmemdup() rather than duplicating its implementation.

Detected with Coccinelle script.

I copied you on my reply to Andrey Smirnov, in which I requested to use platform_device_add_data() for his patches. That said, your patches will be dropped as well.

Shawn

Quoted 26 lines
---
 drivers/soc/imx/gpc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/soc/imx/gpc.c +2 -2
index 196f17b..cc3bad8 100644
@@ -444,12 +444,12 @@ static int imx_gpc_probe(struct platform_device *pdev)
 			if (domain_index >= of_id_data->num_domains)
 				continue;
 
-			domain = kmalloc(sizeof(*domain), GFP_KERNEL);
+			domain = kmemdup(&imx_gpc_domains[domain_index],
+					 sizeof(*domain), GFP_KERNEL);
 			if (!domain) {
 				of_node_put(np);
 				return -ENOMEM;
 			}
-			memcpy(domain, &imx_gpc_domains[domain_index], sizeof(*domain));
 			domain->regmap = regmap;
 			domain->ipg_rate_mhz = ipg_rate_mhz;
 
Signature · 1 line
2.7.4