From: Jon Hunter <jonathanh@nvidia.com>
To: Niklas Cassel <cassel@kernel.org>, Rosen Penev <rosenp@gmail.com>
Cc: linux-ide@vger.kernel.org, Damien Le Moal <dlemoal@kernel.org>,
Thierry Reding <thierry.reding@gmail.com>,
"open list:TEGRA ARCHITECTURE SUPPORT"
<linux-tegra@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ata: ahci_tegra: remove kcalloc
Date: Wed, 25 Mar 2026 10:17:27 +0000 [thread overview]
Message-ID: <63d71f4c-97c0-4c2f-ac92-0a643fcdf75f@nvidia.com> (raw)
In-Reply-To: <acOPMJVsxpBltqGX@ryzen>
On 25/03/2026 07:30, Niklas Cassel wrote:
> Hello Rosen,
>
> subject is a bit misleading:
> "remove kcalloc"
> you are removing devm_kcalloc(), so device managed.
>
>
> On Tue, Mar 24, 2026 at 02:16:29PM -0700, Rosen Penev wrote:
>> 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[];
>
> Personally I'm not a big fan of flexible array members, as there can be
> only one. And if you use it you want to use counted_by().
>
> Yes, there are two device managed allocations. But is that so bad?
>
> Since it is device managed, it will get freed on device removal anyway.
FWIW I am not a big fan of this either. It is not an obvious bang for
the buck for me. The one downside I see is that it does leave the door
open for someone accidentally putting another variable after the
flexible array member. Yes we should catch this in review, but there
really should be at least a comment saying this must be the final member
of the struct.
Jon
--
nvpublic
next prev parent reply other threads:[~2026-03-25 10:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-24 21:16 [PATCH] ata: ahci_tegra: remove kcalloc Rosen Penev
2026-03-24 22:10 ` Damien Le Moal
2026-03-24 22:51 ` Rosen Penev
2026-03-25 7:30 ` Niklas Cassel
2026-03-25 10:17 ` Jon Hunter [this message]
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=63d71f4c-97c0-4c2f-ac92-0a643fcdf75f@nvidia.com \
--to=jonathanh@nvidia.com \
--cc=cassel@kernel.org \
--cc=dlemoal@kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=rosenp@gmail.com \
--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