[7/8] mfd: twl-core: make reg_write callback take const void *

Message ID 20260715175229.24672-8-linkmauve@linkmauve.fr (mailing list archive)
State New
Headers
Series nvmem: make reg_write() take a const void * |

Commit Message

Link Mauve July 15, 2026, 5:52 p.m. UTC
The previous commit switched from a pointer to mutable data to a pointer
to immutable data, so let’s fix all users of the nvmem_config API.

Signed-off-by: Link Mauve <linkmauve@linkmauve.fr>
---
 drivers/mfd/twl-core.c  | 2 +-
 include/linux/mfd/twl.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
  

Comments

sashiko-bot@kernel.org July 15, 2026, 6:08 p.m. UTC | #1
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [Low] The commit message description is not capitalized, violating MFD subsystem guidelines.

Pre-existing issues:
- [High] Probe failure during MFD device registration skips manual resource cleanup, causing resource leaks.
--

--- Patch [7]: [PATCH 7/8] mfd: twl-core: make reg_write callback take const void * ---
commit 5525fd3bfa73424e942892bd1e1fb2d2e9554159
Author: Link Mauve <linkmauve@linkmauve.fr>

mfd: twl-core: make reg_write callback take const void *

This commit updates the reg_write callback to use a const void pointer for
its data argument. It fixes all users of the nvmem_config API to accommodate
this change.

> mfd: twl-core: make reg_write callback take const void *

[Severity: Low]
This isn't a bug, but should the description after the subsystem prefix be
capitalized (i.e., "Make reg_write...") to match the MFD subsystem guidelines?

[Severity: High]
This is a pre-existing issue, but I noticed a potential resource leak in
twl_probe(). If devm_mfd_add_devices() fails, the code jumps directly to
the 'free' label, skipping the 'fail' label:

drivers/mfd/twl-core.c:twl_probe() {
    ...
		status = devm_mfd_add_devices(&client->dev, PLATFORM_DEVID_NONE,
					      cells, num_cells, NULL, 0, NULL);
		if (status < 0)
			goto free;
    ...
fail:
	if (status < 0)
		twl_remove(client);
free:
	if (status < 0)
		platform_device_unregister(pdev);
    ...
}

Does this bypass leak manually requested IRQ domains and unmanaged dummy I2C
devices by skipping twl_remove()?
  

Patch

diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index c024a28b057e..d7e3ab41717b 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -447,7 +447,7 @@  static struct regmap *twl_get_regmap(u8 mod_no)
  *
  * Returns 0 on success or else a negative error code.
  */
-int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
+int twl_i2c_write(u8 mod_no, const u8 *value, u8 reg, unsigned num_bytes)
 {
 	struct regmap *regmap = twl_get_regmap(mod_no);
 	int ret;
diff --git a/include/linux/mfd/twl.h b/include/linux/mfd/twl.h
index b31e07fa4d51..131451d70960 100644
--- a/include/linux/mfd/twl.h
+++ b/include/linux/mfd/twl.h
@@ -168,7 +168,7 @@  int twl_set_regcache_bypass(u8 mod_no, bool enable);
 /*
  * Read and write several 8-bit registers at once.
  */
-int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes);
+int twl_i2c_write(u8 mod_no, const u8 *value, u8 reg, unsigned num_bytes);
 int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes);
 
 /*
@@ -186,7 +186,7 @@  static inline int twl_i2c_write_u16(u8 mod_no, u16 val, u8 reg) {
 	__le16 value;
 
 	value = cpu_to_le16(val);
-	return twl_i2c_write(mod_no, (u8 *) &value, reg, 2);
+	return twl_i2c_write(mod_no, (const u8 *) &value, reg, 2);
 }
 
 static inline int twl_i2c_read_u16(u8 mod_no, u16 *val, u8 reg) {