The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: srini@kernel.org
To: gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, Rosen Penev <rosenp@gmail.com>,
	Srinivas Kandagatla <srini@kernel.org>
Subject: [PATCH 02/14] nvmem: rockchip-otp: alloc clks with main struct
Date: Sat, 30 May 2026 21:53:21 +0100	[thread overview]
Message-ID: <20260530205333.117458-3-srini@kernel.org> (raw)
In-Reply-To: <20260530205333.117458-1-srini@kernel.org>

From: Rosen Penev <rosenp@gmail.com>

Use a flexible array member to simplify allocation slightly. No need for
a separate calloc.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: Srinivas Kandagatla <srini@kernel.org>
---
 drivers/nvmem/rockchip-otp.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/nvmem/rockchip-otp.c b/drivers/nvmem/rockchip-otp.c
index 0ec78b5e19e7..2c0feb036f3f 100644
--- a/drivers/nvmem/rockchip-otp.c
+++ b/drivers/nvmem/rockchip-otp.c
@@ -78,9 +78,9 @@ struct rockchip_data {
 struct rockchip_otp {
 	struct device *dev;
 	void __iomem *base;
-	struct clk_bulk_data *clks;
 	struct reset_control *rst;
 	const struct rockchip_data *data;
+	struct clk_bulk_data clks[];
 };
 
 static int rockchip_otp_reset(struct rockchip_otp *otp)
@@ -424,7 +424,7 @@ static int rockchip_otp_probe(struct platform_device *pdev)
 	if (!data)
 		return dev_err_probe(dev, -EINVAL, "failed to get match data\n");
 
-	otp = devm_kzalloc(&pdev->dev, sizeof(struct rockchip_otp),
+	otp = devm_kzalloc(&pdev->dev, struct_size(otp, clks, data->num_clks),
 			   GFP_KERNEL);
 	if (!otp)
 		return -ENOMEM;
@@ -436,11 +436,6 @@ static int rockchip_otp_probe(struct platform_device *pdev)
 		return dev_err_probe(dev, PTR_ERR(otp->base),
 				     "failed to ioremap resource\n");
 
-	otp->clks = devm_kcalloc(dev, data->num_clks, sizeof(*otp->clks),
-				 GFP_KERNEL);
-	if (!otp->clks)
-		return -ENOMEM;
-
 	for (i = 0; i < data->num_clks; ++i)
 		otp->clks[i].id = data->clks[i];
 
-- 
2.53.0


  parent reply	other threads:[~2026-05-30 20:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-30 20:53 [PATCH 00/14] nvmem: patches for 7.2 srini
2026-05-30 20:53 ` [PATCH 01/14] dt-bindings: nvmem: qfprom: Add glymur compatible srini
2026-05-30 20:53 ` srini [this message]
2026-05-30 20:53 ` [PATCH 03/14] nvmem: core: Default to read-only if wp-gpios present srini
2026-05-30 20:53 ` [PATCH 04/14] dt-bindings: nvmem: qfprom: qcom: Add Hawi compatible srini
2026-05-30 20:53 ` [PATCH 05/14] nvmem: nintendo-otp: Use of_device_get_match_data() srini
2026-05-30 20:53 ` [PATCH 06/14] dt-bindings: nvmem: qfprom: Add Milos compatible srini
2026-05-30 20:53 ` [PATCH 07/14] dt-bindings: nvmem: lan9662-otpc: Add LAN969x series srini
2026-05-30 20:53 ` [PATCH 08/14] nvmem: lan9662-otp: add support for LAN969x srini
2026-05-30 20:53 ` [PATCH 09/14] dt-bindings: nvmem: qcom,qfprom: Add Shikra compatible srini
2026-05-30 20:53 ` [PATCH 10/14] dt-bindings: nvmem: airoha: add SMC eFuses schema srini
2026-05-30 20:53 ` [PATCH 11/14] nvmem: airoha: Add support for SMC eFUSE srini
2026-05-30 20:53 ` [PATCH 12/14] nvmem: qcom: Unify user-visible "Qualcomm" name srini
2026-05-30 20:53 ` [PATCH 13/14] nvmem: cleanup dead code in Kconfig srini
2026-05-30 20:53 ` [PATCH 14/14] nvmem: layouts: u-boot-env: check earlier for ethaddr length srini

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=20260530205333.117458-3-srini@kernel.org \
    --to=srini@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rosenp@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