[7/8] mfd: twl-core: make reg_write callback take const void *
Commit Message
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
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()?
@@ -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;
@@ -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) {