Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1625613 > unrolled thread
| Started by | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| First post | 2017-04-18 22:10 +0200 |
| Last post | 2017-04-18 22:10 +0200 |
| Articles | 3 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH 0/3] SATA: Fine-tuning for two function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-18 22:10 +0200
[PATCH 2/3] ata: libahci: Use devm_kcalloc() in ahci_platform_get_resources() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-18 22:10 +0200
[PATCH 1/3] ata: libahci: Use kcalloc() in ahci_platform_get_resources() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-18 22:10 +0200
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-04-18 22:10 +0200 |
| Subject | [PATCH 0/3] SATA: Fine-tuning for two function implementations |
| Message-ID | <txHBL-22s-5@gated-at.bofh.it> |
From: Markus Elfring <elfring@users.sourceforge.net> Date: Tue, 18 Apr 2017 21:54:32 +0200 A few update suggestions were taken into account from static source code analysis. Markus Elfring (3): Use kcalloc() in ahci_platform_get_resources() Use devm_kcalloc() in ahci_platform_get_resources() Use devm_kcalloc() in mv_platform_probe() drivers/ata/libahci_platform.c | 11 ++++++----- drivers/ata/sata_mv.c | 10 ++++++---- 2 files changed, 12 insertions(+), 9 deletions(-) -- 2.12.2
[toc] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-04-18 22:10 +0200 |
| Subject | [PATCH 2/3] ata: libahci: Use devm_kcalloc() in ahci_platform_get_resources() |
| Message-ID | <txHBL-22s-7@gated-at.bofh.it> |
| In reply to | #1625613 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Apr 2017 21:15:48 +0200
* A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "devm_kcalloc".
This issue was detected by using the Coccinelle software.
* Delete the local variable "sz" which became unnecessary
with this refactoring.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/ata/libahci_platform.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c
index c68ea903b5bf..2bce61f7482f 100644
--- a/drivers/ata/libahci_platform.c
+++ b/drivers/ata/libahci_platform.c
@@ -350,7 +350,7 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev)
struct ahci_host_priv *hpriv;
struct clk *clk;
struct device_node *child;
- int i, sz, enabled_ports = 0, rc = -ENOMEM, child_nodes;
+ int i, enabled_ports = 0, rc = -ENOMEM, child_nodes;
u32 mask_port_map = 0;
if (!devres_open_group(dev, NULL, GFP_KERNEL))
@@ -402,8 +402,8 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev)
if (!child_nodes)
hpriv->nports = 1;
- sz = hpriv->nports * sizeof(*hpriv->phys);
- hpriv->phys = devm_kzalloc(dev, sz, GFP_KERNEL);
+ hpriv->phys = devm_kcalloc(dev, hpriv->nports, sizeof(*hpriv->phys),
+ GFP_KERNEL);
if (!hpriv->phys) {
rc = -ENOMEM;
goto err_out;
--
2.12.2
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-04-18 22:10 +0200 |
| Subject | [PATCH 1/3] ata: libahci: Use kcalloc() in ahci_platform_get_resources() |
| Message-ID | <txHBM-22s-13@gated-at.bofh.it> |
| In reply to | #1625613 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Apr 2017 21:07:34 +0200
A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kcalloc".
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/ata/libahci_platform.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c
index aaa761b9081c..c68ea903b5bf 100644
--- a/drivers/ata/libahci_platform.c
+++ b/drivers/ata/libahci_platform.c
@@ -408,8 +408,9 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev)
rc = -ENOMEM;
goto err_out;
}
- sz = hpriv->nports * sizeof(*hpriv->target_pwrs);
- hpriv->target_pwrs = kzalloc(sz, GFP_KERNEL);
+ hpriv->target_pwrs = kcalloc(hpriv->nports,
+ sizeof(*hpriv->target_pwrs),
+ GFP_KERNEL);
if (!hpriv->target_pwrs) {
rc = -ENOMEM;
goto err_out;
--
2.12.2
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web