From: Rosen Penev <rosenp@gmail.com>
To: mfd@lists.linux.dev
Cc: Aaro Koskinen <aaro.koskinen@iki.fi>,
Andreas Kemnade <andreas@kemnade.info>,
Kevin Hilman <khilman@baylibre.com>,
Roger Quadros <rogerq@kernel.org>,
Tony Lindgren <tony@atomide.com>, Lee Jones <lee@kernel.org>,
linux-omap@vger.kernel.org (open list:OMAP2+ SUPPORT),
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH v4] mfd: twl-core: Embed the twl_client array in twl_private
Date: Fri, 16 Oct 2026 17:47:58 -0700 [thread overview]
Message-ID: <20261017004758.1256875-1-rosenp@gmail.com> (raw)
At most four I2C slave addresses are ever used (TWL4030 class), so
there is no need to allocate the twl_client array separately. Embed a
fixed array of TWL_MAX_SLAVES entries in struct twl_private and drop the
extra devm_kcalloc() and its error handling.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
v4: use a static array
v3: Capitalize Allocate.
v2: don't use twl_get_num_slaves().
drivers/mfd/twl-core.c | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index f86df356d658..4f70d49ed2f0 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -153,13 +153,15 @@ struct twl_mapping {
unsigned char base; /* base address */
};
+#define TWL_MAX_SLAVES 4
+
struct twl_private {
bool ready; /* The core driver is ready to be used */
u32 twl_idcode; /* TWL IDCODE Register value */
unsigned int twl_id;
struct twl_mapping *twl_map;
- struct twl_client *twl_modules;
+ struct twl_client twl_modules[TWL_MAX_SLAVES];
};
static struct twl_private *twl_priv;
@@ -788,15 +790,6 @@ twl_probe(struct i2c_client *client)
}
num_slaves = twl_get_num_slaves();
- twl_priv->twl_modules = devm_kcalloc(&client->dev,
- num_slaves,
- sizeof(struct twl_client),
- GFP_KERNEL);
- if (!twl_priv->twl_modules) {
- status = -ENOMEM;
- goto out;
- }
-
for (i = 0; i < num_slaves; i++) {
struct twl_client *twl = &twl_priv->twl_modules[i];
--
2.56.0
reply other threads:[~2026-10-17 0:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261017004758.1256875-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=aaro.koskinen@iki.fi \
--cc=andreas@kemnade.info \
--cc=khilman@baylibre.com \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=mfd@lists.linux.dev \
--cc=rogerq@kernel.org \
--cc=tony@atomide.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
all inboxes | Powered by JetHome®