From: Rosen Penev <rosenp@gmail.com>
To: linux-ide@vger.kernel.org
Cc: Damien Le Moal <dlemoal@kernel.org>,
Niklas Cassel <cassel@kernel.org>,
Thierry Reding <thierry.reding@gmail.com>,
Jonathan Hunter <jonathanh@nvidia.com>,
linux-tegra@vger.kernel.org (open list:TEGRA ARCHITECTURE
SUPPORT), linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] ata: ahci_tegra: remove kcalloc
Date: Tue, 24 Mar 2026 14:16:29 -0700 [thread overview]
Message-ID: <20260324211629.26924-1-rosenp@gmail.com> (raw)
Combine allocations into one by using a flexible array member.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/ata/ahci_tegra.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/drivers/ata/ahci_tegra.c b/drivers/ata/ahci_tegra.c
index 44584eed6374..5972fe04ff3f 100644
--- a/drivers/ata/ahci_tegra.c
+++ b/drivers/ata/ahci_tegra.c
@@ -175,8 +175,9 @@ struct tegra_ahci_priv {
struct reset_control *sata_cold_rst;
/* Needs special handling, cannot use ahci_platform */
struct clk *sata_clk;
- struct regulator_bulk_data *supplies;
const struct tegra_ahci_soc *soc;
+
+ struct regulator_bulk_data supplies[];
};
static void tegra_ahci_handle_quirks(struct ahci_host_priv *hpriv)
@@ -512,6 +513,7 @@ static const struct scsi_host_template ahci_platform_sht = {
static int tegra_ahci_probe(struct platform_device *pdev)
{
+ const struct tegra_ahci_soc *soc;
struct ahci_host_priv *hpriv;
struct tegra_ahci_priv *tegra;
struct resource *res;
@@ -521,14 +523,15 @@ static int tegra_ahci_probe(struct platform_device *pdev)
if (IS_ERR(hpriv))
return PTR_ERR(hpriv);
- tegra = devm_kzalloc(&pdev->dev, sizeof(*tegra), GFP_KERNEL);
+ soc = of_device_get_match_data(&pdev->dev);
+ tegra = devm_kzalloc(&pdev->dev, struct_size(tegra, supplies, soc->num_supplies), GFP_KERNEL);
if (!tegra)
return -ENOMEM;
hpriv->plat_data = tegra;
tegra->pdev = pdev;
- tegra->soc = of_device_get_match_data(&pdev->dev);
+ tegra->soc = soc;
tegra->sata_regs = devm_platform_ioremap_resource(pdev, 1);
if (IS_ERR(tegra->sata_regs))
@@ -571,12 +574,6 @@ static int tegra_ahci_probe(struct platform_device *pdev)
return PTR_ERR(tegra->sata_clk);
}
- tegra->supplies = devm_kcalloc(&pdev->dev,
- tegra->soc->num_supplies,
- sizeof(*tegra->supplies), GFP_KERNEL);
- if (!tegra->supplies)
- return -ENOMEM;
-
regulator_bulk_set_supply_names(tegra->supplies,
tegra->soc->supply_names,
tegra->soc->num_supplies);
--
2.53.0
next reply other threads:[~2026-03-24 21:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-24 21:16 Rosen Penev [this message]
2026-03-24 22:10 ` [PATCH] ata: ahci_tegra: remove kcalloc Damien Le Moal
2026-03-24 22:51 ` Rosen Penev
2026-03-25 7:30 ` Niklas Cassel
2026-03-25 10:17 ` Jon Hunter
2026-03-25 23:29 ` Rosen Penev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260324211629.26924-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=cassel@kernel.org \
--cc=dlemoal@kernel.org \
--cc=jonathanh@nvidia.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=thierry.reding@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox