Skip to contentSkip to conversation

ata: ahci_platform: minor fixes

PATCH Applied Corentin Labbe 3 participants 6 messages Jul 12, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover ata: ahci_platform: minor fixes

Hello

This patchset fixes some minor problem found when working on supporting allwinner R40 AHCI.

Regards

Corentin Labbe (3):
ata: ahci_platform: correct parameter documentation for
ahci_platform_shutdown
ata: ahci_platform: convert kzallloc to kcalloc
ata: ahci_platform: convert kcalloc to devm_kcalloc

 drivers/ata/libahci_platform.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
Signature · 1 line
2.16.4
#1 lore raw

PATCH 1/3 ata: ahci_platform: correct parameter documentation for ahci_platform_shutdown

The documentation about parameter for ahci_platform_shutdown has a typo.

This fix the following build warning:
drivers/ata/libahci_platform.c:693: warning: Function parameter or member 'pdev' not described in 'ahci_platform_shutdown' drivers/ata/libahci_platform.c:693: warning: Excess function parameter 'dev' description in 'ahci_platform_shutdow

---
 drivers/ata/libahci_platform.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/libahci_platform.c +1 -1
index feee2e11fb33..70052c046559 100644
@@ -607,7 +607,7 @@ static void ahci_host_stop(struct ata_host *host)
 
 /**
  * ahci_platform_shutdown - Disable interrupts and stop DMA for host ports
- * @dev: platform device pointer for the host
+ * @pdev: platform device pointer for the host
  *
  * This function is called during system shutdown and performs the minimal
  * deconfiguration required to ensure that an ahci_platform host cannot
Signature · 1 line
2.16.4
#2 lore raw

PATCH 2/3 ata: ahci_platform: convert kzallloc to kcalloc

In reply to Corentin Labbe

It's better to kcalloc instead of kzalloc(n * sizeof())

---
 drivers/ata/libahci_platform.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/ata/libahci_platform.c +3 -5
index 70052c046559..be9f54423a9b 100644
@@ -351,7 +351,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))
@@ -403,14 +403,12 @@ 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;
 	}
-	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;
Signature · 1 line
2.16.4
#3 lore raw

PATCH 3/3 ata: ahci_platform: convert kcalloc to devm_kcalloc

In reply to Corentin Labbe

Like phys, target_pwrs could be allocated with devm_ function

---
 drivers/ata/libahci_platform.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/ata/libahci_platform.c +1 -3
index be9f54423a9b..fe8939e161ea 100644
@@ -271,8 +271,6 @@ static void ahci_platform_put_resources(struct device *dev, void *res)
 	for (c = 0; c < hpriv->nports; c++)
 		if (hpriv->target_pwrs && hpriv->target_pwrs[c])
 			regulator_put(hpriv->target_pwrs[c]);
-
-	kfree(hpriv->target_pwrs);
 }
 
 static int ahci_platform_get_phy(struct ahci_host_priv *hpriv, u32 port,
@@ -408,7 +406,7 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev)
 		rc = -ENOMEM;
 		goto err_out;
 	}
-	hpriv->target_pwrs = kcalloc(hpriv->nports, sizeof(*hpriv->target_pwrs), GFP_KERNEL);
+	hpriv->target_pwrs = devm_kcalloc(dev, hpriv->nports, sizeof(*hpriv->target_pwrs), GFP_KERNEL);
 	if (!hpriv->target_pwrs) {
 		rc = -ENOMEM;
 		goto err_out;
Signature · 1 line
2.16.4
Applied
#5 lore raw
In reply to Corentin Labbe
Quoted 5 lines · Corentin Labbe

Hello

This patchset fixes some minor problem found when working on supporting allwinner R40 AHCI.

Quoted 7 lines

Regards

Corentin Labbe (3):
ata: ahci_platform: correct parameter documentation for
ahci_platform_shutdown
ata: ahci_platform: convert kzallloc to kcalloc
ata: ahci_platform: convert kcalloc to devm_kcalloc

Applied all three to libata/for-4.19 with Hans's ack added.

Thanks.

Signature · 1 line
tejun