mfd: twl-core: allocate modules with twl_private
Subsystems (2)
PATCH v2 1/1 mfd: twl-core: allocate modules with twl_private
Use a flexible array member to allocate the twl_client array together with struct twl_private. This removes a separate devm_kcalloc() and keeps the module data tied to the main private structure.
Can't use twl_get_num_slaves() for this as that bases its value on twl_priv->twl_id , which is unallocated at this point.
---
v2: don't use twl_get_num_slaves().
drivers/mfd/twl-core.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
drivers/mfd/twl-core.c +4 -12
@@ -159,7 +159,7 @@ struct twl_private {unsigned int twl_id;struct twl_mapping *twl_map; -struct twl_client *twl_modules; +struct twl_client twl_modules[]; };static struct twl_private *twl_priv;
@@ -770,7 +770,9 @@ twl_probe(struct i2c_client *client) goto out; } - twl_priv =devm_kzalloc (&client->dev,sizeof (struct twl_private ), + num_slaves = (id->driver_data &TWL6030_CLASS ) ?3 :4 ; + twl_priv =devm_kzalloc (&client->dev, +struct_size (twl_priv, twl_modules, num_slaves),GFP_KERNEL );if (!twl_priv) { status = -ENOMEM ;
@@ -787,16 +789,6 @@ twl_probe(struct i2c_client *client) twl_regmap_config = twl4030_regmap_config; } - 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.55.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] mfd: commit message description is not capitalized --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] mfd: commit message description is not capitalized
--
commit 6123542ed724a298f0d89ecd6ec1bd20bb22be6c
Author: Rosen Penev <[email protected]>
mfd: twl-core: allocate modules with twl_private
This commit updates the twl-core driver to use a flexible array member for the twl_client array within struct twl_private. This eliminates a separate devm_kcalloc() allocation and keeps the module data tied to the main private structure.
Quoted 1 line
mfd: twl-core: allocate modules with
twl_private
[Severity: Low]
This isn't a bug, but does this violate the MFD subsystem commit message conventions? The guidelines require always capitalizing the description after the subsystem prefix for MFD commits (e.g., "mfd: twl-core: Allocate modules...").
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1