Skip to contentSkip to conversation

mfd: twl-core: Embed the twl_client array in twl_private

PATCH Applied Rosen Penev 3 participants 3 messages Oct 17 – Oct 28

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

PATCH v4 1/1 mfd: twl-core: Embed the twl_client array in twl_private

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.

---
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(-)
drivers/mfd/twl-core.c +3 -10
index f86df356d658..4f70d49ed2f0 100644
@@ -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];
 
Signature · 1 line
2.56.0
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 6 lines

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.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer Applied
#2 lore raw

Re: (subset) [PATCH v4] mfd: twl-core: Embed the twl_client array in twl_private

In reply to Rosen Penev
Quoted 4 lines · Rosen Penev

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.

Applied, thanks!

[1/1] mfd: twl-core: Embed the twl_client array in twl_private

      commit: 73f3a89d27c3da9ea28750a420fa2567c0bc1701

--
Lee Jones [李琼斯]